Skip to content

Commit

Permalink
feat: AuditConfig for IAM v1
Browse files Browse the repository at this point in the history
  • Loading branch information
jskeet committed Apr 5, 2022
1 parent 28de985 commit bc4cfd8
Show file tree
Hide file tree
Showing 9 changed files with 859 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Google.Cloud.Iam.V1.Snippets
// [START api_v1_generated_IAMPolicy_SetIamPolicy_async]
using Google.Api.Gax;
using Google.Cloud.Iam.V1;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

public sealed partial class GeneratedIAMPolicyClientSnippets
Expand All @@ -37,6 +38,7 @@ public async Task SetIamPolicyRequestObjectAsync()
{
ResourceAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
Policy = new Policy(),
UpdateMask = new FieldMask(),
};
// Make the request
Policy response = await iAMPolicyClient.SetIamPolicyAsync(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Google.Cloud.Iam.V1.Snippets
// [START api_v1_generated_IAMPolicy_SetIamPolicy_sync]
using Google.Api.Gax;
using Google.Cloud.Iam.V1;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedIAMPolicyClientSnippets
{
Expand All @@ -36,6 +37,7 @@ public void SetIamPolicyRequestObject()
{
ResourceAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
Policy = new Policy(),
UpdateMask = new FieldMask(),
};
// Make the request
Policy response = iAMPolicyClient.SetIamPolicy(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace Google.Cloud.Iam.V1.Snippets
{
using Google.Api.Gax;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

/// <summary>Generated snippets.</summary>
Expand All @@ -33,6 +34,7 @@ public void SetIamPolicyRequestObject()
{
ResourceAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
Policy = new Policy(),
UpdateMask = new FieldMask(),
};
// Make the request
Policy response = iAMPolicyClient.SetIamPolicy(request);
Expand All @@ -51,6 +53,7 @@ public async Task SetIamPolicyRequestObjectAsync()
{
ResourceAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
Policy = new Policy(),
UpdateMask = new FieldMask(),
};
// Make the request
Policy response = await iAMPolicyClient.SetIamPolicyAsync(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using gax = Google.Api.Gax;
using gaxgrpc = Google.Api.Gax.Grpc;
using proto = Google.Protobuf;
using wkt = Google.Protobuf.WellKnownTypes;
using grpccore = Grpc.Core;
using moq = Moq;
using st = System.Threading;
Expand All @@ -36,12 +37,14 @@ public void SetIamPolicyRequestObject()
{
ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
Policy = new Policy(),
UpdateMask = new wkt::FieldMask(),
};
Policy expectedResponse = new Policy
{
Version = 271578922,
Etag = proto::ByteString.CopyFromUtf8("etage8ad7218"),
Bindings = { new Binding(), },
AuditConfigs = { new AuditConfig(), },
};
mockGrpcClient.Setup(x => x.SetIamPolicy(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
IAMPolicyClient client = new IAMPolicyClientImpl(mockGrpcClient.Object, null);
Expand All @@ -58,12 +61,14 @@ public void SetIamPolicyRequestObject()
{
ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
Policy = new Policy(),
UpdateMask = new wkt::FieldMask(),
};
Policy expectedResponse = new Policy
{
Version = 271578922,
Etag = proto::ByteString.CopyFromUtf8("etage8ad7218"),
Bindings = { new Binding(), },
AuditConfigs = { new AuditConfig(), },
};
mockGrpcClient.Setup(x => x.SetIamPolicyAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<Policy>(stt::Task.FromResult(expectedResponse), null, null, null, null));
IAMPolicyClient client = new IAMPolicyClientImpl(mockGrpcClient.Object, null);
Expand All @@ -88,6 +93,7 @@ public void GetIamPolicyRequestObject()
Version = 271578922,
Etag = proto::ByteString.CopyFromUtf8("etage8ad7218"),
Bindings = { new Binding(), },
AuditConfigs = { new AuditConfig(), },
};
mockGrpcClient.Setup(x => x.GetIamPolicy(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
IAMPolicyClient client = new IAMPolicyClientImpl(mockGrpcClient.Object, null);
Expand All @@ -110,6 +116,7 @@ public void GetIamPolicyRequestObject()
Version = 271578922,
Etag = proto::ByteString.CopyFromUtf8("etage8ad7218"),
Bindings = { new Binding(), },
AuditConfigs = { new AuditConfig(), },
};
mockGrpcClient.Setup(x => x.GetIamPolicyAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<Policy>(stt::Task.FromResult(expectedResponse), null, null, null, null));
IAMPolicyClient client = new IAMPolicyClientImpl(mockGrpcClient.Object, null);
Expand Down
26 changes: 19 additions & 7 deletions apis/Google.Cloud.Iam.V1/Google.Cloud.Iam.V1/IAMPolicyClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ private IAMPolicyClient BuildImpl()

/// <summary>IAMPolicy client wrapper, for convenient use.</summary>
/// <remarks>
/// ## API Overview
/// API Overview
///
///
/// Manages Identity and Access Management (IAM) policies.
///
Expand Down Expand Up @@ -266,6 +267,8 @@ internal static IAMPolicyClient Create(grpccore::CallInvoker callInvoker, IAMPol
/// <summary>
/// Sets the access control policy on the specified resource. Replaces any
/// existing policy.
///
/// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
Expand All @@ -276,6 +279,8 @@ internal static IAMPolicyClient Create(grpccore::CallInvoker callInvoker, IAMPol
/// <summary>
/// Sets the access control policy on the specified resource. Replaces any
/// existing policy.
///
/// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
Expand All @@ -286,6 +291,8 @@ internal static IAMPolicyClient Create(grpccore::CallInvoker callInvoker, IAMPol
/// <summary>
/// Sets the access control policy on the specified resource. Replaces any
/// existing policy.
///
/// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
Expand Down Expand Up @@ -329,7 +336,7 @@ internal static IAMPolicyClient Create(grpccore::CallInvoker callInvoker, IAMPol
/// <summary>
/// Returns permissions that a caller has on the specified resource.
/// If the resource does not exist, this will return an empty set of
/// permissions, not a NOT_FOUND error.
/// permissions, not a `NOT_FOUND` error.
///
/// Note: This operation is designed to be used for building permission-aware
/// UIs and command-line tools, not for authorization checking. This operation
Expand All @@ -344,7 +351,7 @@ internal static IAMPolicyClient Create(grpccore::CallInvoker callInvoker, IAMPol
/// <summary>
/// Returns permissions that a caller has on the specified resource.
/// If the resource does not exist, this will return an empty set of
/// permissions, not a NOT_FOUND error.
/// permissions, not a `NOT_FOUND` error.
///
/// Note: This operation is designed to be used for building permission-aware
/// UIs and command-line tools, not for authorization checking. This operation
Expand All @@ -359,7 +366,7 @@ internal static IAMPolicyClient Create(grpccore::CallInvoker callInvoker, IAMPol
/// <summary>
/// Returns permissions that a caller has on the specified resource.
/// If the resource does not exist, this will return an empty set of
/// permissions, not a NOT_FOUND error.
/// permissions, not a `NOT_FOUND` error.
///
/// Note: This operation is designed to be used for building permission-aware
/// UIs and command-line tools, not for authorization checking. This operation
Expand All @@ -374,7 +381,8 @@ internal static IAMPolicyClient Create(grpccore::CallInvoker callInvoker, IAMPol

/// <summary>IAMPolicy client wrapper implementation, for convenient use.</summary>
/// <remarks>
/// ## API Overview
/// API Overview
///
///
/// Manages Identity and Access Management (IAM) policies.
///
Expand Down Expand Up @@ -452,6 +460,8 @@ public IAMPolicyClientImpl(IAMPolicy.IAMPolicyClient grpcClient, IAMPolicySettin
/// <summary>
/// Sets the access control policy on the specified resource. Replaces any
/// existing policy.
///
/// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
Expand All @@ -465,6 +475,8 @@ public override Policy SetIamPolicy(SetIamPolicyRequest request, gaxgrpc::CallSe
/// <summary>
/// Sets the access control policy on the specified resource. Replaces any
/// existing policy.
///
/// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
/// </summary>
/// <param name="request">The request object containing all of the parameters for the API call.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
Expand Down Expand Up @@ -506,7 +518,7 @@ public override Policy GetIamPolicy(GetIamPolicyRequest request, gaxgrpc::CallSe
/// <summary>
/// Returns permissions that a caller has on the specified resource.
/// If the resource does not exist, this will return an empty set of
/// permissions, not a NOT_FOUND error.
/// permissions, not a `NOT_FOUND` error.
///
/// Note: This operation is designed to be used for building permission-aware
/// UIs and command-line tools, not for authorization checking. This operation
Expand All @@ -524,7 +536,7 @@ public override TestIamPermissionsResponse TestIamPermissions(TestIamPermissions
/// <summary>
/// Returns permissions that a caller has on the specified resource.
/// If the resource does not exist, this will return an empty set of
/// permissions, not a NOT_FOUND error.
/// permissions, not a `NOT_FOUND` error.
///
/// Note: This operation is designed to be used for building permission-aware
/// UIs and command-line tools, not for authorization checking. This operation
Expand Down
Loading

0 comments on commit bc4cfd8

Please sign in to comment.