Skip to content

Commit

Permalink
chore: protos for R/W transaction support on multiplexed sessions
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 683879049

Source-Link: googleapis/googleapis@2b6b93b

Source-Link: googleapis/googleapis-gen@2f0c933
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuU3Bhbm5lci5WMS8uT3dsQm90LnlhbWwiLCJoIjoiMmYwYzkzM2IwMDMxNjRkNWNkMTIwNTA1YTk4Yzg3Yzk1ODg4ZDk4ZiJ9
  • Loading branch information
gcf-owl-bot[bot] committed Oct 9, 2024
1 parent df83180 commit 550d06e
Show file tree
Hide file tree
Showing 86 changed files with 34,296 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../Google.Cloud.Spanner.V1/Google.Cloud.Spanner.V1.csproj" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2024 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 GoogleCSharpSnippets
{
// [START spanner_v1_generated_Spanner_BatchCreateSessions_async_flattened]
using Google.Cloud.Spanner.V1;
using System.Threading.Tasks;

public sealed partial class GeneratedSpannerClientSnippets
{
/// <summary>Snippet for BatchCreateSessionsAsync</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task BatchCreateSessionsAsync()
{
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
string database = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]";
int sessionCount = 0;
// Make the request
BatchCreateSessionsResponse response = await spannerClient.BatchCreateSessionsAsync(database, sessionCount);
}
}
// [END spanner_v1_generated_Spanner_BatchCreateSessions_async_flattened]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2024 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 GoogleCSharpSnippets
{
// [START spanner_v1_generated_Spanner_BatchCreateSessions_async]
using Google.Cloud.Spanner.V1;
using System.Threading.Tasks;

public sealed partial class GeneratedSpannerClientSnippets
{
/// <summary>Snippet for BatchCreateSessionsAsync</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task BatchCreateSessionsRequestObjectAsync()
{
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
BatchCreateSessionsRequest request = new BatchCreateSessionsRequest
{
DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
SessionTemplate = new Session(),
SessionCount = 0,
};
// Make the request
BatchCreateSessionsResponse response = await spannerClient.BatchCreateSessionsAsync(request);
}
}
// [END spanner_v1_generated_Spanner_BatchCreateSessions_async]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2024 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 GoogleCSharpSnippets
{
// [START spanner_v1_generated_Spanner_BatchCreateSessions_sync]
using Google.Cloud.Spanner.V1;

public sealed partial class GeneratedSpannerClientSnippets
{
/// <summary>Snippet for BatchCreateSessions</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public void BatchCreateSessionsRequestObject()
{
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
BatchCreateSessionsRequest request = new BatchCreateSessionsRequest
{
DatabaseAsDatabaseName = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]"),
SessionTemplate = new Session(),
SessionCount = 0,
};
// Make the request
BatchCreateSessionsResponse response = spannerClient.BatchCreateSessions(request);
}
}
// [END spanner_v1_generated_Spanner_BatchCreateSessions_sync]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2024 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 GoogleCSharpSnippets
{
// [START spanner_v1_generated_Spanner_BatchCreateSessions_async_flattened_resourceNames]
using Google.Cloud.Spanner.V1;
using System.Threading.Tasks;

public sealed partial class GeneratedSpannerClientSnippets
{
/// <summary>Snippet for BatchCreateSessionsAsync</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task BatchCreateSessionsResourceNamesAsync()
{
// Create client
SpannerClient spannerClient = await SpannerClient.CreateAsync();
// Initialize request argument(s)
DatabaseName database = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]");
int sessionCount = 0;
// Make the request
BatchCreateSessionsResponse response = await spannerClient.BatchCreateSessionsAsync(database, sessionCount);
}
}
// [END spanner_v1_generated_Spanner_BatchCreateSessions_async_flattened_resourceNames]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2024 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 GoogleCSharpSnippets
{
// [START spanner_v1_generated_Spanner_BatchCreateSessions_sync_flattened_resourceNames]
using Google.Cloud.Spanner.V1;

public sealed partial class GeneratedSpannerClientSnippets
{
/// <summary>Snippet for BatchCreateSessions</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public void BatchCreateSessionsResourceNames()
{
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
DatabaseName database = DatabaseName.FromProjectInstanceDatabase("[PROJECT]", "[INSTANCE]", "[DATABASE]");
int sessionCount = 0;
// Make the request
BatchCreateSessionsResponse response = spannerClient.BatchCreateSessions(database, sessionCount);
}
}
// [END spanner_v1_generated_Spanner_BatchCreateSessions_sync_flattened_resourceNames]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2024 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 GoogleCSharpSnippets
{
// [START spanner_v1_generated_Spanner_BatchCreateSessions_sync_flattened]
using Google.Cloud.Spanner.V1;

public sealed partial class GeneratedSpannerClientSnippets
{
/// <summary>Snippet for BatchCreateSessions</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public void BatchCreateSessions()
{
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
string database = "projects/[PROJECT]/instances/[INSTANCE]/databases/[DATABASE]";
int sessionCount = 0;
// Make the request
BatchCreateSessionsResponse response = spannerClient.BatchCreateSessions(database, sessionCount);
}
}
// [END spanner_v1_generated_Spanner_BatchCreateSessions_sync_flattened]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2024 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 GoogleCSharpSnippets
{
// [START spanner_v1_generated_Spanner_BatchWrite_sync]
using Google.Api.Gax.Grpc;
using Google.Cloud.Spanner.V1;
using System.Threading.Tasks;

public sealed partial class GeneratedSpannerClientSnippets
{
/// <summary>Snippet for BatchWrite</summary>
/// <remarks>
/// This snippet has been automatically generated and should be regarded as a code template only.
/// It will require modifications to work:
/// - It may require correct/in-range values for request initialization.
/// - It may require specifying regional endpoints when creating the service client as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task BatchWriteRequestObject()
{
// Create client
SpannerClient spannerClient = SpannerClient.Create();
// Initialize request argument(s)
BatchWriteRequest request = new BatchWriteRequest
{
SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
RequestOptions = new RequestOptions(),
MutationGroups =
{
new BatchWriteRequest.Types.MutationGroup(),
},
ExcludeTxnFromChangeStreams = false,
};
// Make the request, returning a streaming response
using SpannerClient.BatchWriteStream response = spannerClient.BatchWrite(request);

// Read streaming responses from server until complete
// Note that C# 8 code can use await foreach
AsyncResponseStream<BatchWriteResponse> responseStream = response.GetResponseStream();
while (await responseStream.MoveNextAsync())
{
BatchWriteResponse responseItem = responseStream.Current;
// Do something with streamed response
}
// The response stream has completed
}
}
// [END spanner_v1_generated_Spanner_BatchWrite_sync]
}
Loading

0 comments on commit 550d06e

Please sign in to comment.