public async stt::Task BatchGetAssetsHistoryRequestObjectAsync() { 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); BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { ParentAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"), AssetNames = { "asset_namese42cd316", }, ContentType = ContentType.IamPolicy, ReadTimeWindow = new TimeWindow(), }; BatchGetAssetsHistoryResponse expectedResponse = new BatchGetAssetsHistoryResponse { Assets = { new TemporalAsset(), }, }; mockGrpcClient.Setup(x => x.BatchGetAssetsHistoryAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <BatchGetAssetsHistoryResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null); BatchGetAssetsHistoryResponse responseCallSettings = await client.BatchGetAssetsHistoryAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); BatchGetAssetsHistoryResponse responseCancellationToken = await client.BatchGetAssetsHistoryAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void BatchGetAssetsHistoryRequestObject() { 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); BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { ParentAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"), AssetNames = { "asset_namese42cd316", }, ContentType = ContentType.AccessPolicy, ReadTimeWindow = new TimeWindow(), RelationshipTypes = { "relationship_typesfb911a9b", }, }; BatchGetAssetsHistoryResponse expectedResponse = new BatchGetAssetsHistoryResponse { Assets = { new TemporalAsset(), }, }; mockGrpcClient.Setup(x => x.BatchGetAssetsHistory(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null); BatchGetAssetsHistoryResponse response = client.BatchGetAssetsHistory(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for BatchGetAssetsHistory</summary> public void BatchGetAssetsHistory() { // Snippet: BatchGetAssetsHistory(string,CallSettings) // Create client AssetServiceClient assetServiceClient = AssetServiceClient.Create(); // Initialize request argument(s) string formattedParent = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString(); // Make the request BatchGetAssetsHistoryResponse response = assetServiceClient.BatchGetAssetsHistory(formattedParent); // End snippet }
/// <summary>Snippet for BatchGetAssetsHistoryAsync</summary> public async Task BatchGetAssetsHistoryAsync() { // Snippet: BatchGetAssetsHistoryAsync(string,CallSettings) // Additional: BatchGetAssetsHistoryAsync(string,CancellationToken) // Create client AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync(); // Initialize request argument(s) string formattedParent = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString(); // Make the request BatchGetAssetsHistoryResponse response = await assetServiceClient.BatchGetAssetsHistoryAsync(formattedParent); // End snippet }
/// <summary>Snippet for BatchGetAssetsHistory</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void BatchGetAssetsHistoryRequestObject() { // Create client AssetServiceClient assetServiceClient = AssetServiceClient.Create(); // Initialize request argument(s) BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"), AssetNames = { "", }, ContentType = ContentType.Unspecified, ReadTimeWindow = new TimeWindow(), }; // Make the request BatchGetAssetsHistoryResponse response = assetServiceClient.BatchGetAssetsHistory(request); }
/// <summary>Snippet for BatchGetAssetsHistory</summary> public void BatchGetAssetsHistory_RequestObject() { // Snippet: BatchGetAssetsHistory(BatchGetAssetsHistoryRequest,CallSettings) // Create client AssetServiceClient assetServiceClient = AssetServiceClient.Create(); // Initialize request argument(s) BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), ContentType = ContentType.Unspecified, ReadTimeWindow = new TimeWindow(), }; // Make the request BatchGetAssetsHistoryResponse response = assetServiceClient.BatchGetAssetsHistory(request); // End snippet }
/// <summary>Snippet for BatchGetAssetsHistoryAsync</summary> public async Task BatchGetAssetsHistoryRequestObjectAsync() { // Snippet: BatchGetAssetsHistoryAsync(BatchGetAssetsHistoryRequest, CallSettings) // Additional: BatchGetAssetsHistoryAsync(BatchGetAssetsHistoryRequest, CancellationToken) // Create client AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync(); // Initialize request argument(s) BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"), AssetNames = { "", }, ContentType = ContentType.Unspecified, ReadTimeWindow = new TimeWindow(), }; // Make the request BatchGetAssetsHistoryResponse response = await assetServiceClient.BatchGetAssetsHistoryAsync(request); // End snippet }
/// <summary>Snippet for BatchGetAssetsHistoryAsync</summary> public async Task BatchGetAssetsHistoryAsync_RequestObject() { // Snippet: BatchGetAssetsHistoryAsync(BatchGetAssetsHistoryRequest,CallSettings) // Additional: BatchGetAssetsHistoryAsync(BatchGetAssetsHistoryRequest,CancellationToken) // Create client AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync(); // Initialize request argument(s) BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), ContentType = ContentType.Unspecified, ReadTimeWindow = new TimeWindow(), }; // Make the request BatchGetAssetsHistoryResponse response = await assetServiceClient.BatchGetAssetsHistoryAsync(request); // End snippet }
public async Task BatchGetAssetsHistoryAsync() { Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); BatchGetAssetsHistoryRequest expectedRequest = new BatchGetAssetsHistoryRequest { Parent = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString(), }; BatchGetAssetsHistoryResponse expectedResponse = new BatchGetAssetsHistoryResponse(); mockGrpcClient.Setup(x => x.BatchGetAssetsHistoryAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <BatchGetAssetsHistoryResponse>(Task.FromResult(expectedResponse), null, null, null, null)); AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null); string formattedParent = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString(); BatchGetAssetsHistoryResponse response = await client.BatchGetAssetsHistoryAsync(formattedParent); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task BatchGetAssetsHistoryAsync() { Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), ContentType = ContentType.Unspecified, ReadTimeWindow = new TimeWindow(), }; BatchGetAssetsHistoryResponse expectedResponse = new BatchGetAssetsHistoryResponse(); mockGrpcClient.Setup(x => x.BatchGetAssetsHistoryAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <BatchGetAssetsHistoryResponse>(Task.FromResult(expectedResponse), null, null, null, null)); AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null); BatchGetAssetsHistoryResponse response = await client.BatchGetAssetsHistoryAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public static void Main(string[] args) { // Asset names, e.g.: //storage.googleapis.com/[YOUR_BUCKET_NAME] string[] assetNames = { "ASSET-NAME" }; string projectId = "YOUR-GOOGLE-PROJECT-ID"; BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { ParentAsProjectName = new ProjectName(projectId), ContentType = ContentType.Resource, ReadTimeWindow = new TimeWindow { StartTime = Timestamp.FromDateTime(System.DateTime.UtcNow) } }; request.AssetNames.AddRange(assetNames); AssetServiceClient client = AssetServiceClient.Create(); BatchGetAssetsHistoryResponse response = client.BatchGetAssetsHistory(request); Console.WriteLine(response); }
public void BatchGetAssetsHistory() { Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { Parent = "parent-995424086", ContentType = ContentType.Unspecified, ReadTimeWindow = new TimeWindow(), }; BatchGetAssetsHistoryResponse expectedResponse = new BatchGetAssetsHistoryResponse(); mockGrpcClient.Setup(x => x.BatchGetAssetsHistory(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null); BatchGetAssetsHistoryResponse response = client.BatchGetAssetsHistory(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void BatchGetAssetsHistory2() { Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { Parent = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString(), AssetNames = { }, ContentType = ContentType.Unspecified, ReadTimeWindow = new TimeWindow(), }; BatchGetAssetsHistoryResponse expectedResponse = new BatchGetAssetsHistoryResponse(); mockGrpcClient.Setup(x => x.BatchGetAssetsHistory(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null); BatchGetAssetsHistoryResponse response = client.BatchGetAssetsHistory(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public BatchGetAssetsHistoryResponse BatchGetAssetsHistory(string[] assetNames, string projectId) { // Create the client. AssetServiceClient client = AssetServiceClient.Create(); // Build the request. BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest { ParentAsResourceName = ProjectName.FromProject(projectId), ContentType = ContentType.Resource, ReadTimeWindow = new TimeWindow { StartTime = Timestamp.FromDateTime(DateTime.UtcNow) } }; request.AssetNames.AddRange(assetNames); // Call the API. BatchGetAssetsHistoryResponse response = client.BatchGetAssetsHistory(request); // Return the result. return(response); }