Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
C# support LRO metadata (#1252)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdunelm authored May 9, 2017
1 parent ed631be commit 0f7055d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,10 @@ public String getAndSaveOperationResponseTypeName(
Method method, ModelTypeTable typeTable, GapicMethodConfig methodConfig) {
String responseTypeName =
typeTable.getFullNameFor(methodConfig.getLongRunningConfig().getReturnType());
String metaTypeName =
typeTable.getFullNameFor(methodConfig.getLongRunningConfig().getMetadataType());
return typeTable.getAndSaveNicknameForContainer(
"Google.LongRunning.Operation", responseTypeName);
"Google.LongRunning.Operation", responseTypeName, metaTypeName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public TypeName getTypeName(String fullName) {
String containerTypeName = fullName.substring(0, firstGenericOpenIndex);
List<String> genericParamNames =
Splitter.on(',')
.trimResults()
.splitToList(fullName.substring(firstGenericOpenIndex + 1, lastGenericCloseIndex));
return getContainerTypeName(
containerTypeName, genericParamNames.toArray(new String[genericParamNames.size()]));
Expand Down Expand Up @@ -76,7 +77,7 @@ public TypeName getContainerTypeName(String containerFullName, String... element
for (int i = 0; i < elementTypeNames.length; i++) {
elementTypeNames[i] = getTypeName(elementFullNames[i]);
}
String argPattern = Joiner.on(",").join(Collections.nCopies(elementTypeNames.length, "%i"));
String argPattern = Joiner.on(", ").join(Collections.nCopies(elementTypeNames.length, "%i"));
String pattern = "%s<" + argPattern + ">";
return new TypeName(
containerTypeName.getFullName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3544,7 +3544,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// A Task containing the RPC response.
/// </returns>
public virtual Task<Operation<Book>> GetBigBookAsync(
public virtual Task<Operation<Book, GetBigBookMetadata>> GetBigBookAsync(
BookName name,
CallSettings callSettings = null) => GetBigBookAsync(
new GetBookRequest
Expand All @@ -3565,7 +3565,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// A Task containing the RPC response.
/// </returns>
public virtual Task<Operation<Book>> GetBigBookAsync(
public virtual Task<Operation<Book, GetBigBookMetadata>> GetBigBookAsync(
BookName name,
CancellationToken cancellationToken) => GetBigBookAsync(
name,
Expand All @@ -3583,7 +3583,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// The RPC response.
/// </returns>
public virtual Operation<Book> GetBigBook(
public virtual Operation<Book, GetBigBookMetadata> GetBigBook(
BookName name,
CallSettings callSettings = null) => GetBigBook(
new GetBookRequest
Expand All @@ -3604,7 +3604,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// A Task containing the RPC response.
/// </returns>
public virtual Task<Operation<Book>> GetBigBookAsync(
public virtual Task<Operation<Book, GetBigBookMetadata>> GetBigBookAsync(
GetBookRequest request,
CallSettings callSettings = null)
{
Expand All @@ -3617,9 +3617,9 @@ namespace Google.Example.Library.V1
/// <param name="operationName">The name of a previously invoked operation. Must not be <c>null</c> or empty.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
/// <returns>A task representing the result of polling the operation.</returns>
public virtual Task<Operation<Book>> PollOnceGetBigBookAsync(
public virtual Task<Operation<Book, GetBigBookMetadata>> PollOnceGetBigBookAsync(
string operationName,
CallSettings callSettings = null) => Operation<Book>.PollOnceFromNameAsync(
CallSettings callSettings = null) => Operation<Book, GetBigBookMetadata>.PollOnceFromNameAsync(
GaxPreconditions.CheckNotNullOrEmpty(operationName, nameof(operationName)),
LongRunningOperationsClient,
callSettings);
Expand All @@ -3636,7 +3636,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// The RPC response.
/// </returns>
public virtual Operation<Book> GetBigBook(
public virtual Operation<Book, GetBigBookMetadata> GetBigBook(
GetBookRequest request,
CallSettings callSettings = null)
{
Expand All @@ -3649,9 +3649,9 @@ namespace Google.Example.Library.V1
/// <param name="operationName">The name of a previously invoked operation. Must not be <c>null</c> or empty.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
/// <returns>The result of polling the operation.</returns>
public virtual Operation<Book> PollOnceGetBigBook(
public virtual Operation<Book, GetBigBookMetadata> PollOnceGetBigBook(
string operationName,
CallSettings callSettings = null) => Operation<Book>.PollOnceFromName(
CallSettings callSettings = null) => Operation<Book, GetBigBookMetadata>.PollOnceFromName(
GaxPreconditions.CheckNotNullOrEmpty(operationName, nameof(operationName)),
LongRunningOperationsClient,
callSettings);
Expand All @@ -3668,7 +3668,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// A Task containing the RPC response.
/// </returns>
public virtual Task<Operation<Empty>> GetBigNothingAsync(
public virtual Task<Operation<Empty, GetBigBookMetadata>> GetBigNothingAsync(
BookName name,
CallSettings callSettings = null) => GetBigNothingAsync(
new GetBookRequest
Expand All @@ -3689,7 +3689,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// A Task containing the RPC response.
/// </returns>
public virtual Task<Operation<Empty>> GetBigNothingAsync(
public virtual Task<Operation<Empty, GetBigBookMetadata>> GetBigNothingAsync(
BookName name,
CancellationToken cancellationToken) => GetBigNothingAsync(
name,
Expand All @@ -3707,7 +3707,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// The RPC response.
/// </returns>
public virtual Operation<Empty> GetBigNothing(
public virtual Operation<Empty, GetBigBookMetadata> GetBigNothing(
BookName name,
CallSettings callSettings = null) => GetBigNothing(
new GetBookRequest
Expand All @@ -3728,7 +3728,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// A Task containing the RPC response.
/// </returns>
public virtual Task<Operation<Empty>> GetBigNothingAsync(
public virtual Task<Operation<Empty, GetBigBookMetadata>> GetBigNothingAsync(
GetBookRequest request,
CallSettings callSettings = null)
{
Expand All @@ -3741,9 +3741,9 @@ namespace Google.Example.Library.V1
/// <param name="operationName">The name of a previously invoked operation. Must not be <c>null</c> or empty.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
/// <returns>A task representing the result of polling the operation.</returns>
public virtual Task<Operation<Empty>> PollOnceGetBigNothingAsync(
public virtual Task<Operation<Empty, GetBigBookMetadata>> PollOnceGetBigNothingAsync(
string operationName,
CallSettings callSettings = null) => Operation<Empty>.PollOnceFromNameAsync(
CallSettings callSettings = null) => Operation<Empty, GetBigBookMetadata>.PollOnceFromNameAsync(
GaxPreconditions.CheckNotNullOrEmpty(operationName, nameof(operationName)),
LongRunningOperationsClient,
callSettings);
Expand All @@ -3760,7 +3760,7 @@ namespace Google.Example.Library.V1
/// <returns>
/// The RPC response.
/// </returns>
public virtual Operation<Empty> GetBigNothing(
public virtual Operation<Empty, GetBigBookMetadata> GetBigNothing(
GetBookRequest request,
CallSettings callSettings = null)
{
Expand All @@ -3773,9 +3773,9 @@ namespace Google.Example.Library.V1
/// <param name="operationName">The name of a previously invoked operation. Must not be <c>null</c> or empty.</param>
/// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
/// <returns>The result of polling the operation.</returns>
public virtual Operation<Empty> PollOnceGetBigNothing(
public virtual Operation<Empty, GetBigBookMetadata> PollOnceGetBigNothing(
string operationName,
CallSettings callSettings = null) => Operation<Empty>.PollOnceFromName(
CallSettings callSettings = null) => Operation<Empty, GetBigBookMetadata>.PollOnceFromName(
GaxPreconditions.CheckNotNullOrEmpty(operationName, nameof(operationName)),
LongRunningOperationsClient,
callSettings);
Expand Down Expand Up @@ -5559,7 +5559,7 @@ namespace Google.Example.Library.V1
Modify_DiscussBookRequestCallSettings(ref callSettings);
BidirectionalStreamingSettings effectiveStreamingSettings =
streamingSettings ?? _callDiscussBook.StreamingSettings;
AsyncDuplexStreamingCall<DiscussBookRequest,Comment> call =
AsyncDuplexStreamingCall<DiscussBookRequest, Comment> call =
_callDiscussBook.Call(callSettings);
BufferedClientStreamWriter<DiscussBookRequest> writeBuffer =
new BufferedClientStreamWriter<DiscussBookRequest>(
Expand All @@ -5581,7 +5581,7 @@ namespace Google.Example.Library.V1
/// instance associated with this streaming call.</param>
public DiscussBookStreamImpl(
LibraryServiceClientImpl service,
AsyncDuplexStreamingCall<DiscussBookRequest,Comment> call,
AsyncDuplexStreamingCall<DiscussBookRequest, Comment> call,
BufferedClientStreamWriter<DiscussBookRequest> writeBuffer)
{
_service = service;
Expand All @@ -5599,7 +5599,7 @@ namespace Google.Example.Library.V1
}

/// <inheritdoc/>
public override AsyncDuplexStreamingCall<DiscussBookRequest,Comment> GrpcCall { get; }
public override AsyncDuplexStreamingCall<DiscussBookRequest, Comment> GrpcCall { get; }

/// <inheritdoc/>
public override Task TryWriteAsync(DiscussBookRequest message) =>
Expand Down Expand Up @@ -5762,12 +5762,12 @@ namespace Google.Example.Library.V1
/// <returns>
/// A Task containing the RPC response.
/// </returns>
public override async Task<Operation<Book>> GetBigBookAsync(
public override async Task<Operation<Book, GetBigBookMetadata>> GetBigBookAsync(
GetBookRequest request,
CallSettings callSettings = null)
{
Modify_GetBookRequest(ref request, ref callSettings);
return new Operation<Book>(
return new Operation<Book, GetBigBookMetadata>(
await _callGetBigBook.Async(request, callSettings).ConfigureAwait(false), LongRunningOperationsClient);
}

Expand All @@ -5783,12 +5783,12 @@ namespace Google.Example.Library.V1
/// <returns>
/// The RPC response.
/// </returns>
public override Operation<Book> GetBigBook(
public override Operation<Book, GetBigBookMetadata> GetBigBook(
GetBookRequest request,
CallSettings callSettings = null)
{
Modify_GetBookRequest(ref request, ref callSettings);
return new Operation<Book>(
return new Operation<Book, GetBigBookMetadata>(
_callGetBigBook.Sync(request, callSettings), LongRunningOperationsClient);
}

Expand All @@ -5804,12 +5804,12 @@ namespace Google.Example.Library.V1
/// <returns>
/// A Task containing the RPC response.
/// </returns>
public override async Task<Operation<Empty>> GetBigNothingAsync(
public override async Task<Operation<Empty, GetBigBookMetadata>> GetBigNothingAsync(
GetBookRequest request,
CallSettings callSettings = null)
{
Modify_GetBookRequest(ref request, ref callSettings);
return new Operation<Empty>(
return new Operation<Empty, GetBigBookMetadata>(
await _callGetBigNothing.Async(request, callSettings).ConfigureAwait(false), LongRunningOperationsClient);
}

Expand All @@ -5825,12 +5825,12 @@ namespace Google.Example.Library.V1
/// <returns>
/// The RPC response.
/// </returns>
public override Operation<Empty> GetBigNothing(
public override Operation<Empty, GetBigBookMetadata> GetBigNothing(
GetBookRequest request,
CallSettings callSettings = null)
{
Modify_GetBookRequest(ref request, ref callSettings);
return new Operation<Empty>(
return new Operation<Empty, GetBigBookMetadata>(
_callGetBigNothing.Sync(request, callSettings), LongRunningOperationsClient);
}

Expand Down
Loading

0 comments on commit 0f7055d

Please sign in to comment.