Skip to content

Commit

Permalink
docs: [Google.Cloud.BigQuery.Storage.V1] improve documentation for wr…
Browse files Browse the repository at this point in the history
…ite client (#8218)

* docs: improve documentation for write client
feat: update default timeout/retry information
feat: update parent annotation for BatchCommitWriteStreamsRequest
feat: expose additional StorageError enum values

PiperOrigin-RevId: 431973595

Source-Link: googleapis/googleapis@25d691b

Source-Link: googleapis/googleapis-gen@0ca2187
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuQmlnUXVlcnkuU3RvcmFnZS5WMS8uT3dsQm90LnlhbWwiLCJoIjoiMGNhMjE4NzlhZTMxMzZhMmQ3MWZhODI0YjQ5ZGZhZjhhMGFlMGYyZSJ9
  • Loading branch information
gcf-owl-bot[bot] committed Mar 4, 2022
1 parent 9f989fd commit e64637d
Show file tree
Hide file tree
Showing 13 changed files with 409 additions and 94 deletions.
Expand Up @@ -32,7 +32,7 @@ public async Task BatchCommitWriteStreamsAsync()
// Create client
BigQueryWriteClient bigQueryWriteClient = await BigQueryWriteClient.CreateAsync();
// Initialize request argument(s)
string parent = "";
string parent = "projects/[PROJECT]/datasets/[DATASET]/tables/[TABLE]";
// Make the request
BatchCommitWriteStreamsResponse response = await bigQueryWriteClient.BatchCommitWriteStreamsAsync(parent);
}
Expand Down
Expand Up @@ -34,7 +34,7 @@ public async Task BatchCommitWriteStreamsRequestObjectAsync()
// Initialize request argument(s)
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
Parent = "",
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
WriteStreams = { "", },
};
// Make the request
Expand Down
Expand Up @@ -33,7 +33,7 @@ public void BatchCommitWriteStreamsRequestObject()
// Initialize request argument(s)
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
Parent = "",
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
WriteStreams = { "", },
};
// Make the request
Expand Down
@@ -0,0 +1,41 @@
// 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.BigQuery.Storage.V1.Snippets
{
// [START bigquerystorage_v1_generated_BigQueryWrite_BatchCommitWriteStreams_async_flattened_resourceNames]
using Google.Cloud.BigQuery.Storage.V1;
using System.Threading.Tasks;

public sealed partial class GeneratedBigQueryWriteClientSnippets
{
/// <summary>Snippet for BatchCommitWriteStreamsAsync</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 BatchCommitWriteStreamsResourceNamesAsync()
{
// Create client
BigQueryWriteClient bigQueryWriteClient = await BigQueryWriteClient.CreateAsync();
// Initialize request argument(s)
TableName parent = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]");
// Make the request
BatchCommitWriteStreamsResponse response = await bigQueryWriteClient.BatchCommitWriteStreamsAsync(parent);
}
}
// [END bigquerystorage_v1_generated_BigQueryWrite_BatchCommitWriteStreams_async_flattened_resourceNames]
}
@@ -0,0 +1,40 @@
// 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.BigQuery.Storage.V1.Snippets
{
// [START bigquerystorage_v1_generated_BigQueryWrite_BatchCommitWriteStreams_sync_flattened_resourceNames]
using Google.Cloud.BigQuery.Storage.V1;

public sealed partial class GeneratedBigQueryWriteClientSnippets
{
/// <summary>Snippet for BatchCommitWriteStreams</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public void BatchCommitWriteStreamsResourceNames()
{
// Create client
BigQueryWriteClient bigQueryWriteClient = BigQueryWriteClient.Create();
// Initialize request argument(s)
TableName parent = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]");
// Make the request
BatchCommitWriteStreamsResponse response = bigQueryWriteClient.BatchCommitWriteStreams(parent);
}
}
// [END bigquerystorage_v1_generated_BigQueryWrite_BatchCommitWriteStreams_sync_flattened_resourceNames]
}
Expand Up @@ -31,7 +31,7 @@ public void BatchCommitWriteStreams()
// Create client
BigQueryWriteClient bigQueryWriteClient = BigQueryWriteClient.Create();
// Initialize request argument(s)
string parent = "";
string parent = "projects/[PROJECT]/datasets/[DATASET]/tables/[TABLE]";
// Make the request
BatchCommitWriteStreamsResponse response = bigQueryWriteClient.BatchCommitWriteStreams(parent);
}
Expand Down
Expand Up @@ -889,6 +889,57 @@
},
"origin": "API_DEFINITION"
},
{
"regionTag": "bigquerystorage_v1_generated_BigQueryWrite_BatchCommitWriteStreams_sync_flattened_resourceNames",
"title": "BatchCommitWriteStreamsResourceNames",
"description": "Snippet for BatchCommitWriteStreams",
"file": "BigQueryWriteClient.BatchCommitWriteStreamsResourceNamesSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "BatchCommitWriteStreams",
"fullName": "Google.Cloud.BigQuery.Storage.V1.BigQueryWriteClient.BatchCommitWriteStreams",
"resultType": "Google.Cloud.BigQuery.Storage.V1.BatchCommitWriteStreamsResponse",
"client": {
"shortName": "BigQueryWriteClient",
"fullName": "Google.Cloud.BigQuery.Storage.V1.BigQueryWriteClient"
},
"method": {
"shortName": "BatchCommitWriteStreams",
"fullName": "google.cloud.bigquery.storage.v1.BigQueryWrite.BatchCommitWriteStreams",
"service": {
"shortName": "BigQueryWrite",
"fullName": "google.cloud.bigquery.storage.v1.BigQueryWrite"
}
}
},
"origin": "API_DEFINITION"
},
{
"regionTag": "bigquerystorage_v1_generated_BigQueryWrite_BatchCommitWriteStreams_async_flattened_resourceNames",
"title": "BatchCommitWriteStreamsResourceNamesAsync",
"description": "Snippet for BatchCommitWriteStreamsAsync",
"file": "BigQueryWriteClient.BatchCommitWriteStreamsResourceNamesAsyncSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "BatchCommitWriteStreamsAsync",
"fullName": "Google.Cloud.BigQuery.Storage.V1.BigQueryWriteClient.BatchCommitWriteStreamsAsync",
"async": true,
"resultType": "System.Threading.Tasks.Task<Google.Cloud.BigQuery.Storage.V1.BatchCommitWriteStreamsResponse>",
"client": {
"shortName": "BigQueryWriteClient",
"fullName": "Google.Cloud.BigQuery.Storage.V1.BigQueryWriteClient"
},
"method": {
"shortName": "BatchCommitWriteStreams",
"fullName": "google.cloud.bigquery.storage.v1.BigQueryWrite.BatchCommitWriteStreams",
"service": {
"shortName": "BigQueryWrite",
"fullName": "google.cloud.bigquery.storage.v1.BigQueryWrite"
}
}
},
"origin": "API_DEFINITION"
},
{
"regionTag": "bigquerystorage_v1_generated_BigQueryWrite_FlushRows_sync",
"title": "FlushRowsRequestObject",
Expand Down
Expand Up @@ -348,7 +348,7 @@ public void BatchCommitWriteStreamsRequestObject()
// Initialize request argument(s)
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
Parent = "",
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
WriteStreams = { "", },
};
// Make the request
Expand All @@ -366,7 +366,7 @@ public async Task BatchCommitWriteStreamsRequestObjectAsync()
// Initialize request argument(s)
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
Parent = "",
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
WriteStreams = { "", },
};
// Make the request
Expand All @@ -381,7 +381,7 @@ public void BatchCommitWriteStreams()
// Create client
BigQueryWriteClient bigQueryWriteClient = BigQueryWriteClient.Create();
// Initialize request argument(s)
string parent = "";
string parent = "projects/[PROJECT]/datasets/[DATASET]/tables/[TABLE]";
// Make the request
BatchCommitWriteStreamsResponse response = bigQueryWriteClient.BatchCommitWriteStreams(parent);
// End snippet
Expand All @@ -395,7 +395,34 @@ public async Task BatchCommitWriteStreamsAsync()
// Create client
BigQueryWriteClient bigQueryWriteClient = await BigQueryWriteClient.CreateAsync();
// Initialize request argument(s)
string parent = "";
string parent = "projects/[PROJECT]/datasets/[DATASET]/tables/[TABLE]";
// Make the request
BatchCommitWriteStreamsResponse response = await bigQueryWriteClient.BatchCommitWriteStreamsAsync(parent);
// End snippet
}

