Skip to content

Commit

Permalink
feat: add datastore aggregation query APIs
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 477890345

Source-Link: googleapis/googleapis@82bf674

Source-Link: googleapis/googleapis-gen@5fb8115
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuRGF0YXN0b3JlLlYxLy5Pd2xCb3QueWFtbCIsImgiOiI1ZmI4MTE1MTYxZWExNGE1YzU1MTg4NWM2ODFjMzYyN2MyZjY2NjMwIn0=
  • Loading branch information
gcf-owl-bot[bot] authored and jskeet committed Sep 30, 2022
1 parent 14cf35b commit 5e75d6c
Show file tree
Hide file tree
Showing 12 changed files with 2,686 additions and 173 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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.Datastore.V1.Snippets
{
// [START datastore_v1_generated_Datastore_RunAggregationQuery_async]
using Google.Cloud.Datastore.V1;
using System.Threading.Tasks;

public sealed partial class GeneratedDatastoreClientSnippets
{
/// <summary>Snippet for RunAggregationQueryAsync</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 RunAggregationQueryRequestObjectAsync()
{
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
RunAggregationQueryRequest request = new RunAggregationQueryRequest
{
ReadOptions = new ReadOptions(),
PartitionId = new PartitionId(),
AggregationQuery = new AggregationQuery(),
ProjectId = "",
DatabaseId = "",
};
// Make the request
RunAggregationQueryResponse response = await datastoreClient.RunAggregationQueryAsync(request);
}
}
// [END datastore_v1_generated_Datastore_RunAggregationQuery_async]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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.Datastore.V1.Snippets
{
// [START datastore_v1_generated_Datastore_RunAggregationQuery_sync]
using Google.Cloud.Datastore.V1;

public sealed partial class GeneratedDatastoreClientSnippets
{
/// <summary>Snippet for RunAggregationQuery</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public void RunAggregationQueryRequestObject()
{
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
RunAggregationQueryRequest request = new RunAggregationQueryRequest
{
ReadOptions = new ReadOptions(),
PartitionId = new PartitionId(),
AggregationQuery = new AggregationQuery(),
ProjectId = "",
DatabaseId = "",
};
// Make the request
RunAggregationQueryResponse response = datastoreClient.RunAggregationQuery(request);
}
}
// [END datastore_v1_generated_Datastore_RunAggregationQuery_sync]
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,59 @@
"canonical": true,
"origin": "API_DEFINITION"
},
{
"regionTag": "datastore_v1_generated_Datastore_RunAggregationQuery_sync",
"title": "RunAggregationQueryRequestObject",
"description": "Snippet for RunAggregationQuery",
"file": "DatastoreClient.RunAggregationQueryRequestObjectSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "RunAggregationQuery",
"fullName": "Google.Cloud.Datastore.V1.DatastoreClient.RunAggregationQuery",
"resultType": "Google.Cloud.Datastore.V1.RunAggregationQueryResponse",
"client": {
"shortName": "DatastoreClient",
"fullName": "Google.Cloud.Datastore.V1.DatastoreClient"
},
"method": {
"shortName": "RunAggregationQuery",
"fullName": "google.datastore.v1.Datastore.RunAggregationQuery",
"service": {
"shortName": "Datastore",
"fullName": "google.datastore.v1.Datastore"
}
}
},
"canonical": true,
"origin": "API_DEFINITION"
},
{
"regionTag": "datastore_v1_generated_Datastore_RunAggregationQuery_async",
"title": "RunAggregationQueryRequestObjectAsync",
"description": "Snippet for RunAggregationQueryAsync",
"file": "DatastoreClient.RunAggregationQueryRequestObjectAsyncSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "RunAggregationQueryAsync",
"fullName": "Google.Cloud.Datastore.V1.DatastoreClient.RunAggregationQueryAsync",
"async": true,
"resultType": "System.Threading.Tasks.Task<Google.Cloud.Datastore.V1.RunAggregationQueryResponse>",
"client": {
"shortName": "DatastoreClient",
"fullName": "Google.Cloud.Datastore.V1.DatastoreClient"
},
"method": {
"shortName": "RunAggregationQuery",
"fullName": "google.datastore.v1.Datastore.RunAggregationQuery",
"service": {
"shortName": "Datastore",
"fullName": "google.datastore.v1.Datastore"
}
}
},
"canonical": true,
"origin": "API_DEFINITION"
},
{
"regionTag": "datastore_v1_generated_Datastore_BeginTransaction_sync",
"title": "BeginTransactionRequestObject",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,47 @@ public async Task RunQueryRequestObjectAsync()
// End snippet
}

