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

Account for placeholders in additional bindings #2416

Merged
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 @@ -64,6 +64,7 @@
import com.google.protobuf.Descriptors.FieldDescriptor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -361,11 +362,14 @@ private RestMethodConfigView generateRestMethodConfigView(HttpRule httpRule, Sur
List<String> additionalBindings = new ArrayList<>();
Map.Entry<String, String> entry = getHttpMethodEntry(httpRule);
String uriTemplate = entry.getValue();
Set<String> templateVars = PathTemplate.create(uriTemplate).vars();
Set<String> templateVars = new HashSet<String>();
templateVars.addAll(PathTemplate.create(uriTemplate).vars());

if (httpRule.getAdditionalBindingsCount() > 0) {
for (HttpRule additionalBindingHttpRule : httpRule.getAdditionalBindingsList()) {
additionalBindings.add(getHttpMethodEntry(additionalBindingHttpRule).getValue());
String additionalBindingTemplate = getHttpMethodEntry(additionalBindingHttpRule).getValue();
templateVars.addAll(PathTemplate.create(additionalBindingTemplate).vars());
additionalBindings.add(additionalBindingTemplate);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,11 @@ interfaces:
groups:
- parameters:
- name
- alt_book_name
# FIXME: Configure which fields are required.
required_fields:
- name
- alt_book_name
# FIXME: Configure the retryable codes for this method.
retry_codes_name: non_idempotent
# FIXME: Configure the retryable params for this method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,10 @@ const GetBookFromAnywhereRequest = {
* @property {string} name
* The name of the book to retrieve.
*
* @property {string} altBookName
* An alternate book name, used to test proper processing of placeholders
* within additional bindings.
*
* @typedef GetBookFromAbsolutelyAnywhereRequest
* @memberof google.example.library.v1
* @see [google.example.library.v1.GetBookFromAbsolutelyAnywhereRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/library.proto}
Expand Down Expand Up @@ -4602,6 +4606,9 @@ class LibraryServiceClient {
* The request object that will be sent.
* @param {string} request.name
* The name of the book to retrieve.
* @param {string} [request.altBookName]
* An alternate book name, used to test proper processing of placeholders
* within additional bindings.
* @param {Object} [options]
* Optional parameters. You can override the default settings for this call, e.g, timeout,
* retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,9 @@ class LibraryServiceGapicClient
* @param string $name The name of the book to retrieve.
* @param array $optionalArgs {
* Optional.
* @type string $altBookName
* An alternate book name, used to test proper processing of placeholders
* within additional bindings.
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a
* {@see Google\ApiCore\RetrySettings} object, or an associative array
Expand All @@ -1351,6 +1354,9 @@ class LibraryServiceGapicClient
{
$request = new GetBookFromAbsolutelyAnywhereRequest();
$request->setName($name);
if (isset($optionalArgs['altBookName'])) {
$request->setAltBookName($optionalArgs['altBookName']);
}

return $this->startCall(
'GetBookFromAbsolutelyAnywhere',
Expand Down Expand Up @@ -2638,7 +2644,7 @@ return [
'additionalBindings' => [
[
'method' => 'post',
'uriTemplate' => '/v1/{name=bookShelves/*/books/*}',
'uriTemplate' => '/v1/{alt_book_name=bookShelves/*/books/*}',
],
],
'placeholders' => [
Expand All @@ -2647,6 +2653,11 @@ return [
'getName',
],
],
'alt_book_name' => [
'getters' => [
'getAltBookName',
],
],
]
],
'UpdateBookIndex' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,7 @@ class LibraryServiceClient(object):
def get_book_from_absolutely_anywhere(
self,
name,
alt_book_name=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None):
Expand All @@ -2296,6 +2297,8 @@ class LibraryServiceClient(object):

Args:
name (str): The name of the book to retrieve.
alt_book_name (str): An alternate book name, used to test proper processing of placeholders
within additional bindings.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will not
be retried.
Expand Down Expand Up @@ -2326,6 +2329,7 @@ class LibraryServiceClient(object):

request = library_pb2.GetBookFromAbsolutelyAnywhereRequest(
name=name,
alt_book_name=alt_book_name,
)
return self._inner_api_calls['get_book_from_absolutely_anywhere'](request, retry=retry, timeout=timeout, metadata=metadata)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,10 @@ module Google
# @!attribute [rw] name
# @return [String]
# The name of the book to retrieve.
# @!attribute [rw] alt_book_name
# @return [String]
# An alternate book name, used to test proper processing of placeholders
# within additional bindings.
class GetBookFromAbsolutelyAnywhereRequest; end

# Request message for LibraryService.UpdateBookIndex.
Expand Down Expand Up @@ -3781,6 +3785,9 @@ module Library
#
# @param name [String]
# The name of the book to retrieve.
# @param alt_book_name [String]
# An alternate book name, used to test proper processing of placeholders
# within additional bindings.
# @param options [Google::Gax::CallOptions]
# Overrides the default settings for this call, e.g, timeout,
# retries, etc.
Expand All @@ -3798,10 +3805,12 @@ module Library

def get_book_from_absolutely_anywhere \
name,
alt_book_name: nil,
options: nil,
&block
req = {
name: name
name: name,
alt_book_name: alt_book_name
}.delete_if { |_, v| v.nil? }
req = Google::Gax::to_proto(req, Google::Example::Library::V1::GetBookFromAbsolutelyAnywhereRequest)
@get_book_from_absolutely_anywhere.call(req, options, &block)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ service LibraryService {
option (google.api.http) = {
post: "/v1/{name=archives/*/books/*}"
additional_bindings {
post: "/v1/{name=bookShelves/*/books/*}"
post: "/v1/{alt_book_name=bookShelves/*/books/*}"
}
};
}
Expand Down Expand Up @@ -583,6 +583,10 @@ message GetBookFromAnywhereRequest {
message GetBookFromAbsolutelyAnywhereRequest {
// The name of the book to retrieve.
string name = 1;

// An alternate book name, used to test proper processing of placeholders
// within additional bindings.
string alt_book_name = 2;
}

// Request message for LibraryService.UpdateBookIndex.
Expand Down