Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ service Deprecated {

// Test method
rpc DeprecatedResponseMethod(Request) returns(DeprecatedMessageResponse);

// Test method
rpc DeprecatedResourcesFieldPaginatedMethod(PaginatedRequest) returns(DeprecatedResourcesFieldPaginatedResponse) {
option (google.api.method_signature) = "name";
};

// Test method
rpc DeprecatedPaginatedMethod(PaginatedRequest) returns(PaginatedResponse) {
option deprecated = true;
};

// Test method
rpc DeprecatedResponsePaginatedMethod(PaginatedRequest) returns(DeprecatedPaginatedResponse);
}

// A whole service that's deprecated this time. One RPC which is explicitly
Expand Down Expand Up @@ -59,3 +72,26 @@ message DeprecatedMessageResponse {

message Response {
}

message PaginatedRequest {
string name = 1;
int32 page_size = 2;
string page_token = 3;
}

message DeprecatedResourcesFieldPaginatedResponse {
repeated Response items = 1 [deprecated = true];
string next_page_token = 2;
repeated Response replacement_items = 3;
}

message PaginatedResponse {
repeated Response items = 1;
string next_page_token = 2;
}

message DeprecatedPaginatedResponse {
option deprecated = true;
repeated Response items = 1;
string next_page_token = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Protobuf.Collections;
using Google.Protobuf.Reflection;
using Grpc.Core;
using System;
Expand All @@ -37,6 +38,12 @@ public DeprecatedClient(CallInvoker callInvoker) { }
public virtual AsyncUnaryCall<Response> DeprecatedMethodAsync(Request request, CallOptions callOptions) => throw new NotImplementedException();
public virtual DeprecatedMessageResponse DeprecatedResponseMethod(Request request, CallOptions callOptions) => throw new NotImplementedException();
public virtual AsyncUnaryCall<DeprecatedMessageResponse> DeprecatedResponseMethodAsync(Request request, CallOptions callOptions) => throw new NotImplementedException();
public virtual DeprecatedResourcesFieldPaginatedResponse DeprecatedResourcesFieldPaginatedMethod(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException();
public virtual AsyncUnaryCall<DeprecatedResourcesFieldPaginatedResponse> DeprecatedResourcesFieldPaginatedMethodAsync(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException();
public virtual PaginatedResponse DeprecatedPaginatedMethod(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException();
public virtual AsyncUnaryCall<PaginatedResponse> DeprecatedPaginatedMethodAsync(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException();
public virtual DeprecatedPaginatedResponse DeprecatedResponsePaginatedMethod(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException();
public virtual AsyncUnaryCall<DeprecatedPaginatedResponse> DeprecatedResponsePaginatedMethodAsync(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException();
}
}

Expand Down Expand Up @@ -72,4 +79,32 @@ public class Request : ProtoMsgFake<Request> { }
public class DeprecatedMessageResponse : ProtoMsgFake<DeprecatedMessageResponse> { }

public class Response : ProtoMsgFake<Response> { }

public partial class PaginatedRequest : ProtoMsgFake<PaginatedRequest>
{
public string Name { get; set; }
public int PageSize { get; set; }
public string PageToken { get; set; }
}

public partial class DeprecatedResourcesFieldPaginatedResponse : ProtoMsgFake<DeprecatedResourcesFieldPaginatedResponse>
{
[Obsolete]
public RepeatedField<Response> Items => throw new NotImplementedException();
public string NextPageToken { get; set; }
public RepeatedField<Response> ReplacementItems => throw new NotImplementedException();
}

public partial class PaginatedResponse : ProtoMsgFake<PaginatedResponse>
{
public RepeatedField<Response> Items => throw new NotImplementedException();
public string NextPageToken { get; set; }
}

[Obsolete]
public partial class DeprecatedPaginatedResponse : ProtoMsgFake<DeprecatedPaginatedResponse>
{
public RepeatedField<Response> Items => throw new NotImplementedException();
public string NextPageToken { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright 2019 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 deprecated_generated_Deprecated_DeprecatedPaginatedMethod_async]
using Google.Api.Gax;
using System;
using System.Threading.Tasks;
using Testing.Deprecated;

public sealed partial class GeneratedDeprecatedClientSnippets
{
/// <summary>Snippet for DeprecatedPaginatedMethodAsync</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 DeprecatedPaginatedMethodRequestObjectAsync()
{
// Create client
DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync();
// Initialize request argument(s)
PaginatedRequest request = new PaginatedRequest { Name = "", };
// Make the request
#pragma warning disable CS0612
PagedAsyncEnumerable<PaginatedResponse, Response> response = deprecatedClient.DeprecatedPaginatedMethodAsync(request);
#pragma warning restore CS0612

// Iterate over all response items, lazily performing RPCs as required
await foreach (Response item in response)
{
// Do something with each item
Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
await foreach (PaginatedResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Response item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Response> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Response item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
}
}
// [END deprecated_generated_Deprecated_DeprecatedPaginatedMethod_async]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2019 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 deprecated_generated_Deprecated_DeprecatedPaginatedMethod_sync]
using Google.Api.Gax;
using System;
using Testing.Deprecated;

public sealed partial class GeneratedDeprecatedClientSnippets
{
/// <summary>Snippet for DeprecatedPaginatedMethod</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 DeprecatedPaginatedMethodRequestObject()
{
// Create client
DeprecatedClient deprecatedClient = DeprecatedClient.Create();
// Initialize request argument(s)
PaginatedRequest request = new PaginatedRequest { Name = "", };
// Make the request
#pragma warning disable CS0612
PagedEnumerable<PaginatedResponse, Response> response = deprecatedClient.DeprecatedPaginatedMethod(request);
#pragma warning restore CS0612

// Iterate over all response items, lazily performing RPCs as required
foreach (Response item in response)
{
// Do something with each item
Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (PaginatedResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Response item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Response> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Response item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
}
}
// [END deprecated_generated_Deprecated_DeprecatedPaginatedMethod_sync]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright 2019 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 deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_async_flattened]
using Google.Api.Gax;
using System;
using System.Threading.Tasks;
using Testing.Deprecated;

public sealed partial class GeneratedDeprecatedClientSnippets
{
/// <summary>Snippet for DeprecatedResourcesFieldPaginatedMethodAsync</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 DeprecatedResourcesFieldPaginatedMethodAsync()
{
// Create client
DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
PagedAsyncEnumerable<DeprecatedResourcesFieldPaginatedResponse, Response> response = deprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsync(name);

// Iterate over all response items, lazily performing RPCs as required
await foreach (Response item in response)
{
// Do something with each item
Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
await foreach (DeprecatedResourcesFieldPaginatedResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Response item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Response> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Response item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
}
}
// [END deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_async_flattened]
}
Loading
Loading