diff --git a/google-cloud-core/pom.xml b/google-cloud-core/pom.xml index e3fb52ed2ef8..47b74b9a6492 100644 --- a/google-cloud-core/pom.xml +++ b/google-cloud-core/pom.xml @@ -106,7 +106,7 @@ com.google.api gax - 0.0.18 + 0.0.19 com.google.api.grpc diff --git a/google-cloud-core/src/main/java/com/google/cloud/GrpcServiceOptions.java b/google-cloud-core/src/main/java/com/google/cloud/GrpcServiceOptions.java index 330a3dff2b15..5976c322244f 100644 --- a/google-cloud-core/src/main/java/com/google/cloud/GrpcServiceOptions.java +++ b/google-cloud-core/src/main/java/com/google/cloud/GrpcServiceOptions.java @@ -20,7 +20,7 @@ import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.spi.ServiceRpcFactory; import com.google.common.annotations.VisibleForTesting; @@ -226,7 +226,7 @@ protected ExecutorFactory executorFactory() { /** * Returns a builder for API call settings. */ - protected ApiCallSettings.Builder apiCallSettings() { + protected UnaryApiCallSettings.Builder apiCallSettings() { // todo(mziccard): specify timeout these settings: // retryParams().retryMaxAttempts(), retryParams().retryMinAttempts() final RetrySettings.Builder builder = RetrySettings.newBuilder() @@ -237,7 +237,7 @@ protected ApiCallSettings.Builder apiCallSettings() { .setInitialRetryDelay(Duration.millis(retryParams().initialRetryDelayMillis())) .setRetryDelayMultiplier(retryParams().retryDelayBackoffFactor()) .setMaxRetryDelay(Duration.millis(retryParams().maxRetryDelayMillis())); - return ApiCallSettings.newBuilder().setRetrySettingsBuilder(builder); + return UnaryApiCallSettings.newBuilder().setRetrySettingsBuilder(builder); } /** diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceApi.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceApi.java index fecd24c11af0..f31f638d6a44 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceApi.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceApi.java @@ -13,7 +13,7 @@ */ package com.google.cloud.errorreporting.spi.v1beta1; -import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup; import com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest; @@ -54,8 +54,8 @@ *
  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -83,8 +83,8 @@ public class ErrorGroupServiceApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable getGroupCallable; - private final ApiCallable updateGroupCallable; + private final UnaryApiCallable getGroupCallable; + private final UnaryApiCallable updateGroupCallable; private static final PathTemplate GROUP_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding("projects/{project}/groups/{group}"); @@ -130,9 +130,9 @@ protected ErrorGroupServiceApi(ErrorGroupServiceSettings settings) throws IOExce this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.getGroupCallable = - ApiCallable.create(settings.getGroupSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.getGroupSettings(), this.channel, this.executor); this.updateGroupCallable = - ApiCallable.create(settings.updateGroupSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.updateGroupSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -226,7 +226,7 @@ private final ErrorGroup getGroup(GetGroupRequest request) { * } * */ - public final ApiCallable getGroupCallable() { + public final UnaryApiCallable getGroupCallable() { return getGroupCallable; } @@ -292,7 +292,7 @@ private final ErrorGroup updateGroup(UpdateGroupRequest request) { * } * */ - public final ApiCallable updateGroupCallable() { + public final UnaryApiCallable updateGroupCallable() { return updateGroupCallable; } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceSettings.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceSettings.java index 4dc8bbeae7f1..5b5d9016960e 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceSettings.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceSettings.java @@ -15,9 +15,9 @@ import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -140,7 +140,7 @@ private ErrorGroupServiceSettings(Builder settingsBuilder) throws IOException { /** Builder for ErrorGroupServiceSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final SimpleCallSettings.Builder getGroupSettings; private final SimpleCallSettings.Builder updateGroupSettings; @@ -184,8 +184,8 @@ private Builder() { updateGroupSettings = SimpleCallSettings.newBuilder(ErrorGroupServiceGrpc.METHOD_UPDATE_GROUP); - methodSettingsBuilders = - ImmutableList.of(getGroupSettings, updateGroupSettings); + unaryMethodSettingsBuilders = + ImmutableList.of(getGroupSettings, updateGroupSettings); } private static Builder createDefault() { @@ -210,8 +210,8 @@ private Builder(ErrorGroupServiceSettings settings) { getGroupSettings = settings.getGroupSettings.toBuilder(); updateGroupSettings = settings.updateGroupSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of(getGroupSettings, updateGroupSettings); + unaryMethodSettingsBuilders = + ImmutableList.of(getGroupSettings, updateGroupSettings); } @Override @@ -262,11 +262,14 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceApi.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceApi.java index f333c555e500..c486708f6616 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceApi.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceApi.java @@ -13,13 +13,13 @@ */ package com.google.cloud.errorreporting.spi.v1beta1; -import com.google.api.gax.core.PagedListResponse; -import com.google.api.gax.grpc.ApiCallable; +import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListEventsPagedResponse; +import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListGroupStatsPagedResponse; + +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.devtools.clouderrorreporting.v1beta1.DeleteEventsRequest; import com.google.devtools.clouderrorreporting.v1beta1.DeleteEventsResponse; -import com.google.devtools.clouderrorreporting.v1beta1.ErrorEvent; -import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats; import com.google.devtools.clouderrorreporting.v1beta1.ListEventsRequest; import com.google.devtools.clouderrorreporting.v1beta1.ListEventsResponse; import com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest; @@ -62,8 +62,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -91,16 +91,14 @@ public class ErrorStatsServiceApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable listGroupStatsCallable; - private final ApiCallable< - ListGroupStatsRequest, - PagedListResponse> + private final UnaryApiCallable + listGroupStatsCallable; + private final UnaryApiCallable listGroupStatsPagedCallable; - private final ApiCallable listEventsCallable; - private final ApiCallable< - ListEventsRequest, PagedListResponse> + private final UnaryApiCallable listEventsCallable; + private final UnaryApiCallable listEventsPagedCallable; - private final ApiCallable deleteEventsCallable; + private final UnaryApiCallable deleteEventsCallable; private static final PathTemplate PROJECT_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding("projects/{project}"); @@ -139,16 +137,17 @@ protected ErrorStatsServiceApi(ErrorStatsServiceSettings settings) throws IOExce this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.listGroupStatsCallable = - ApiCallable.create(settings.listGroupStatsSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listGroupStatsSettings(), this.channel, this.executor); this.listGroupStatsPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listGroupStatsSettings(), this.channel, this.executor); this.listEventsCallable = - ApiCallable.create(settings.listEventsSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listEventsSettings(), this.channel, this.executor); this.listEventsPagedCallable = - ApiCallable.createPagedVariant(settings.listEventsSettings(), this.channel, this.executor); + UnaryApiCallable.createPagedVariant( + settings.listEventsSettings(), this.channel, this.executor); this.deleteEventsCallable = - ApiCallable.create(settings.deleteEventsSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.deleteEventsSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -195,13 +194,14 @@ public final ErrorStatsServiceSettings getSettings() { * href="https://support.google.com/cloud/answer/6158840">Google Cloud Platform project * ID</a>. *

    Example: <code>projects/my-project-123</code>. - * @param timeRange [Required] List data for the given time range. The service is tuned for - * retrieving data up to (approximately) 'now'. Retrieving data for arbitrary time periods in - * the past can result in higher response times or in returning incomplete results. + * @param timeRange [Required] List data for the given time range. Only + * <code>ErrorGroupStats</code> with a non-zero count in the given time range are + * returned, unless the request contains an explicit group_id list. If a group_id list is + * given, also <code>ErrorGroupStats</code> with zero occurrences are returned. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse - listGroupStats(String projectName, QueryTimeRange timeRange) { + public final ListGroupStatsPagedResponse listGroupStats( + String projectName, QueryTimeRange timeRange) { PROJECT_PATH_TEMPLATE.validate(projectName, "listGroupStats"); ListGroupStatsRequest request = ListGroupStatsRequest.newBuilder() @@ -234,8 +234,7 @@ public final ErrorStatsServiceSettings getSettings() { * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse - listGroupStats(ListGroupStatsRequest request) { + public final ListGroupStatsPagedResponse listGroupStats(ListGroupStatsRequest request) { return listGroupStatsPagedCallable().call(request); } @@ -253,7 +252,7 @@ public final ErrorStatsServiceSettings getSettings() { * .setProjectName(formattedProjectName) * .setTimeRange(timeRange) * .build(); - * ListenableFuture<PagedListResponse<ListGroupStatsRequest,ListGroupStatsResponse,ErrorGroupStats>> future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request); + * ListenableFuture<ListGroupStatsPagedResponse> future = errorStatsServiceApi.listGroupStatsPagedCallable().futureCall(request); * // Do something * for (ErrorGroupStats element : future.get().iterateAllElements()) { * // doThingsWith(element); @@ -261,9 +260,7 @@ public final ErrorStatsServiceSettings getSettings() { * } * */ - public final ApiCallable< - ListGroupStatsRequest, - PagedListResponse> + public final UnaryApiCallable listGroupStatsPagedCallable() { return listGroupStatsPagedCallable; } @@ -297,7 +294,8 @@ public final ErrorStatsServiceSettings getSettings() { * } * */ - public final ApiCallable listGroupStatsCallable() { + public final UnaryApiCallable + listGroupStatsCallable() { return listGroupStatsCallable; } @@ -323,8 +321,7 @@ public final ApiCallable listGrou * @param groupId [Required] The group for which events shall be returned. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse listEvents( - String projectName, String groupId) { + public final ListEventsPagedResponse listEvents(String projectName, String groupId) { PROJECT_PATH_TEMPLATE.validate(projectName, "listEvents"); ListEventsRequest request = ListEventsRequest.newBuilder().setProjectName(projectName).setGroupId(groupId).build(); @@ -354,8 +351,7 @@ public final PagedListResponse listEvents( - ListEventsRequest request) { + public final ListEventsPagedResponse listEvents(ListEventsRequest request) { return listEventsPagedCallable().call(request); } @@ -373,7 +369,7 @@ public final PagedListResponse */ - public final ApiCallable< - ListEventsRequest, PagedListResponse> + public final UnaryApiCallable listEventsPagedCallable() { return listEventsPagedCallable; } @@ -416,7 +411,7 @@ public final PagedListResponse */ - public final ApiCallable listEventsCallable() { + public final UnaryApiCallable listEventsCallable() { return listEventsCallable; } @@ -486,7 +481,7 @@ private final DeleteEventsResponse deleteEvents(DeleteEventsRequest request) { * } * */ - public final ApiCallable deleteEventsCallable() { + public final UnaryApiCallable deleteEventsCallable() { return deleteEventsCallable; } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceSettings.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceSettings.java index b34dde3f867b..2dd7678f68be 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceSettings.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceSettings.java @@ -13,13 +13,19 @@ */ package com.google.cloud.errorreporting.spi.v1beta1; +import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListEventsPagedResponse; +import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListGroupStatsPagedResponse; + import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.CallContext; import com.google.api.gax.grpc.PageStreamingCallSettings; import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseFactory; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -90,20 +96,22 @@ public class ErrorStatsServiceSettings extends ServiceApiSettings { .build(); private final PageStreamingCallSettings< - ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats> + ListGroupStatsRequest, ListGroupStatsResponse, ListGroupStatsPagedResponse> listGroupStatsSettings; - private final PageStreamingCallSettings + private final PageStreamingCallSettings< + ListEventsRequest, ListEventsResponse, ListEventsPagedResponse> listEventsSettings; private final SimpleCallSettings deleteEventsSettings; /** Returns the object with the settings used for calls to listGroupStats. */ - public PageStreamingCallSettings + public PageStreamingCallSettings< + ListGroupStatsRequest, ListGroupStatsResponse, ListGroupStatsPagedResponse> listGroupStatsSettings() { return listGroupStatsSettings; } /** Returns the object with the settings used for calls to listEvents. */ - public PageStreamingCallSettings + public PageStreamingCallSettings listEventsSettings() { return listEventsSettings; } @@ -228,15 +236,45 @@ public Iterable extractResources(ListEventsResponse payload) { } }; + private static final PagedListResponseFactory< + ListGroupStatsRequest, ListGroupStatsResponse, ListGroupStatsPagedResponse> + LIST_GROUP_STATS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListGroupStatsRequest, ListGroupStatsResponse, ListGroupStatsPagedResponse>() { + @Override + public ListGroupStatsPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListGroupStatsRequest request, + CallContext context) { + return new ListGroupStatsPagedResponse( + callable, LIST_GROUP_STATS_PAGE_STR_DESC, request, context); + } + }; + + private static final PagedListResponseFactory< + ListEventsRequest, ListEventsResponse, ListEventsPagedResponse> + LIST_EVENTS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListEventsRequest, ListEventsResponse, ListEventsPagedResponse>() { + @Override + public ListEventsPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListEventsRequest request, + CallContext context) { + return new ListEventsPagedResponse( + callable, LIST_EVENTS_PAGE_STR_DESC, request, context); + } + }; + /** Builder for ErrorStatsServiceSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final PageStreamingCallSettings.Builder< - ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats> + ListGroupStatsRequest, ListGroupStatsResponse, ListGroupStatsPagedResponse> listGroupStatsSettings; private final PageStreamingCallSettings.Builder< - ListEventsRequest, ListEventsResponse, ErrorEvent> + ListEventsRequest, ListEventsResponse, ListEventsPagedResponse> listEventsSettings; private final SimpleCallSettings.Builder deleteEventsSettings; @@ -277,17 +315,17 @@ private Builder() { listGroupStatsSettings = PageStreamingCallSettings.newBuilder( - ErrorStatsServiceGrpc.METHOD_LIST_GROUP_STATS, LIST_GROUP_STATS_PAGE_STR_DESC); + ErrorStatsServiceGrpc.METHOD_LIST_GROUP_STATS, LIST_GROUP_STATS_PAGE_STR_FACT); listEventsSettings = PageStreamingCallSettings.newBuilder( - ErrorStatsServiceGrpc.METHOD_LIST_EVENTS, LIST_EVENTS_PAGE_STR_DESC); + ErrorStatsServiceGrpc.METHOD_LIST_EVENTS, LIST_EVENTS_PAGE_STR_FACT); deleteEventsSettings = SimpleCallSettings.newBuilder(ErrorStatsServiceGrpc.METHOD_DELETE_EVENTS); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listGroupStatsSettings, listEventsSettings, deleteEventsSettings); } @@ -319,8 +357,8 @@ private Builder(ErrorStatsServiceSettings settings) { listEventsSettings = settings.listEventsSettings.toBuilder(); deleteEventsSettings = settings.deleteEventsSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listGroupStatsSettings, listEventsSettings, deleteEventsSettings); } @@ -372,23 +410,27 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } /** Returns the builder for the settings used for calls to listGroupStats. */ public PageStreamingCallSettings.Builder< - ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats> + ListGroupStatsRequest, ListGroupStatsResponse, ListGroupStatsPagedResponse> listGroupStatsSettings() { return listGroupStatsSettings; } /** Returns the builder for the settings used for calls to listEvents. */ - public PageStreamingCallSettings.Builder + public PageStreamingCallSettings.Builder< + ListEventsRequest, ListEventsResponse, ListEventsPagedResponse> listEventsSettings() { return listEventsSettings; } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/PagedResponseWrappers.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/PagedResponseWrappers.java new file mode 100644 index 000000000000..7b14a0f8ffd0 --- /dev/null +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/PagedResponseWrappers.java @@ -0,0 +1,61 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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 + * + * http://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. + */ +package com.google.cloud.errorreporting.spi.v1beta1; + +import com.google.api.gax.grpc.CallContext; +import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseImpl; +import com.google.api.gax.grpc.UnaryApiCallable; +import com.google.devtools.clouderrorreporting.v1beta1.ErrorEvent; +import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats; +import com.google.devtools.clouderrorreporting.v1beta1.ListEventsRequest; +import com.google.devtools.clouderrorreporting.v1beta1.ListEventsResponse; +import com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest; +import com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsResponse; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Wrapper class to contain paged response types for page streaming methods. Each static class + * inside this wrapper class is used as the return type of one of an API method that implements the + * page streaming pattern. + */ +@javax.annotation.Generated("by GAPIC") +public class PagedResponseWrappers { + + public static class ListGroupStatsPagedResponse + extends PagedListResponseImpl< + ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats> { + + public ListGroupStatsPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor + pageDescriptor, + ListGroupStatsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListEventsPagedResponse + extends PagedListResponseImpl { + + public ListEventsPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor pageDescriptor, + ListEventsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } +} diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceApi.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceApi.java index cdd5714e093e..02f5292cccfe 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceApi.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceApi.java @@ -13,7 +13,7 @@ */ package com.google.cloud.errorreporting.spi.v1beta1; -import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.devtools.clouderrorreporting.v1beta1.ReportErrorEventRequest; import com.google.devtools.clouderrorreporting.v1beta1.ReportErrorEventResponse; @@ -56,8 +56,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -85,7 +85,7 @@ public class ReportErrorsServiceApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable + private final UnaryApiCallable reportErrorEventCallable; private static final PathTemplate PROJECT_PATH_TEMPLATE = @@ -126,7 +126,7 @@ protected ReportErrorsServiceApi(ReportErrorsServiceSettings settings) throws IO this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.reportErrorEventCallable = - ApiCallable.create(settings.reportErrorEventSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.reportErrorEventSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -246,7 +246,7 @@ public final ReportErrorEventResponse reportErrorEvent(ReportErrorEventRequest r * } * */ - public final ApiCallable + public final UnaryApiCallable reportErrorEventCallable() { return reportErrorEventCallable; } diff --git a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceSettings.java b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceSettings.java index a4b390017c31..0ee512a2ce06 100644 --- a/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceSettings.java +++ b/google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ReportErrorsServiceSettings.java @@ -15,9 +15,9 @@ import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -134,7 +134,7 @@ private ReportErrorsServiceSettings(Builder settingsBuilder) throws IOException /** Builder for ReportErrorsServiceSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final SimpleCallSettings.Builder reportErrorEventSettings; @@ -176,7 +176,8 @@ private Builder() { reportErrorEventSettings = SimpleCallSettings.newBuilder(ReportErrorsServiceGrpc.METHOD_REPORT_ERROR_EVENT); - methodSettingsBuilders = ImmutableList.of(reportErrorEventSettings); + unaryMethodSettingsBuilders = + ImmutableList.of(reportErrorEventSettings); } private static Builder createDefault() { @@ -195,7 +196,8 @@ private Builder(ReportErrorsServiceSettings settings) { reportErrorEventSettings = settings.reportErrorEventSettings.toBuilder(); - methodSettingsBuilders = ImmutableList.of(reportErrorEventSettings); + unaryMethodSettingsBuilders = + ImmutableList.of(reportErrorEventSettings); } @Override @@ -246,11 +248,14 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } diff --git a/google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceTest.java b/google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceTest.java index df94dfc07b04..323f437c222e 100644 --- a/google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceTest.java +++ b/google-cloud-errorreporting/src/test/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceTest.java @@ -14,7 +14,9 @@ package com.google.cloud.errorreporting.spi.v1beta1; -import com.google.api.gax.core.PagedListResponse; +import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListEventsPagedResponse; +import static com.google.cloud.errorreporting.spi.v1beta1.PagedResponseWrappers.ListGroupStatsPagedResponse; + import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; import com.google.common.collect.Lists; @@ -98,8 +100,8 @@ public void listGroupStatsTest() { String formattedProjectName = ErrorStatsServiceApi.formatProjectName("[PROJECT]"); QueryTimeRange timeRange = QueryTimeRange.newBuilder().build(); - PagedListResponse - pagedListResponse = api.listGroupStats(formattedProjectName, timeRange); + ListGroupStatsPagedResponse pagedListResponse = + api.listGroupStats(formattedProjectName, timeRange); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); @@ -131,8 +133,7 @@ public void listEventsTest() { String formattedProjectName = ErrorStatsServiceApi.formatProjectName("[PROJECT]"); String groupId = "groupId506361563"; - PagedListResponse pagedListResponse = - api.listEvents(formattedProjectName, groupId); + ListEventsPagedResponse pagedListResponse = api.listEvents(formattedProjectName, groupId); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/LanguageServiceApi.java b/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/LanguageServiceApi.java index 1f663b9929f6..9d63071e2aee 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/LanguageServiceApi.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/LanguageServiceApi.java @@ -13,7 +13,7 @@ */ package com.google.cloud.language.spi.v1beta1; -import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.cloud.language.v1beta1.AnalyzeEntitiesRequest; import com.google.cloud.language.v1beta1.AnalyzeEntitiesResponse; import com.google.cloud.language.v1beta1.AnalyzeSentimentRequest; @@ -60,8 +60,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -89,11 +89,11 @@ public class LanguageServiceApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable + private final UnaryApiCallable analyzeSentimentCallable; - private final ApiCallable + private final UnaryApiCallable analyzeEntitiesCallable; - private final ApiCallable annotateTextCallable; + private final UnaryApiCallable annotateTextCallable; /** Constructs an instance of LanguageServiceApi with default settings. */ public static final LanguageServiceApi create() throws IOException { @@ -119,11 +119,11 @@ protected LanguageServiceApi(LanguageServiceSettings settings) throws IOExceptio this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.analyzeSentimentCallable = - ApiCallable.create(settings.analyzeSentimentSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.analyzeSentimentSettings(), this.channel, this.executor); this.analyzeEntitiesCallable = - ApiCallable.create(settings.analyzeEntitiesSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.analyzeEntitiesSettings(), this.channel, this.executor); this.annotateTextCallable = - ApiCallable.create(settings.annotateTextSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.annotateTextSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -213,7 +213,7 @@ private final AnalyzeSentimentResponse analyzeSentiment(AnalyzeSentimentRequest * } * */ - public final ApiCallable + public final UnaryApiCallable analyzeSentimentCallable() { return analyzeSentimentCallable; } @@ -294,7 +294,7 @@ public final AnalyzeEntitiesResponse analyzeEntities(AnalyzeEntitiesRequest requ * } * */ - public final ApiCallable + public final UnaryApiCallable analyzeEntitiesCallable() { return analyzeEntitiesCallable; } @@ -385,7 +385,7 @@ public final AnnotateTextResponse annotateText(AnnotateTextRequest request) { * } * */ - public final ApiCallable annotateTextCallable() { + public final UnaryApiCallable annotateTextCallable() { return annotateTextCallable; } diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/LanguageServiceSettings.java b/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/LanguageServiceSettings.java index 394c2a7add5e..50533421b2c1 100644 --- a/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/LanguageServiceSettings.java +++ b/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/LanguageServiceSettings.java @@ -15,9 +15,9 @@ import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; import com.google.auth.Credentials; import com.google.cloud.language.v1beta1.AnalyzeEntitiesRequest; import com.google.cloud.language.v1beta1.AnalyzeEntitiesResponse; @@ -153,7 +153,7 @@ private LanguageServiceSettings(Builder settingsBuilder) throws IOException { /** Builder for LanguageServiceSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final SimpleCallSettings.Builder analyzeSentimentSettings; @@ -205,8 +205,8 @@ private Builder() { annotateTextSettings = SimpleCallSettings.newBuilder(LanguageServiceGrpc.METHOD_ANNOTATE_TEXT); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( analyzeSentimentSettings, analyzeEntitiesSettings, annotateTextSettings); } @@ -238,8 +238,8 @@ private Builder(LanguageServiceSettings settings) { analyzeEntitiesSettings = settings.analyzeEntitiesSettings.toBuilder(); annotateTextSettings = settings.annotateTextSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( analyzeSentimentSettings, analyzeEntitiesSettings, annotateTextSettings); } @@ -291,11 +291,14 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } diff --git a/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/PagedResponseWrappers.java b/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/PagedResponseWrappers.java new file mode 100644 index 000000000000..e3882450d408 --- /dev/null +++ b/google-cloud-language/src/main/java/com/google/cloud/language/spi/v1beta1/PagedResponseWrappers.java @@ -0,0 +1,23 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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 + * + * http://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. + */ +package com.google.cloud.language.spi.v1beta1; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Wrapper class to contain paged response types for page streaming methods. Each static class + * inside this wrapper class is used as the return type of one of an API method that implements the + * page streaming pattern. + */ +@javax.annotation.Generated("by GAPIC") +public class PagedResponseWrappers {} diff --git a/google-cloud-logging/pom.xml b/google-cloud-logging/pom.xml index d2185f866bb2..c277ef51017f 100644 --- a/google-cloud-logging/pom.xml +++ b/google-cloud-logging/pom.xml @@ -30,7 +30,7 @@ com.google.api.grpc grpc-google-logging-v2 - 0.1.0 + 0.1.1 io.grpc diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/DefaultLoggingRpc.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/DefaultLoggingRpc.java index a707c29d5a42..788c78453323 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/DefaultLoggingRpc.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/DefaultLoggingRpc.java @@ -19,7 +19,7 @@ import static com.google.common.base.MoreObjects.firstNonNull; import com.google.api.gax.core.ConnectionSettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; import com.google.api.gax.grpc.ApiException; import com.google.cloud.AuthCredentials; import com.google.cloud.GrpcServiceOptions.ExecutorFactory; @@ -92,7 +92,7 @@ protected ExecutorFactory executorFactory() { } @Override - protected ApiCallSettings.Builder apiCallSettings() { + protected UnaryApiCallSettings.Builder apiCallSettings() { return super.apiCallSettings(); } @@ -133,7 +133,7 @@ public DefaultLoggingRpc(LoggingOptions options) throws IOException { logBuilder.provideChannelWith(connectionSettings); metricsBuilder.provideChannelWith(connectionSettings); } - ApiCallSettings.Builder callSettingsBuilder = internalOptions.apiCallSettings(); + UnaryApiCallSettings.Builder callSettingsBuilder = internalOptions.apiCallSettings(); confBuilder.applyToAllApiMethods(callSettingsBuilder); logBuilder.applyToAllApiMethods(callSettingsBuilder); metricsBuilder.applyToAllApiMethods(callSettingsBuilder); diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Api.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Api.java index f49aca494e33..1c92911ade80 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Api.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Api.java @@ -13,8 +13,9 @@ */ package com.google.cloud.logging.spi.v2; -import com.google.api.gax.core.PagedListResponse; -import com.google.api.gax.grpc.ApiCallable; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListSinksPagedResponse; + +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.logging.v2.CreateSinkRequest; import com.google.logging.v2.DeleteSinkRequest; @@ -61,8 +62,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -90,14 +91,12 @@ public class ConfigServiceV2Api implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable listSinksCallable; - private final ApiCallable< - ListSinksRequest, PagedListResponse> - listSinksPagedCallable; - private final ApiCallable getSinkCallable; - private final ApiCallable createSinkCallable; - private final ApiCallable updateSinkCallable; - private final ApiCallable deleteSinkCallable; + private final UnaryApiCallable listSinksCallable; + private final UnaryApiCallable listSinksPagedCallable; + private final UnaryApiCallable getSinkCallable; + private final UnaryApiCallable createSinkCallable; + private final UnaryApiCallable updateSinkCallable; + private final UnaryApiCallable deleteSinkCallable; private static final PathTemplate PARENT_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding("projects/{project}"); @@ -156,17 +155,18 @@ protected ConfigServiceV2Api(ConfigServiceV2Settings settings) throws IOExceptio this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.listSinksCallable = - ApiCallable.create(settings.listSinksSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listSinksSettings(), this.channel, this.executor); this.listSinksPagedCallable = - ApiCallable.createPagedVariant(settings.listSinksSettings(), this.channel, this.executor); + UnaryApiCallable.createPagedVariant( + settings.listSinksSettings(), this.channel, this.executor); this.getSinkCallable = - ApiCallable.create(settings.getSinkSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.getSinkSettings(), this.channel, this.executor); this.createSinkCallable = - ApiCallable.create(settings.createSinkSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.createSinkSettings(), this.channel, this.executor); this.updateSinkCallable = - ApiCallable.create(settings.updateSinkSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.updateSinkSettings(), this.channel, this.executor); this.deleteSinkCallable = - ApiCallable.create(settings.deleteSinkSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.deleteSinkSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -207,12 +207,11 @@ public final ConfigServiceV2Settings getSettings() { * } * * - * @param parent Required. The resource name containing the sinks. Example: + * @param parent Required. The cloud resource containing the sinks. Example: * `"projects/my-logging-project"`. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse listSinks( - String parent) { + public final ListSinksPagedResponse listSinks(String parent) { PARENT_PATH_TEMPLATE.validate(parent, "listSinks"); ListSinksRequest request = ListSinksRequest.newBuilder().setParent(parent).build(); return listSinks(request); @@ -239,8 +238,7 @@ public final PagedListResponse lis * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse listSinks( - ListSinksRequest request) { + public final ListSinksPagedResponse listSinks(ListSinksRequest request) { return listSinksPagedCallable().call(request); } @@ -256,7 +254,7 @@ public final PagedListResponse lis * ListSinksRequest request = ListSinksRequest.newBuilder() * .setParent(formattedParent) * .build(); - * ListenableFuture<PagedListResponse<ListSinksRequest,ListSinksResponse,LogSink>> future = configServiceV2Api.listSinksPagedCallable().futureCall(request); + * ListenableFuture<ListSinksPagedResponse> future = configServiceV2Api.listSinksPagedCallable().futureCall(request); * // Do something * for (LogSink element : future.get().iterateAllElements()) { * // doThingsWith(element); @@ -264,9 +262,7 @@ public final PagedListResponse lis * } * */ - public final ApiCallable< - ListSinksRequest, PagedListResponse> - listSinksPagedCallable() { + public final UnaryApiCallable listSinksPagedCallable() { return listSinksPagedCallable; } @@ -297,7 +293,7 @@ public final PagedListResponse lis * } * */ - public final ApiCallable listSinksCallable() { + public final UnaryApiCallable listSinksCallable() { return listSinksCallable; } @@ -314,7 +310,7 @@ public final ApiCallable listSinksCallable( * } * * - * @param sinkName The resource name of the sink to return. Example: + * @param sinkName Required. The resource name of the sink to return. Example: * `"projects/my-project-id/sinks/my-sink-id"`. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ @@ -365,7 +361,7 @@ private final LogSink getSink(GetSinkRequest request) { * } * */ - public final ApiCallable getSinkCallable() { + public final UnaryApiCallable getSinkCallable() { return getSinkCallable; } @@ -383,9 +379,10 @@ public final ApiCallable getSinkCallable() { * } * * - * @param parent The resource in which to create the sink. Example: `"projects/my-project-id"`. - *

    The new sink must be provided in the request. - * @param sink The new sink, which must not have an identifier that already exists. + * @param parent Required. The resource in which to create the sink. Example: + * `"projects/my-project-id"`. The new sink must be provided in the request. + * @param sink Required. The new sink, whose `name` parameter is a sink identifier that is not + * already in use. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final LogSink createSink(String parent, LogSink sink) { @@ -440,13 +437,13 @@ public final LogSink createSink(CreateSinkRequest request) { * } * */ - public final ApiCallable createSinkCallable() { + public final UnaryApiCallable createSinkCallable() { return createSinkCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates or updates a sink. + * Updates or creates a sink. * *

    Sample code: * @@ -458,12 +455,11 @@ public final ApiCallable createSinkCallable() { * } * * - * @param sinkName The resource name of the sink to update. Example: - * `"projects/my-project-id/sinks/my-sink-id"`. - *

    The updated sink must be provided in the request and have the same name that is - * specified in `sinkName`. If the sink does not exist, it is created. - * @param sink The updated sink, whose name must be the same as the sink identifier in `sinkName`. - * If `sinkName` does not exist, then this method creates a new sink. + * @param sinkName Required. The resource name of the sink to update, including the parent + * resource and the sink identifier. If the sink does not exist, this method creates the sink. + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param sink Required. The updated sink, whose name is the same identifier that appears as part + * of `sinkName`. If `sinkName` does not exist, then this method creates a new sink. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final LogSink updateSink(String sinkName, LogSink sink) { @@ -475,7 +471,7 @@ public final LogSink updateSink(String sinkName, LogSink sink) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates or updates a sink. + * Updates or creates a sink. * *

    Sample code: * @@ -500,7 +496,7 @@ public final LogSink updateSink(UpdateSinkRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates or updates a sink. + * Updates or creates a sink. * *

    Sample code: * @@ -518,7 +514,7 @@ public final LogSink updateSink(UpdateSinkRequest request) { * } * */ - public final ApiCallable updateSinkCallable() { + public final UnaryApiCallable updateSinkCallable() { return updateSinkCallable; } @@ -535,8 +531,9 @@ public final ApiCallable updateSinkCallable() { * } * * - * @param sinkName The resource name of the sink to delete. Example: - * `"projects/my-project-id/sinks/my-sink-id"`. + * @param sinkName Required. The resource name of the sink to delete, including the parent + * resource and the sink identifier. Example: `"projects/my-project-id/sinks/my-sink-id"`. It + * is an error if the sink does not exist. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final void deleteSink(String sinkName) { @@ -586,7 +583,7 @@ private final void deleteSink(DeleteSinkRequest request) { * } * */ - public final ApiCallable deleteSinkCallable() { + public final UnaryApiCallable deleteSinkCallable() { return deleteSinkCallable; } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java index f44dddab6743..26ab7aa3ef84 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java @@ -13,13 +13,18 @@ */ package com.google.cloud.logging.spi.v2; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListSinksPagedResponse; + import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.CallContext; import com.google.api.gax.grpc.PageStreamingCallSettings; import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseFactory; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -94,7 +99,8 @@ public class ConfigServiceV2Settings extends ServiceApiSettings { .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) .build(); - private final PageStreamingCallSettings + private final PageStreamingCallSettings< + ListSinksRequest, ListSinksResponse, ListSinksPagedResponse> listSinksSettings; private final SimpleCallSettings getSinkSettings; private final SimpleCallSettings createSinkSettings; @@ -102,7 +108,7 @@ public class ConfigServiceV2Settings extends ServiceApiSettings { private final SimpleCallSettings deleteSinkSettings; /** Returns the object with the settings used for calls to listSinks. */ - public PageStreamingCallSettings + public PageStreamingCallSettings listSinksSettings() { return listSinksSettings; } @@ -207,11 +213,27 @@ public Iterable extractResources(ListSinksResponse payload) { } }; + private static final PagedListResponseFactory< + ListSinksRequest, ListSinksResponse, ListSinksPagedResponse> + LIST_SINKS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListSinksRequest, ListSinksResponse, ListSinksPagedResponse>() { + @Override + public ListSinksPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListSinksRequest request, + CallContext context) { + return new ListSinksPagedResponse( + callable, LIST_SINKS_PAGE_STR_DESC, request, context); + } + }; + /** Builder for ConfigServiceV2Settings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; - private final PageStreamingCallSettings.Builder + private final PageStreamingCallSettings.Builder< + ListSinksRequest, ListSinksResponse, ListSinksPagedResponse> listSinksSettings; private final SimpleCallSettings.Builder getSinkSettings; private final SimpleCallSettings.Builder createSinkSettings; @@ -254,7 +276,7 @@ private Builder() { listSinksSettings = PageStreamingCallSettings.newBuilder( - ConfigServiceV2Grpc.METHOD_LIST_SINKS, LIST_SINKS_PAGE_STR_DESC); + ConfigServiceV2Grpc.METHOD_LIST_SINKS, LIST_SINKS_PAGE_STR_FACT); getSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_GET_SINK); @@ -264,8 +286,8 @@ private Builder() { deleteSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_DELETE_SINK); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listSinksSettings, getSinkSettings, createSinkSettings, @@ -313,8 +335,8 @@ private Builder(ConfigServiceV2Settings settings) { updateSinkSettings = settings.updateSinkSettings.toBuilder(); deleteSinkSettings = settings.deleteSinkSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listSinksSettings, getSinkSettings, createSinkSettings, @@ -370,16 +392,20 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } /** Returns the builder for the settings used for calls to listSinks. */ - public PageStreamingCallSettings.Builder + public PageStreamingCallSettings.Builder< + ListSinksRequest, ListSinksResponse, ListSinksPagedResponse> listSinksSettings() { return listSinksSettings; } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java index 0200b82f7d2a..7be2f99b75b6 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java @@ -13,10 +13,11 @@ */ package com.google.cloud.logging.spi.v2; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogEntriesPagedResponse; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListMonitoredResourceDescriptorsPagedResponse; + import com.google.api.MonitoredResource; -import com.google.api.MonitoredResourceDescriptor; -import com.google.api.gax.core.PagedListResponse; -import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.logging.v2.DeleteLogRequest; import com.google.logging.v2.ListLogEntriesRequest; @@ -64,8 +65,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -93,22 +94,18 @@ public class LoggingServiceV2Api implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable deleteLogCallable; - private final ApiCallable + private final UnaryApiCallable deleteLogCallable; + private final UnaryApiCallable writeLogEntriesCallable; - private final ApiCallable listLogEntriesCallable; - private final ApiCallable< - ListLogEntriesRequest, - PagedListResponse> + private final UnaryApiCallable + listLogEntriesCallable; + private final UnaryApiCallable listLogEntriesPagedCallable; - private final ApiCallable< + private final UnaryApiCallable< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> listMonitoredResourceDescriptorsCallable; - private final ApiCallable< - ListMonitoredResourceDescriptorsRequest, - PagedListResponse< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor>> + private final UnaryApiCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsPagedCallable; private static final PathTemplate PARENT_PATH_TEMPLATE = @@ -168,19 +165,19 @@ protected LoggingServiceV2Api(LoggingServiceV2Settings settings) throws IOExcept this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.deleteLogCallable = - ApiCallable.create(settings.deleteLogSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.deleteLogSettings(), this.channel, this.executor); this.writeLogEntriesCallable = - ApiCallable.create(settings.writeLogEntriesSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.writeLogEntriesSettings(), this.channel, this.executor); this.listLogEntriesCallable = - ApiCallable.create(settings.listLogEntriesSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listLogEntriesSettings(), this.channel, this.executor); this.listLogEntriesPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listLogEntriesSettings(), this.channel, this.executor); this.listMonitoredResourceDescriptorsCallable = - ApiCallable.create( + UnaryApiCallable.create( settings.listMonitoredResourceDescriptorsSettings(), this.channel, this.executor); this.listMonitoredResourceDescriptorsPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listMonitoredResourceDescriptorsSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { @@ -271,7 +268,7 @@ private final void deleteLog(DeleteLogRequest request) { * } * */ - public final ApiCallable deleteLogCallable() { + public final UnaryApiCallable deleteLogCallable() { return deleteLogCallable; } @@ -291,19 +288,24 @@ public final ApiCallable deleteLogCallable() { * } * * - * @param logName Optional. A default log resource name for those log entries in `entries` that do - * not specify their own `logName`. Example: `"projects/my-project/logs/syslog"`. See + * @param logName Optional. A default log resource name that is assigned to all log entries in + * `entries` that do not specify a value for `log_name`. Example: + * `"projects/my-project/logs/syslog"`. See [LogEntry][google.logging.v2.LogEntry]. + * @param resource Optional. A default monitored resource object that is assigned to all log + * entries in `entries` that do not specify a value for `resource`. Example: + *

    { "type": "gce_instance", "labels": { "zone": "us-central1-a", "instance_id": + * "00000000000000000000" }} + *

    See [LogEntry][google.logging.v2.LogEntry]. + * @param labels Optional. Default labels that are added to the `labels` field of all log entries + * in `entries`. If a log entry already has a label with the same key as a label in this + * parameter, then the log entry's label is not changed. See * [LogEntry][google.logging.v2.LogEntry]. - * @param resource Optional. A default monitored resource for those log entries in `entries` that - * do not specify their own `resource`. - * @param labels Optional. User-defined `key:value` items that are added to the `labels` field of - * each log entry in `entries`, except when a log entry specifies its own `key:value` item - * with the same key. Example: `{ "size": "large", "color":"red" }` - * @param entries Required. The log entries to write. The log entries must have values for all - * required fields. - *

    To improve throughput and to avoid exceeding the quota limit for calls to - * `entries.write`, use this field to write multiple log entries at once rather than // - * calling this method for each log entry. + * @param entries Required. The log entries to write. Values supplied for the fields `log_name`, + * `resource`, and `labels` in this `entries.write` request are added to those log entries + * that do not provide their own values for the fields. + *

    To improve throughput and to avoid exceeding the [quota limit](/logging/quota-policy) + * for calls to `entries.write`, you should write multiple log entries at once rather than + * calling this method for each individual log entry. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final WriteLogEntriesResponse writeLogEntries( @@ -365,7 +367,7 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * } * */ - public final ApiCallable + public final UnaryApiCallable writeLogEntriesCallable() { return writeLogEntriesCallable; } @@ -388,11 +390,13 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * } * * - * @param projectIds Required. One or more project IDs or project numbers from which to retrieve - * log entries. Examples of a project ID: `"my-project-1A"`, `"1234567890"`. - * @param filter Optional. An [advanced logs filter](/logging/docs/view/advanced_filters). The - * filter is compared against all log entries in the projects specified by `projectIds`. Only - * entries that match the filter are retrieved. An empty filter matches all log entries. + * @param projectIds Deprecated. One or more project identifiers or project numbers from which to + * retrieve log entries. Examples: `"my-project-1A"`, `"1234567890"`. If present, these + * project identifiers are converted to resource format and added to the list of resources in + * `resourceNames`. Callers should use `resourceNames` rather than this parameter. + * @param filter Optional. A filter that chooses which log entries to return. See [Advanced Logs + * Filters](/logging/docs/view/advanced_filters). Only log entries that match the filter are + * returned. An empty filter matches all log entries. * @param orderBy Optional. How the results should be sorted. Presently, the only permitted values * are `"timestamp asc"` (default) and `"timestamp desc"`. The first option returns entries in * order of increasing values of `LogEntry.timestamp` (oldest first), and the second option @@ -400,8 +404,8 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * timestamps are returned in order of `LogEntry.insertId`. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse - listLogEntries(List projectIds, String filter, String orderBy) { + public final ListLogEntriesPagedResponse listLogEntries( + List projectIds, String filter, String orderBy) { ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder() .addAllProjectIds(projectIds) @@ -433,8 +437,7 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse - listLogEntries(ListLogEntriesRequest request) { + public final ListLogEntriesPagedResponse listLogEntries(ListLogEntriesRequest request) { return listLogEntriesPagedCallable().call(request); } @@ -451,7 +454,7 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder() * .addAllProjectIds(projectIds) * .build(); - * ListenableFuture<PagedListResponse<ListLogEntriesRequest,ListLogEntriesResponse,LogEntry>> future = loggingServiceV2Api.listLogEntriesPagedCallable().futureCall(request); + * ListenableFuture<ListLogEntriesPagedResponse> future = loggingServiceV2Api.listLogEntriesPagedCallable().futureCall(request); * // Do something * for (LogEntry element : future.get().iterateAllElements()) { * // doThingsWith(element); @@ -459,9 +462,7 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * } * */ - public final ApiCallable< - ListLogEntriesRequest, - PagedListResponse> + public final UnaryApiCallable listLogEntriesPagedCallable() { return listLogEntriesPagedCallable; } @@ -494,7 +495,8 @@ public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest requ * } * */ - public final ApiCallable listLogEntriesCallable() { + public final UnaryApiCallable + listLogEntriesCallable() { return listLogEntriesCallable; } @@ -516,10 +518,8 @@ public final ApiCallable listLogE * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> - listMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest request) { + public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResourceDescriptors( + ListMonitoredResourceDescriptorsRequest request) { return listMonitoredResourceDescriptorsPagedCallable().call(request); } @@ -532,7 +532,7 @@ public final ApiCallable listLogE *

    
        * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
        *   ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder().build();
    -   *   ListenableFuture<PagedListResponse<ListMonitoredResourceDescriptorsRequest,ListMonitoredResourceDescriptorsResponse,MonitoredResourceDescriptor>> future = loggingServiceV2Api.listMonitoredResourceDescriptorsPagedCallable().futureCall(request);
    +   *   ListenableFuture<ListMonitoredResourceDescriptorsPagedResponse> future = loggingServiceV2Api.listMonitoredResourceDescriptorsPagedCallable().futureCall(request);
        *   // Do something
        *   for (MonitoredResourceDescriptor element : future.get().iterateAllElements()) {
        *     // doThingsWith(element);
    @@ -540,11 +540,8 @@ public final ApiCallable listLogE
        * }
        * 
    */ - public final ApiCallable< - ListMonitoredResourceDescriptorsRequest, - PagedListResponse< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor>> + public final UnaryApiCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsPagedCallable() { return listMonitoredResourceDescriptorsPagedCallable; } @@ -573,7 +570,7 @@ public final ApiCallable listLogE * } * */ - public final ApiCallable< + public final UnaryApiCallable< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> listMonitoredResourceDescriptorsCallable() { return listMonitoredResourceDescriptorsCallable; diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java index 3db49f10b4f0..5e3e5ab115a7 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java @@ -13,14 +13,20 @@ */ package com.google.cloud.logging.spi.v2; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogEntriesPagedResponse; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListMonitoredResourceDescriptorsPagedResponse; + import com.google.api.MonitoredResourceDescriptor; import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.CallContext; import com.google.api.gax.grpc.PageStreamingCallSettings; import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseFactory; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -99,11 +105,12 @@ public class LoggingServiceV2Settings extends ServiceApiSettings { private final SimpleCallSettings deleteLogSettings; private final SimpleCallSettings writeLogEntriesSettings; - private final PageStreamingCallSettings + private final PageStreamingCallSettings< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> listLogEntriesSettings; private final PageStreamingCallSettings< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> + ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsSettings; /** Returns the object with the settings used for calls to deleteLog. */ @@ -118,7 +125,8 @@ public SimpleCallSettings deleteLogSettings() { } /** Returns the object with the settings used for calls to listLogEntries. */ - public PageStreamingCallSettings + public PageStreamingCallSettings< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> listLogEntriesSettings() { return listLogEntriesSettings; } @@ -126,7 +134,7 @@ public SimpleCallSettings deleteLogSettings() { /** Returns the object with the settings used for calls to listMonitoredResourceDescriptors. */ public PageStreamingCallSettings< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> + ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsSettings() { return listMonitoredResourceDescriptorsSettings; } @@ -258,19 +266,54 @@ public Iterable extractResources( } }; + private static final PagedListResponseFactory< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> + LIST_LOG_ENTRIES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse>() { + @Override + public ListLogEntriesPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListLogEntriesRequest request, + CallContext context) { + return new ListLogEntriesPagedResponse( + callable, LIST_LOG_ENTRIES_PAGE_STR_DESC, request, context); + } + }; + + private static final PagedListResponseFactory< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse> + LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse>() { + @Override + public ListMonitoredResourceDescriptorsPagedResponse createPagedListResponse( + UnaryApiCallable< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse> + callable, + ListMonitoredResourceDescriptorsRequest request, + CallContext context) { + return new ListMonitoredResourceDescriptorsPagedResponse( + callable, LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC, request, context); + } + }; + /** Builder for LoggingServiceV2Settings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final SimpleCallSettings.Builder deleteLogSettings; private final SimpleCallSettings.Builder writeLogEntriesSettings; private final PageStreamingCallSettings.Builder< - ListLogEntriesRequest, ListLogEntriesResponse, LogEntry> + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> listLogEntriesSettings; private final PageStreamingCallSettings.Builder< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> + ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -324,15 +367,15 @@ private Builder() { listLogEntriesSettings = PageStreamingCallSettings.newBuilder( - LoggingServiceV2Grpc.METHOD_LIST_LOG_ENTRIES, LIST_LOG_ENTRIES_PAGE_STR_DESC); + LoggingServiceV2Grpc.METHOD_LIST_LOG_ENTRIES, LIST_LOG_ENTRIES_PAGE_STR_FACT); listMonitoredResourceDescriptorsSettings = PageStreamingCallSettings.newBuilder( LoggingServiceV2Grpc.METHOD_LIST_MONITORED_RESOURCE_DESCRIPTORS, - LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC); + LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( deleteLogSettings, writeLogEntriesSettings, listLogEntriesSettings, @@ -374,8 +417,8 @@ private Builder(LoggingServiceV2Settings settings) { listMonitoredResourceDescriptorsSettings = settings.listMonitoredResourceDescriptorsSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( deleteLogSettings, writeLogEntriesSettings, listLogEntriesSettings, @@ -430,11 +473,14 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } @@ -451,7 +497,7 @@ public SimpleCallSettings.Builder deleteLogSettings() { /** Returns the builder for the settings used for calls to listLogEntries. */ public PageStreamingCallSettings.Builder< - ListLogEntriesRequest, ListLogEntriesResponse, LogEntry> + ListLogEntriesRequest, ListLogEntriesResponse, ListLogEntriesPagedResponse> listLogEntriesSettings() { return listLogEntriesSettings; } @@ -459,7 +505,7 @@ public SimpleCallSettings.Builder deleteLogSettings() { /** Returns the builder for the settings used for calls to listMonitoredResourceDescriptors. */ public PageStreamingCallSettings.Builder< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> + ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsSettings() { return listMonitoredResourceDescriptorsSettings; } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java index e458ba1c756e..90303869b5a7 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java @@ -13,8 +13,9 @@ */ package com.google.cloud.logging.spi.v2; -import com.google.api.gax.core.PagedListResponse; -import com.google.api.gax.grpc.ApiCallable; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogMetricsPagedResponse; + +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.logging.v2.CreateLogMetricRequest; import com.google.logging.v2.DeleteLogMetricRequest; @@ -60,8 +61,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -89,15 +90,14 @@ public class MetricsServiceV2Api implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable listLogMetricsCallable; - private final ApiCallable< - ListLogMetricsRequest, - PagedListResponse> + private final UnaryApiCallable + listLogMetricsCallable; + private final UnaryApiCallable listLogMetricsPagedCallable; - private final ApiCallable getLogMetricCallable; - private final ApiCallable createLogMetricCallable; - private final ApiCallable updateLogMetricCallable; - private final ApiCallable deleteLogMetricCallable; + private final UnaryApiCallable getLogMetricCallable; + private final UnaryApiCallable createLogMetricCallable; + private final UnaryApiCallable updateLogMetricCallable; + private final UnaryApiCallable deleteLogMetricCallable; private static final PathTemplate PARENT_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding("projects/{project}"); @@ -156,18 +156,18 @@ protected MetricsServiceV2Api(MetricsServiceV2Settings settings) throws IOExcept this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.listLogMetricsCallable = - ApiCallable.create(settings.listLogMetricsSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listLogMetricsSettings(), this.channel, this.executor); this.listLogMetricsPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listLogMetricsSettings(), this.channel, this.executor); this.getLogMetricCallable = - ApiCallable.create(settings.getLogMetricSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.getLogMetricSettings(), this.channel, this.executor); this.createLogMetricCallable = - ApiCallable.create(settings.createLogMetricSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.createLogMetricSettings(), this.channel, this.executor); this.updateLogMetricCallable = - ApiCallable.create(settings.updateLogMetricSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.updateLogMetricSettings(), this.channel, this.executor); this.deleteLogMetricCallable = - ApiCallable.create(settings.deleteLogMetricSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.deleteLogMetricSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -212,8 +212,7 @@ public final MetricsServiceV2Settings getSettings() { * `"projects/my-project-id"`. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse - listLogMetrics(String parent) { + public final ListLogMetricsPagedResponse listLogMetrics(String parent) { PARENT_PATH_TEMPLATE.validate(parent, "listLogMetrics"); ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder().setParent(parent).build(); return listLogMetrics(request); @@ -240,8 +239,7 @@ public final MetricsServiceV2Settings getSettings() { * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse - listLogMetrics(ListLogMetricsRequest request) { + public final ListLogMetricsPagedResponse listLogMetrics(ListLogMetricsRequest request) { return listLogMetricsPagedCallable().call(request); } @@ -257,7 +255,7 @@ public final MetricsServiceV2Settings getSettings() { * ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder() * .setParent(formattedParent) * .build(); - * ListenableFuture<PagedListResponse<ListLogMetricsRequest,ListLogMetricsResponse,LogMetric>> future = metricsServiceV2Api.listLogMetricsPagedCallable().futureCall(request); + * ListenableFuture<ListLogMetricsPagedResponse> future = metricsServiceV2Api.listLogMetricsPagedCallable().futureCall(request); * // Do something * for (LogMetric element : future.get().iterateAllElements()) { * // doThingsWith(element); @@ -265,9 +263,7 @@ public final MetricsServiceV2Settings getSettings() { * } * */ - public final ApiCallable< - ListLogMetricsRequest, - PagedListResponse> + public final UnaryApiCallable listLogMetricsPagedCallable() { return listLogMetricsPagedCallable; } @@ -299,7 +295,8 @@ public final MetricsServiceV2Settings getSettings() { * } * */ - public final ApiCallable listLogMetricsCallable() { + public final UnaryApiCallable + listLogMetricsCallable() { return listLogMetricsCallable; } @@ -368,7 +365,7 @@ private final LogMetric getLogMetric(GetLogMetricRequest request) { * } * */ - public final ApiCallable getLogMetricCallable() { + public final UnaryApiCallable getLogMetricCallable() { return getLogMetricCallable; } @@ -444,7 +441,7 @@ public final LogMetric createLogMetric(CreateLogMetricRequest request) { * } * */ - public final ApiCallable createLogMetricCallable() { + public final UnaryApiCallable createLogMetricCallable() { return createLogMetricCallable; } @@ -522,7 +519,7 @@ public final LogMetric updateLogMetric(UpdateLogMetricRequest request) { * } * */ - public final ApiCallable updateLogMetricCallable() { + public final UnaryApiCallable updateLogMetricCallable() { return updateLogMetricCallable; } @@ -591,7 +588,7 @@ private final void deleteLogMetric(DeleteLogMetricRequest request) { * } * */ - public final ApiCallable deleteLogMetricCallable() { + public final UnaryApiCallable deleteLogMetricCallable() { return deleteLogMetricCallable; } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java index 33302e500c2f..a59f5e3fe76a 100644 --- a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java @@ -13,13 +13,18 @@ */ package com.google.cloud.logging.spi.v2; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogMetricsPagedResponse; + import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.CallContext; import com.google.api.gax.grpc.PageStreamingCallSettings; import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseFactory; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -94,7 +99,8 @@ public class MetricsServiceV2Settings extends ServiceApiSettings { .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) .build(); - private final PageStreamingCallSettings + private final PageStreamingCallSettings< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> listLogMetricsSettings; private final SimpleCallSettings getLogMetricSettings; private final SimpleCallSettings createLogMetricSettings; @@ -102,7 +108,8 @@ public class MetricsServiceV2Settings extends ServiceApiSettings { private final SimpleCallSettings deleteLogMetricSettings; /** Returns the object with the settings used for calls to listLogMetrics. */ - public PageStreamingCallSettings + public PageStreamingCallSettings< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> listLogMetricsSettings() { return listLogMetricsSettings; } @@ -209,12 +216,27 @@ public Iterable extractResources(ListLogMetricsResponse payload) { } }; + private static final PagedListResponseFactory< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> + LIST_LOG_METRICS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse>() { + @Override + public ListLogMetricsPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListLogMetricsRequest request, + CallContext context) { + return new ListLogMetricsPagedResponse( + callable, LIST_LOG_METRICS_PAGE_STR_DESC, request, context); + } + }; + /** Builder for MetricsServiceV2Settings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final PageStreamingCallSettings.Builder< - ListLogMetricsRequest, ListLogMetricsResponse, LogMetric> + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> listLogMetricsSettings; private final SimpleCallSettings.Builder getLogMetricSettings; private final SimpleCallSettings.Builder @@ -259,7 +281,7 @@ private Builder() { listLogMetricsSettings = PageStreamingCallSettings.newBuilder( - MetricsServiceV2Grpc.METHOD_LIST_LOG_METRICS, LIST_LOG_METRICS_PAGE_STR_DESC); + MetricsServiceV2Grpc.METHOD_LIST_LOG_METRICS, LIST_LOG_METRICS_PAGE_STR_FACT); getLogMetricSettings = SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_GET_LOG_METRIC); @@ -273,8 +295,8 @@ private Builder() { deleteLogMetricSettings = SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_DELETE_LOG_METRIC); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listLogMetricsSettings, getLogMetricSettings, createLogMetricSettings, @@ -322,8 +344,8 @@ private Builder(MetricsServiceV2Settings settings) { updateLogMetricSettings = settings.updateLogMetricSettings.toBuilder(); deleteLogMetricSettings = settings.deleteLogMetricSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listLogMetricsSettings, getLogMetricSettings, createLogMetricSettings, @@ -379,17 +401,20 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } /** Returns the builder for the settings used for calls to listLogMetrics. */ public PageStreamingCallSettings.Builder< - ListLogMetricsRequest, ListLogMetricsResponse, LogMetric> + ListLogMetricsRequest, ListLogMetricsResponse, ListLogMetricsPagedResponse> listLogMetricsSettings() { return listLogMetricsSettings; } diff --git a/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/PagedResponseWrappers.java b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/PagedResponseWrappers.java new file mode 100644 index 000000000000..75ad77db6970 --- /dev/null +++ b/google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2/PagedResponseWrappers.java @@ -0,0 +1,98 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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 + * + * http://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. + */ +package com.google.cloud.logging.spi.v2; + +import com.google.api.MonitoredResourceDescriptor; +import com.google.api.gax.grpc.CallContext; +import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseImpl; +import com.google.api.gax.grpc.UnaryApiCallable; +import com.google.logging.v2.ListLogEntriesRequest; +import com.google.logging.v2.ListLogEntriesResponse; +import com.google.logging.v2.ListLogMetricsRequest; +import com.google.logging.v2.ListLogMetricsResponse; +import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest; +import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse; +import com.google.logging.v2.ListSinksRequest; +import com.google.logging.v2.ListSinksResponse; +import com.google.logging.v2.LogEntry; +import com.google.logging.v2.LogMetric; +import com.google.logging.v2.LogSink; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Wrapper class to contain paged response types for page streaming methods. Each static class + * inside this wrapper class is used as the return type of one of an API method that implements the + * page streaming pattern. + */ +@javax.annotation.Generated("by GAPIC") +public class PagedResponseWrappers { + + public static class ListLogEntriesPagedResponse + extends PagedListResponseImpl { + + public ListLogEntriesPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor + pageDescriptor, + ListLogEntriesRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListMonitoredResourceDescriptorsPagedResponse + extends PagedListResponseImpl< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> { + + public ListMonitoredResourceDescriptorsPagedResponse( + UnaryApiCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> + callable, + PageStreamingDescriptor< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> + pageDescriptor, + ListMonitoredResourceDescriptorsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListSinksPagedResponse + extends PagedListResponseImpl { + + public ListSinksPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor pageDescriptor, + ListSinksRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListLogMetricsPagedResponse + extends PagedListResponseImpl { + + public ListLogMetricsPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor + pageDescriptor, + ListLogMetricsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } +} diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Test.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Test.java index 4ea8363a0dd8..32433dc85e51 100644 --- a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Test.java +++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Test.java @@ -14,7 +14,8 @@ package com.google.cloud.logging.spi.v2; -import com.google.api.gax.core.PagedListResponse; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListSinksPagedResponse; + import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; import com.google.common.collect.Lists; @@ -93,8 +94,7 @@ public void listSinksTest() { String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]"); - PagedListResponse pagedListResponse = - api.listSinks(formattedParent); + ListSinksPagedResponse pagedListResponse = api.listSinks(formattedParent); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); @@ -113,8 +113,14 @@ public void getSinkTest() { String name = "name3373707"; String destination = "destination-1429847026"; String filter = "filter-1274492040"; + String writerIdentity = "writerIdentity775638794"; LogSink expectedResponse = - LogSink.newBuilder().setName(name).setDestination(destination).setFilter(filter).build(); + LogSink.newBuilder() + .setName(name) + .setDestination(destination) + .setFilter(filter) + .setWriterIdentity(writerIdentity) + .build(); List expectedResponses = new ArrayList<>(); expectedResponses.add(expectedResponse); mockConfigServiceV2.setResponses(expectedResponses); @@ -137,8 +143,14 @@ public void createSinkTest() { String name = "name3373707"; String destination = "destination-1429847026"; String filter = "filter-1274492040"; + String writerIdentity = "writerIdentity775638794"; LogSink expectedResponse = - LogSink.newBuilder().setName(name).setDestination(destination).setFilter(filter).build(); + LogSink.newBuilder() + .setName(name) + .setDestination(destination) + .setFilter(filter) + .setWriterIdentity(writerIdentity) + .build(); List expectedResponses = new ArrayList<>(); expectedResponses.add(expectedResponse); mockConfigServiceV2.setResponses(expectedResponses); @@ -163,8 +175,14 @@ public void updateSinkTest() { String name = "name3373707"; String destination = "destination-1429847026"; String filter = "filter-1274492040"; + String writerIdentity = "writerIdentity775638794"; LogSink expectedResponse = - LogSink.newBuilder().setName(name).setDestination(destination).setFilter(filter).build(); + LogSink.newBuilder() + .setName(name) + .setDestination(destination) + .setFilter(filter) + .setWriterIdentity(writerIdentity) + .build(); List expectedResponses = new ArrayList<>(); expectedResponses.add(expectedResponse); mockConfigServiceV2.setResponses(expectedResponses); diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Test.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Test.java index 24e7dcd5d64e..e4a44b72031e 100644 --- a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Test.java +++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Test.java @@ -14,8 +14,9 @@ package com.google.cloud.logging.spi.v2; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogEntriesPagedResponse; + import com.google.api.MonitoredResource; -import com.google.api.gax.core.PagedListResponse; import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; import com.google.common.collect.Lists; @@ -146,8 +147,7 @@ public void listLogEntriesTest() { String filter = "filter-1274492040"; String orderBy = "orderBy1234304744"; - PagedListResponse pagedListResponse = - api.listLogEntries(projectIds, filter, orderBy); + ListLogEntriesPagedResponse pagedListResponse = api.listLogEntries(projectIds, filter, orderBy); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); diff --git a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Test.java b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Test.java index a497c5570804..54c76528be31 100644 --- a/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Test.java +++ b/google-cloud-logging/src/test/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Test.java @@ -14,7 +14,8 @@ package com.google.cloud.logging.spi.v2; -import com.google.api.gax.core.PagedListResponse; +import static com.google.cloud.logging.spi.v2.PagedResponseWrappers.ListLogMetricsPagedResponse; + import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; import com.google.common.collect.Lists; @@ -96,8 +97,7 @@ public void listLogMetricsTest() { String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]"); - PagedListResponse pagedListResponse = - api.listLogMetrics(formattedParent); + ListLogMetricsPagedResponse pagedListResponse = api.listLogMetrics(formattedParent); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/AgentTranslationServiceApi.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/AgentTranslationServiceApi.java index a81142c23194..8697604f2ba8 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/AgentTranslationServiceApi.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/AgentTranslationServiceApi.java @@ -14,7 +14,7 @@ package com.google.cloud.monitoring.spi.v3; import com.google.api.MonitoredResource; -import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.monitoring.v3.CollectdPayload; import com.google.monitoring.v3.CreateCollectdTimeSeriesRequest; @@ -61,7 +61,7 @@ * which must be constructed before the call. Not every API method will have a request object * method. *

  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + * UnaryApiCallable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -89,7 +89,7 @@ public class AgentTranslationServiceApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable + private final UnaryApiCallable createCollectdTimeSeriesCallable; private static final PathTemplate PROJECT_PATH_TEMPLATE = @@ -131,7 +131,7 @@ protected AgentTranslationServiceApi(AgentTranslationServiceSettings settings) this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.createCollectdTimeSeriesCallable = - ApiCallable.create( + UnaryApiCallable.create( settings.createCollectdTimeSeriesSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { @@ -265,7 +265,7 @@ public final void createCollectdTimeSeries(CreateCollectdTimeSeriesRequest reque * } * */ - public final ApiCallable + public final UnaryApiCallable createCollectdTimeSeriesCallable() { return createCollectdTimeSeriesCallable; } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/AgentTranslationServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/AgentTranslationServiceSettings.java index 72bbff0eebbb..ef043a160a97 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/AgentTranslationServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/AgentTranslationServiceSettings.java @@ -15,7 +15,7 @@ import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; import com.google.auth.Credentials; @@ -133,7 +133,7 @@ private AgentTranslationServiceSettings(Builder settingsBuilder) throws IOExcept /** Builder for AgentTranslationServiceSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList methodSettingsBuilders; private final SimpleCallSettings.Builder createCollectdTimeSeriesSettings; @@ -177,7 +177,7 @@ private Builder() { AgentTranslationServiceGrpc.METHOD_CREATE_COLLECTD_TIME_SERIES); methodSettingsBuilders = - ImmutableList.of(createCollectdTimeSeriesSettings); + ImmutableList.of(createCollectdTimeSeriesSettings); } private static Builder createDefault() { @@ -197,7 +197,7 @@ private Builder(AgentTranslationServiceSettings settings) { createCollectdTimeSeriesSettings = settings.createCollectdTimeSeriesSettings.toBuilder(); methodSettingsBuilders = - ImmutableList.of(createCollectdTimeSeriesSettings); + ImmutableList.of(createCollectdTimeSeriesSettings); } @Override @@ -251,7 +251,7 @@ public Builder setClientLibHeader(String name, String version) { * Applies the given settings to all of the API methods in this service. Only values that are * non-null will be applied, so this method is not capable of un-setting any values. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) throws Exception { super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); return this; } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceApi.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceApi.java index 850406c119de..c8edcaae8b7f 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceApi.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceApi.java @@ -13,9 +13,10 @@ */ package com.google.cloud.monitoring.spi.v3; -import com.google.api.MonitoredResource; -import com.google.api.gax.core.PagedListResponse; -import com.google.api.gax.grpc.ApiCallable; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListGroupMembersPagedResponse; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListGroupsPagedResponse; + +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.monitoring.v3.CreateGroupRequest; import com.google.monitoring.v3.DeleteGroupRequest; @@ -25,7 +26,6 @@ import com.google.monitoring.v3.ListGroupMembersResponse; import com.google.monitoring.v3.ListGroupsRequest; import com.google.monitoring.v3.ListGroupsResponse; -import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; import io.grpc.ManagedChannel; @@ -72,8 +72,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -101,19 +101,16 @@ public class GroupServiceApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable listGroupsCallable; - private final ApiCallable< - ListGroupsRequest, PagedListResponse> + private final UnaryApiCallable listGroupsCallable; + private final UnaryApiCallable listGroupsPagedCallable; - private final ApiCallable getGroupCallable; - private final ApiCallable createGroupCallable; - private final ApiCallable updateGroupCallable; - private final ApiCallable deleteGroupCallable; - private final ApiCallable + private final UnaryApiCallable getGroupCallable; + private final UnaryApiCallable createGroupCallable; + private final UnaryApiCallable updateGroupCallable; + private final UnaryApiCallable deleteGroupCallable; + private final UnaryApiCallable listGroupMembersCallable; - private final ApiCallable< - ListGroupMembersRequest, - PagedListResponse> + private final UnaryApiCallable listGroupMembersPagedCallable; private static final PathTemplate PROJECT_PATH_TEMPLATE = @@ -172,21 +169,22 @@ protected GroupServiceApi(GroupServiceSettings settings) throws IOException { this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.listGroupsCallable = - ApiCallable.create(settings.listGroupsSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listGroupsSettings(), this.channel, this.executor); this.listGroupsPagedCallable = - ApiCallable.createPagedVariant(settings.listGroupsSettings(), this.channel, this.executor); + UnaryApiCallable.createPagedVariant( + settings.listGroupsSettings(), this.channel, this.executor); this.getGroupCallable = - ApiCallable.create(settings.getGroupSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.getGroupSettings(), this.channel, this.executor); this.createGroupCallable = - ApiCallable.create(settings.createGroupSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.createGroupSettings(), this.channel, this.executor); this.updateGroupCallable = - ApiCallable.create(settings.updateGroupSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.updateGroupSettings(), this.channel, this.executor); this.deleteGroupCallable = - ApiCallable.create(settings.deleteGroupSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.deleteGroupSettings(), this.channel, this.executor); this.listGroupMembersCallable = - ApiCallable.create(settings.listGroupMembersSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listGroupMembersSettings(), this.channel, this.executor); this.listGroupMembersPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listGroupMembersSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { @@ -215,7 +213,7 @@ public final GroupServiceSettings getSettings() { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the existing groups. The project ID in the URL path must refer to a Stackdriver account. + * Lists the existing groups. * *

    Sample code: * @@ -234,14 +232,13 @@ public final GroupServiceSettings getSettings() { * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse listGroups( - ListGroupsRequest request) { + public final ListGroupsPagedResponse listGroups(ListGroupsRequest request) { return listGroupsPagedCallable().call(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the existing groups. The project ID in the URL path must refer to a Stackdriver account. + * Lists the existing groups. * *

    Sample code: * @@ -251,7 +248,7 @@ public final PagedListResponse lis * ListGroupsRequest request = ListGroupsRequest.newBuilder() * .setName(formattedName) * .build(); - * ListenableFuture<PagedListResponse<ListGroupsRequest,ListGroupsResponse,Group>> future = groupServiceApi.listGroupsPagedCallable().futureCall(request); + * ListenableFuture<ListGroupsPagedResponse> future = groupServiceApi.listGroupsPagedCallable().futureCall(request); * // Do something * for (Group element : future.get().iterateAllElements()) { * // doThingsWith(element); @@ -259,15 +256,14 @@ public final PagedListResponse lis * } * */ - public final ApiCallable< - ListGroupsRequest, PagedListResponse> + public final UnaryApiCallable listGroupsPagedCallable() { return listGroupsPagedCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the existing groups. The project ID in the URL path must refer to a Stackdriver account. + * Lists the existing groups. * *

    Sample code: * @@ -292,13 +288,13 @@ public final PagedListResponse lis * } * */ - public final ApiCallable listGroupsCallable() { + public final UnaryApiCallable listGroupsCallable() { return listGroupsCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets a single group. The project ID in the URL path must refer to a Stackdriver account. + * Gets a single group. * *

    Sample code: * @@ -321,7 +317,7 @@ public final Group getGroup(String name) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets a single group. The project ID in the URL path must refer to a Stackdriver account. + * Gets a single group. * *

    Sample code: * @@ -344,7 +340,7 @@ private final Group getGroup(GetGroupRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets a single group. The project ID in the URL path must refer to a Stackdriver account. + * Gets a single group. * *

    Sample code: * @@ -360,13 +356,13 @@ private final Group getGroup(GetGroupRequest request) { * } * */ - public final ApiCallable getGroupCallable() { + public final UnaryApiCallable getGroupCallable() { return getGroupCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates a new group. The project ID in the URL path must refer to a Stackdriver account. + * Creates a new group. * *

    Sample code: * @@ -374,8 +370,7 @@ public final ApiCallable getGroupCallable() { * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) { * String formattedName = GroupServiceApi.formatProjectName("[PROJECT]"); * Group group = Group.newBuilder().build(); - * boolean validateOnly = false; - * Group response = groupServiceApi.createGroup(formattedName, group, validateOnly); + * Group response = groupServiceApi.createGroup(formattedName, group); * } * * @@ -383,23 +378,18 @@ public final ApiCallable getGroupCallable() { * `"projects/{project_id_or_number}"`. * @param group A group definition. It is an error to define the `name` field because the system * assigns the name. - * @param validateOnly If true, validate this request but do not create the group. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final Group createGroup(String name, Group group, boolean validateOnly) { + public final Group createGroup(String name, Group group) { PROJECT_PATH_TEMPLATE.validate(name, "createGroup"); CreateGroupRequest request = - CreateGroupRequest.newBuilder() - .setName(name) - .setGroup(group) - .setValidateOnly(validateOnly) - .build(); + CreateGroupRequest.newBuilder().setName(name).setGroup(group).build(); return createGroup(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates a new group. The project ID in the URL path must refer to a Stackdriver account. + * Creates a new group. * *

    Sample code: * @@ -407,11 +397,9 @@ public final Group createGroup(String name, Group group, boolean validateOnly) { * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) { * String formattedName = GroupServiceApi.formatProjectName("[PROJECT]"); * Group group = Group.newBuilder().build(); - * boolean validateOnly = false; * CreateGroupRequest request = CreateGroupRequest.newBuilder() * .setName(formattedName) * .setGroup(group) - * .setValidateOnly(validateOnly) * .build(); * Group response = groupServiceApi.createGroup(request); * } @@ -426,7 +414,7 @@ public final Group createGroup(CreateGroupRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Creates a new group. The project ID in the URL path must refer to a Stackdriver account. + * Creates a new group. * *

    Sample code: * @@ -434,11 +422,9 @@ public final Group createGroup(CreateGroupRequest request) { * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) { * String formattedName = GroupServiceApi.formatProjectName("[PROJECT]"); * Group group = Group.newBuilder().build(); - * boolean validateOnly = false; * CreateGroupRequest request = CreateGroupRequest.newBuilder() * .setName(formattedName) * .setGroup(group) - * .setValidateOnly(validateOnly) * .build(); * ListenableFuture<Group> future = groupServiceApi.createGroupCallable().futureCall(request); * // Do something @@ -446,50 +432,43 @@ public final Group createGroup(CreateGroupRequest request) { * } * */ - public final ApiCallable createGroupCallable() { + public final UnaryApiCallable createGroupCallable() { return createGroupCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Updates an existing group. You can change any group attributes except `name`. The project ID in - * the URL path must refer to a Stackdriver account. + * Updates an existing group. You can change any group attributes except `name`. * *

    Sample code: * *

    
        * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) {
        *   Group group = Group.newBuilder().build();
    -   *   boolean validateOnly = false;
    -   *   Group response = groupServiceApi.updateGroup(group, validateOnly);
    +   *   Group response = groupServiceApi.updateGroup(group);
        * }
        * 
    * * @param group The new definition of the group. All fields of the existing group, excepting * `name`, are replaced with the corresponding fields of this group. - * @param validateOnly If true, validate this request but do not update the existing group. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final Group updateGroup(Group group, boolean validateOnly) { - UpdateGroupRequest request = - UpdateGroupRequest.newBuilder().setGroup(group).setValidateOnly(validateOnly).build(); + public final Group updateGroup(Group group) { + UpdateGroupRequest request = UpdateGroupRequest.newBuilder().setGroup(group).build(); return updateGroup(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Updates an existing group. You can change any group attributes except `name`. The project ID in - * the URL path must refer to a Stackdriver account. + * Updates an existing group. You can change any group attributes except `name`. * *

    Sample code: * *

    
        * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) {
        *   Group group = Group.newBuilder().build();
    -   *   boolean validateOnly = false;
        *   UpdateGroupRequest request = UpdateGroupRequest.newBuilder()
        *     .setGroup(group)
    -   *     .setValidateOnly(validateOnly)
        *     .build();
        *   Group response = groupServiceApi.updateGroup(request);
        * }
    @@ -504,18 +483,15 @@ public final Group updateGroup(UpdateGroupRequest request) {
     
       // AUTO-GENERATED DOCUMENTATION AND METHOD
       /**
    -   * Updates an existing group. You can change any group attributes except `name`. The project ID in
    -   * the URL path must refer to a Stackdriver account.
    +   * Updates an existing group. You can change any group attributes except `name`.
        *
        * 

    Sample code: * *

    
        * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) {
        *   Group group = Group.newBuilder().build();
    -   *   boolean validateOnly = false;
        *   UpdateGroupRequest request = UpdateGroupRequest.newBuilder()
        *     .setGroup(group)
    -   *     .setValidateOnly(validateOnly)
        *     .build();
        *   ListenableFuture<Group> future = groupServiceApi.updateGroupCallable().futureCall(request);
        *   // Do something
    @@ -523,13 +499,13 @@ public final Group updateGroup(UpdateGroupRequest request) {
        * }
        * 
    */ - public final ApiCallable updateGroupCallable() { + public final UnaryApiCallable updateGroupCallable() { return updateGroupCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Deletes an existing group. The project ID in the URL path must refer to a Stackdriver account. + * Deletes an existing group. * *

    Sample code: * @@ -552,7 +528,7 @@ public final void deleteGroup(String name) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Deletes an existing group. The project ID in the URL path must refer to a Stackdriver account. + * Deletes an existing group. * *

    Sample code: * @@ -575,7 +551,7 @@ private final void deleteGroup(DeleteGroupRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Deletes an existing group. The project ID in the URL path must refer to a Stackdriver account. + * Deletes an existing group. * *

    Sample code: * @@ -591,23 +567,20 @@ private final void deleteGroup(DeleteGroupRequest request) { * } *

    */ - public final ApiCallable deleteGroupCallable() { + public final UnaryApiCallable deleteGroupCallable() { return deleteGroupCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the monitored resources that are members of a group. The project ID in the URL path must - * refer to a Stackdriver account. + * Lists the monitored resources that are members of a group. * *

    Sample code: * *

    
        * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) {
        *   String formattedName = GroupServiceApi.formatGroupName("[PROJECT]", "[GROUP]");
    -   *   String filter = "";
    -   *   TimeInterval interval = TimeInterval.newBuilder().build();
    -   *   for (MonitoredResource element : groupServiceApi.listGroupMembers(formattedName, filter, interval).iterateAllElements()) {
    +   *   for (MonitoredResource element : groupServiceApi.listGroupMembers(formattedName).iterateAllElements()) {
        *     // doThingsWith(element);
        *   }
        * }
    @@ -615,45 +588,25 @@ public final ApiCallable deleteGroupCallable() {
        *
        * @param name The group whose members are listed. The format is
        *     `"projects/{project_id_or_number}/groups/{group_id}"`.
    -   * @param filter An optional [list filter](/monitoring/api/learn_more#filtering) describing the
    -   *     members to be returned. The filter may reference the type, labels, and metadata of
    -   *     monitored resources that comprise the group. For example, to return only resources
    -   *     representing Compute Engine VM instances, use this filter:
    -   *     

    resource.type = "gce_instance" - * @param interval An optional time interval for which results should be returned. Only members - * that were part of the group during the specified interval are included in the response. If - * no interval is provided then the group membership over the last minute is returned. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse< - ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource> - listGroupMembers(String name, String filter, TimeInterval interval) { + public final ListGroupMembersPagedResponse listGroupMembers(String name) { GROUP_PATH_TEMPLATE.validate(name, "listGroupMembers"); - ListGroupMembersRequest request = - ListGroupMembersRequest.newBuilder() - .setName(name) - .setFilter(filter) - .setInterval(interval) - .build(); + ListGroupMembersRequest request = ListGroupMembersRequest.newBuilder().setName(name).build(); return listGroupMembers(request); } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the monitored resources that are members of a group. The project ID in the URL path must - * refer to a Stackdriver account. + * Lists the monitored resources that are members of a group. * *

    Sample code: * *

    
        * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) {
        *   String formattedName = GroupServiceApi.formatGroupName("[PROJECT]", "[GROUP]");
    -   *   String filter = "";
    -   *   TimeInterval interval = TimeInterval.newBuilder().build();
        *   ListGroupMembersRequest request = ListGroupMembersRequest.newBuilder()
        *     .setName(formattedName)
    -   *     .setFilter(filter)
    -   *     .setInterval(interval)
        *     .build();
        *   for (MonitoredResource element : groupServiceApi.listGroupMembers(request).iterateAllElements()) {
        *     // doThingsWith(element);
    @@ -664,30 +617,23 @@ public final ApiCallable deleteGroupCallable() {
        * @param request The request object containing all of the parameters for the API call.
        * @throws com.google.api.gax.grpc.ApiException if the remote call fails
        */
    -  public final PagedListResponse<
    -          ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource>
    -      listGroupMembers(ListGroupMembersRequest request) {
    +  public final ListGroupMembersPagedResponse listGroupMembers(ListGroupMembersRequest request) {
         return listGroupMembersPagedCallable().call(request);
       }
     
       // AUTO-GENERATED DOCUMENTATION AND METHOD
       /**
    -   * Lists the monitored resources that are members of a group. The project ID in the URL path must
    -   * refer to a Stackdriver account.
    +   * Lists the monitored resources that are members of a group.
        *
        * 

    Sample code: * *

    
        * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) {
        *   String formattedName = GroupServiceApi.formatGroupName("[PROJECT]", "[GROUP]");
    -   *   String filter = "";
    -   *   TimeInterval interval = TimeInterval.newBuilder().build();
        *   ListGroupMembersRequest request = ListGroupMembersRequest.newBuilder()
        *     .setName(formattedName)
    -   *     .setFilter(filter)
    -   *     .setInterval(interval)
        *     .build();
    -   *   ListenableFuture<PagedListResponse<ListGroupMembersRequest,ListGroupMembersResponse,MonitoredResource>> future = groupServiceApi.listGroupMembersPagedCallable().futureCall(request);
    +   *   ListenableFuture<ListGroupMembersPagedResponse> future = groupServiceApi.listGroupMembersPagedCallable().futureCall(request);
        *   // Do something
        *   for (MonitoredResource element : future.get().iterateAllElements()) {
        *     // doThingsWith(element);
    @@ -695,29 +641,22 @@ public final ApiCallable deleteGroupCallable() {
        * }
        * 
    */ - public final ApiCallable< - ListGroupMembersRequest, - PagedListResponse> + public final UnaryApiCallable listGroupMembersPagedCallable() { return listGroupMembersPagedCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Lists the monitored resources that are members of a group. The project ID in the URL path must - * refer to a Stackdriver account. + * Lists the monitored resources that are members of a group. * *

    Sample code: * *

    
        * try (GroupServiceApi groupServiceApi = GroupServiceApi.create()) {
        *   String formattedName = GroupServiceApi.formatGroupName("[PROJECT]", "[GROUP]");
    -   *   String filter = "";
    -   *   TimeInterval interval = TimeInterval.newBuilder().build();
        *   ListGroupMembersRequest request = ListGroupMembersRequest.newBuilder()
        *     .setName(formattedName)
    -   *     .setFilter(filter)
    -   *     .setInterval(interval)
        *     .build();
        *   while (true) {
        *     ListGroupMembersResponse response = groupServiceApi.listGroupMembersCallable().call(request);
    @@ -734,7 +673,7 @@ public final ApiCallable deleteGroupCallable() {
        * }
        * 
    */ - public final ApiCallable + public final UnaryApiCallable listGroupMembersCallable() { return listGroupMembersCallable; } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceSettings.java index a5e1f1d06d73..a2de766c811d 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/GroupServiceSettings.java @@ -13,14 +13,20 @@ */ package com.google.cloud.monitoring.spi.v3; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListGroupMembersPagedResponse; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListGroupsPagedResponse; + import com.google.api.MonitoredResource; import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.CallContext; import com.google.api.gax.grpc.PageStreamingCallSettings; import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseFactory; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -91,18 +97,19 @@ public class GroupServiceSettings extends ServiceApiSettings { .provideCredentialsWith(DEFAULT_SERVICE_SCOPES) .build(); - private final PageStreamingCallSettings + private final PageStreamingCallSettings< + ListGroupsRequest, ListGroupsResponse, ListGroupsPagedResponse> listGroupsSettings; private final SimpleCallSettings getGroupSettings; private final SimpleCallSettings createGroupSettings; private final SimpleCallSettings updateGroupSettings; private final SimpleCallSettings deleteGroupSettings; private final PageStreamingCallSettings< - ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource> + ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> listGroupMembersSettings; /** Returns the object with the settings used for calls to listGroups. */ - public PageStreamingCallSettings + public PageStreamingCallSettings listGroupsSettings() { return listGroupsSettings; } @@ -129,7 +136,7 @@ public SimpleCallSettings deleteGroupSettings() { /** Returns the object with the settings used for calls to listGroupMembers. */ public PageStreamingCallSettings< - ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource> + ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> listGroupMembersSettings() { return listGroupMembersSettings; } @@ -255,18 +262,49 @@ public Iterable extractResources(ListGroupMembersResponse pay } }; + private static final PagedListResponseFactory< + ListGroupsRequest, ListGroupsResponse, ListGroupsPagedResponse> + LIST_GROUPS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListGroupsRequest, ListGroupsResponse, ListGroupsPagedResponse>() { + @Override + public ListGroupsPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListGroupsRequest request, + CallContext context) { + return new ListGroupsPagedResponse( + callable, LIST_GROUPS_PAGE_STR_DESC, request, context); + } + }; + + private static final PagedListResponseFactory< + ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> + LIST_GROUP_MEMBERS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse>() { + @Override + public ListGroupMembersPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListGroupMembersRequest request, + CallContext context) { + return new ListGroupMembersPagedResponse( + callable, LIST_GROUP_MEMBERS_PAGE_STR_DESC, request, context); + } + }; + /** Builder for GroupServiceSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; - private final PageStreamingCallSettings.Builder + private final PageStreamingCallSettings.Builder< + ListGroupsRequest, ListGroupsResponse, ListGroupsPagedResponse> listGroupsSettings; private final SimpleCallSettings.Builder getGroupSettings; private final SimpleCallSettings.Builder createGroupSettings; private final SimpleCallSettings.Builder updateGroupSettings; private final SimpleCallSettings.Builder deleteGroupSettings; private final PageStreamingCallSettings.Builder< - ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource> + ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> listGroupMembersSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -305,7 +343,7 @@ private Builder() { listGroupsSettings = PageStreamingCallSettings.newBuilder( - GroupServiceGrpc.METHOD_LIST_GROUPS, LIST_GROUPS_PAGE_STR_DESC); + GroupServiceGrpc.METHOD_LIST_GROUPS, LIST_GROUPS_PAGE_STR_FACT); getGroupSettings = SimpleCallSettings.newBuilder(GroupServiceGrpc.METHOD_GET_GROUP); @@ -317,10 +355,10 @@ private Builder() { listGroupMembersSettings = PageStreamingCallSettings.newBuilder( - GroupServiceGrpc.METHOD_LIST_GROUP_MEMBERS, LIST_GROUP_MEMBERS_PAGE_STR_DESC); + GroupServiceGrpc.METHOD_LIST_GROUP_MEMBERS, LIST_GROUP_MEMBERS_PAGE_STR_FACT); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listGroupsSettings, getGroupSettings, createGroupSettings, @@ -375,8 +413,8 @@ private Builder(GroupServiceSettings settings) { deleteGroupSettings = settings.deleteGroupSettings.toBuilder(); listGroupMembersSettings = settings.listGroupMembersSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listGroupsSettings, getGroupSettings, createGroupSettings, @@ -433,16 +471,20 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } /** Returns the builder for the settings used for calls to listGroups. */ - public PageStreamingCallSettings.Builder + public PageStreamingCallSettings.Builder< + ListGroupsRequest, ListGroupsResponse, ListGroupsPagedResponse> listGroupsSettings() { return listGroupsSettings; } @@ -469,7 +511,7 @@ public SimpleCallSettings.Builder deleteGroupSettings /** Returns the builder for the settings used for calls to listGroupMembers. */ public PageStreamingCallSettings.Builder< - ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource> + ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> listGroupMembersSettings() { return listGroupMembersSettings; } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/MetricServiceApi.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/MetricServiceApi.java index bd3599c6d493..9f0f48cb04da 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/MetricServiceApi.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/MetricServiceApi.java @@ -13,10 +13,13 @@ */ package com.google.cloud.monitoring.spi.v3; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMetricDescriptorsPagedResponse; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMonitoredResourceDescriptorsPagedResponse; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListTimeSeriesPagedResponse; + import com.google.api.MetricDescriptor; import com.google.api.MonitoredResourceDescriptor; -import com.google.api.gax.core.PagedListResponse; -import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.monitoring.v3.CreateMetricDescriptorRequest; import com.google.monitoring.v3.CreateTimeSeriesRequest; @@ -28,7 +31,9 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest; import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; +import com.google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView; import com.google.monitoring.v3.ListTimeSeriesResponse; +import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; import io.grpc.ManagedChannel; @@ -68,8 +73,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -97,42 +102,36 @@ public class MetricServiceApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable< + private final UnaryApiCallable< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> listMonitoredResourceDescriptorsCallable; - private final ApiCallable< - ListMonitoredResourceDescriptorsRequest, - PagedListResponse< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor>> + private final UnaryApiCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsPagedCallable; - private final ApiCallable + private final UnaryApiCallable getMonitoredResourceDescriptorCallable; - private final ApiCallable + private final UnaryApiCallable listMetricDescriptorsCallable; - private final ApiCallable< - ListMetricDescriptorsRequest, - PagedListResponse< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor>> + private final UnaryApiCallable listMetricDescriptorsPagedCallable; - private final ApiCallable + private final UnaryApiCallable getMetricDescriptorCallable; - private final ApiCallable + private final UnaryApiCallable createMetricDescriptorCallable; - private final ApiCallable deleteMetricDescriptorCallable; - private final ApiCallable listTimeSeriesCallable; - private final ApiCallable< - ListTimeSeriesRequest, - PagedListResponse> + private final UnaryApiCallable + deleteMetricDescriptorCallable; + private final UnaryApiCallable + listTimeSeriesCallable; + private final UnaryApiCallable listTimeSeriesPagedCallable; - private final ApiCallable createTimeSeriesCallable; + private final UnaryApiCallable createTimeSeriesCallable; private static final PathTemplate PROJECT_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding("projects/{project}"); - private static final PathTemplate METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE = + private static final PathTemplate METRIC_DESCRIPTOR_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding( - "projects/{project}/metricDescriptors/{metric_descriptor_path=**}"); + "projects/{project}/metricDescriptors/{metric_descriptor=**}"); private static final PathTemplate MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding( @@ -144,14 +143,12 @@ public static final String formatProjectName(String project) { } /** - * Formats a string containing the fully-qualified path to represent a metric_descriptor_path - * resource. + * Formats a string containing the fully-qualified path to represent a metric_descriptor resource. */ - public static final String formatMetricDescriptorPathName( - String project, String metricDescriptorPath) { - return METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.instantiate( + public static final String formatMetricDescriptorName(String project, String metricDescriptor) { + return METRIC_DESCRIPTOR_PATH_TEMPLATE.instantiate( "project", project, - "metric_descriptor_path", metricDescriptorPath); + "metric_descriptor", metricDescriptor); } /** @@ -171,23 +168,20 @@ public static final String parseProjectFromProjectName(String projectName) { } /** - * Parses the project from the given fully-qualified path which represents a metricDescriptorPath + * Parses the project from the given fully-qualified path which represents a metricDescriptor * resource. */ - public static final String parseProjectFromMetricDescriptorPathName( - String metricDescriptorPathName) { - return METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.parse(metricDescriptorPathName).get("project"); + public static final String parseProjectFromMetricDescriptorName(String metricDescriptorName) { + return METRIC_DESCRIPTOR_PATH_TEMPLATE.parse(metricDescriptorName).get("project"); } /** - * Parses the metric_descriptor_path from the given fully-qualified path which represents a - * metricDescriptorPath resource. + * Parses the metric_descriptor from the given fully-qualified path which represents a + * metricDescriptor resource. */ - public static final String parseMetricDescriptorPathFromMetricDescriptorPathName( - String metricDescriptorPathName) { - return METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE - .parse(metricDescriptorPathName) - .get("metric_descriptor_path"); + public static final String parseMetricDescriptorFromMetricDescriptorName( + String metricDescriptorName) { + return METRIC_DESCRIPTOR_PATH_TEMPLATE.parse(metricDescriptorName).get("metric_descriptor"); } /** @@ -235,32 +229,36 @@ protected MetricServiceApi(MetricServiceSettings settings) throws IOException { this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.listMonitoredResourceDescriptorsCallable = - ApiCallable.create( + UnaryApiCallable.create( settings.listMonitoredResourceDescriptorsSettings(), this.channel, this.executor); this.listMonitoredResourceDescriptorsPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listMonitoredResourceDescriptorsSettings(), this.channel, this.executor); this.getMonitoredResourceDescriptorCallable = - ApiCallable.create( + UnaryApiCallable.create( settings.getMonitoredResourceDescriptorSettings(), this.channel, this.executor); this.listMetricDescriptorsCallable = - ApiCallable.create(settings.listMetricDescriptorsSettings(), this.channel, this.executor); + UnaryApiCallable.create( + settings.listMetricDescriptorsSettings(), this.channel, this.executor); this.listMetricDescriptorsPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listMetricDescriptorsSettings(), this.channel, this.executor); this.getMetricDescriptorCallable = - ApiCallable.create(settings.getMetricDescriptorSettings(), this.channel, this.executor); + UnaryApiCallable.create( + settings.getMetricDescriptorSettings(), this.channel, this.executor); this.createMetricDescriptorCallable = - ApiCallable.create(settings.createMetricDescriptorSettings(), this.channel, this.executor); + UnaryApiCallable.create( + settings.createMetricDescriptorSettings(), this.channel, this.executor); this.deleteMetricDescriptorCallable = - ApiCallable.create(settings.deleteMetricDescriptorSettings(), this.channel, this.executor); + UnaryApiCallable.create( + settings.deleteMetricDescriptorSettings(), this.channel, this.executor); this.listTimeSeriesCallable = - ApiCallable.create(settings.listTimeSeriesSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listTimeSeriesSettings(), this.channel, this.executor); this.listTimeSeriesPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listTimeSeriesSettings(), this.channel, this.executor); this.createTimeSeriesCallable = - ApiCallable.create(settings.createTimeSeriesSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.createTimeSeriesSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -296,8 +294,7 @@ public final MetricServiceSettings getSettings() { *

    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
        *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
    -   *   String filter = "";
    -   *   for (MonitoredResourceDescriptor element : metricServiceApi.listMonitoredResourceDescriptors(formattedName, filter).iterateAllElements()) {
    +   *   for (MonitoredResourceDescriptor element : metricServiceApi.listMonitoredResourceDescriptors(formattedName).iterateAllElements()) {
        *     // doThingsWith(element);
        *   }
        * }
    @@ -305,22 +302,13 @@ public final MetricServiceSettings getSettings() {
        *
        * @param name The project on which to execute the request. The format is
        *     `"projects/{project_id_or_number}"`.
    -   * @param filter An optional [filter](/monitoring/api/v3/filters) describing the descriptors to be
    -   *     returned. The filter can reference the descriptor's type and labels. For example, the
    -   *     following filter returns only Google Compute Engine descriptors that have an `id` label:
    -   *     

    resource.type = starts_with("gce_") AND resource.label:id * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> - listMonitoredResourceDescriptors(String name, String filter) { + public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResourceDescriptors( + String name) { PROJECT_PATH_TEMPLATE.validate(name, "listMonitoredResourceDescriptors"); ListMonitoredResourceDescriptorsRequest request = - ListMonitoredResourceDescriptorsRequest.newBuilder() - .setName(name) - .setFilter(filter) - .build(); + ListMonitoredResourceDescriptorsRequest.newBuilder().setName(name).build(); return listMonitoredResourceDescriptors(request); } @@ -334,10 +322,8 @@ public final MetricServiceSettings getSettings() { *

    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
        *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
    -   *   String filter = "";
        *   ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
        *     .setName(formattedName)
    -   *     .setFilter(filter)
        *     .build();
        *   for (MonitoredResourceDescriptor element : metricServiceApi.listMonitoredResourceDescriptors(request).iterateAllElements()) {
        *     // doThingsWith(element);
    @@ -348,10 +334,8 @@ public final MetricServiceSettings getSettings() {
        * @param request The request object containing all of the parameters for the API call.
        * @throws com.google.api.gax.grpc.ApiException if the remote call fails
        */
    -  public final PagedListResponse<
    -          ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse,
    -          MonitoredResourceDescriptor>
    -      listMonitoredResourceDescriptors(ListMonitoredResourceDescriptorsRequest request) {
    +  public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResourceDescriptors(
    +      ListMonitoredResourceDescriptorsRequest request) {
         return listMonitoredResourceDescriptorsPagedCallable().call(request);
       }
     
    @@ -365,12 +349,10 @@ public final MetricServiceSettings getSettings() {
        * 
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
        *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
    -   *   String filter = "";
        *   ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
        *     .setName(formattedName)
    -   *     .setFilter(filter)
        *     .build();
    -   *   ListenableFuture<PagedListResponse<ListMonitoredResourceDescriptorsRequest,ListMonitoredResourceDescriptorsResponse,MonitoredResourceDescriptor>> future = metricServiceApi.listMonitoredResourceDescriptorsPagedCallable().futureCall(request);
    +   *   ListenableFuture<ListMonitoredResourceDescriptorsPagedResponse> future = metricServiceApi.listMonitoredResourceDescriptorsPagedCallable().futureCall(request);
        *   // Do something
        *   for (MonitoredResourceDescriptor element : future.get().iterateAllElements()) {
        *     // doThingsWith(element);
    @@ -378,11 +360,8 @@ public final MetricServiceSettings getSettings() {
        * }
        * 
    */ - public final ApiCallable< - ListMonitoredResourceDescriptorsRequest, - PagedListResponse< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor>> + public final UnaryApiCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsPagedCallable() { return listMonitoredResourceDescriptorsPagedCallable; } @@ -397,10 +376,8 @@ public final MetricServiceSettings getSettings() { *
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
        *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
    -   *   String filter = "";
        *   ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
        *     .setName(formattedName)
    -   *     .setFilter(filter)
        *     .build();
        *   while (true) {
        *     ListMonitoredResourceDescriptorsResponse response = metricServiceApi.listMonitoredResourceDescriptorsCallable().call(request);
    @@ -417,7 +394,7 @@ public final MetricServiceSettings getSettings() {
        * }
        * 
    */ - public final ApiCallable< + public final UnaryApiCallable< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> listMonitoredResourceDescriptorsCallable() { return listMonitoredResourceDescriptorsCallable; @@ -493,7 +470,7 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor( * } *
    */ - public final ApiCallable + public final UnaryApiCallable getMonitoredResourceDescriptorCallable() { return getMonitoredResourceDescriptorCallable; } @@ -508,8 +485,7 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor( *
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
        *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
    -   *   String filter = "";
    -   *   for (MetricDescriptor element : metricServiceApi.listMetricDescriptors(formattedName, filter).iterateAllElements()) {
    +   *   for (MetricDescriptor element : metricServiceApi.listMetricDescriptors(formattedName).iterateAllElements()) {
        *     // doThingsWith(element);
        *   }
        * }
    @@ -517,19 +493,12 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor(
        *
        * @param name The project on which to execute the request. The format is
        *     `"projects/{project_id_or_number}"`.
    -   * @param filter If this field is empty, all custom and system-defined metric descriptors are
    -   *     returned. Otherwise, the [filter](/monitoring/api/v3/filters) specifies which metric
    -   *     descriptors are to be returned. For example, the following filter matches all [custom
    -   *     metrics](/monitoring/custom-metrics):
    -   *     

    metric.type = starts_with("custom.googleapis.com/") * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor> - listMetricDescriptors(String name, String filter) { + public final ListMetricDescriptorsPagedResponse listMetricDescriptors(String name) { PROJECT_PATH_TEMPLATE.validate(name, "listMetricDescriptors"); ListMetricDescriptorsRequest request = - ListMetricDescriptorsRequest.newBuilder().setName(name).setFilter(filter).build(); + ListMetricDescriptorsRequest.newBuilder().setName(name).build(); return listMetricDescriptors(request); } @@ -543,10 +512,8 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor( *

    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
        *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
    -   *   String filter = "";
        *   ListMetricDescriptorsRequest request = ListMetricDescriptorsRequest.newBuilder()
        *     .setName(formattedName)
    -   *     .setFilter(filter)
        *     .build();
        *   for (MetricDescriptor element : metricServiceApi.listMetricDescriptors(request).iterateAllElements()) {
        *     // doThingsWith(element);
    @@ -557,9 +524,8 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor(
        * @param request The request object containing all of the parameters for the API call.
        * @throws com.google.api.gax.grpc.ApiException if the remote call fails
        */
    -  public final PagedListResponse<
    -          ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor>
    -      listMetricDescriptors(ListMetricDescriptorsRequest request) {
    +  public final ListMetricDescriptorsPagedResponse listMetricDescriptors(
    +      ListMetricDescriptorsRequest request) {
         return listMetricDescriptorsPagedCallable().call(request);
       }
     
    @@ -573,12 +539,10 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor(
        * 
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
        *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
    -   *   String filter = "";
        *   ListMetricDescriptorsRequest request = ListMetricDescriptorsRequest.newBuilder()
        *     .setName(formattedName)
    -   *     .setFilter(filter)
        *     .build();
    -   *   ListenableFuture<PagedListResponse<ListMetricDescriptorsRequest,ListMetricDescriptorsResponse,MetricDescriptor>> future = metricServiceApi.listMetricDescriptorsPagedCallable().futureCall(request);
    +   *   ListenableFuture<ListMetricDescriptorsPagedResponse> future = metricServiceApi.listMetricDescriptorsPagedCallable().futureCall(request);
        *   // Do something
        *   for (MetricDescriptor element : future.get().iterateAllElements()) {
        *     // doThingsWith(element);
    @@ -586,10 +550,7 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor(
        * }
        * 
    */ - public final ApiCallable< - ListMetricDescriptorsRequest, - PagedListResponse< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor>> + public final UnaryApiCallable listMetricDescriptorsPagedCallable() { return listMetricDescriptorsPagedCallable; } @@ -604,10 +565,8 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor( *
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
        *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
    -   *   String filter = "";
        *   ListMetricDescriptorsRequest request = ListMetricDescriptorsRequest.newBuilder()
        *     .setName(formattedName)
    -   *     .setFilter(filter)
        *     .build();
        *   while (true) {
        *     ListMetricDescriptorsResponse response = metricServiceApi.listMetricDescriptorsCallable().call(request);
    @@ -624,7 +583,7 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor(
        * }
        * 
    */ - public final ApiCallable + public final UnaryApiCallable listMetricDescriptorsCallable() { return listMetricDescriptorsCallable; } @@ -637,7 +596,7 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor( * *
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
    -   *   String formattedName = MetricServiceApi.formatMetricDescriptorPathName("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]");
    +   *   String formattedName = MetricServiceApi.formatMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
        *   MetricDescriptor response = metricServiceApi.getMetricDescriptor(formattedName);
        * }
        * 
    @@ -648,7 +607,7 @@ private final MonitoredResourceDescriptor getMonitoredResourceDescriptor( * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final MetricDescriptor getMetricDescriptor(String name) { - METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.validate(name, "getMetricDescriptor"); + METRIC_DESCRIPTOR_PATH_TEMPLATE.validate(name, "getMetricDescriptor"); GetMetricDescriptorRequest request = GetMetricDescriptorRequest.newBuilder().setName(name).build(); return getMetricDescriptor(request); @@ -662,7 +621,7 @@ public final MetricDescriptor getMetricDescriptor(String name) { * *
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
    -   *   String formattedName = MetricServiceApi.formatMetricDescriptorPathName("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]");
    +   *   String formattedName = MetricServiceApi.formatMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
        *   GetMetricDescriptorRequest request = GetMetricDescriptorRequest.newBuilder()
        *     .setName(formattedName)
        *     .build();
    @@ -685,7 +644,7 @@ private final MetricDescriptor getMetricDescriptor(GetMetricDescriptorRequest re
        *
        * 
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
    -   *   String formattedName = MetricServiceApi.formatMetricDescriptorPathName("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]");
    +   *   String formattedName = MetricServiceApi.formatMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
        *   GetMetricDescriptorRequest request = GetMetricDescriptorRequest.newBuilder()
        *     .setName(formattedName)
        *     .build();
    @@ -695,7 +654,7 @@ private final MetricDescriptor getMetricDescriptor(GetMetricDescriptorRequest re
        * }
        * 
    */ - public final ApiCallable + public final UnaryApiCallable getMetricDescriptorCallable() { return getMetricDescriptorCallable; } @@ -778,7 +737,7 @@ public final MetricDescriptor createMetricDescriptor(CreateMetricDescriptorReque * } *
    */ - public final ApiCallable + public final UnaryApiCallable createMetricDescriptorCallable() { return createMetricDescriptorCallable; } @@ -792,7 +751,7 @@ public final MetricDescriptor createMetricDescriptor(CreateMetricDescriptorReque * *
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
    -   *   String formattedName = MetricServiceApi.formatMetricDescriptorPathName("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]");
    +   *   String formattedName = MetricServiceApi.formatMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
        *   metricServiceApi.deleteMetricDescriptor(formattedName);
        * }
        * 
    @@ -803,7 +762,7 @@ public final MetricDescriptor createMetricDescriptor(CreateMetricDescriptorReque * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final void deleteMetricDescriptor(String name) { - METRIC_DESCRIPTOR_PATH_PATH_TEMPLATE.validate(name, "deleteMetricDescriptor"); + METRIC_DESCRIPTOR_PATH_TEMPLATE.validate(name, "deleteMetricDescriptor"); DeleteMetricDescriptorRequest request = DeleteMetricDescriptorRequest.newBuilder().setName(name).build(); deleteMetricDescriptor(request); @@ -818,7 +777,7 @@ public final void deleteMetricDescriptor(String name) { * *
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
    -   *   String formattedName = MetricServiceApi.formatMetricDescriptorPathName("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]");
    +   *   String formattedName = MetricServiceApi.formatMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
        *   DeleteMetricDescriptorRequest request = DeleteMetricDescriptorRequest.newBuilder()
        *     .setName(formattedName)
        *     .build();
    @@ -842,7 +801,7 @@ private final void deleteMetricDescriptor(DeleteMetricDescriptorRequest request)
        *
        * 
    
        * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
    -   *   String formattedName = MetricServiceApi.formatMetricDescriptorPathName("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]");
    +   *   String formattedName = MetricServiceApi.formatMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
        *   DeleteMetricDescriptorRequest request = DeleteMetricDescriptorRequest.newBuilder()
        *     .setName(formattedName)
        *     .build();
    @@ -852,7 +811,8 @@ private final void deleteMetricDescriptor(DeleteMetricDescriptorRequest request)
        * }
        * 
    */ - public final ApiCallable deleteMetricDescriptorCallable() { + public final UnaryApiCallable + deleteMetricDescriptorCallable() { return deleteMetricDescriptorCallable; } @@ -867,15 +827,57 @@ public final ApiCallable deleteMetricDescr * String formattedName = MetricServiceApi.formatProjectName("[PROJECT]"); * String filter = ""; * TimeInterval interval = TimeInterval.newBuilder().build(); - * Aggregation aggregation = Aggregation.newBuilder().build(); - * String orderBy = ""; + * ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL; + * for (TimeSeries element : metricServiceApi.listTimeSeries(formattedName, filter, interval, view).iterateAllElements()) { + * // doThingsWith(element); + * } + * } + *
    + * + * @param name The project on which to execute the request. The format is + * "projects/{project_id_or_number}". + * @param filter A [monitoring filter](/monitoring/api/v3/filters) that specifies which time + * series should be returned. The filter must specify a single metric type, and can + * additionally specify metric labels and other information. For example: + *

    metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND + * metric.label.instance_name = "my-instance-name" + * @param interval The time interval for which results should be returned. Only time series that + * contain data points in the specified interval are included in the response. + * @param view Specifies which information is returned about the time series. + * @throws com.google.api.gax.grpc.ApiException if the remote call fails + */ + public final ListTimeSeriesPagedResponse listTimeSeries( + String name, + String filter, + TimeInterval interval, + ListTimeSeriesRequest.TimeSeriesView view) { + PROJECT_PATH_TEMPLATE.validate(name, "listTimeSeries"); + ListTimeSeriesRequest request = + ListTimeSeriesRequest.newBuilder() + .setName(name) + .setFilter(filter) + .setInterval(interval) + .setView(view) + .build(); + return listTimeSeries(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists time series that match a filter. This method does not require a Stackdriver account. + * + *

    Sample code: + * + *

    
    +   * try (MetricServiceApi metricServiceApi = MetricServiceApi.create()) {
    +   *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
    +   *   String filter = "";
    +   *   TimeInterval interval = TimeInterval.newBuilder().build();
        *   ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
        *   ListTimeSeriesRequest request = ListTimeSeriesRequest.newBuilder()
        *     .setName(formattedName)
        *     .setFilter(filter)
        *     .setInterval(interval)
    -   *     .setAggregation(aggregation)
    -   *     .setOrderBy(orderBy)
        *     .setView(view)
        *     .build();
        *   for (TimeSeries element : metricServiceApi.listTimeSeries(request).iterateAllElements()) {
    @@ -887,8 +889,7 @@ public final ApiCallable deleteMetricDescr
        * @param request The request object containing all of the parameters for the API call.
        * @throws com.google.api.gax.grpc.ApiException if the remote call fails
        */
    -  public final PagedListResponse
    -      listTimeSeries(ListTimeSeriesRequest request) {
    +  public final ListTimeSeriesPagedResponse listTimeSeries(ListTimeSeriesRequest request) {
         return listTimeSeriesPagedCallable().call(request);
       }
     
    @@ -903,18 +904,14 @@ public final ApiCallable deleteMetricDescr
        *   String formattedName = MetricServiceApi.formatProjectName("[PROJECT]");
        *   String filter = "";
        *   TimeInterval interval = TimeInterval.newBuilder().build();
    -   *   Aggregation aggregation = Aggregation.newBuilder().build();
    -   *   String orderBy = "";
        *   ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
        *   ListTimeSeriesRequest request = ListTimeSeriesRequest.newBuilder()
        *     .setName(formattedName)
        *     .setFilter(filter)
        *     .setInterval(interval)
    -   *     .setAggregation(aggregation)
    -   *     .setOrderBy(orderBy)
        *     .setView(view)
        *     .build();
    -   *   ListenableFuture<PagedListResponse<ListTimeSeriesRequest,ListTimeSeriesResponse,TimeSeries>> future = metricServiceApi.listTimeSeriesPagedCallable().futureCall(request);
    +   *   ListenableFuture<ListTimeSeriesPagedResponse> future = metricServiceApi.listTimeSeriesPagedCallable().futureCall(request);
        *   // Do something
        *   for (TimeSeries element : future.get().iterateAllElements()) {
        *     // doThingsWith(element);
    @@ -922,9 +919,7 @@ public final ApiCallable deleteMetricDescr
        * }
        * 
    */ - public final ApiCallable< - ListTimeSeriesRequest, - PagedListResponse> + public final UnaryApiCallable listTimeSeriesPagedCallable() { return listTimeSeriesPagedCallable; } @@ -940,15 +935,11 @@ public final ApiCallable deleteMetricDescr * String formattedName = MetricServiceApi.formatProjectName("[PROJECT]"); * String filter = ""; * TimeInterval interval = TimeInterval.newBuilder().build(); - * Aggregation aggregation = Aggregation.newBuilder().build(); - * String orderBy = ""; * ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL; * ListTimeSeriesRequest request = ListTimeSeriesRequest.newBuilder() * .setName(formattedName) * .setFilter(filter) * .setInterval(interval) - * .setAggregation(aggregation) - * .setOrderBy(orderBy) * .setView(view) * .build(); * while (true) { @@ -966,7 +957,8 @@ public final ApiCallable deleteMetricDescr * } *
    */ - public final ApiCallable listTimeSeriesCallable() { + public final UnaryApiCallable + listTimeSeriesCallable() { return listTimeSeriesCallable; } @@ -1050,7 +1042,7 @@ public final void createTimeSeries(CreateTimeSeriesRequest request) { * } *
    */ - public final ApiCallable createTimeSeriesCallable() { + public final UnaryApiCallable createTimeSeriesCallable() { return createTimeSeriesCallable; } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/MetricServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/MetricServiceSettings.java index c7c89badb66d..3c68173882bc 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/MetricServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/MetricServiceSettings.java @@ -13,15 +13,22 @@ */ package com.google.cloud.monitoring.spi.v3; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMetricDescriptorsPagedResponse; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMonitoredResourceDescriptorsPagedResponse; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListTimeSeriesPagedResponse; + import com.google.api.MetricDescriptor; import com.google.api.MonitoredResourceDescriptor; import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.CallContext; import com.google.api.gax.grpc.PageStreamingCallSettings; import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseFactory; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -97,13 +104,14 @@ public class MetricServiceSettings extends ServiceApiSettings { private final PageStreamingCallSettings< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> + ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsSettings; private final SimpleCallSettings< GetMonitoredResourceDescriptorRequest, MonitoredResourceDescriptor> getMonitoredResourceDescriptorSettings; private final PageStreamingCallSettings< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor> + ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, + ListMetricDescriptorsPagedResponse> listMetricDescriptorsSettings; private final SimpleCallSettings getMetricDescriptorSettings; @@ -111,14 +119,15 @@ public class MetricServiceSettings extends ServiceApiSettings { createMetricDescriptorSettings; private final SimpleCallSettings deleteMetricDescriptorSettings; - private final PageStreamingCallSettings + private final PageStreamingCallSettings< + ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> listTimeSeriesSettings; private final SimpleCallSettings createTimeSeriesSettings; /** Returns the object with the settings used for calls to listMonitoredResourceDescriptors. */ public PageStreamingCallSettings< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> + ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsSettings() { return listMonitoredResourceDescriptorsSettings; } @@ -131,7 +140,8 @@ public class MetricServiceSettings extends ServiceApiSettings { /** Returns the object with the settings used for calls to listMetricDescriptors. */ public PageStreamingCallSettings< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor> + ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, + ListMetricDescriptorsPagedResponse> listMetricDescriptorsSettings() { return listMetricDescriptorsSettings; } @@ -154,7 +164,8 @@ public SimpleCallSettings deleteMetricDesc } /** Returns the object with the settings used for calls to listTimeSeries. */ - public PageStreamingCallSettings + public PageStreamingCallSettings< + ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> listTimeSeriesSettings() { return listTimeSeriesSettings; } @@ -337,19 +348,73 @@ public Iterable extractResources(ListTimeSeriesResponse payload) { } }; + private static final PagedListResponseFactory< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse> + LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, + ListMonitoredResourceDescriptorsPagedResponse>() { + @Override + public ListMonitoredResourceDescriptorsPagedResponse createPagedListResponse( + UnaryApiCallable< + ListMonitoredResourceDescriptorsRequest, + ListMonitoredResourceDescriptorsResponse> + callable, + ListMonitoredResourceDescriptorsRequest request, + CallContext context) { + return new ListMonitoredResourceDescriptorsPagedResponse( + callable, LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC, request, context); + } + }; + + private static final PagedListResponseFactory< + ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, + ListMetricDescriptorsPagedResponse> + LIST_METRIC_DESCRIPTORS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, + ListMetricDescriptorsPagedResponse>() { + @Override + public ListMetricDescriptorsPagedResponse createPagedListResponse( + UnaryApiCallable + callable, + ListMetricDescriptorsRequest request, + CallContext context) { + return new ListMetricDescriptorsPagedResponse( + callable, LIST_METRIC_DESCRIPTORS_PAGE_STR_DESC, request, context); + } + }; + + private static final PagedListResponseFactory< + ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> + LIST_TIME_SERIES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse>() { + @Override + public ListTimeSeriesPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListTimeSeriesRequest request, + CallContext context) { + return new ListTimeSeriesPagedResponse( + callable, LIST_TIME_SERIES_PAGE_STR_DESC, request, context); + } + }; + /** Builder for MetricServiceSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final PageStreamingCallSettings.Builder< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> + ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsSettings; private final SimpleCallSettings.Builder< GetMonitoredResourceDescriptorRequest, MonitoredResourceDescriptor> getMonitoredResourceDescriptorSettings; private final PageStreamingCallSettings.Builder< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor> + ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, + ListMetricDescriptorsPagedResponse> listMetricDescriptorsSettings; private final SimpleCallSettings.Builder getMetricDescriptorSettings; @@ -358,7 +423,7 @@ public static class Builder extends ServiceApiSettings.Builder { private final SimpleCallSettings.Builder deleteMetricDescriptorSettings; private final PageStreamingCallSettings.Builder< - ListTimeSeriesRequest, ListTimeSeriesResponse, TimeSeries> + ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> listTimeSeriesSettings; private final SimpleCallSettings.Builder createTimeSeriesSettings; @@ -400,7 +465,7 @@ private Builder() { listMonitoredResourceDescriptorsSettings = PageStreamingCallSettings.newBuilder( MetricServiceGrpc.METHOD_LIST_MONITORED_RESOURCE_DESCRIPTORS, - LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC); + LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT); getMonitoredResourceDescriptorSettings = SimpleCallSettings.newBuilder(MetricServiceGrpc.METHOD_GET_MONITORED_RESOURCE_DESCRIPTOR); @@ -408,7 +473,7 @@ private Builder() { listMetricDescriptorsSettings = PageStreamingCallSettings.newBuilder( MetricServiceGrpc.METHOD_LIST_METRIC_DESCRIPTORS, - LIST_METRIC_DESCRIPTORS_PAGE_STR_DESC); + LIST_METRIC_DESCRIPTORS_PAGE_STR_FACT); getMetricDescriptorSettings = SimpleCallSettings.newBuilder(MetricServiceGrpc.METHOD_GET_METRIC_DESCRIPTOR); @@ -421,13 +486,13 @@ private Builder() { listTimeSeriesSettings = PageStreamingCallSettings.newBuilder( - MetricServiceGrpc.METHOD_LIST_TIME_SERIES, LIST_TIME_SERIES_PAGE_STR_DESC); + MetricServiceGrpc.METHOD_LIST_TIME_SERIES, LIST_TIME_SERIES_PAGE_STR_FACT); createTimeSeriesSettings = SimpleCallSettings.newBuilder(MetricServiceGrpc.METHOD_CREATE_TIME_SERIES); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listMonitoredResourceDescriptorsSettings, getMonitoredResourceDescriptorSettings, listMetricDescriptorsSettings, @@ -498,8 +563,8 @@ private Builder(MetricServiceSettings settings) { listTimeSeriesSettings = settings.listTimeSeriesSettings.toBuilder(); createTimeSeriesSettings = settings.createTimeSeriesSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( listMonitoredResourceDescriptorsSettings, getMonitoredResourceDescriptorSettings, listMetricDescriptorsSettings, @@ -558,18 +623,21 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } /** Returns the builder for the settings used for calls to listMonitoredResourceDescriptors. */ public PageStreamingCallSettings.Builder< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> + ListMonitoredResourceDescriptorsPagedResponse> listMonitoredResourceDescriptorsSettings() { return listMonitoredResourceDescriptorsSettings; } @@ -583,7 +651,8 @@ public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) thr /** Returns the builder for the settings used for calls to listMetricDescriptors. */ public PageStreamingCallSettings.Builder< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor> + ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, + ListMetricDescriptorsPagedResponse> listMetricDescriptorsSettings() { return listMetricDescriptorsSettings; } @@ -608,7 +677,7 @@ public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) thr /** Returns the builder for the settings used for calls to listTimeSeries. */ public PageStreamingCallSettings.Builder< - ListTimeSeriesRequest, ListTimeSeriesResponse, TimeSeries> + ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> listTimeSeriesSettings() { return listTimeSeriesSettings; } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/PagedResponseWrappers.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/PagedResponseWrappers.java new file mode 100644 index 000000000000..4786a307ea43 --- /dev/null +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/PagedResponseWrappers.java @@ -0,0 +1,118 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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 + * + * http://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. + */ +package com.google.cloud.monitoring.spi.v3; + +import com.google.api.MetricDescriptor; +import com.google.api.MonitoredResource; +import com.google.api.MonitoredResourceDescriptor; +import com.google.api.gax.grpc.CallContext; +import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseImpl; +import com.google.api.gax.grpc.UnaryApiCallable; +import com.google.monitoring.v3.Group; +import com.google.monitoring.v3.ListGroupMembersRequest; +import com.google.monitoring.v3.ListGroupMembersResponse; +import com.google.monitoring.v3.ListGroupsRequest; +import com.google.monitoring.v3.ListGroupsResponse; +import com.google.monitoring.v3.ListMetricDescriptorsRequest; +import com.google.monitoring.v3.ListMetricDescriptorsResponse; +import com.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest; +import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; +import com.google.monitoring.v3.ListTimeSeriesRequest; +import com.google.monitoring.v3.ListTimeSeriesResponse; +import com.google.monitoring.v3.TimeSeries; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Wrapper class to contain paged response types for page streaming methods. Each static class + * inside this wrapper class is used as the return type of one of an API method that implements the + * page streaming pattern. + */ +@javax.annotation.Generated("by GAPIC") +public class PagedResponseWrappers { + + public static class ListGroupsPagedResponse + extends PagedListResponseImpl { + + public ListGroupsPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor pageDescriptor, + ListGroupsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListGroupMembersPagedResponse + extends PagedListResponseImpl< + ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource> { + + public ListGroupMembersPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor< + ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource> + pageDescriptor, + ListGroupMembersRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListMonitoredResourceDescriptorsPagedResponse + extends PagedListResponseImpl< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> { + + public ListMonitoredResourceDescriptorsPagedResponse( + UnaryApiCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> + callable, + PageStreamingDescriptor< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, + MonitoredResourceDescriptor> + pageDescriptor, + ListMonitoredResourceDescriptorsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListMetricDescriptorsPagedResponse + extends PagedListResponseImpl< + ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor> { + + public ListMetricDescriptorsPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor< + ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor> + pageDescriptor, + ListMetricDescriptorsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListTimeSeriesPagedResponse + extends PagedListResponseImpl { + + public ListTimeSeriesPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor + pageDescriptor, + ListTimeSeriesRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } +} diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/package-info.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/package-info.java index 9d1a0e61adb7..799592dcae51 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/package-info.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/spi/v3/package-info.java @@ -55,25 +55,5 @@ * } * *

    - * - * ========================== AgentTranslationServiceApi ========================== - * - *

    Service Description: The AgentTranslation API allows `collectd`-based agents to write time - * series data to Cloud Monitoring. See [google.monitoring.v3.MetricService.CreateTimeSeries] - * instead. - * - *

    Sample for AgentTranslationServiceApi: - * - *

    - * 
    - * try (AgentTranslationServiceApi agentTranslationServiceApi = AgentTranslationServiceApi.create()) {
    - *   String formattedName = AgentTranslationServiceApi.formatProjectName("[PROJECT]");
    - *   MonitoredResource resource = MonitoredResource.newBuilder().build();
    - *   String collectdVersion = "";
    - *   List<CollectdPayload> collectdPayloads = new ArrayList<>();
    - *   agentTranslationServiceApi.createCollectdTimeSeries(formattedName, resource, collectdVersion, collectdPayloads);
    - * }
    - * 
    - * 
    */ package com.google.cloud.monitoring.spi.v3; diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/spi/v3/GroupServiceTest.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/spi/v3/GroupServiceTest.java index c3944b8cb0af..016bbc63b15b 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/spi/v3/GroupServiceTest.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/spi/v3/GroupServiceTest.java @@ -14,8 +14,9 @@ package com.google.cloud.monitoring.spi.v3; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListGroupMembersPagedResponse; + import com.google.api.MonitoredResource; -import com.google.api.gax.core.PagedListResponse; import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; import com.google.common.collect.Lists; @@ -25,7 +26,6 @@ import com.google.monitoring.v3.Group; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; -import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; @@ -44,7 +44,6 @@ public class GroupServiceTest { private static MockGroupService mockGroupService; private static MockMetricService mockMetricService; - private static MockAgentTranslationService mockAgentTranslationService; private static MockServiceHelper serviceHelper; private GroupServiceApi api; @@ -52,12 +51,9 @@ public class GroupServiceTest { public static void startStaticServer() { mockGroupService = new MockGroupService(); mockMetricService = new MockMetricService(); - mockAgentTranslationService = new MockAgentTranslationService(); serviceHelper = new MockServiceHelper( - "in-process-1", - Arrays.asList( - mockGroupService, mockMetricService, mockAgentTranslationService)); + "in-process-1", Arrays.asList(mockGroupService, mockMetricService)); serviceHelper.start(); } @@ -135,9 +131,8 @@ public void createGroupTest() { String formattedName = GroupServiceApi.formatProjectName("[PROJECT]"); Group group = Group.newBuilder().build(); - boolean validateOnly = false; - Group actualResponse = api.createGroup(formattedName, group, validateOnly); + Group actualResponse = api.createGroup(formattedName, group); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockGroupService.getRequests(); @@ -146,7 +141,6 @@ public void createGroupTest() { Assert.assertEquals(formattedName, actualRequest.getName()); Assert.assertEquals(group, actualRequest.getGroup()); - Assert.assertEquals(validateOnly, actualRequest.getValidateOnly()); } @Test @@ -170,9 +164,8 @@ public void updateGroupTest() { mockGroupService.setResponses(expectedResponses); Group group = Group.newBuilder().build(); - boolean validateOnly = false; - Group actualResponse = api.updateGroup(group, validateOnly); + Group actualResponse = api.updateGroup(group); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockGroupService.getRequests(); @@ -180,7 +173,6 @@ public void updateGroupTest() { UpdateGroupRequest actualRequest = (UpdateGroupRequest) actualRequests.get(0); Assert.assertEquals(group, actualRequest.getGroup()); - Assert.assertEquals(validateOnly, actualRequest.getValidateOnly()); } @Test @@ -220,11 +212,8 @@ public void listGroupMembersTest() { mockGroupService.setResponses(expectedResponses); String formattedName = GroupServiceApi.formatGroupName("[PROJECT]", "[GROUP]"); - String filter = "filter-1274492040"; - TimeInterval interval = TimeInterval.newBuilder().build(); - PagedListResponse - pagedListResponse = api.listGroupMembers(formattedName, filter, interval); + ListGroupMembersPagedResponse pagedListResponse = api.listGroupMembers(formattedName); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); @@ -235,7 +224,5 @@ public void listGroupMembersTest() { ListGroupMembersRequest actualRequest = (ListGroupMembersRequest) actualRequests.get(0); Assert.assertEquals(formattedName, actualRequest.getName()); - Assert.assertEquals(filter, actualRequest.getFilter()); - Assert.assertEquals(interval, actualRequest.getInterval()); } } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/spi/v3/MetricServiceTest.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/spi/v3/MetricServiceTest.java index fa8034b62219..d3a671e3a5d5 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/spi/v3/MetricServiceTest.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/spi/v3/MetricServiceTest.java @@ -14,9 +14,12 @@ package com.google.cloud.monitoring.spi.v3; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMetricDescriptorsPagedResponse; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListMonitoredResourceDescriptorsPagedResponse; +import static com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListTimeSeriesPagedResponse; + import com.google.api.MetricDescriptor; import com.google.api.MonitoredResourceDescriptor; -import com.google.api.gax.core.PagedListResponse; import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; import com.google.common.collect.Lists; @@ -29,6 +32,10 @@ import com.google.monitoring.v3.ListMetricDescriptorsResponse; import com.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest; import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; +import com.google.monitoring.v3.ListTimeSeriesRequest; +import com.google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView; +import com.google.monitoring.v3.ListTimeSeriesResponse; +import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; @@ -47,7 +54,6 @@ public class MetricServiceTest { private static MockGroupService mockGroupService; private static MockMetricService mockMetricService; - private static MockAgentTranslationService mockAgentTranslationService; private static MockServiceHelper serviceHelper; private MetricServiceApi api; @@ -55,12 +61,9 @@ public class MetricServiceTest { public static void startStaticServer() { mockGroupService = new MockGroupService(); mockMetricService = new MockMetricService(); - mockAgentTranslationService = new MockAgentTranslationService(); serviceHelper = new MockServiceHelper( - "in-process-1", - Arrays.asList( - mockGroupService, mockMetricService, mockAgentTranslationService)); + "in-process-1", Arrays.asList(mockGroupService, mockMetricService)); serviceHelper.start(); } @@ -102,12 +105,9 @@ public void listMonitoredResourceDescriptorsTest() { mockMetricService.setResponses(expectedResponses); String formattedName = MetricServiceApi.formatProjectName("[PROJECT]"); - String filter = "filter-1274492040"; - PagedListResponse< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> - pagedListResponse = api.listMonitoredResourceDescriptors(formattedName, filter); + ListMonitoredResourceDescriptorsPagedResponse pagedListResponse = + api.listMonitoredResourceDescriptors(formattedName); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); @@ -120,7 +120,6 @@ public void listMonitoredResourceDescriptorsTest() { (ListMonitoredResourceDescriptorsRequest) actualRequests.get(0); Assert.assertEquals(formattedName, actualRequest.getName()); - Assert.assertEquals(filter, actualRequest.getFilter()); } @Test @@ -174,10 +173,8 @@ public void listMetricDescriptorsTest() { mockMetricService.setResponses(expectedResponses); String formattedName = MetricServiceApi.formatProjectName("[PROJECT]"); - String filter = "filter-1274492040"; - PagedListResponse - pagedListResponse = api.listMetricDescriptors(formattedName, filter); + ListMetricDescriptorsPagedResponse pagedListResponse = api.listMetricDescriptors(formattedName); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); @@ -189,14 +186,13 @@ public void listMetricDescriptorsTest() { (ListMetricDescriptorsRequest) actualRequests.get(0); Assert.assertEquals(formattedName, actualRequest.getName()); - Assert.assertEquals(filter, actualRequest.getFilter()); } @Test @SuppressWarnings("all") public void getMetricDescriptorTest() { String formattedName2 = - MetricServiceApi.formatMetricDescriptorPathName("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]"); + MetricServiceApi.formatMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]"); String type = "type3575610"; String unit = "unit3594628"; String description = "description-1724546052"; @@ -214,7 +210,7 @@ public void getMetricDescriptorTest() { mockMetricService.setResponses(expectedResponses); String formattedName = - MetricServiceApi.formatMetricDescriptorPathName("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]"); + MetricServiceApi.formatMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]"); MetricDescriptor actualResponse = api.getMetricDescriptor(formattedName); Assert.assertEquals(expectedResponse, actualResponse); @@ -270,7 +266,7 @@ public void deleteMetricDescriptorTest() { mockMetricService.setResponses(expectedResponses); String formattedName = - MetricServiceApi.formatMetricDescriptorPathName("[PROJECT]", "[METRIC_DESCRIPTOR_PATH]"); + MetricServiceApi.formatMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]"); api.deleteMetricDescriptor(formattedName); @@ -282,6 +278,43 @@ public void deleteMetricDescriptorTest() { Assert.assertEquals(formattedName, actualRequest.getName()); } + @Test + @SuppressWarnings("all") + public void listTimeSeriesTest() { + String nextPageToken = ""; + TimeSeries timeSeriesElement = TimeSeries.newBuilder().build(); + List timeSeries = Arrays.asList(timeSeriesElement); + ListTimeSeriesResponse expectedResponse = + ListTimeSeriesResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllTimeSeries(timeSeries) + .build(); + List expectedResponses = new ArrayList<>(); + expectedResponses.add(expectedResponse); + mockMetricService.setResponses(expectedResponses); + + String formattedName = MetricServiceApi.formatProjectName("[PROJECT]"); + String filter = "filter-1274492040"; + TimeInterval interval = TimeInterval.newBuilder().build(); + ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL; + + ListTimeSeriesPagedResponse pagedListResponse = + api.listTimeSeries(formattedName, filter, interval, view); + + List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTimeSeriesList().get(0), resources.get(0)); + + List actualRequests = mockMetricService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListTimeSeriesRequest actualRequest = (ListTimeSeriesRequest) actualRequests.get(0); + + Assert.assertEquals(formattedName, actualRequest.getName()); + Assert.assertEquals(filter, actualRequest.getFilter()); + Assert.assertEquals(interval, actualRequest.getInterval()); + Assert.assertEquals(view, actualRequest.getView()); + } + @Test @SuppressWarnings("all") public void createTimeSeriesTest() { diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/DefaultPubSubRpc.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/DefaultPubSubRpc.java index ed59a2b90a72..6557aa25405f 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/DefaultPubSubRpc.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/DefaultPubSubRpc.java @@ -19,7 +19,7 @@ import static com.google.common.base.MoreObjects.firstNonNull; import com.google.api.gax.core.ConnectionSettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; import com.google.api.gax.grpc.ApiException; import com.google.cloud.AuthCredentials; import com.google.cloud.GrpcServiceOptions.ExecutorFactory; @@ -94,7 +94,7 @@ protected ExecutorFactory executorFactory() { } @Override - protected ApiCallSettings.Builder apiCallSettings() { + protected UnaryApiCallSettings.Builder apiCallSettings() { return super.apiCallSettings(); } @@ -154,7 +154,7 @@ public DefaultPubSubRpc(PubSubOptions options) throws IOException { pubBuilder.provideChannelWith(connectionSettings); subBuilder.provideChannelWith(connectionSettings); } - ApiCallSettings.Builder callSettingsBuilder = internalOptions.apiCallSettings(); + UnaryApiCallSettings.Builder callSettingsBuilder = internalOptions.apiCallSettings(); pubBuilder.applyToAllApiMethods(callSettingsBuilder); subBuilder.applyToAllApiMethods(callSettingsBuilder); publisherApi = PublisherApi.create(pubBuilder.build()); @@ -183,7 +183,7 @@ public V apply(ApiException exception) { @Override public Future create(Topic topic) { - // TODO: it would be nice if we can get the idempotent information from the ApiCallSettings + // TODO: it would be nice if we can get the idempotent information from the UnaryApiCallSettings // or from the exception return translate(publisherApi.createTopicCallable().futureCall(topic), true); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PagedResponseWrappers.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PagedResponseWrappers.java new file mode 100644 index 000000000000..11d3e6081fa3 --- /dev/null +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PagedResponseWrappers.java @@ -0,0 +1,78 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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 + * + * http://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. + */ +package com.google.cloud.pubsub.spi.v1; + +import com.google.api.gax.grpc.CallContext; +import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseImpl; +import com.google.api.gax.grpc.UnaryApiCallable; +import com.google.pubsub.v1.ListSubscriptionsRequest; +import com.google.pubsub.v1.ListSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicSubscriptionsRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicsRequest; +import com.google.pubsub.v1.ListTopicsResponse; +import com.google.pubsub.v1.Subscription; +import com.google.pubsub.v1.Topic; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Wrapper class to contain paged response types for page streaming methods. Each static class + * inside this wrapper class is used as the return type of one of an API method that implements the + * page streaming pattern. + */ +@javax.annotation.Generated("by GAPIC") +public class PagedResponseWrappers { + + public static class ListTopicsPagedResponse + extends PagedListResponseImpl { + + public ListTopicsPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor pageDescriptor, + ListTopicsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListTopicSubscriptionsPagedResponse + extends PagedListResponseImpl< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> { + + public ListTopicSubscriptionsPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + pageDescriptor, + ListTopicSubscriptionsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } + + public static class ListSubscriptionsPagedResponse + extends PagedListResponseImpl< + ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> { + + public ListSubscriptionsPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor + pageDescriptor, + ListSubscriptionsRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } +} diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherApi.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherApi.java index be922966c3c3..06b10503bb14 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherApi.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherApi.java @@ -13,8 +13,10 @@ */ package com.google.cloud.pubsub.spi.v1; -import com.google.api.gax.core.PagedListResponse; -import com.google.api.gax.grpc.ApiCallable; +import static com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListTopicSubscriptionsPagedResponse; +import static com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListTopicsPagedResponse; + +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.Policy; @@ -69,8 +71,8 @@ *
  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -98,23 +100,20 @@ public class PublisherApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable createTopicCallable; - private final ApiCallable publishCallable; - private final ApiCallable getTopicCallable; - private final ApiCallable listTopicsCallable; - private final ApiCallable< - ListTopicsRequest, PagedListResponse> + private final UnaryApiCallable createTopicCallable; + private final UnaryApiCallable publishCallable; + private final UnaryApiCallable getTopicCallable; + private final UnaryApiCallable listTopicsCallable; + private final UnaryApiCallable listTopicsPagedCallable; - private final ApiCallable + private final UnaryApiCallable listTopicSubscriptionsCallable; - private final ApiCallable< - ListTopicSubscriptionsRequest, - PagedListResponse> + private final UnaryApiCallable listTopicSubscriptionsPagedCallable; - private final ApiCallable deleteTopicCallable; - private final ApiCallable setIamPolicyCallable; - private final ApiCallable getIamPolicyCallable; - private final ApiCallable + private final UnaryApiCallable deleteTopicCallable; + private final UnaryApiCallable setIamPolicyCallable; + private final UnaryApiCallable getIamPolicyCallable; + private final UnaryApiCallable testIamPermissionsCallable; private static final PathTemplate PROJECT_PATH_TEMPLATE = @@ -173,31 +172,33 @@ protected PublisherApi(PublisherSettings settings) throws IOException { this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.createTopicCallable = - ApiCallable.create(settings.createTopicSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.createTopicSettings(), this.channel, this.executor); this.publishCallable = - ApiCallable.create(settings.publishSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.publishSettings(), this.channel, this.executor); if (settings.publishSettings().getBundlerFactory() != null) { closeables.add(settings.publishSettings().getBundlerFactory()); } this.getTopicCallable = - ApiCallable.create(settings.getTopicSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.getTopicSettings(), this.channel, this.executor); this.listTopicsCallable = - ApiCallable.create(settings.listTopicsSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listTopicsSettings(), this.channel, this.executor); this.listTopicsPagedCallable = - ApiCallable.createPagedVariant(settings.listTopicsSettings(), this.channel, this.executor); + UnaryApiCallable.createPagedVariant( + settings.listTopicsSettings(), this.channel, this.executor); this.listTopicSubscriptionsCallable = - ApiCallable.create(settings.listTopicSubscriptionsSettings(), this.channel, this.executor); + UnaryApiCallable.create( + settings.listTopicSubscriptionsSettings(), this.channel, this.executor); this.listTopicSubscriptionsPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listTopicSubscriptionsSettings(), this.channel, this.executor); this.deleteTopicCallable = - ApiCallable.create(settings.deleteTopicSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.deleteTopicSettings(), this.channel, this.executor); this.setIamPolicyCallable = - ApiCallable.create(settings.setIamPolicySettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.setIamPolicySettings(), this.channel, this.executor); this.getIamPolicyCallable = - ApiCallable.create(settings.getIamPolicySettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.getIamPolicySettings(), this.channel, this.executor); this.testIamPermissionsCallable = - ApiCallable.create(settings.testIamPermissionsSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.testIamPermissionsSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -290,7 +291,7 @@ private final Topic createTopic(Topic request) { * } *

  • */ - public final ApiCallable createTopicCallable() { + public final UnaryApiCallable createTopicCallable() { return createTopicCallable; } @@ -382,7 +383,7 @@ public final PublishResponse publish(PublishRequest request) { * } *
    */ - public final ApiCallable publishCallable() { + public final UnaryApiCallable publishCallable() { return publishCallable; } @@ -449,7 +450,7 @@ private final Topic getTopic(GetTopicRequest request) { * } * */ - public final ApiCallable getTopicCallable() { + public final UnaryApiCallable getTopicCallable() { return getTopicCallable; } @@ -471,8 +472,7 @@ public final ApiCallable getTopicCallable() { * @param project The name of the cloud project that topics belong to. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse listTopics( - String project) { + public final ListTopicsPagedResponse listTopics(String project) { PROJECT_PATH_TEMPLATE.validate(project, "listTopics"); ListTopicsRequest request = ListTopicsRequest.newBuilder().setProject(project).build(); return listTopics(request); @@ -499,8 +499,7 @@ public final PagedListResponse lis * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse listTopics( - ListTopicsRequest request) { + public final ListTopicsPagedResponse listTopics(ListTopicsRequest request) { return listTopicsPagedCallable().call(request); } @@ -516,7 +515,7 @@ public final PagedListResponse lis * ListTopicsRequest request = ListTopicsRequest.newBuilder() * .setProject(formattedProject) * .build(); - * ListenableFuture<PagedListResponse<ListTopicsRequest,ListTopicsResponse,Topic>> future = publisherApi.listTopicsPagedCallable().futureCall(request); + * ListenableFuture<ListTopicsPagedResponse> future = publisherApi.listTopicsPagedCallable().futureCall(request); * // Do something * for (Topic element : future.get().iterateAllElements()) { * // doThingsWith(element); @@ -524,8 +523,7 @@ public final PagedListResponse lis * } * */ - public final ApiCallable< - ListTopicsRequest, PagedListResponse> + public final UnaryApiCallable listTopicsPagedCallable() { return listTopicsPagedCallable; } @@ -557,7 +555,7 @@ public final PagedListResponse lis * } * */ - public final ApiCallable listTopicsCallable() { + public final UnaryApiCallable listTopicsCallable() { return listTopicsCallable; } @@ -579,9 +577,7 @@ public final ApiCallable listTopicsCallab * @param topic The name of the topic that subscriptions are attached to. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> - listTopicSubscriptions(String topic) { + public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions(String topic) { TOPIC_PATH_TEMPLATE.validate(topic, "listTopicSubscriptions"); ListTopicSubscriptionsRequest request = ListTopicSubscriptionsRequest.newBuilder().setTopic(topic).build(); @@ -609,9 +605,8 @@ public final ApiCallable listTopicsCallab * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> - listTopicSubscriptions(ListTopicSubscriptionsRequest request) { + public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions( + ListTopicSubscriptionsRequest request) { return listTopicSubscriptionsPagedCallable().call(request); } @@ -627,7 +622,7 @@ public final ApiCallable listTopicsCallab * ListTopicSubscriptionsRequest request = ListTopicSubscriptionsRequest.newBuilder() * .setTopic(formattedTopic) * .build(); - * ListenableFuture<PagedListResponse<ListTopicSubscriptionsRequest,ListTopicSubscriptionsResponse,String>> future = publisherApi.listTopicSubscriptionsPagedCallable().futureCall(request); + * ListenableFuture<ListTopicSubscriptionsPagedResponse> future = publisherApi.listTopicSubscriptionsPagedCallable().futureCall(request); * // Do something * for (String element : future.get().iterateAllElements()) { * // doThingsWith(element); @@ -635,9 +630,7 @@ public final ApiCallable listTopicsCallab * } * */ - public final ApiCallable< - ListTopicSubscriptionsRequest, - PagedListResponse> + public final UnaryApiCallable listTopicSubscriptionsPagedCallable() { return listTopicSubscriptionsPagedCallable; } @@ -669,7 +662,7 @@ public final ApiCallable listTopicsCallab * } * */ - public final ApiCallable + public final UnaryApiCallable listTopicSubscriptionsCallable() { return listTopicSubscriptionsCallable; } @@ -746,7 +739,7 @@ private final void deleteTopic(DeleteTopicRequest request) { * } * */ - public final ApiCallable deleteTopicCallable() { + public final UnaryApiCallable deleteTopicCallable() { return deleteTopicCallable; } @@ -764,11 +757,12 @@ public final ApiCallable deleteTopicCallable() { * } * * - * @param resource REQUIRED: The resource for which policy is being specified. Resource is usually - * specified as a path, such as, projects/{project}/zones/{zone}/disks/{disk}. - * @param policy REQUIRED: The complete policy to be applied to the 'resource'. The size of the - * policy is limited to a few 10s of KB. An empty policy is in general a valid policy but - * certain services (like Projects) might reject them. + * @param resource REQUIRED: The resource for which the policy is being specified. `resource` is + * usually specified as a path. For example, a Project resource is specified as + * `projects/{project}`. + * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the + * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud + * Platform services (such as Projects) might reject them. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final Policy setIamPolicy(String resource, Policy policy) { @@ -823,14 +817,14 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * } * */ - public final ApiCallable setIamPolicyCallable() { + public final UnaryApiCallable setIamPolicyCallable() { return setIamPolicyCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets the access control policy for a resource. Is empty if the policy or the resource does not - * exist. + * Gets the access control policy for a resource. Returns an empty policy if the resource exists + * and does not have a policy set. * *

    Sample code: * @@ -841,8 +835,9 @@ public final ApiCallable setIamPolicyCallable() { * } * * - * @param resource REQUIRED: The resource for which policy is being requested. Resource is usually - * specified as a path, such as, projects/{project}. + * @param resource REQUIRED: The resource for which the policy is being requested. `resource` is + * usually specified as a path. For example, a Project resource is specified as + * `projects/{project}`. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final Policy getIamPolicy(String resource) { @@ -853,8 +848,8 @@ public final Policy getIamPolicy(String resource) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets the access control policy for a resource. Is empty if the policy or the resource does not - * exist. + * Gets the access control policy for a resource. Returns an empty policy if the resource exists + * and does not have a policy set. * *

    Sample code: * @@ -877,8 +872,8 @@ private final Policy getIamPolicy(GetIamPolicyRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets the access control policy for a resource. Is empty if the policy or the resource does not - * exist. + * Gets the access control policy for a resource. Returns an empty policy if the resource exists + * and does not have a policy set. * *

    Sample code: * @@ -894,7 +889,7 @@ private final Policy getIamPolicy(GetIamPolicyRequest request) { * } * */ - public final ApiCallable getIamPolicyCallable() { + public final UnaryApiCallable getIamPolicyCallable() { return getIamPolicyCallable; } @@ -912,10 +907,12 @@ public final ApiCallable getIamPolicyCallable() { * } * * - * @param resource REQUIRED: The resource for which policy detail is being requested. Resource is - * usually specified as a path, such as, projects/{project}. - * @param permissions The set of permissions to check for the 'resource'. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. + * @param resource REQUIRED: The resource for which the policy detail is being requested. + * `resource` is usually specified as a path. For example, a Project resource is specified as + * `projects/{project}`. + * @param permissions The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final TestIamPermissionsResponse testIamPermissions( @@ -974,7 +971,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * } * */ - public final ApiCallable + public final UnaryApiCallable testIamPermissionsCallable() { return testIamPermissionsCallable; } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherSettings.java index 8c50b07d0d06..ab77490afad3 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherSettings.java @@ -13,17 +13,23 @@ */ package com.google.cloud.pubsub.spi.v1; +import static com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListTopicSubscriptionsPagedResponse; +import static com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListTopicsPagedResponse; + import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.BundlingCallSettings; import com.google.api.gax.grpc.BundlingDescriptor; import com.google.api.gax.grpc.BundlingSettings; +import com.google.api.gax.grpc.CallContext; import com.google.api.gax.grpc.PageStreamingCallSettings; import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseFactory; import com.google.api.gax.grpc.RequestIssuer; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -109,10 +115,12 @@ public class PublisherSettings extends ServiceApiSettings { private final SimpleCallSettings createTopicSettings; private final BundlingCallSettings publishSettings; private final SimpleCallSettings getTopicSettings; - private final PageStreamingCallSettings + private final PageStreamingCallSettings< + ListTopicsRequest, ListTopicsResponse, ListTopicsPagedResponse> listTopicsSettings; private final PageStreamingCallSettings< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, + ListTopicSubscriptionsPagedResponse> listTopicSubscriptionsSettings; private final SimpleCallSettings deleteTopicSettings; private final SimpleCallSettings setIamPolicySettings; @@ -136,14 +144,15 @@ public SimpleCallSettings getTopicSettings() { } /** Returns the object with the settings used for calls to listTopics. */ - public PageStreamingCallSettings + public PageStreamingCallSettings listTopicsSettings() { return listTopicsSettings; } /** Returns the object with the settings used for calls to listTopicSubscriptions. */ public PageStreamingCallSettings< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, + ListTopicSubscriptionsPagedResponse> listTopicSubscriptionsSettings() { return listTopicSubscriptionsSettings; } @@ -295,6 +304,39 @@ public Iterable extractResources(ListTopicSubscriptionsResponse payload) } }; + private static final PagedListResponseFactory< + ListTopicsRequest, ListTopicsResponse, ListTopicsPagedResponse> + LIST_TOPICS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListTopicsRequest, ListTopicsResponse, ListTopicsPagedResponse>() { + @Override + public ListTopicsPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListTopicsRequest request, + CallContext context) { + return new ListTopicsPagedResponse( + callable, LIST_TOPICS_PAGE_STR_DESC, request, context); + } + }; + + private static final PagedListResponseFactory< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, + ListTopicSubscriptionsPagedResponse> + LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, + ListTopicSubscriptionsPagedResponse>() { + @Override + public ListTopicSubscriptionsPagedResponse createPagedListResponse( + UnaryApiCallable + callable, + ListTopicSubscriptionsRequest request, + CallContext context) { + return new ListTopicSubscriptionsPagedResponse( + callable, LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC, request, context); + } + }; + private static final BundlingDescriptor PUBLISH_BUNDLING_DESC = new BundlingDescriptor() { @Override @@ -359,15 +401,17 @@ public long countBytes(PublishRequest request) { /** Builder for PublisherSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final SimpleCallSettings.Builder createTopicSettings; private final BundlingCallSettings.Builder publishSettings; private final SimpleCallSettings.Builder getTopicSettings; - private final PageStreamingCallSettings.Builder + private final PageStreamingCallSettings.Builder< + ListTopicsRequest, ListTopicsResponse, ListTopicsPagedResponse> listTopicsSettings; private final PageStreamingCallSettings.Builder< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, + ListTopicSubscriptionsPagedResponse> listTopicSubscriptionsSettings; private final SimpleCallSettings.Builder deleteTopicSettings; private final SimpleCallSettings.Builder setIamPolicySettings; @@ -434,12 +478,12 @@ private Builder() { listTopicsSettings = PageStreamingCallSettings.newBuilder( - PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC); + PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_FACT); listTopicSubscriptionsSettings = PageStreamingCallSettings.newBuilder( PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, - LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC); + LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_FACT); deleteTopicSettings = SimpleCallSettings.newBuilder(PublisherGrpc.METHOD_DELETE_TOPIC); @@ -450,8 +494,8 @@ private Builder() { testIamPermissionsSettings = SimpleCallSettings.newBuilder(IAMPolicyGrpc.METHOD_TEST_IAM_PERMISSIONS); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( createTopicSettings, publishSettings, getTopicSettings, @@ -536,8 +580,8 @@ private Builder(PublisherSettings settings) { getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( createTopicSettings, publishSettings, getTopicSettings, @@ -597,11 +641,14 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } @@ -621,14 +668,16 @@ public SimpleCallSettings.Builder getTopicSettings() { } /** Returns the builder for the settings used for calls to listTopics. */ - public PageStreamingCallSettings.Builder + public PageStreamingCallSettings.Builder< + ListTopicsRequest, ListTopicsResponse, ListTopicsPagedResponse> listTopicsSettings() { return listTopicsSettings; } /** Returns the builder for the settings used for calls to listTopicSubscriptions. */ public PageStreamingCallSettings.Builder< - ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String> + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, + ListTopicSubscriptionsPagedResponse> listTopicSubscriptionsSettings() { return listTopicSubscriptionsSettings; } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberApi.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberApi.java index 3505cd9d1825..fc33f40bcd3b 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberApi.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberApi.java @@ -13,8 +13,9 @@ */ package com.google.cloud.pubsub.spi.v1; -import com.google.api.gax.core.PagedListResponse; -import com.google.api.gax.grpc.ApiCallable; +import static com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListSubscriptionsPagedResponse; + +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.api.gax.protobuf.PathTemplate; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.Policy; @@ -73,8 +74,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -102,22 +103,20 @@ public class SubscriberApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable createSubscriptionCallable; - private final ApiCallable getSubscriptionCallable; - private final ApiCallable + private final UnaryApiCallable createSubscriptionCallable; + private final UnaryApiCallable getSubscriptionCallable; + private final UnaryApiCallable listSubscriptionsCallable; - private final ApiCallable< - ListSubscriptionsRequest, - PagedListResponse> + private final UnaryApiCallable listSubscriptionsPagedCallable; - private final ApiCallable deleteSubscriptionCallable; - private final ApiCallable modifyAckDeadlineCallable; - private final ApiCallable acknowledgeCallable; - private final ApiCallable pullCallable; - private final ApiCallable modifyPushConfigCallable; - private final ApiCallable setIamPolicyCallable; - private final ApiCallable getIamPolicyCallable; - private final ApiCallable + private final UnaryApiCallable deleteSubscriptionCallable; + private final UnaryApiCallable modifyAckDeadlineCallable; + private final UnaryApiCallable acknowledgeCallable; + private final UnaryApiCallable pullCallable; + private final UnaryApiCallable modifyPushConfigCallable; + private final UnaryApiCallable setIamPolicyCallable; + private final UnaryApiCallable getIamPolicyCallable; + private final UnaryApiCallable testIamPermissionsCallable; private static final PathTemplate PROJECT_PATH_TEMPLATE = @@ -202,29 +201,30 @@ protected SubscriberApi(SubscriberSettings settings) throws IOException { this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.createSubscriptionCallable = - ApiCallable.create(settings.createSubscriptionSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.createSubscriptionSettings(), this.channel, this.executor); this.getSubscriptionCallable = - ApiCallable.create(settings.getSubscriptionSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.getSubscriptionSettings(), this.channel, this.executor); this.listSubscriptionsCallable = - ApiCallable.create(settings.listSubscriptionsSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listSubscriptionsSettings(), this.channel, this.executor); this.listSubscriptionsPagedCallable = - ApiCallable.createPagedVariant( + UnaryApiCallable.createPagedVariant( settings.listSubscriptionsSettings(), this.channel, this.executor); this.deleteSubscriptionCallable = - ApiCallable.create(settings.deleteSubscriptionSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.deleteSubscriptionSettings(), this.channel, this.executor); this.modifyAckDeadlineCallable = - ApiCallable.create(settings.modifyAckDeadlineSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.modifyAckDeadlineSettings(), this.channel, this.executor); this.acknowledgeCallable = - ApiCallable.create(settings.acknowledgeSettings(), this.channel, this.executor); - this.pullCallable = ApiCallable.create(settings.pullSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.acknowledgeSettings(), this.channel, this.executor); + this.pullCallable = + UnaryApiCallable.create(settings.pullSettings(), this.channel, this.executor); this.modifyPushConfigCallable = - ApiCallable.create(settings.modifyPushConfigSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.modifyPushConfigSettings(), this.channel, this.executor); this.setIamPolicyCallable = - ApiCallable.create(settings.setIamPolicySettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.setIamPolicySettings(), this.channel, this.executor); this.getIamPolicyCallable = - ApiCallable.create(settings.getIamPolicySettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.getIamPolicySettings(), this.channel, this.executor); this.testIamPermissionsCallable = - ApiCallable.create(settings.testIamPermissionsSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.testIamPermissionsSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -365,7 +365,7 @@ public final Subscription createSubscription(Subscription request) { * } * */ - public final ApiCallable createSubscriptionCallable() { + public final UnaryApiCallable createSubscriptionCallable() { return createSubscriptionCallable; } @@ -433,7 +433,7 @@ private final Subscription getSubscription(GetSubscriptionRequest request) { * } * */ - public final ApiCallable getSubscriptionCallable() { + public final UnaryApiCallable getSubscriptionCallable() { return getSubscriptionCallable; } @@ -455,8 +455,7 @@ public final ApiCallable getSubscriptionCa * @param project The name of the cloud project that subscriptions belong to. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse - listSubscriptions(String project) { + public final ListSubscriptionsPagedResponse listSubscriptions(String project) { PROJECT_PATH_TEMPLATE.validate(project, "listSubscriptions"); ListSubscriptionsRequest request = ListSubscriptionsRequest.newBuilder().setProject(project).build(); @@ -484,8 +483,7 @@ public final ApiCallable getSubscriptionCa * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse - listSubscriptions(ListSubscriptionsRequest request) { + public final ListSubscriptionsPagedResponse listSubscriptions(ListSubscriptionsRequest request) { return listSubscriptionsPagedCallable().call(request); } @@ -501,7 +499,7 @@ public final ApiCallable getSubscriptionCa * ListSubscriptionsRequest request = ListSubscriptionsRequest.newBuilder() * .setProject(formattedProject) * .build(); - * ListenableFuture<PagedListResponse<ListSubscriptionsRequest,ListSubscriptionsResponse,Subscription>> future = subscriberApi.listSubscriptionsPagedCallable().futureCall(request); + * ListenableFuture<ListSubscriptionsPagedResponse> future = subscriberApi.listSubscriptionsPagedCallable().futureCall(request); * // Do something * for (Subscription element : future.get().iterateAllElements()) { * // doThingsWith(element); @@ -509,9 +507,7 @@ public final ApiCallable getSubscriptionCa * } * */ - public final ApiCallable< - ListSubscriptionsRequest, - PagedListResponse> + public final UnaryApiCallable listSubscriptionsPagedCallable() { return listSubscriptionsPagedCallable; } @@ -543,7 +539,7 @@ public final ApiCallable getSubscriptionCa * } * */ - public final ApiCallable + public final UnaryApiCallable listSubscriptionsCallable() { return listSubscriptionsCallable; } @@ -621,7 +617,7 @@ private final void deleteSubscription(DeleteSubscriptionRequest request) { * } * */ - public final ApiCallable deleteSubscriptionCallable() { + public final UnaryApiCallable deleteSubscriptionCallable() { return deleteSubscriptionCallable; } @@ -718,7 +714,7 @@ public final void modifyAckDeadline(ModifyAckDeadlineRequest request) { * } * */ - public final ApiCallable modifyAckDeadlineCallable() { + public final UnaryApiCallable modifyAckDeadlineCallable() { return modifyAckDeadlineCallable; } @@ -805,7 +801,7 @@ public final void acknowledge(AcknowledgeRequest request) { * } * */ - public final ApiCallable acknowledgeCallable() { + public final UnaryApiCallable acknowledgeCallable() { return acknowledgeCallable; } @@ -895,7 +891,7 @@ public final PullResponse pull(PullRequest request) { * } * */ - public final ApiCallable pullCallable() { + public final UnaryApiCallable pullCallable() { return pullCallable; } @@ -990,7 +986,7 @@ public final void modifyPushConfig(ModifyPushConfigRequest request) { * } * */ - public final ApiCallable modifyPushConfigCallable() { + public final UnaryApiCallable modifyPushConfigCallable() { return modifyPushConfigCallable; } @@ -1008,11 +1004,12 @@ public final ApiCallable modifyPushConfigCallabl * } * * - * @param resource REQUIRED: The resource for which policy is being specified. Resource is usually - * specified as a path, such as, projects/{project}/zones/{zone}/disks/{disk}. - * @param policy REQUIRED: The complete policy to be applied to the 'resource'. The size of the - * policy is limited to a few 10s of KB. An empty policy is in general a valid policy but - * certain services (like Projects) might reject them. + * @param resource REQUIRED: The resource for which the policy is being specified. `resource` is + * usually specified as a path. For example, a Project resource is specified as + * `projects/{project}`. + * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the + * policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud + * Platform services (such as Projects) might reject them. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final Policy setIamPolicy(String resource, Policy policy) { @@ -1067,14 +1064,14 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * } * */ - public final ApiCallable setIamPolicyCallable() { + public final UnaryApiCallable setIamPolicyCallable() { return setIamPolicyCallable; } // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets the access control policy for a resource. Is empty if the policy or the resource does not - * exist. + * Gets the access control policy for a resource. Returns an empty policy if the resource exists + * and does not have a policy set. * *

    Sample code: * @@ -1085,8 +1082,9 @@ public final ApiCallable setIamPolicyCallable() { * } * * - * @param resource REQUIRED: The resource for which policy is being requested. Resource is usually - * specified as a path, such as, projects/{project}. + * @param resource REQUIRED: The resource for which the policy is being requested. `resource` is + * usually specified as a path. For example, a Project resource is specified as + * `projects/{project}`. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final Policy getIamPolicy(String resource) { @@ -1097,8 +1095,8 @@ public final Policy getIamPolicy(String resource) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets the access control policy for a resource. Is empty if the policy or the resource does not - * exist. + * Gets the access control policy for a resource. Returns an empty policy if the resource exists + * and does not have a policy set. * *

    Sample code: * @@ -1121,8 +1119,8 @@ private final Policy getIamPolicy(GetIamPolicyRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Gets the access control policy for a resource. Is empty if the policy or the resource does not - * exist. + * Gets the access control policy for a resource. Returns an empty policy if the resource exists + * and does not have a policy set. * *

    Sample code: * @@ -1138,7 +1136,7 @@ private final Policy getIamPolicy(GetIamPolicyRequest request) { * } * */ - public final ApiCallable getIamPolicyCallable() { + public final UnaryApiCallable getIamPolicyCallable() { return getIamPolicyCallable; } @@ -1156,10 +1154,12 @@ public final ApiCallable getIamPolicyCallable() { * } * * - * @param resource REQUIRED: The resource for which policy detail is being requested. Resource is - * usually specified as a path, such as, projects/{project}. - * @param permissions The set of permissions to check for the 'resource'. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. + * @param resource REQUIRED: The resource for which the policy detail is being requested. + * `resource` is usually specified as a path. For example, a Project resource is specified as + * `projects/{project}`. + * @param permissions The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ public final TestIamPermissionsResponse testIamPermissions( @@ -1218,7 +1218,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * } * */ - public final ApiCallable + public final UnaryApiCallable testIamPermissionsCallable() { return testIamPermissionsCallable; } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberSettings.java index 4396e5b692f9..667209b57642 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberSettings.java @@ -13,13 +13,18 @@ */ package com.google.cloud.pubsub.spi.v1; +import static com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListSubscriptionsPagedResponse; + import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.CallContext; import com.google.api.gax.grpc.PageStreamingCallSettings; import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseFactory; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -103,7 +108,7 @@ public class SubscriberSettings extends ServiceApiSettings { private final SimpleCallSettings createSubscriptionSettings; private final SimpleCallSettings getSubscriptionSettings; private final PageStreamingCallSettings< - ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + ListSubscriptionsRequest, ListSubscriptionsResponse, ListSubscriptionsPagedResponse> listSubscriptionsSettings; private final SimpleCallSettings deleteSubscriptionSettings; private final SimpleCallSettings modifyAckDeadlineSettings; @@ -127,7 +132,7 @@ public SimpleCallSettings getSubscriptionS /** Returns the object with the settings used for calls to listSubscriptions. */ public PageStreamingCallSettings< - ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + ListSubscriptionsRequest, ListSubscriptionsResponse, ListSubscriptionsPagedResponse> listSubscriptionsSettings() { return listSubscriptionsSettings; } @@ -265,15 +270,31 @@ public Iterable extractResources(ListSubscriptionsResponse payload } }; + private static final PagedListResponseFactory< + ListSubscriptionsRequest, ListSubscriptionsResponse, ListSubscriptionsPagedResponse> + LIST_SUBSCRIPTIONS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListSubscriptionsRequest, ListSubscriptionsResponse, + ListSubscriptionsPagedResponse>() { + @Override + public ListSubscriptionsPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListSubscriptionsRequest request, + CallContext context) { + return new ListSubscriptionsPagedResponse( + callable, LIST_SUBSCRIPTIONS_PAGE_STR_DESC, request, context); + } + }; + /** Builder for SubscriberSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final SimpleCallSettings.Builder createSubscriptionSettings; private final SimpleCallSettings.Builder getSubscriptionSettings; private final PageStreamingCallSettings.Builder< - ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + ListSubscriptionsRequest, ListSubscriptionsResponse, ListSubscriptionsPagedResponse> listSubscriptionsSettings; private final SimpleCallSettings.Builder deleteSubscriptionSettings; @@ -340,7 +361,7 @@ private Builder() { listSubscriptionsSettings = PageStreamingCallSettings.newBuilder( - SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS, LIST_SUBSCRIPTIONS_PAGE_STR_DESC); + SubscriberGrpc.METHOD_LIST_SUBSCRIPTIONS, LIST_SUBSCRIPTIONS_PAGE_STR_FACT); deleteSubscriptionSettings = SimpleCallSettings.newBuilder(SubscriberGrpc.METHOD_DELETE_SUBSCRIPTION); @@ -362,8 +383,8 @@ private Builder() { testIamPermissionsSettings = SimpleCallSettings.newBuilder(IAMPolicyGrpc.METHOD_TEST_IAM_PERMISSIONS); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( createSubscriptionSettings, getSubscriptionSettings, listSubscriptionsSettings, @@ -453,8 +474,8 @@ private Builder(SubscriberSettings settings) { getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( createSubscriptionSettings, getSubscriptionSettings, listSubscriptionsSettings, @@ -516,11 +537,14 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } @@ -537,7 +561,7 @@ public SimpleCallSettings.Builder createSubscription /** Returns the builder for the settings used for calls to listSubscriptions. */ public PageStreamingCallSettings.Builder< - ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription> + ListSubscriptionsRequest, ListSubscriptionsResponse, ListSubscriptionsPagedResponse> listSubscriptionsSettings() { return listSubscriptionsSettings; } diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/spi/v1/PublisherTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/spi/v1/PublisherTest.java index 7d76c1a27111..54b07c63362d 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/spi/v1/PublisherTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/spi/v1/PublisherTest.java @@ -14,7 +14,9 @@ package com.google.cloud.pubsub.spi.v1; -import com.google.api.gax.core.PagedListResponse; +import static com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListTopicSubscriptionsPagedResponse; +import static com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListTopicsPagedResponse; + import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; import com.google.common.collect.Lists; @@ -173,8 +175,7 @@ public void listTopicsTest() { String formattedProject = PublisherApi.formatProjectName("[PROJECT]"); - PagedListResponse pagedListResponse = - api.listTopics(formattedProject); + ListTopicsPagedResponse pagedListResponse = api.listTopics(formattedProject); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); @@ -204,8 +205,8 @@ public void listTopicSubscriptionsTest() { String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); - PagedListResponse - pagedListResponse = api.listTopicSubscriptions(formattedTopic); + ListTopicSubscriptionsPagedResponse pagedListResponse = + api.listTopicSubscriptions(formattedTopic); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/spi/v1/SubscriberTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/spi/v1/SubscriberTest.java index 28e25b421ac7..1fa6597ab0db 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/spi/v1/SubscriberTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/spi/v1/SubscriberTest.java @@ -14,7 +14,8 @@ package com.google.cloud.pubsub.spi.v1; -import com.google.api.gax.core.PagedListResponse; +import static com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListSubscriptionsPagedResponse; + import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; import com.google.common.collect.Lists; @@ -169,8 +170,7 @@ public void listSubscriptionsTest() { String formattedProject = SubscriberApi.formatProjectName("[PROJECT]"); - PagedListResponse - pagedListResponse = api.listSubscriptions(formattedProject); + ListSubscriptionsPagedResponse pagedListResponse = api.listSubscriptions(formattedProject); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/PagedResponseWrappers.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/PagedResponseWrappers.java new file mode 100644 index 000000000000..fedd705772e4 --- /dev/null +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/PagedResponseWrappers.java @@ -0,0 +1,23 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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 + * + * http://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. + */ +package com.google.cloud.speech.spi.v1beta1; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Wrapper class to contain paged response types for page streaming methods. Each static class + * inside this wrapper class is used as the return type of one of an API method that implements the + * page streaming pattern. + */ +@javax.annotation.Generated("by GAPIC") +public class PagedResponseWrappers {} diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/SpeechApi.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/SpeechApi.java index 9ce5e2917edc..1b435d1f6cfa 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/SpeechApi.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/SpeechApi.java @@ -13,10 +13,13 @@ */ package com.google.cloud.speech.spi.v1beta1; -import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.StreamingApiCallable; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.cloud.speech.v1beta1.AsyncRecognizeRequest; import com.google.cloud.speech.v1beta1.RecognitionAudio; import com.google.cloud.speech.v1beta1.RecognitionConfig; +import com.google.cloud.speech.v1beta1.StreamingRecognizeRequest; +import com.google.cloud.speech.v1beta1.StreamingRecognizeResponse; import com.google.cloud.speech.v1beta1.SyncRecognizeRequest; import com.google.cloud.speech.v1beta1.SyncRecognizeResponse; import com.google.longrunning.Operation; @@ -57,8 +60,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -86,8 +89,10 @@ public class SpeechApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable syncRecognizeCallable; - private final ApiCallable asyncRecognizeCallable; + private final UnaryApiCallable syncRecognizeCallable; + private final UnaryApiCallable asyncRecognizeCallable; + private final StreamingApiCallable + streamingRecognizeCallable; /** Constructs an instance of SpeechApi with default settings. */ public static final SpeechApi create() throws IOException { @@ -112,9 +117,11 @@ protected SpeechApi(SpeechSettings settings) throws IOException { this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.syncRecognizeCallable = - ApiCallable.create(settings.syncRecognizeSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.syncRecognizeSettings(), this.channel, this.executor); this.asyncRecognizeCallable = - ApiCallable.create(settings.asyncRecognizeSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.asyncRecognizeSettings(), this.channel, this.executor); + this.streamingRecognizeCallable = + StreamingApiCallable.create(settings.streamingRecognizeSettings(), this.channel); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -214,7 +221,8 @@ public final SyncRecognizeResponse syncRecognize(SyncRecognizeRequest request) { * } * */ - public final ApiCallable syncRecognizeCallable() { + public final UnaryApiCallable + syncRecognizeCallable() { return syncRecognizeCallable; } @@ -294,10 +302,49 @@ public final Operation asyncRecognize(AsyncRecognizeRequest request) { * } * */ - public final ApiCallable asyncRecognizeCallable() { + public final UnaryApiCallable asyncRecognizeCallable() { return asyncRecognizeCallable; } + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Perform bidirectional streaming speech-recognition: receive results while sending audio. This + * method is only available via the gRPC API (not REST). + * + *

    Sample code: + * + *

    
    +   * try (SpeechApi speechApi = SpeechApi.create()) {
    +   *   StreamObserver<StreamingRecognizeResponse> responseObserver =
    +   *       new StreamObserver<StreamingRecognizeResponse>() {
    +   *         @Override
    +   *         public void onNext(StreamingRecognizeResponse response) {
    +   *           // Do something when receive a response
    +   *         }
    +   *
    +   *         @Override
    +   *         public void onError(Throwable t) {
    +   *           // Add error-handling
    +   *         }
    +   *
    +   *         @Override
    +   *         public void onCompleted() {
    +   *           // Do something when complete.
    +   *         }
    +   *       };
    +   *   StreamObserver<StreamingRecognizeRequest> requestObserver =
    +   *       speechApi.streamingRecognizeCallable().bidiStreamingCall(responseObserver)});
    +   *
    +   *   StreamingRecognizeRequest request = StreamingRecognizeRequest.newBuilder().build();
    +   *   requestObserver.onNext(request);
    +   * }
    +   * 
    + */ + public final StreamingApiCallable + streamingRecognizeCallable() { + return streamingRecognizeCallable; + } + /** * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately * cancelled. diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/SpeechSettings.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/SpeechSettings.java index ed78555815e4..94625f32d08a 100644 --- a/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/SpeechSettings.java +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/spi/v1beta1/SpeechSettings.java @@ -15,12 +15,15 @@ import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.StreamingCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; import com.google.auth.Credentials; import com.google.cloud.speech.v1beta1.AsyncRecognizeRequest; import com.google.cloud.speech.v1beta1.SpeechGrpc; +import com.google.cloud.speech.v1beta1.StreamingRecognizeRequest; +import com.google.cloud.speech.v1beta1.StreamingRecognizeResponse; import com.google.cloud.speech.v1beta1.SyncRecognizeRequest; import com.google.cloud.speech.v1beta1.SyncRecognizeResponse; import com.google.common.collect.ImmutableList; @@ -85,6 +88,8 @@ public class SpeechSettings extends ServiceApiSettings { private final SimpleCallSettings syncRecognizeSettings; private final SimpleCallSettings asyncRecognizeSettings; + private final StreamingCallSettings + streamingRecognizeSettings; /** Returns the object with the settings used for calls to syncRecognize. */ public SimpleCallSettings syncRecognizeSettings() { @@ -96,6 +101,12 @@ public SimpleCallSettings asyncRecognizeSettin return asyncRecognizeSettings; } + /** Returns the object with the settings used for calls to streamingRecognize. */ + public StreamingCallSettings + streamingRecognizeSettings() { + return streamingRecognizeSettings; + } + /** Returns the default service address. */ public static String getDefaultServiceAddress() { return DEFAULT_SERVICE_ADDRESS; @@ -137,16 +148,20 @@ private SpeechSettings(Builder settingsBuilder) throws IOException { syncRecognizeSettings = settingsBuilder.syncRecognizeSettings().build(); asyncRecognizeSettings = settingsBuilder.asyncRecognizeSettings().build(); + streamingRecognizeSettings = settingsBuilder.streamingRecognizeSettings().build(); } /** Builder for SpeechSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final SimpleCallSettings.Builder syncRecognizeSettings; private final SimpleCallSettings.Builder asyncRecognizeSettings; + private final StreamingCallSettings.Builder< + StreamingRecognizeRequest, StreamingRecognizeResponse> + streamingRecognizeSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -186,8 +201,12 @@ private Builder() { asyncRecognizeSettings = SimpleCallSettings.newBuilder(SpeechGrpc.METHOD_ASYNC_RECOGNIZE); - methodSettingsBuilders = - ImmutableList.of(syncRecognizeSettings, asyncRecognizeSettings); + streamingRecognizeSettings = + StreamingCallSettings.newBuilder(SpeechGrpc.METHOD_STREAMING_RECOGNIZE); + + unaryMethodSettingsBuilders = + ImmutableList.of( + syncRecognizeSettings, asyncRecognizeSettings); } private static Builder createDefault() { @@ -211,9 +230,11 @@ private Builder(SpeechSettings settings) { syncRecognizeSettings = settings.syncRecognizeSettings.toBuilder(); asyncRecognizeSettings = settings.asyncRecognizeSettings.toBuilder(); + streamingRecognizeSettings = settings.streamingRecognizeSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of(syncRecognizeSettings, asyncRecognizeSettings); + unaryMethodSettingsBuilders = + ImmutableList.of( + syncRecognizeSettings, asyncRecognizeSettings); } @Override @@ -264,11 +285,14 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } @@ -283,6 +307,12 @@ public SimpleCallSettings.Builder asyncRecogni return asyncRecognizeSettings; } + /** Returns the builder for the settings used for calls to streamingRecognize. */ + public StreamingCallSettings.Builder + streamingRecognizeSettings() { + return streamingRecognizeSettings; + } + @Override public SpeechSettings build() throws IOException { return new SpeechSettings(this); diff --git a/google-cloud-speech/src/test/java/com/google/cloud/speech/spi/v1beta1/MockSpeechImpl.java b/google-cloud-speech/src/test/java/com/google/cloud/speech/spi/v1beta1/MockSpeechImpl.java index a33911f8274b..5ac9a8fe8f21 100644 --- a/google-cloud-speech/src/test/java/com/google/cloud/speech/spi/v1beta1/MockSpeechImpl.java +++ b/google-cloud-speech/src/test/java/com/google/cloud/speech/spi/v1beta1/MockSpeechImpl.java @@ -72,8 +72,25 @@ public void asyncRecognize( @Override public StreamObserver streamingRecognize( - StreamObserver responseObserver) { - System.err.println("Streaming method is not supported."); - return null; + final StreamObserver responseObserver) { + final StreamingRecognizeResponse response = (StreamingRecognizeResponse) responses.remove(); + StreamObserver requestObserver = + new StreamObserver() { + @Override + public void onNext(StreamingRecognizeRequest value) { + responseObserver.onNext(response); + } + + @Override + public void onError(Throwable t) { + responseObserver.onError(t); + } + + @Override + public void onCompleted() { + responseObserver.onCompleted(); + } + }; + return requestObserver; } } diff --git a/google-cloud-speech/src/test/java/com/google/cloud/speech/spi/v1beta1/SpeechTest.java b/google-cloud-speech/src/test/java/com/google/cloud/speech/spi/v1beta1/SpeechTest.java index c59e64f80ddc..f1e8dcbb7ed2 100644 --- a/google-cloud-speech/src/test/java/com/google/cloud/speech/spi/v1beta1/SpeechTest.java +++ b/google-cloud-speech/src/test/java/com/google/cloud/speech/spi/v1beta1/SpeechTest.java @@ -14,15 +14,20 @@ package com.google.cloud.speech.spi.v1beta1; +import com.google.api.gax.grpc.StreamingApiCallable; import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; +import com.google.api.gax.testing.MockStreamObserver; import com.google.cloud.speech.v1beta1.AsyncRecognizeRequest; import com.google.cloud.speech.v1beta1.RecognitionAudio; import com.google.cloud.speech.v1beta1.RecognitionConfig; +import com.google.cloud.speech.v1beta1.StreamingRecognizeRequest; +import com.google.cloud.speech.v1beta1.StreamingRecognizeResponse; import com.google.cloud.speech.v1beta1.SyncRecognizeRequest; import com.google.cloud.speech.v1beta1.SyncRecognizeResponse; import com.google.longrunning.Operation; import com.google.protobuf.GeneratedMessageV3; +import io.grpc.stub.StreamObserver; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -113,4 +118,31 @@ public void asyncRecognizeTest() { Assert.assertEquals(config, actualRequest.getConfig()); Assert.assertEquals(audio, actualRequest.getAudio()); } + + @Test + @SuppressWarnings("all") + public void streamingRecognizeTest() throws Exception { + int resultIndex = 520358448; + StreamingRecognizeResponse expectedResponse = + StreamingRecognizeResponse.newBuilder().setResultIndex(resultIndex).build(); + List expectedResponses = new ArrayList<>(); + expectedResponses.add(expectedResponse); + mockSpeech.setResponses(expectedResponses); + StreamingRecognizeRequest request = StreamingRecognizeRequest.newBuilder().build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + StreamingApiCallable callable = + api.streamingRecognizeCallable(); + StreamObserver requestObserver = + callable.bidiStreamingCall(responseObserver); + + requestObserver.onNext(request); + requestObserver.onCompleted(); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + Assert.assertEquals(0, responseObserver.errors().size()); + } } diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/PagedResponseWrappers.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/PagedResponseWrappers.java new file mode 100644 index 000000000000..a8a19823b403 --- /dev/null +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/PagedResponseWrappers.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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 + * + * http://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. + */ +package com.google.cloud.trace.spi.v1; + +import com.google.api.gax.grpc.CallContext; +import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseImpl; +import com.google.api.gax.grpc.UnaryApiCallable; +import com.google.devtools.cloudtrace.v1.ListTracesRequest; +import com.google.devtools.cloudtrace.v1.ListTracesResponse; +import com.google.devtools.cloudtrace.v1.Trace; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Wrapper class to contain paged response types for page streaming methods. Each static class + * inside this wrapper class is used as the return type of one of an API method that implements the + * page streaming pattern. + */ +@javax.annotation.Generated("by GAPIC") +public class PagedResponseWrappers { + + public static class ListTracesPagedResponse + extends PagedListResponseImpl { + + public ListTracesPagedResponse( + UnaryApiCallable callable, + PageStreamingDescriptor pageDescriptor, + ListTracesRequest request, + CallContext context) { + super(callable, pageDescriptor, request, context); + } + } +} diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/TraceServiceApi.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/TraceServiceApi.java index d990e788a3b6..306ce4988770 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/TraceServiceApi.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/TraceServiceApi.java @@ -13,8 +13,9 @@ */ package com.google.cloud.trace.spi.v1; -import com.google.api.gax.core.PagedListResponse; -import com.google.api.gax.grpc.ApiCallable; +import static com.google.cloud.trace.spi.v1.PagedResponseWrappers.ListTracesPagedResponse; + +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.devtools.cloudtrace.v1.GetTraceRequest; import com.google.devtools.cloudtrace.v1.ListTracesRequest; import com.google.devtools.cloudtrace.v1.ListTracesResponse; @@ -62,8 +63,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -91,11 +92,10 @@ public class TraceServiceApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable patchTracesCallable; - private final ApiCallable getTraceCallable; - private final ApiCallable listTracesCallable; - private final ApiCallable< - ListTracesRequest, PagedListResponse> + private final UnaryApiCallable patchTracesCallable; + private final UnaryApiCallable getTraceCallable; + private final UnaryApiCallable listTracesCallable; + private final UnaryApiCallable listTracesPagedCallable; /** Constructs an instance of TraceServiceApi with default settings. */ @@ -121,13 +121,14 @@ protected TraceServiceApi(TraceServiceSettings settings) throws IOException { this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.patchTracesCallable = - ApiCallable.create(settings.patchTracesSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.patchTracesSettings(), this.channel, this.executor); this.getTraceCallable = - ApiCallable.create(settings.getTraceSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.getTraceSettings(), this.channel, this.executor); this.listTracesCallable = - ApiCallable.create(settings.listTracesSettings(), this.channel, this.executor); + UnaryApiCallable.create(settings.listTracesSettings(), this.channel, this.executor); this.listTracesPagedCallable = - ApiCallable.createPagedVariant(settings.listTracesSettings(), this.channel, this.executor); + UnaryApiCallable.createPagedVariant( + settings.listTracesSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -155,8 +156,8 @@ public final TraceServiceSettings getSettings() { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Sends new traces to Cloud Trace or updates existing traces. If the ID of a trace that you send - * matches that of an existing trace, any fields in the existing trace and its spans are + * Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you + * send matches that of an existing trace, any fields in the existing trace and its spans are * overwritten by the provided values, and any new fields provided are merged with the existing * trace data. If the ID does not match, a new trace is created. * @@ -182,8 +183,8 @@ public final void patchTraces(String projectId, Traces traces) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Sends new traces to Cloud Trace or updates existing traces. If the ID of a trace that you send - * matches that of an existing trace, any fields in the existing trace and its spans are + * Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you + * send matches that of an existing trace, any fields in the existing trace and its spans are * overwritten by the provided values, and any new fields provided are merged with the existing * trace data. If the ID does not match, a new trace is created. * @@ -210,8 +211,8 @@ public final void patchTraces(PatchTracesRequest request) { // AUTO-GENERATED DOCUMENTATION AND METHOD /** - * Sends new traces to Cloud Trace or updates existing traces. If the ID of a trace that you send - * matches that of an existing trace, any fields in the existing trace and its spans are + * Sends new traces to Stackdriver Trace or updates existing traces. If the ID of a trace that you + * send matches that of an existing trace, any fields in the existing trace and its spans are * overwritten by the provided values, and any new fields provided are merged with the existing * trace data. If the ID does not match, a new trace is created. * @@ -231,7 +232,7 @@ public final void patchTraces(PatchTracesRequest request) { * } * */ - public final ApiCallable patchTracesCallable() { + public final UnaryApiCallable patchTracesCallable() { return patchTracesCallable; } @@ -304,7 +305,7 @@ private final Trace getTrace(GetTraceRequest request) { * } * */ - public final ApiCallable getTraceCallable() { + public final UnaryApiCallable getTraceCallable() { return getTraceCallable; } @@ -326,8 +327,7 @@ public final ApiCallable getTraceCallable() { * @param projectId ID of the Cloud project where the trace data is stored. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse listTraces( - String projectId) { + public final ListTracesPagedResponse listTraces(String projectId) { ListTracesRequest request = ListTracesRequest.newBuilder().setProjectId(projectId).build(); return listTraces(request); } @@ -353,8 +353,7 @@ public final PagedListResponse lis * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.grpc.ApiException if the remote call fails */ - public final PagedListResponse listTraces( - ListTracesRequest request) { + public final ListTracesPagedResponse listTraces(ListTracesRequest request) { return listTracesPagedCallable().call(request); } @@ -370,7 +369,7 @@ public final PagedListResponse lis * ListTracesRequest request = ListTracesRequest.newBuilder() * .setProjectId(projectId) * .build(); - * ListenableFuture<PagedListResponse<ListTracesRequest,ListTracesResponse,Trace>> future = traceServiceApi.listTracesPagedCallable().futureCall(request); + * ListenableFuture<ListTracesPagedResponse> future = traceServiceApi.listTracesPagedCallable().futureCall(request); * // Do something * for (Trace element : future.get().iterateAllElements()) { * // doThingsWith(element); @@ -378,8 +377,7 @@ public final PagedListResponse lis * } * */ - public final ApiCallable< - ListTracesRequest, PagedListResponse> + public final UnaryApiCallable listTracesPagedCallable() { return listTracesPagedCallable; } @@ -411,7 +409,7 @@ public final PagedListResponse lis * } * */ - public final ApiCallable listTracesCallable() { + public final UnaryApiCallable listTracesCallable() { return listTracesCallable; } diff --git a/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/TraceServiceSettings.java b/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/TraceServiceSettings.java index 698295f4b86b..99b9a75d7bf5 100644 --- a/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/TraceServiceSettings.java +++ b/google-cloud-trace/src/main/java/com/google/cloud/trace/spi/v1/TraceServiceSettings.java @@ -13,13 +13,18 @@ */ package com.google.cloud.trace.spi.v1; +import static com.google.cloud.trace.spi.v1.PagedResponseWrappers.ListTracesPagedResponse; + import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; +import com.google.api.gax.grpc.CallContext; import com.google.api.gax.grpc.PageStreamingCallSettings; import com.google.api.gax.grpc.PageStreamingDescriptor; +import com.google.api.gax.grpc.PagedListResponseFactory; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.auth.Credentials; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -92,7 +97,8 @@ public class TraceServiceSettings extends ServiceApiSettings { private final SimpleCallSettings patchTracesSettings; private final SimpleCallSettings getTraceSettings; - private final PageStreamingCallSettings + private final PageStreamingCallSettings< + ListTracesRequest, ListTracesResponse, ListTracesPagedResponse> listTracesSettings; /** Returns the object with the settings used for calls to patchTraces. */ @@ -106,7 +112,7 @@ public SimpleCallSettings getTraceSettings() { } /** Returns the object with the settings used for calls to listTraces. */ - public PageStreamingCallSettings + public PageStreamingCallSettings listTracesSettings() { return listTracesSettings; } @@ -191,13 +197,29 @@ public Iterable extractResources(ListTracesResponse payload) { } }; + private static final PagedListResponseFactory< + ListTracesRequest, ListTracesResponse, ListTracesPagedResponse> + LIST_TRACES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListTracesRequest, ListTracesResponse, ListTracesPagedResponse>() { + @Override + public ListTracesPagedResponse createPagedListResponse( + UnaryApiCallable callable, + ListTracesRequest request, + CallContext context) { + return new ListTracesPagedResponse( + callable, LIST_TRACES_PAGE_STR_DESC, request, context); + } + }; + /** Builder for TraceServiceSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final SimpleCallSettings.Builder patchTracesSettings; private final SimpleCallSettings.Builder getTraceSettings; - private final PageStreamingCallSettings.Builder + private final PageStreamingCallSettings.Builder< + ListTracesRequest, ListTracesResponse, ListTracesPagedResponse> listTracesSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -240,10 +262,10 @@ private Builder() { listTracesSettings = PageStreamingCallSettings.newBuilder( - TraceServiceGrpc.METHOD_LIST_TRACES, LIST_TRACES_PAGE_STR_DESC); + TraceServiceGrpc.METHOD_LIST_TRACES, LIST_TRACES_PAGE_STR_FACT); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( patchTracesSettings, getTraceSettings, listTracesSettings); } @@ -275,8 +297,8 @@ private Builder(TraceServiceSettings settings) { getTraceSettings = settings.getTraceSettings.toBuilder(); listTracesSettings = settings.listTracesSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of( + unaryMethodSettingsBuilders = + ImmutableList.of( patchTracesSettings, getTraceSettings, listTracesSettings); } @@ -328,11 +350,14 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } @@ -347,7 +372,8 @@ public SimpleCallSettings.Builder getTraceSettings() { } /** Returns the builder for the settings used for calls to listTraces. */ - public PageStreamingCallSettings.Builder + public PageStreamingCallSettings.Builder< + ListTracesRequest, ListTracesResponse, ListTracesPagedResponse> listTracesSettings() { return listTracesSettings; } diff --git a/google-cloud-trace/src/test/java/com/google/cloud/trace/spi/v1/TraceServiceTest.java b/google-cloud-trace/src/test/java/com/google/cloud/trace/spi/v1/TraceServiceTest.java index c11b05b0c269..043d10f8f639 100644 --- a/google-cloud-trace/src/test/java/com/google/cloud/trace/spi/v1/TraceServiceTest.java +++ b/google-cloud-trace/src/test/java/com/google/cloud/trace/spi/v1/TraceServiceTest.java @@ -14,7 +14,8 @@ package com.google.cloud.trace.spi.v1; -import com.google.api.gax.core.PagedListResponse; +import static com.google.cloud.trace.spi.v1.PagedResponseWrappers.ListTracesPagedResponse; + import com.google.api.gax.testing.MockGrpcService; import com.google.api.gax.testing.MockServiceHelper; import com.google.common.collect.Lists; @@ -134,8 +135,7 @@ public void listTracesTest() { String projectId = "projectId-1969970175"; - PagedListResponse pagedListResponse = - api.listTraces(projectId); + ListTracesPagedResponse pagedListResponse = api.listTraces(projectId); List resources = Lists.newArrayList(pagedListResponse.iterateAllElements()); Assert.assertEquals(1, resources.size()); diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/ImageAnnotatorApi.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/ImageAnnotatorApi.java index 58672211034a..c129aa51f004 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/ImageAnnotatorApi.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/ImageAnnotatorApi.java @@ -13,7 +13,7 @@ */ package com.google.cloud.vision.spi.v1; -import com.google.api.gax.grpc.ApiCallable; +import com.google.api.gax.grpc.UnaryApiCallable; import com.google.cloud.vision.v1.AnnotateImageRequest; import com.google.cloud.vision.v1.BatchAnnotateImagesRequest; import com.google.cloud.vision.v1.BatchAnnotateImagesResponse; @@ -55,8 +55,8 @@ *

  • A "request object" method. This type of method only takes one parameter, a request object, * which must be constructed before the call. Not every API method will have a request object * method. - *
  • A "callable" method. This type of method takes no parameters and returns an immutable - * ApiCallable object, which can be used to initiate calls to the service. + *
  • A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. * * *

    See the individual methods for example code. @@ -84,7 +84,7 @@ public class ImageAnnotatorApi implements AutoCloseable { private final ScheduledExecutorService executor; private final List closeables = new ArrayList<>(); - private final ApiCallable + private final UnaryApiCallable batchAnnotateImagesCallable; /** Constructs an instance of ImageAnnotatorApi with default settings. */ @@ -110,7 +110,8 @@ protected ImageAnnotatorApi(ImageAnnotatorSettings settings) throws IOException this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor); this.batchAnnotateImagesCallable = - ApiCallable.create(settings.batchAnnotateImagesSettings(), this.channel, this.executor); + UnaryApiCallable.create( + settings.batchAnnotateImagesSettings(), this.channel, this.executor); if (settings.getChannelProvider().shouldAutoClose()) { closeables.add( @@ -201,7 +202,7 @@ private final BatchAnnotateImagesResponse batchAnnotateImages( * } * */ - public final ApiCallable + public final UnaryApiCallable batchAnnotateImagesCallable() { return batchAnnotateImagesCallable; } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/ImageAnnotatorSettings.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/ImageAnnotatorSettings.java index e23eb9a78f52..798c75dcad76 100644 --- a/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/ImageAnnotatorSettings.java +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/ImageAnnotatorSettings.java @@ -15,9 +15,9 @@ import com.google.api.gax.core.ConnectionSettings; import com.google.api.gax.core.RetrySettings; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ServiceApiSettings; import com.google.api.gax.grpc.SimpleCallSettings; +import com.google.api.gax.grpc.UnaryApiCallSettings; import com.google.auth.Credentials; import com.google.cloud.vision.v1.BatchAnnotateImagesRequest; import com.google.cloud.vision.v1.BatchAnnotateImagesResponse; @@ -133,7 +133,7 @@ private ImageAnnotatorSettings(Builder settingsBuilder) throws IOException { /** Builder for ImageAnnotatorSettings. */ public static class Builder extends ServiceApiSettings.Builder { - private final ImmutableList methodSettingsBuilders; + private final ImmutableList unaryMethodSettingsBuilders; private final SimpleCallSettings.Builder< BatchAnnotateImagesRequest, BatchAnnotateImagesResponse> @@ -176,8 +176,8 @@ private Builder() { batchAnnotateImagesSettings = SimpleCallSettings.newBuilder(ImageAnnotatorGrpc.METHOD_BATCH_ANNOTATE_IMAGES); - methodSettingsBuilders = - ImmutableList.of(batchAnnotateImagesSettings); + unaryMethodSettingsBuilders = + ImmutableList.of(batchAnnotateImagesSettings); } private static Builder createDefault() { @@ -196,8 +196,8 @@ private Builder(ImageAnnotatorSettings settings) { batchAnnotateImagesSettings = settings.batchAnnotateImagesSettings.toBuilder(); - methodSettingsBuilders = - ImmutableList.of(batchAnnotateImagesSettings); + unaryMethodSettingsBuilders = + ImmutableList.of(batchAnnotateImagesSettings); } @Override @@ -248,11 +248,14 @@ public Builder setClientLibHeader(String name, String version) { } /** - * Applies the given settings to all of the API methods in this service. Only values that are - * non-null will be applied, so this method is not capable of un-setting any values. + * Applies the given settings to all of the unary API methods in this service. Only values that + * are non-null will be applied, so this method is not capable of un-setting any values. + * + *

    Note: This method does not support applying settings to streaming methods. */ - public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { - super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); + public Builder applyToAllApiMethods(UnaryApiCallSettings.Builder apiCallSettings) + throws Exception { + super.applyToAllApiMethods(unaryMethodSettingsBuilders, apiCallSettings); return this; } diff --git a/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/PagedResponseWrappers.java b/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/PagedResponseWrappers.java new file mode 100644 index 000000000000..53121286e524 --- /dev/null +++ b/google-cloud-vision/src/main/java/com/google/cloud/vision/spi/v1/PagedResponseWrappers.java @@ -0,0 +1,23 @@ +/* + * Copyright 2016 Google Inc. All Rights Reserved. + * + * 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 + * + * http://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. + */ +package com.google.cloud.vision.spi.v1; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Wrapper class to contain paged response types for page streaming methods. Each static class + * inside this wrapper class is used as the return type of one of an API method that implements the + * page streaming pattern. + */ +@javax.annotation.Generated("by GAPIC") +public class PagedResponseWrappers {}