/// <summary>Snippet for RunAggregationQuery</summary>
public void RunAggregationQueryRequestObject()
{
// Snippet: RunAggregationQuery(RunAggregationQueryRequest, CallSettings)
// Create client
DatastoreClient datastoreClient = DatastoreClient.Create();
// Initialize request argument(s)
RunAggregationQueryRequest request = new RunAggregationQueryRequest
{
ReadOptions = new ReadOptions(),
PartitionId = new PartitionId(),
AggregationQuery = new AggregationQuery(),
ProjectId = "",
DatabaseId = "",
};
// Make the request
RunAggregationQueryResponse response = datastoreClient.RunAggregationQuery(request);
// End snippet
}

/// <summary>Snippet for RunAggregationQueryAsync</summary>
public async Task RunAggregationQueryRequestObjectAsync()
{
// Snippet: RunAggregationQueryAsync(RunAggregationQueryRequest, CallSettings)
// Additional: RunAggregationQueryAsync(RunAggregationQueryRequest, CancellationToken)
// Create client
DatastoreClient datastoreClient = await DatastoreClient.CreateAsync();
// Initialize request argument(s)
RunAggregationQueryRequest request = new RunAggregationQueryRequest
{
ReadOptions = new ReadOptions(),
PartitionId = new PartitionId(),
AggregationQuery = new AggregationQuery(),
ProjectId = "",
DatabaseId = "",
};
// Make the request
RunAggregationQueryResponse response = await datastoreClient.RunAggregationQueryAsync(request);
// End snippet
}

/// <summary>Snippet for BeginTransaction</summary>
public void BeginTransactionRequestObject()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,58 @@ public void RunQueryRequestObject()
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public void RunAggregationQueryRequestObject()
{
moq::Mock<Datastore.DatastoreClient> mockGrpcClient = new moq::Mock<Datastore.DatastoreClient>(moq::MockBehavior.Strict);
RunAggregationQueryRequest request = new RunAggregationQueryRequest
{
ReadOptions = new ReadOptions(),
PartitionId = new PartitionId(),
AggregationQuery = new AggregationQuery(),
GqlQuery = new GqlQuery(),
ProjectId = "project_id43ad98b0",
DatabaseId = "database_idbff1efc9",
};
RunAggregationQueryResponse expectedResponse = new RunAggregationQueryResponse
{
Batch = new AggregationResultBatch(),
Query = new AggregationQuery(),
};
mockGrpcClient.Setup(x => x.RunAggregationQuery(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null, null);
RunAggregationQueryResponse response = client.RunAggregationQuery(request);
xunit::Assert.Same(expectedResponse, response);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public async stt::Task RunAggregationQueryRequestObjectAsync()
{
moq::Mock<Datastore.DatastoreClient> mockGrpcClient = new moq::Mock<Datastore.DatastoreClient>(moq::MockBehavior.Strict);
RunAggregationQueryRequest request = new RunAggregationQueryRequest
{
ReadOptions = new ReadOptions(),
PartitionId = new PartitionId(),
AggregationQuery = new AggregationQuery(),
GqlQuery = new GqlQuery(),
ProjectId = "project_id43ad98b0",
DatabaseId = "database_idbff1efc9",
};
RunAggregationQueryResponse expectedResponse = new RunAggregationQueryResponse
{
Batch = new AggregationResultBatch(),
Query = new AggregationQuery(),
};
mockGrpcClient.Setup(x => x.RunAggregationQueryAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<RunAggregationQueryResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null, null);
RunAggregationQueryResponse responseCallSettings = await client.RunAggregationQueryAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));
xunit::Assert.Same(expectedResponse, responseCallSettings);
RunAggregationQueryResponse responseCancellationToken = await client.RunAggregationQueryAsync(request, st::CancellationToken.None);
xunit::Assert.Same(expectedResponse, responseCancellationToken);
mockGrpcClient.VerifyAll();
}

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

0 comments on commit 5e75d6c

Please sign in to comment.