Skip to content

Commit

Permalink
feat: Release of query system
Browse files Browse the repository at this point in the history
Committer: lvv@

PiperOrigin-RevId: 466748663

Source-Link: googleapis/googleapis@80d630f

Source-Link: googleapis/googleapis-gen@252f5ad
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuQXNzZXQuVjEvLk93bEJvdC55YW1sIiwiaCI6IjI1MmY1YWRlMThhMzFhNzJmMTI4MTBiYmZkMWQ4M2Q1NmE4ZTcyZTEifQ==
  • Loading branch information
gcf-owl-bot[bot] authored and amanda-tarafa committed Aug 10, 2022
1 parent 0fe494e commit 9677dd3
Show file tree
Hide file tree
Showing 10 changed files with 3,312 additions and 291 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Google.Cloud.Asset.V1.Snippets
{
// [START cloudasset_v1_generated_AssetService_QueryAssets_async]
using Google.Api.Gax;
using Google.Cloud.Asset.V1;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

public sealed partial class GeneratedAssetServiceClientSnippets
{
/// <summary>Snippet for QueryAssetsAsync</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 QueryAssetsRequestObjectAsync()
{
// Create client
AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
// Initialize request argument(s)
QueryAssetsRequest request = new QueryAssetsRequest
{
ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
Statement = "",
PageSize = 0,
PageToken = "",
Timeout = new Duration(),
ReadTimeWindow = new TimeWindow(),
OutputConfig = new QueryAssetsOutputConfig(),
};
// Make the request
QueryAssetsResponse response = await assetServiceClient.QueryAssetsAsync(request);
}
}
// [END cloudasset_v1_generated_AssetService_QueryAssets_async]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Google.Cloud.Asset.V1.Snippets
{
// [START cloudasset_v1_generated_AssetService_QueryAssets_sync]
using Google.Api.Gax;
using Google.Cloud.Asset.V1;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedAssetServiceClientSnippets
{
/// <summary>Snippet for QueryAssets</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public void QueryAssetsRequestObject()
{
// Create client
AssetServiceClient assetServiceClient = AssetServiceClient.Create();
// Initialize request argument(s)
QueryAssetsRequest request = new QueryAssetsRequest
{
ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
Statement = "",
PageSize = 0,
PageToken = "",
Timeout = new Duration(),
ReadTimeWindow = new TimeWindow(),
OutputConfig = new QueryAssetsOutputConfig(),
};
// Make the request
QueryAssetsResponse response = assetServiceClient.QueryAssets(request);
}
}
// [END cloudasset_v1_generated_AssetService_QueryAssets_sync]
}
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,59 @@
"canonical": true,
"origin": "API_DEFINITION"
},
{
"regionTag": "cloudasset_v1_generated_AssetService_QueryAssets_sync",
"title": "QueryAssetsRequestObject",
"description": "Snippet for QueryAssets",
"file": "AssetServiceClient.QueryAssetsRequestObjectSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "QueryAssets",
"fullName": "Google.Cloud.Asset.V1.AssetServiceClient.QueryAssets",
"resultType": "Google.Cloud.Asset.V1.QueryAssetsResponse",
"client": {
"shortName": "AssetServiceClient",
"fullName": "Google.Cloud.Asset.V1.AssetServiceClient"
},
"method": {
"shortName": "QueryAssets",
"fullName": "google.cloud.asset.v1.AssetService.QueryAssets",
"service": {
"shortName": "AssetService",
"fullName": "google.cloud.asset.v1.AssetService"
}
}
},
"canonical": true,
"origin": "API_DEFINITION"
},
{
"regionTag": "cloudasset_v1_generated_AssetService_QueryAssets_async",
"title": "QueryAssetsRequestObjectAsync",
"description": "Snippet for QueryAssetsAsync",
"file": "AssetServiceClient.QueryAssetsRequestObjectAsyncSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "QueryAssetsAsync",
"fullName": "Google.Cloud.Asset.V1.AssetServiceClient.QueryAssetsAsync",
"async": true,
"resultType": "System.Threading.Tasks.Task<Google.Cloud.Asset.V1.QueryAssetsResponse>",
"client": {
"shortName": "AssetServiceClient",
"fullName": "Google.Cloud.Asset.V1.AssetServiceClient"
},
"method": {
"shortName": "QueryAssets",
"fullName": "google.cloud.asset.v1.AssetService.QueryAssets",
"service": {
"shortName": "AssetService",
"fullName": "google.cloud.asset.v1.AssetService"
}
}
},
"canonical": true,
"origin": "API_DEFINITION"
},
{
"regionTag": "cloudasset_v1_generated_AssetService_CreateSavedQuery_sync",
"title": "CreateSavedQueryRequestObject",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,51 @@ public async Task AnalyzeMoveRequestObjectAsync()
// End snippet
}

