public void AnalyzeIamPolicyRequestObject() { moq::Mock <AssetService.AssetServiceClient> mockGrpcClient = new moq::Mock <AssetService.AssetServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); AnalyzeIamPolicyRequest request = new AnalyzeIamPolicyRequest { AnalysisQuery = new IamPolicyAnalysisQuery(), Options = new AnalyzeIamPolicyRequest.Types.Options(), }; AnalyzeIamPolicyResponse expectedResponse = new AnalyzeIamPolicyResponse { MainAnalysis = new AnalyzeIamPolicyResponse.Types.IamPolicyAnalysis(), ServiceAccountImpersonationAnalysis = { new AnalyzeIamPolicyResponse.Types.IamPolicyAnalysis(), }, FullyExplored = false, NonCriticalErrors = { new IamPolicyAnalysisResult.Types.AnalysisState(), }, }; mockGrpcClient.Setup(x => x.AnalyzeIamPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null); AnalyzeIamPolicyResponse response = client.AnalyzeIamPolicy(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task AnalyzeIamPolicyRequestObjectAsync() { moq::Mock <AssetService.AssetServiceClient> mockGrpcClient = new moq::Mock <AssetService.AssetServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); AnalyzeIamPolicyRequest request = new AnalyzeIamPolicyRequest { AnalysisQuery = new IamPolicyAnalysisQuery(), Options = new AnalyzeIamPolicyRequest.Types.Options(), }; AnalyzeIamPolicyResponse expectedResponse = new AnalyzeIamPolicyResponse { MainAnalysis = new AnalyzeIamPolicyResponse.Types.IamPolicyAnalysis(), ServiceAccountImpersonationAnalysis = { new AnalyzeIamPolicyResponse.Types.IamPolicyAnalysis(), }, FullyExplored = false, NonCriticalErrors = { new IamPolicyAnalysisResult.Types.AnalysisState(), }, }; mockGrpcClient.Setup(x => x.AnalyzeIamPolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AnalyzeIamPolicyResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null); AnalyzeIamPolicyResponse responseCallSettings = await client.AnalyzeIamPolicyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); AnalyzeIamPolicyResponse responseCancellationToken = await client.AnalyzeIamPolicyAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public AnalyzeIamPolicyResponse AnalyzeIamPolicy(string scope, string fullResourceName) { // Create the client. AssetServiceClient client = AssetServiceClient.Create(); // Build the request. AnalyzeIamPolicyRequest request = new AnalyzeIamPolicyRequest { AnalysisQuery = new IamPolicyAnalysisQuery { Scope = scope, ResourceSelector = new IamPolicyAnalysisQuery.Types.ResourceSelector { FullResourceName = fullResourceName, }, Options = new IamPolicyAnalysisQuery.Types.Options { ExpandGroups = true, OutputGroupEdges = true, }, }, }; // Call the API. AnalyzeIamPolicyResponse response = client.AnalyzeIamPolicy(request); // Return the result. return(response); }
/// <summary>Snippet for AnalyzeIamPolicy</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void AnalyzeIamPolicyRequestObject() { // Create client AssetServiceClient assetServiceClient = AssetServiceClient.Create(); // Initialize request argument(s) AnalyzeIamPolicyRequest request = new AnalyzeIamPolicyRequest { AnalysisQuery = new IamPolicyAnalysisQuery(), ExecutionTimeout = new Duration(), }; // Make the request AnalyzeIamPolicyResponse response = assetServiceClient.AnalyzeIamPolicy(request); }
/// <summary>Snippet for AnalyzeIamPolicyAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task AnalyzeIamPolicyRequestObjectAsync() { // Create client AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync(); // Initialize request argument(s) AnalyzeIamPolicyRequest request = new AnalyzeIamPolicyRequest { AnalysisQuery = new IamPolicyAnalysisQuery(), Options = new AnalyzeIamPolicyRequest.Types.Options(), }; // Make the request AnalyzeIamPolicyResponse response = await assetServiceClient.AnalyzeIamPolicyAsync(request); }
/// <summary>Snippet for AnalyzeIamPolicy</summary> public void AnalyzeIamPolicyRequestObject() { // Snippet: AnalyzeIamPolicy(AnalyzeIamPolicyRequest, CallSettings) // Create client AssetServiceClient assetServiceClient = AssetServiceClient.Create(); // Initialize request argument(s) AnalyzeIamPolicyRequest request = new AnalyzeIamPolicyRequest { AnalysisQuery = new IamPolicyAnalysisQuery(), Options = new AnalyzeIamPolicyRequest.Types.Options(), }; // Make the request AnalyzeIamPolicyResponse response = assetServiceClient.AnalyzeIamPolicy(request); // End snippet }
/// <summary>Snippet for AnalyzeIamPolicyAsync</summary> public async Task AnalyzeIamPolicyRequestObjectAsync() { // Snippet: AnalyzeIamPolicyAsync(AnalyzeIamPolicyRequest, CallSettings) // Additional: AnalyzeIamPolicyAsync(AnalyzeIamPolicyRequest, CancellationToken) // Create client AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync(); // Initialize request argument(s) AnalyzeIamPolicyRequest request = new AnalyzeIamPolicyRequest { AnalysisQuery = new IamPolicyAnalysisQuery(), ExecutionTimeout = new Duration(), }; // Make the request AnalyzeIamPolicyResponse response = await assetServiceClient.AnalyzeIamPolicyAsync(request); // End snippet }