/// <summary>Snippet for BatchCommitWriteStreams</summary>
public void BatchCommitWriteStreamsResourceNames()
{
// Snippet: BatchCommitWriteStreams(TableName, CallSettings)
// Create client
BigQueryWriteClient bigQueryWriteClient = BigQueryWriteClient.Create();
// Initialize request argument(s)
TableName parent = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]");
// Make the request
BatchCommitWriteStreamsResponse response = bigQueryWriteClient.BatchCommitWriteStreams(parent);
// End snippet
}

/// <summary>Snippet for BatchCommitWriteStreamsAsync</summary>
public async Task BatchCommitWriteStreamsResourceNamesAsync()
{
// Snippet: BatchCommitWriteStreamsAsync(TableName, CallSettings)
// Additional: BatchCommitWriteStreamsAsync(TableName, CancellationToken)
// Create client
BigQueryWriteClient bigQueryWriteClient = await BigQueryWriteClient.CreateAsync();
// Initialize request argument(s)
TableName parent = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]");
// Make the request
BatchCommitWriteStreamsResponse response = await bigQueryWriteClient.BatchCommitWriteStreamsAsync(parent);
// End snippet
Expand Down
Expand Up @@ -459,7 +459,7 @@ public void BatchCommitWriteStreamsRequestObject()
moq::Mock<BigQueryWrite.BigQueryWriteClient> mockGrpcClient = new moq::Mock<BigQueryWrite.BigQueryWriteClient>(moq::MockBehavior.Strict);
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
Parent = "parent7858e4d0",
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
WriteStreams =
{
"write_streams405973b2",
Expand All @@ -483,7 +483,7 @@ public void BatchCommitWriteStreamsRequestObject()
moq::Mock<BigQueryWrite.BigQueryWriteClient> mockGrpcClient = new moq::Mock<BigQueryWrite.BigQueryWriteClient>(moq::MockBehavior.Strict);
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
Parent = "parent7858e4d0",
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
WriteStreams =
{
"write_streams405973b2",
Expand All @@ -509,7 +509,7 @@ public void BatchCommitWriteStreams()
moq::Mock<BigQueryWrite.BigQueryWriteClient> mockGrpcClient = new moq::Mock<BigQueryWrite.BigQueryWriteClient>(moq::MockBehavior.Strict);
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
Parent = "parent7858e4d0",
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
};
BatchCommitWriteStreamsResponse expectedResponse = new BatchCommitWriteStreamsResponse
{
Expand All @@ -529,7 +529,7 @@ public void BatchCommitWriteStreams()
moq::Mock<BigQueryWrite.BigQueryWriteClient> mockGrpcClient = new moq::Mock<BigQueryWrite.BigQueryWriteClient>(moq::MockBehavior.Strict);
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
Parent = "parent7858e4d0",
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
};
BatchCommitWriteStreamsResponse expectedResponse = new BatchCommitWriteStreamsResponse
{
Expand All @@ -545,6 +545,48 @@ public void BatchCommitWriteStreams()
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public void BatchCommitWriteStreamsResourceNames()
{
moq::Mock<BigQueryWrite.BigQueryWriteClient> mockGrpcClient = new moq::Mock<BigQueryWrite.BigQueryWriteClient>(moq::MockBehavior.Strict);
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
};
BatchCommitWriteStreamsResponse expectedResponse = new BatchCommitWriteStreamsResponse
{
CommitTime = new wkt::Timestamp(),
StreamErrors = { new StorageError(), },
};
mockGrpcClient.Setup(x => x.BatchCommitWriteStreams(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
BigQueryWriteClient client = new BigQueryWriteClientImpl(mockGrpcClient.Object, null);
BatchCommitWriteStreamsResponse response = client.BatchCommitWriteStreams(request.ParentAsTableName);
xunit::Assert.Same(expectedResponse, response);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public async stt::Task BatchCommitWriteStreamsResourceNamesAsync()
{
moq::Mock<BigQueryWrite.BigQueryWriteClient> mockGrpcClient = new moq::Mock<BigQueryWrite.BigQueryWriteClient>(moq::MockBehavior.Strict);
BatchCommitWriteStreamsRequest request = new BatchCommitWriteStreamsRequest
{
ParentAsTableName = TableName.FromProjectDatasetTable("[PROJECT]", "[DATASET]", "[TABLE]"),
};
BatchCommitWriteStreamsResponse expectedResponse = new BatchCommitWriteStreamsResponse
{
CommitTime = new wkt::Timestamp(),
StreamErrors = { new StorageError(), },
};
mockGrpcClient.Setup(x => x.BatchCommitWriteStreamsAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<BatchCommitWriteStreamsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
BigQueryWriteClient client = new BigQueryWriteClientImpl(mockGrpcClient.Object, null);
BatchCommitWriteStreamsResponse responseCallSettings = await client.BatchCommitWriteStreamsAsync(request.ParentAsTableName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));
xunit::Assert.Same(expectedResponse, responseCallSettings);
BatchCommitWriteStreamsResponse responseCancellationToken = await client.BatchCommitWriteStreamsAsync(request.ParentAsTableName, st::CancellationToken.None);
xunit::Assert.Same(expectedResponse, responseCancellationToken);
mockGrpcClient.VerifyAll();
}

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

0 comments on commit e64637d

Please sign in to comment.