/// <summary>Snippet for QueryAssets</summary>
public void QueryAssetsRequestObject()
{
// Snippet: QueryAssets(QueryAssetsRequest, CallSettings)
// Create client
AssetServiceClient assetServiceClient = AssetServiceClient.Create();
// Initialize request argument(s)
QueryAssetsRequest request = new QueryAssetsRequest
{
ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
Statement = "",
PageSize = 0,
PageToken = "",
Timeout = new Duration(),
ReadTimeWindow = new TimeWindow(),
OutputConfig = new QueryAssetsOutputConfig(),
};
// Make the request
QueryAssetsResponse response = assetServiceClient.QueryAssets(request);
// End snippet
}

/// <summary>Snippet for QueryAssetsAsync</summary>
public async Task QueryAssetsRequestObjectAsync()
{
// Snippet: QueryAssetsAsync(QueryAssetsRequest, CallSettings)
// Additional: QueryAssetsAsync(QueryAssetsRequest, CancellationToken)
// Create client
AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();
// Initialize request argument(s)
QueryAssetsRequest request = new QueryAssetsRequest
{
ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
Statement = "",
PageSize = 0,
PageToken = "",
Timeout = new Duration(),
ReadTimeWindow = new TimeWindow(),
OutputConfig = new QueryAssetsOutputConfig(),
};
// Make the request
QueryAssetsResponse response = await assetServiceClient.QueryAssetsAsync(request);
// End snippet
}

/// <summary>Snippet for CreateSavedQuery</summary>
public void CreateSavedQueryRequestObject()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using gagr = Google.Api.Gax.ResourceNames;
using lro = Google.LongRunning;
using wkt = Google.Protobuf.WellKnownTypes;
using gr = Google.Rpc;
using gt = Google.Type;
using grpccore = Grpc.Core;
using moq = Moq;
Expand Down Expand Up @@ -877,6 +878,72 @@ public void AnalyzeMoveRequestObject()
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public void QueryAssetsRequestObject()
{
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);
QueryAssetsRequest request = new QueryAssetsRequest
{
ParentAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
Statement = "statement56bf4542",
JobReference = "job_reference0b9f6693",
PageSize = -226905851,
PageToken = "page_tokenf09e5538",
Timeout = new wkt::Duration(),
ReadTimeWindow = new TimeWindow(),
ReadTime = new wkt::Timestamp(),
OutputConfig = new QueryAssetsOutputConfig(),
};
QueryAssetsResponse expectedResponse = new QueryAssetsResponse
{
JobReference = "job_reference0b9f6693",
Done = true,
Error = new gr::Status(),
QueryResult = new QueryResult(),
OutputConfig = new QueryAssetsOutputConfig(),
};
mockGrpcClient.Setup(x => x.QueryAssets(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null, null);
QueryAssetsResponse response = client.QueryAssets(request);
xunit::Assert.Same(expectedResponse, response);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public async stt::Task QueryAssetsRequestObjectAsync()
{
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);
QueryAssetsRequest request = new QueryAssetsRequest
{
ParentAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
Statement = "statement56bf4542",
JobReference = "job_reference0b9f6693",
PageSize = -226905851,
PageToken = "page_tokenf09e5538",
Timeout = new wkt::Duration(),
ReadTimeWindow = new TimeWindow(),
ReadTime = new wkt::Timestamp(),
OutputConfig = new QueryAssetsOutputConfig(),
};
QueryAssetsResponse expectedResponse = new QueryAssetsResponse
{
JobReference = "job_reference0b9f6693",
Done = true,
Error = new gr::Status(),
QueryResult = new QueryResult(),
OutputConfig = new QueryAssetsOutputConfig(),
};
mockGrpcClient.Setup(x => x.QueryAssetsAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<QueryAssetsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null, null);
QueryAssetsResponse responseCallSettings = await client.QueryAssetsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));
xunit::Assert.Same(expectedResponse, responseCallSettings);
QueryAssetsResponse responseCancellationToken = await client.QueryAssetsAsync(request, st::CancellationToken.None);
xunit::Assert.Same(expectedResponse, responseCancellationToken);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public void CreateSavedQueryRequestObject()
{
Expand Down
Loading

0 comments on commit 9677dd3

Please sign in to comment.