From 18a19771d42b71e28d7f5e8e65d078169ba775b8 Mon Sep 17 00:00:00 2001 From: Suraj Dhamecha <48670070+suraj-qlogic@users.noreply.github.com> Date: Wed, 23 Sep 2020 21:56:49 +0530 Subject: [PATCH] chore: remove duplicate monitor client classes (#271) --- .../v3/AlertPolicyServiceClient.java | 823 --------- .../v3/AlertPolicyServiceSettings.java | 231 --- .../monitoring/v3/GroupServiceClient.java | 987 ---------- .../monitoring/v3/GroupServiceSettings.java | 244 --- .../monitoring/v3/MetricServiceClient.java | 1492 --------------- .../monitoring/v3/MetricServiceSettings.java | 292 --- .../v3/NotificationChannelServiceClient.java | 1611 ----------------- .../NotificationChannelServiceSettings.java | 345 ---- .../v3/UptimeCheckServiceClient.java | 928 ---------- .../v3/UptimeCheckServiceSettings.java | 258 --- .../cloud/monitoring/v3/package-info.java | 121 -- .../v3/stub/AlertPolicyServiceStub.java | 71 - .../stub/AlertPolicyServiceStubSettings.java | 455 ----- .../monitoring/v3/stub/GroupServiceStub.java | 82 - .../v3/stub/GroupServiceStubSettings.java | 531 ------ ...GrpcAlertPolicyServiceCallableFactory.java | 115 -- .../v3/stub/GrpcAlertPolicyServiceStub.java | 308 ---- .../stub/GrpcGroupServiceCallableFactory.java | 115 -- .../v3/stub/GrpcGroupServiceStub.java | 327 ---- .../GrpcMetricServiceCallableFactory.java | 115 -- .../v3/stub/GrpcMetricServiceStub.java | 464 ----- ...ficationChannelServiceCallableFactory.java | 115 -- .../GrpcNotificationChannelServiceStub.java | 586 ------ ...GrpcUptimeCheckServiceCallableFactory.java | 115 -- .../v3/stub/GrpcUptimeCheckServiceStub.java | 367 ---- .../monitoring/v3/stub/MetricServiceStub.java | 110 -- .../v3/stub/MetricServiceStubSettings.java | 724 -------- .../stub/NotificationChannelServiceStub.java | 125 -- ...otificationChannelServiceStubSettings.java | 761 -------- .../v3/stub/UptimeCheckServiceStub.java | 88 - .../stub/UptimeCheckServiceStubSettings.java | 580 ------ .../v3/AlertPolicyServiceClientTest.java | 317 ---- .../monitoring/v3/GroupServiceClientTest.java | 391 ---- .../v3/MetricServiceClientTest.java | 507 ------ .../monitoring/v3/MetricServiceSmokeTest.java | 66 - .../monitoring/v3/MockAlertPolicyService.java | 57 - .../v3/MockAlertPolicyServiceImpl.java | 142 -- .../cloud/monitoring/v3/MockGroupService.java | 57 - .../monitoring/v3/MockGroupServiceImpl.java | 154 -- .../monitoring/v3/MockMetricService.java | 57 - .../monitoring/v3/MockMetricServiceImpl.java | 195 -- .../v3/MockNotificationChannelService.java | 57 - .../MockNotificationChannelServiceImpl.java | 232 --- .../monitoring/v3/MockUptimeCheckService.java | 57 - .../v3/MockUptimeCheckServiceImpl.java | 160 -- .../NotificationChannelServiceClientTest.java | 604 ------ .../v3/UptimeCheckServiceClientTest.java | 336 ---- 47 files changed, 16875 deletions(-) delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/package-info.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceCallableFactory.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceCallableFactory.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceCallableFactory.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceCallableFactory.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceCallableFactory.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java delete mode 100644 src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyService.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyServiceImpl.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockGroupService.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockGroupServiceImpl.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockMetricService.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockMetricServiceImpl.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelService.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelServiceImpl.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckService.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckServiceImpl.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java delete mode 100644 src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java diff --git a/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java b/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java deleted file mode 100644 index 6a48c01f..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java +++ /dev/null @@ -1,823 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.paging.AbstractFixedSizeCollection; -import com.google.api.gax.paging.AbstractPage; -import com.google.api.gax.paging.AbstractPagedListResponse; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStub; -import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStubSettings; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.AlertPolicyName; -import com.google.monitoring.v3.CreateAlertPolicyRequest; -import com.google.monitoring.v3.DeleteAlertPolicyRequest; -import com.google.monitoring.v3.GetAlertPolicyRequest; -import com.google.monitoring.v3.ListAlertPoliciesRequest; -import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.ProjectName; -import com.google.monitoring.v3.UpdateAlertPolicyRequest; -import com.google.protobuf.Empty; -import com.google.protobuf.FieldMask; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND SERVICE -/** - * Service Description: The AlertPolicyService API is used to manage (list, create, delete, edit) - * alert policies in Stackdriver Monitoring. An alerting policy is a description of the conditions - * under which some aspect of your system is considered to be "unhealthy" and the ways to notify - * people or services about this state. In addition to using this API, alert policies can also be - * managed through [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/), which can be - * reached by clicking the "Monitoring" tab in [Cloud Console](https://console.cloud.google.com/). - * - *

This class provides the ability to make remote calls to the backing service through method - * calls that map to API methods. Sample code to get started: - * - *

- * 
- * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
- *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
- *   AlertPolicy response = alertPolicyServiceClient.getAlertPolicy(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the alertPolicyServiceClient object to clean up resources - * such as threads. In the example above, try-with-resources is used, which automatically calls - * close(). - * - *

The surface of this class includes several types of Java methods for each of the API's - * methods: - * - *

    - *
  1. A "flattened" method. With this type of method, the fields of the request type have been - * converted into function parameters. It may be the case that not all fields are available as - * parameters, and not every API method will have a flattened method entry point. - *
  2. 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. - *
  3. 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. - * - *

Many parameters require resource names to be formatted in a particular way. To assist with - * these names, this class includes a format method for each type of name, and additionally a parse - * method to extract the individual identifiers contained within names that are returned. - * - *

This class can be customized by passing in a custom instance of AlertPolicyServiceSettings to - * create(). For example: - * - *

To customize credentials: - * - *

- * 
- * AlertPolicyServiceSettings alertPolicyServiceSettings =
- *     AlertPolicyServiceSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * AlertPolicyServiceClient alertPolicyServiceClient =
- *     AlertPolicyServiceClient.create(alertPolicyServiceSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * AlertPolicyServiceSettings alertPolicyServiceSettings =
- *     AlertPolicyServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
- * AlertPolicyServiceClient alertPolicyServiceClient =
- *     AlertPolicyServiceClient.create(alertPolicyServiceSettings);
- * 
- * 
- */ -@Generated("by gapic-generator") -public class AlertPolicyServiceClient implements BackgroundResource { - private final AlertPolicyServiceSettings settings; - private final AlertPolicyServiceStub stub; - - /** Constructs an instance of AlertPolicyServiceClient with default settings. */ - public static final AlertPolicyServiceClient create() throws IOException { - return create(AlertPolicyServiceSettings.newBuilder().build()); - } - - /** - * Constructs an instance of AlertPolicyServiceClient, using the given settings. The channels are - * created based on the settings passed in, or defaults for any settings that are not set. - */ - public static final AlertPolicyServiceClient create(AlertPolicyServiceSettings settings) - throws IOException { - return new AlertPolicyServiceClient(settings); - } - - /** - * Constructs an instance of AlertPolicyServiceClient, using the given stub for making calls. This - * is for advanced usage - prefer to use AlertPolicyServiceSettings}. - */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final AlertPolicyServiceClient create(AlertPolicyServiceStub stub) { - return new AlertPolicyServiceClient(stub); - } - - /** - * Constructs an instance of AlertPolicyServiceClient, using the given settings. This is protected - * so that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ - protected AlertPolicyServiceClient(AlertPolicyServiceSettings settings) throws IOException { - this.settings = settings; - this.stub = ((AlertPolicyServiceStubSettings) settings.getStubSettings()).createStub(); - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected AlertPolicyServiceClient(AlertPolicyServiceStub stub) { - this.settings = null; - this.stub = stub; - } - - public final AlertPolicyServiceSettings getSettings() { - return settings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public AlertPolicyServiceStub getStub() { - return stub; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing alerting policies for the project. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (AlertPolicy element : alertPolicyServiceClient.listAlertPolicies(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project whose alert policies are to be listed. The format is - *

projects/[PROJECT_ID] - *

Note that this field names the parent container in which the alerting policies to be - * listed are stored. To retrieve a single alerting policy by name, use the - * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy] operation, - * instead. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListAlertPoliciesPagedResponse listAlertPolicies(ProjectName name) { - ListAlertPoliciesRequest request = - ListAlertPoliciesRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return listAlertPolicies(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing alerting policies for the project. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (AlertPolicy element : alertPolicyServiceClient.listAlertPolicies(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project whose alert policies are to be listed. The format is - *

projects/[PROJECT_ID] - *

Note that this field names the parent container in which the alerting policies to be - * listed are stored. To retrieve a single alerting policy by name, use the - * [GetAlertPolicy][google.monitoring.v3.AlertPolicyService.GetAlertPolicy] operation, - * instead. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListAlertPoliciesPagedResponse listAlertPolicies(String name) { - ListAlertPoliciesRequest request = ListAlertPoliciesRequest.newBuilder().setName(name).build(); - return listAlertPolicies(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing alerting policies for the project. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListAlertPoliciesRequest request = ListAlertPoliciesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   for (AlertPolicy element : alertPolicyServiceClient.listAlertPolicies(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListAlertPoliciesPagedResponse listAlertPolicies(ListAlertPoliciesRequest request) { - return listAlertPoliciesPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing alerting policies for the project. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListAlertPoliciesRequest request = ListAlertPoliciesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<ListAlertPoliciesPagedResponse> future = alertPolicyServiceClient.listAlertPoliciesPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (AlertPolicy element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listAlertPoliciesPagedCallable() { - return stub.listAlertPoliciesPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing alerting policies for the project. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListAlertPoliciesRequest request = ListAlertPoliciesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   while (true) {
-   *     ListAlertPoliciesResponse response = alertPolicyServiceClient.listAlertPoliciesCallable().call(request);
-   *     for (AlertPolicy element : response.getAlertPoliciesList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listAlertPoliciesCallable() { - return stub.listAlertPoliciesCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
-   *   AlertPolicy response = alertPolicyServiceClient.getAlertPolicy(name);
-   * }
-   * 
- * - * @param name The alerting policy to retrieve. The format is - *

projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final AlertPolicy getAlertPolicy(AlertPolicyName name) { - - GetAlertPolicyRequest request = - GetAlertPolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return getAlertPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
-   *   AlertPolicy response = alertPolicyServiceClient.getAlertPolicy(name.toString());
-   * }
-   * 
- * - * @param name The alerting policy to retrieve. The format is - *

projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final AlertPolicy getAlertPolicy(String name) { - - GetAlertPolicyRequest request = GetAlertPolicyRequest.newBuilder().setName(name).build(); - return getAlertPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
-   *   GetAlertPolicyRequest request = GetAlertPolicyRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   AlertPolicy response = alertPolicyServiceClient.getAlertPolicy(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final AlertPolicy getAlertPolicy(GetAlertPolicyRequest request) { - return getAlertPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
-   *   GetAlertPolicyRequest request = GetAlertPolicyRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<AlertPolicy> future = alertPolicyServiceClient.getAlertPolicyCallable().futureCall(request);
-   *   // Do something
-   *   AlertPolicy response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable getAlertPolicyCallable() { - return stub.getAlertPolicyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
-   *   AlertPolicy response = alertPolicyServiceClient.createAlertPolicy(name, alertPolicy);
-   * }
-   * 
- * - * @param name The project in which to create the alerting policy. The format is - * `projects/[PROJECT_ID]`. - *

Note that this field names the parent container in which the alerting policy will be - * written, not the name of the created policy. The alerting policy that is returned will have - * a name that contains a normalized representation of this name as a prefix but adds a suffix - * of the form `/alertPolicies/[POLICY_ID]`, identifying the policy in the container. - * @param alertPolicy The requested alerting policy. You should omit the `name` field in this - * policy. The name will be returned in the new policy, including a new [ALERT_POLICY_ID] - * value. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final AlertPolicy createAlertPolicy(ProjectName name, AlertPolicy alertPolicy) { - - CreateAlertPolicyRequest request = - CreateAlertPolicyRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setAlertPolicy(alertPolicy) - .build(); - return createAlertPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
-   *   AlertPolicy response = alertPolicyServiceClient.createAlertPolicy(name.toString(), alertPolicy);
-   * }
-   * 
- * - * @param name The project in which to create the alerting policy. The format is - * `projects/[PROJECT_ID]`. - *

Note that this field names the parent container in which the alerting policy will be - * written, not the name of the created policy. The alerting policy that is returned will have - * a name that contains a normalized representation of this name as a prefix but adds a suffix - * of the form `/alertPolicies/[POLICY_ID]`, identifying the policy in the container. - * @param alertPolicy The requested alerting policy. You should omit the `name` field in this - * policy. The name will be returned in the new policy, including a new [ALERT_POLICY_ID] - * value. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final AlertPolicy createAlertPolicy(String name, AlertPolicy alertPolicy) { - - CreateAlertPolicyRequest request = - CreateAlertPolicyRequest.newBuilder().setName(name).setAlertPolicy(alertPolicy).build(); - return createAlertPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
-   *   CreateAlertPolicyRequest request = CreateAlertPolicyRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setAlertPolicy(alertPolicy)
-   *     .build();
-   *   AlertPolicy response = alertPolicyServiceClient.createAlertPolicy(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final AlertPolicy createAlertPolicy(CreateAlertPolicyRequest request) { - return createAlertPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
-   *   CreateAlertPolicyRequest request = CreateAlertPolicyRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setAlertPolicy(alertPolicy)
-   *     .build();
-   *   ApiFuture<AlertPolicy> future = alertPolicyServiceClient.createAlertPolicyCallable().futureCall(request);
-   *   // Do something
-   *   AlertPolicy response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable createAlertPolicyCallable() { - return stub.createAlertPolicyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
-   *   alertPolicyServiceClient.deleteAlertPolicy(name);
-   * }
-   * 
- * - * @param name The alerting policy to delete. The format is: - *

projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] - *

For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteAlertPolicy(AlertPolicyName name) { - - DeleteAlertPolicyRequest request = - DeleteAlertPolicyRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - deleteAlertPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
-   *   alertPolicyServiceClient.deleteAlertPolicy(name.toString());
-   * }
-   * 
- * - * @param name The alerting policy to delete. The format is: - *

projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID] - *

For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteAlertPolicy(String name) { - - DeleteAlertPolicyRequest request = DeleteAlertPolicyRequest.newBuilder().setName(name).build(); - deleteAlertPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
-   *   DeleteAlertPolicyRequest request = DeleteAlertPolicyRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   alertPolicyServiceClient.deleteAlertPolicy(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteAlertPolicy(DeleteAlertPolicyRequest request) { - deleteAlertPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
-   *   DeleteAlertPolicyRequest request = DeleteAlertPolicyRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = alertPolicyServiceClient.deleteAlertPolicyCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable deleteAlertPolicyCallable() { - return stub.deleteAlertPolicyCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an alerting policy. You can either replace the entire policy with a new one or replace - * only certain fields in the current alerting policy by specifying the fields to be updated via - * `updateMask`. Returns the updated alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
-   *   AlertPolicy response = alertPolicyServiceClient.updateAlertPolicy(updateMask, alertPolicy);
-   * }
-   * 
- * - * @param updateMask Optional. A list of alerting policy field names. If this field is not empty, - * each listed field in the existing alerting policy is set to the value of the corresponding - * field in the supplied policy (`alert_policy`), or to the field's default value if the field - * is not in the supplied alerting policy. Fields not listed retain their previous value. - *

Examples of valid field masks include `display_name`, `documentation`, - * `documentation.content`, `documentation.mime_type`, `user_labels`, `user_label.nameofkey`, - * `enabled`, `conditions`, `combiner`, etc. - *

If this field is empty, then the supplied alerting policy replaces the existing policy. - * It is the same as deleting the existing policy and adding the supplied policy, except for - * the following: - *

+ The new policy will have the same `[ALERT_POLICY_ID]` as the former policy. This gives - * you continuity with the former policy in your notifications and incidents. + Conditions in - * the new policy will keep their former `[CONDITION_ID]` if the supplied condition includes - * the `name` field with that `[CONDITION_ID]`. If the supplied condition omits the `name` - * field, then a new `[CONDITION_ID]` is created. - * @param alertPolicy Required. The updated alerting policy or the updated values for the fields - * listed in `update_mask`. If `update_mask` is not empty, any fields in this policy that are - * not in `update_mask` are ignored. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final AlertPolicy updateAlertPolicy(FieldMask updateMask, AlertPolicy alertPolicy) { - - UpdateAlertPolicyRequest request = - UpdateAlertPolicyRequest.newBuilder() - .setUpdateMask(updateMask) - .setAlertPolicy(alertPolicy) - .build(); - return updateAlertPolicy(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an alerting policy. You can either replace the entire policy with a new one or replace - * only certain fields in the current alerting policy by specifying the fields to be updated via - * `updateMask`. Returns the updated alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
-   *   UpdateAlertPolicyRequest request = UpdateAlertPolicyRequest.newBuilder()
-   *     .setAlertPolicy(alertPolicy)
-   *     .build();
-   *   AlertPolicy response = alertPolicyServiceClient.updateAlertPolicy(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final AlertPolicy updateAlertPolicy(UpdateAlertPolicyRequest request) { - return updateAlertPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an alerting policy. You can either replace the entire policy with a new one or replace - * only certain fields in the current alerting policy by specifying the fields to be updated via - * `updateMask`. Returns the updated alerting policy. - * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
-   *   UpdateAlertPolicyRequest request = UpdateAlertPolicyRequest.newBuilder()
-   *     .setAlertPolicy(alertPolicy)
-   *     .build();
-   *   ApiFuture<AlertPolicy> future = alertPolicyServiceClient.updateAlertPolicyCallable().futureCall(request);
-   *   // Do something
-   *   AlertPolicy response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable updateAlertPolicyCallable() { - return stub.updateAlertPolicyCallable(); - } - - @Override - public final void close() { - stub.close(); - } - - @Override - public void shutdown() { - stub.shutdown(); - } - - @Override - public boolean isShutdown() { - return stub.isShutdown(); - } - - @Override - public boolean isTerminated() { - return stub.isTerminated(); - } - - @Override - public void shutdownNow() { - stub.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return stub.awaitTermination(duration, unit); - } - - public static class ListAlertPoliciesPagedResponse - extends AbstractPagedListResponse< - ListAlertPoliciesRequest, - ListAlertPoliciesResponse, - AlertPolicy, - ListAlertPoliciesPage, - ListAlertPoliciesFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListAlertPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListAlertPoliciesPagedResponse apply(ListAlertPoliciesPage input) { - return new ListAlertPoliciesPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListAlertPoliciesPagedResponse(ListAlertPoliciesPage page) { - super(page, ListAlertPoliciesFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListAlertPoliciesPage - extends AbstractPage< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, AlertPolicy, ListAlertPoliciesPage> { - - private ListAlertPoliciesPage( - PageContext context, - ListAlertPoliciesResponse response) { - super(context, response); - } - - private static ListAlertPoliciesPage createEmptyPage() { - return new ListAlertPoliciesPage(null, null); - } - - @Override - protected ListAlertPoliciesPage createPage( - PageContext context, - ListAlertPoliciesResponse response) { - return new ListAlertPoliciesPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListAlertPoliciesFixedSizeCollection - extends AbstractFixedSizeCollection< - ListAlertPoliciesRequest, - ListAlertPoliciesResponse, - AlertPolicy, - ListAlertPoliciesPage, - ListAlertPoliciesFixedSizeCollection> { - - private ListAlertPoliciesFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListAlertPoliciesFixedSizeCollection createEmptyCollection() { - return new ListAlertPoliciesFixedSizeCollection(null, 0); - } - - @Override - protected ListAlertPoliciesFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListAlertPoliciesFixedSizeCollection(pages, collectionSize); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java b/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java deleted file mode 100644 index a324ae58..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.AlertPolicyServiceClient.ListAlertPoliciesPagedResponse; - -import com.google.api.core.ApiFunction; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientSettings; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStubSettings; -import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.CreateAlertPolicyRequest; -import com.google.monitoring.v3.DeleteAlertPolicyRequest; -import com.google.monitoring.v3.GetAlertPolicyRequest; -import com.google.monitoring.v3.ListAlertPoliciesRequest; -import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.UpdateAlertPolicyRequest; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link AlertPolicyServiceClient}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getAlertPolicy to 30 seconds: - * - *

- * 
- * AlertPolicyServiceSettings.Builder alertPolicyServiceSettingsBuilder =
- *     AlertPolicyServiceSettings.newBuilder();
- * alertPolicyServiceSettingsBuilder.getAlertPolicySettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * AlertPolicyServiceSettings alertPolicyServiceSettings = alertPolicyServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class AlertPolicyServiceSettings extends ClientSettings { - /** Returns the object with the settings used for calls to listAlertPolicies. */ - public PagedCallSettings< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, ListAlertPoliciesPagedResponse> - listAlertPoliciesSettings() { - return ((AlertPolicyServiceStubSettings) getStubSettings()).listAlertPoliciesSettings(); - } - - /** Returns the object with the settings used for calls to getAlertPolicy. */ - public UnaryCallSettings getAlertPolicySettings() { - return ((AlertPolicyServiceStubSettings) getStubSettings()).getAlertPolicySettings(); - } - - /** Returns the object with the settings used for calls to createAlertPolicy. */ - public UnaryCallSettings createAlertPolicySettings() { - return ((AlertPolicyServiceStubSettings) getStubSettings()).createAlertPolicySettings(); - } - - /** Returns the object with the settings used for calls to deleteAlertPolicy. */ - public UnaryCallSettings deleteAlertPolicySettings() { - return ((AlertPolicyServiceStubSettings) getStubSettings()).deleteAlertPolicySettings(); - } - - /** Returns the object with the settings used for calls to updateAlertPolicy. */ - public UnaryCallSettings updateAlertPolicySettings() { - return ((AlertPolicyServiceStubSettings) getStubSettings()).updateAlertPolicySettings(); - } - - public static final AlertPolicyServiceSettings create(AlertPolicyServiceStubSettings stub) - throws IOException { - return new AlertPolicyServiceSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return AlertPolicyServiceStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return AlertPolicyServiceStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return AlertPolicyServiceStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return AlertPolicyServiceStubSettings.defaultCredentialsProviderBuilder(); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return AlertPolicyServiceStubSettings.defaultGrpcTransportProviderBuilder(); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return AlertPolicyServiceStubSettings.defaultTransportChannelProvider(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return AlertPolicyServiceStubSettings.defaultApiClientHeaderProviderBuilder(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected AlertPolicyServiceSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - } - - /** Builder for AlertPolicyServiceSettings. */ - public static class Builder extends ClientSettings.Builder { - protected Builder() throws IOException { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(AlertPolicyServiceStubSettings.newBuilder(clientContext)); - } - - private static Builder createDefault() { - return new Builder(AlertPolicyServiceStubSettings.newBuilder()); - } - - protected Builder(AlertPolicyServiceSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(AlertPolicyServiceStubSettings.Builder stubSettings) { - super(stubSettings); - } - - public AlertPolicyServiceStubSettings.Builder getStubSettingsBuilder() { - return ((AlertPolicyServiceStubSettings.Builder) getStubSettings()); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods( - getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); - return this; - } - - /** Returns the builder for the settings used for calls to listAlertPolicies. */ - public PagedCallSettings.Builder< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, ListAlertPoliciesPagedResponse> - listAlertPoliciesSettings() { - return getStubSettingsBuilder().listAlertPoliciesSettings(); - } - - /** Returns the builder for the settings used for calls to getAlertPolicy. */ - public UnaryCallSettings.Builder getAlertPolicySettings() { - return getStubSettingsBuilder().getAlertPolicySettings(); - } - - /** Returns the builder for the settings used for calls to createAlertPolicy. */ - public UnaryCallSettings.Builder - createAlertPolicySettings() { - return getStubSettingsBuilder().createAlertPolicySettings(); - } - - /** Returns the builder for the settings used for calls to deleteAlertPolicy. */ - public UnaryCallSettings.Builder deleteAlertPolicySettings() { - return getStubSettingsBuilder().deleteAlertPolicySettings(); - } - - /** Returns the builder for the settings used for calls to updateAlertPolicy. */ - public UnaryCallSettings.Builder - updateAlertPolicySettings() { - return getStubSettingsBuilder().updateAlertPolicySettings(); - } - - @Override - public AlertPolicyServiceSettings build() throws IOException { - return new AlertPolicyServiceSettings(this); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java b/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java deleted file mode 100644 index de0afe01..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java +++ /dev/null @@ -1,987 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.MonitoredResource; -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.paging.AbstractFixedSizeCollection; -import com.google.api.gax.paging.AbstractPage; -import com.google.api.gax.paging.AbstractPagedListResponse; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.monitoring.v3.stub.GroupServiceStub; -import com.google.cloud.monitoring.v3.stub.GroupServiceStubSettings; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.monitoring.v3.CreateGroupRequest; -import com.google.monitoring.v3.DeleteGroupRequest; -import com.google.monitoring.v3.GetGroupRequest; -import com.google.monitoring.v3.Group; -import com.google.monitoring.v3.GroupName; -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.ProjectName; -import com.google.monitoring.v3.UpdateGroupRequest; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND SERVICE -/** - * Service Description: The Group API lets you inspect and manage your - * [groups](#google.monitoring.v3.Group). - * - *

A group is a named filter that is used to identify a collection of monitored resources. Groups - * are typically used to mirror the physical and/or logical topology of the environment. Because - * group membership is computed dynamically, monitored resources that are started in the future are - * automatically placed in matching groups. By using a group to name monitored resources in, for - * example, an alert policy, the target of that alert policy is updated automatically as monitored - * resources are added and removed from the infrastructure. - * - *

This class provides the ability to make remote calls to the backing service through method - * calls that map to API methods. Sample code to get started: - * - *

- * 
- * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
- *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
- *   Group response = groupServiceClient.getGroup(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the groupServiceClient object to clean up resources such - * as threads. In the example above, try-with-resources is used, which automatically calls close(). - * - *

The surface of this class includes several types of Java methods for each of the API's - * methods: - * - *

    - *
  1. A "flattened" method. With this type of method, the fields of the request type have been - * converted into function parameters. It may be the case that not all fields are available as - * parameters, and not every API method will have a flattened method entry point. - *
  2. 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. - *
  3. 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. - * - *

Many parameters require resource names to be formatted in a particular way. To assist with - * these names, this class includes a format method for each type of name, and additionally a parse - * method to extract the individual identifiers contained within names that are returned. - * - *

This class can be customized by passing in a custom instance of GroupServiceSettings to - * create(). For example: - * - *

To customize credentials: - * - *

- * 
- * GroupServiceSettings groupServiceSettings =
- *     GroupServiceSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * GroupServiceClient groupServiceClient =
- *     GroupServiceClient.create(groupServiceSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * GroupServiceSettings groupServiceSettings =
- *     GroupServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
- * GroupServiceClient groupServiceClient =
- *     GroupServiceClient.create(groupServiceSettings);
- * 
- * 
- */ -@Generated("by gapic-generator") -public class GroupServiceClient implements BackgroundResource { - private final GroupServiceSettings settings; - private final GroupServiceStub stub; - - /** Constructs an instance of GroupServiceClient with default settings. */ - public static final GroupServiceClient create() throws IOException { - return create(GroupServiceSettings.newBuilder().build()); - } - - /** - * Constructs an instance of GroupServiceClient, using the given settings. The channels are - * created based on the settings passed in, or defaults for any settings that are not set. - */ - public static final GroupServiceClient create(GroupServiceSettings settings) throws IOException { - return new GroupServiceClient(settings); - } - - /** - * Constructs an instance of GroupServiceClient, using the given stub for making calls. This is - * for advanced usage - prefer to use GroupServiceSettings}. - */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final GroupServiceClient create(GroupServiceStub stub) { - return new GroupServiceClient(stub); - } - - /** - * Constructs an instance of GroupServiceClient, using the given settings. This is protected so - * that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ - protected GroupServiceClient(GroupServiceSettings settings) throws IOException { - this.settings = settings; - this.stub = ((GroupServiceStubSettings) settings.getStubSettings()).createStub(); - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected GroupServiceClient(GroupServiceStub stub) { - this.settings = null; - this.stub = stub; - } - - public final GroupServiceSettings getSettings() { - return settings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public GroupServiceStub getStub() { - return stub; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing groups. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (Group element : groupServiceClient.listGroups(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project whose groups are to be listed. The format is - * `"projects/{project_id_or_number}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListGroupsPagedResponse listGroups(ProjectName name) { - ListGroupsRequest request = - ListGroupsRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return listGroups(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing groups. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (Group element : groupServiceClient.listGroups(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project whose groups are to be listed. The format is - * `"projects/{project_id_or_number}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListGroupsPagedResponse listGroups(String name) { - ListGroupsRequest request = ListGroupsRequest.newBuilder().setName(name).build(); - return listGroups(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing groups. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListGroupsRequest request = ListGroupsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   for (Group element : groupServiceClient.listGroups(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListGroupsPagedResponse listGroups(ListGroupsRequest request) { - return listGroupsPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing groups. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListGroupsRequest request = ListGroupsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<ListGroupsPagedResponse> future = groupServiceClient.listGroupsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (Group element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable listGroupsPagedCallable() { - return stub.listGroupsPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing groups. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListGroupsRequest request = ListGroupsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   while (true) {
-   *     ListGroupsResponse response = groupServiceClient.listGroupsCallable().call(request);
-   *     for (Group element : response.getGroupList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable listGroupsCallable() { - return stub.listGroupsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   Group response = groupServiceClient.getGroup(name);
-   * }
-   * 
- * - * @param name The group to retrieve. The format is - * `"projects/{project_id_or_number}/groups/{group_id}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Group getGroup(GroupName name) { - - GetGroupRequest request = - GetGroupRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return getGroup(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   Group response = groupServiceClient.getGroup(name.toString());
-   * }
-   * 
- * - * @param name The group to retrieve. The format is - * `"projects/{project_id_or_number}/groups/{group_id}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Group getGroup(String name) { - - GetGroupRequest request = GetGroupRequest.newBuilder().setName(name).build(); - return getGroup(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   GetGroupRequest request = GetGroupRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   Group response = groupServiceClient.getGroup(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Group getGroup(GetGroupRequest request) { - return getGroupCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   GetGroupRequest request = GetGroupRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Group> future = groupServiceClient.getGroupCallable().futureCall(request);
-   *   // Do something
-   *   Group response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable getGroupCallable() { - return stub.getGroupCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   Group group = Group.newBuilder().build();
-   *   Group response = groupServiceClient.createGroup(name, group);
-   * }
-   * 
- * - * @param name The project in which to create the group. The format is - * `"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. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Group createGroup(ProjectName name, Group group) { - - CreateGroupRequest request = - CreateGroupRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setGroup(group) - .build(); - return createGroup(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   Group group = Group.newBuilder().build();
-   *   Group response = groupServiceClient.createGroup(name.toString(), group);
-   * }
-   * 
- * - * @param name The project in which to create the group. The format is - * `"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. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Group createGroup(String name, Group group) { - - CreateGroupRequest request = - CreateGroupRequest.newBuilder().setName(name).setGroup(group).build(); - return createGroup(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   Group group = Group.newBuilder().build();
-   *   CreateGroupRequest request = CreateGroupRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setGroup(group)
-   *     .build();
-   *   Group response = groupServiceClient.createGroup(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Group createGroup(CreateGroupRequest request) { - return createGroupCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   Group group = Group.newBuilder().build();
-   *   CreateGroupRequest request = CreateGroupRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setGroup(group)
-   *     .build();
-   *   ApiFuture<Group> future = groupServiceClient.createGroupCallable().futureCall(request);
-   *   // Do something
-   *   Group response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable createGroupCallable() { - return stub.createGroupCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an existing group. You can change any group attributes except `name`. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   Group group = Group.newBuilder().build();
-   *   Group response = groupServiceClient.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. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - 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`. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   Group group = Group.newBuilder().build();
-   *   UpdateGroupRequest request = UpdateGroupRequest.newBuilder()
-   *     .setGroup(group)
-   *     .build();
-   *   Group response = groupServiceClient.updateGroup(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Group updateGroup(UpdateGroupRequest request) { - return updateGroupCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an existing group. You can change any group attributes except `name`. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   Group group = Group.newBuilder().build();
-   *   UpdateGroupRequest request = UpdateGroupRequest.newBuilder()
-   *     .setGroup(group)
-   *     .build();
-   *   ApiFuture<Group> future = groupServiceClient.updateGroupCallable().futureCall(request);
-   *   // Do something
-   *   Group response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable updateGroupCallable() { - return stub.updateGroupCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an existing group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   groupServiceClient.deleteGroup(name);
-   * }
-   * 
- * - * @param name The group to delete. The format is - * `"projects/{project_id_or_number}/groups/{group_id}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteGroup(GroupName name) { - - DeleteGroupRequest request = - DeleteGroupRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - deleteGroup(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an existing group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   groupServiceClient.deleteGroup(name.toString());
-   * }
-   * 
- * - * @param name The group to delete. The format is - * `"projects/{project_id_or_number}/groups/{group_id}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteGroup(String name) { - - DeleteGroupRequest request = DeleteGroupRequest.newBuilder().setName(name).build(); - deleteGroup(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an existing group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   DeleteGroupRequest request = DeleteGroupRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   groupServiceClient.deleteGroup(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteGroup(DeleteGroupRequest request) { - deleteGroupCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an existing group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   DeleteGroupRequest request = DeleteGroupRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = groupServiceClient.deleteGroupCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable deleteGroupCallable() { - return stub.deleteGroupCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the monitored resources that are members of a group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   for (MonitoredResource element : groupServiceClient.listGroupMembers(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The group whose members are listed. The format is - * `"projects/{project_id_or_number}/groups/{group_id}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListGroupMembersPagedResponse listGroupMembers(GroupName name) { - ListGroupMembersRequest request = - ListGroupMembersRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return listGroupMembers(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the monitored resources that are members of a group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   for (MonitoredResource element : groupServiceClient.listGroupMembers(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The group whose members are listed. The format is - * `"projects/{project_id_or_number}/groups/{group_id}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListGroupMembersPagedResponse listGroupMembers(String name) { - 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. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   ListGroupMembersRequest request = ListGroupMembersRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   for (MonitoredResource element : groupServiceClient.listGroupMembers(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - 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. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   ListGroupMembersRequest request = ListGroupMembersRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<ListGroupMembersPagedResponse> future = groupServiceClient.listGroupMembersPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (MonitoredResource element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listGroupMembersPagedCallable() { - return stub.listGroupMembersPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the monitored resources that are members of a group. - * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
-   *   ListGroupMembersRequest request = ListGroupMembersRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   while (true) {
-   *     ListGroupMembersResponse response = groupServiceClient.listGroupMembersCallable().call(request);
-   *     for (MonitoredResource element : response.getMembersList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listGroupMembersCallable() { - return stub.listGroupMembersCallable(); - } - - @Override - public final void close() { - stub.close(); - } - - @Override - public void shutdown() { - stub.shutdown(); - } - - @Override - public boolean isShutdown() { - return stub.isShutdown(); - } - - @Override - public boolean isTerminated() { - return stub.isTerminated(); - } - - @Override - public void shutdownNow() { - stub.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return stub.awaitTermination(duration, unit); - } - - public static class ListGroupsPagedResponse - extends AbstractPagedListResponse< - ListGroupsRequest, - ListGroupsResponse, - Group, - ListGroupsPage, - ListGroupsFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListGroupsPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListGroupsPagedResponse apply(ListGroupsPage input) { - return new ListGroupsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListGroupsPagedResponse(ListGroupsPage page) { - super(page, ListGroupsFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListGroupsPage - extends AbstractPage { - - private ListGroupsPage( - PageContext context, - ListGroupsResponse response) { - super(context, response); - } - - private static ListGroupsPage createEmptyPage() { - return new ListGroupsPage(null, null); - } - - @Override - protected ListGroupsPage createPage( - PageContext context, - ListGroupsResponse response) { - return new ListGroupsPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListGroupsFixedSizeCollection - extends AbstractFixedSizeCollection< - ListGroupsRequest, - ListGroupsResponse, - Group, - ListGroupsPage, - ListGroupsFixedSizeCollection> { - - private ListGroupsFixedSizeCollection(List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListGroupsFixedSizeCollection createEmptyCollection() { - return new ListGroupsFixedSizeCollection(null, 0); - } - - @Override - protected ListGroupsFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListGroupsFixedSizeCollection(pages, collectionSize); - } - } - - public static class ListGroupMembersPagedResponse - extends AbstractPagedListResponse< - ListGroupMembersRequest, - ListGroupMembersResponse, - MonitoredResource, - ListGroupMembersPage, - ListGroupMembersFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListGroupMembersPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListGroupMembersPagedResponse apply(ListGroupMembersPage input) { - return new ListGroupMembersPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListGroupMembersPagedResponse(ListGroupMembersPage page) { - super(page, ListGroupMembersFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListGroupMembersPage - extends AbstractPage< - ListGroupMembersRequest, - ListGroupMembersResponse, - MonitoredResource, - ListGroupMembersPage> { - - private ListGroupMembersPage( - PageContext context, - ListGroupMembersResponse response) { - super(context, response); - } - - private static ListGroupMembersPage createEmptyPage() { - return new ListGroupMembersPage(null, null); - } - - @Override - protected ListGroupMembersPage createPage( - PageContext context, - ListGroupMembersResponse response) { - return new ListGroupMembersPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListGroupMembersFixedSizeCollection - extends AbstractFixedSizeCollection< - ListGroupMembersRequest, - ListGroupMembersResponse, - MonitoredResource, - ListGroupMembersPage, - ListGroupMembersFixedSizeCollection> { - - private ListGroupMembersFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListGroupMembersFixedSizeCollection createEmptyCollection() { - return new ListGroupMembersFixedSizeCollection(null, 0); - } - - @Override - protected ListGroupMembersFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListGroupMembersFixedSizeCollection(pages, collectionSize); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java b/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java deleted file mode 100644 index 28ef4a22..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupMembersPagedResponse; -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse; - -import com.google.api.core.ApiFunction; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientSettings; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.monitoring.v3.stub.GroupServiceStubSettings; -import com.google.monitoring.v3.CreateGroupRequest; -import com.google.monitoring.v3.DeleteGroupRequest; -import com.google.monitoring.v3.GetGroupRequest; -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.UpdateGroupRequest; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link GroupServiceClient}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getGroup to 30 seconds: - * - *

- * 
- * GroupServiceSettings.Builder groupServiceSettingsBuilder =
- *     GroupServiceSettings.newBuilder();
- * groupServiceSettingsBuilder.getGroupSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * GroupServiceSettings groupServiceSettings = groupServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class GroupServiceSettings extends ClientSettings { - /** Returns the object with the settings used for calls to listGroups. */ - public PagedCallSettings - listGroupsSettings() { - return ((GroupServiceStubSettings) getStubSettings()).listGroupsSettings(); - } - - /** Returns the object with the settings used for calls to getGroup. */ - public UnaryCallSettings getGroupSettings() { - return ((GroupServiceStubSettings) getStubSettings()).getGroupSettings(); - } - - /** Returns the object with the settings used for calls to createGroup. */ - public UnaryCallSettings createGroupSettings() { - return ((GroupServiceStubSettings) getStubSettings()).createGroupSettings(); - } - - /** Returns the object with the settings used for calls to updateGroup. */ - public UnaryCallSettings updateGroupSettings() { - return ((GroupServiceStubSettings) getStubSettings()).updateGroupSettings(); - } - - /** Returns the object with the settings used for calls to deleteGroup. */ - public UnaryCallSettings deleteGroupSettings() { - return ((GroupServiceStubSettings) getStubSettings()).deleteGroupSettings(); - } - - /** Returns the object with the settings used for calls to listGroupMembers. */ - public PagedCallSettings< - ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> - listGroupMembersSettings() { - return ((GroupServiceStubSettings) getStubSettings()).listGroupMembersSettings(); - } - - public static final GroupServiceSettings create(GroupServiceStubSettings stub) - throws IOException { - return new GroupServiceSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return GroupServiceStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return GroupServiceStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return GroupServiceStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return GroupServiceStubSettings.defaultCredentialsProviderBuilder(); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return GroupServiceStubSettings.defaultGrpcTransportProviderBuilder(); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return GroupServiceStubSettings.defaultTransportChannelProvider(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return GroupServiceStubSettings.defaultApiClientHeaderProviderBuilder(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected GroupServiceSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - } - - /** Builder for GroupServiceSettings. */ - public static class Builder extends ClientSettings.Builder { - protected Builder() throws IOException { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(GroupServiceStubSettings.newBuilder(clientContext)); - } - - private static Builder createDefault() { - return new Builder(GroupServiceStubSettings.newBuilder()); - } - - protected Builder(GroupServiceSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(GroupServiceStubSettings.Builder stubSettings) { - super(stubSettings); - } - - public GroupServiceStubSettings.Builder getStubSettingsBuilder() { - return ((GroupServiceStubSettings.Builder) getStubSettings()); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods( - getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); - return this; - } - - /** Returns the builder for the settings used for calls to listGroups. */ - public PagedCallSettings.Builder - listGroupsSettings() { - return getStubSettingsBuilder().listGroupsSettings(); - } - - /** Returns the builder for the settings used for calls to getGroup. */ - public UnaryCallSettings.Builder getGroupSettings() { - return getStubSettingsBuilder().getGroupSettings(); - } - - /** Returns the builder for the settings used for calls to createGroup. */ - public UnaryCallSettings.Builder createGroupSettings() { - return getStubSettingsBuilder().createGroupSettings(); - } - - /** Returns the builder for the settings used for calls to updateGroup. */ - public UnaryCallSettings.Builder updateGroupSettings() { - return getStubSettingsBuilder().updateGroupSettings(); - } - - /** Returns the builder for the settings used for calls to deleteGroup. */ - public UnaryCallSettings.Builder deleteGroupSettings() { - return getStubSettingsBuilder().deleteGroupSettings(); - } - - /** Returns the builder for the settings used for calls to listGroupMembers. */ - public PagedCallSettings.Builder< - ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> - listGroupMembersSettings() { - return getStubSettingsBuilder().listGroupMembersSettings(); - } - - @Override - public GroupServiceSettings build() throws IOException { - return new GroupServiceSettings(this); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java b/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java deleted file mode 100644 index d5e19788..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java +++ /dev/null @@ -1,1492 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.MetricDescriptor; -import com.google.api.MonitoredResourceDescriptor; -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.paging.AbstractFixedSizeCollection; -import com.google.api.gax.paging.AbstractPage; -import com.google.api.gax.paging.AbstractPagedListResponse; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.monitoring.v3.stub.MetricServiceStub; -import com.google.cloud.monitoring.v3.stub.MetricServiceStubSettings; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.monitoring.v3.CreateMetricDescriptorRequest; -import com.google.monitoring.v3.CreateTimeSeriesRequest; -import com.google.monitoring.v3.DeleteMetricDescriptorRequest; -import com.google.monitoring.v3.GetMetricDescriptorRequest; -import com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest; -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.MetricDescriptorName; -import com.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.monitoring.v3.ProjectName; -import com.google.monitoring.v3.TimeInterval; -import com.google.monitoring.v3.TimeSeries; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND SERVICE -/** - * Service Description: Manages metric descriptors, monitored resource descriptors, and time series - * data. - * - *

This class provides the ability to make remote calls to the backing service through method - * calls that map to API methods. Sample code to get started: - * - *

- * 
- * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
- *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.of("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
- *   MonitoredResourceDescriptor response = metricServiceClient.getMonitoredResourceDescriptor(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the metricServiceClient object to clean up resources such - * as threads. In the example above, try-with-resources is used, which automatically calls close(). - * - *

The surface of this class includes several types of Java methods for each of the API's - * methods: - * - *

    - *
  1. A "flattened" method. With this type of method, the fields of the request type have been - * converted into function parameters. It may be the case that not all fields are available as - * parameters, and not every API method will have a flattened method entry point. - *
  2. 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. - *
  3. 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. - * - *

Many parameters require resource names to be formatted in a particular way. To assist with - * these names, this class includes a format method for each type of name, and additionally a parse - * method to extract the individual identifiers contained within names that are returned. - * - *

This class can be customized by passing in a custom instance of MetricServiceSettings to - * create(). For example: - * - *

To customize credentials: - * - *

- * 
- * MetricServiceSettings metricServiceSettings =
- *     MetricServiceSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * MetricServiceClient metricServiceClient =
- *     MetricServiceClient.create(metricServiceSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * MetricServiceSettings metricServiceSettings =
- *     MetricServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
- * MetricServiceClient metricServiceClient =
- *     MetricServiceClient.create(metricServiceSettings);
- * 
- * 
- */ -@Generated("by gapic-generator") -public class MetricServiceClient implements BackgroundResource { - private final MetricServiceSettings settings; - private final MetricServiceStub stub; - - /** Constructs an instance of MetricServiceClient with default settings. */ - public static final MetricServiceClient create() throws IOException { - return create(MetricServiceSettings.newBuilder().build()); - } - - /** - * Constructs an instance of MetricServiceClient, using the given settings. The channels are - * created based on the settings passed in, or defaults for any settings that are not set. - */ - public static final MetricServiceClient create(MetricServiceSettings settings) - throws IOException { - return new MetricServiceClient(settings); - } - - /** - * Constructs an instance of MetricServiceClient, using the given stub for making calls. This is - * for advanced usage - prefer to use MetricServiceSettings}. - */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final MetricServiceClient create(MetricServiceStub stub) { - return new MetricServiceClient(stub); - } - - /** - * Constructs an instance of MetricServiceClient, using the given settings. This is protected so - * that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ - protected MetricServiceClient(MetricServiceSettings settings) throws IOException { - this.settings = settings; - this.stub = ((MetricServiceStubSettings) settings.getStubSettings()).createStub(); - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected MetricServiceClient(MetricServiceStub stub) { - this.settings = null; - this.stub = stub; - } - - public final MetricServiceSettings getSettings() { - return settings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public MetricServiceStub getStub() { - return stub; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists monitored resource descriptors that match a filter. This method does not require a - * Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (MonitoredResourceDescriptor element : metricServiceClient.listMonitoredResourceDescriptors(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is - * `"projects/{project_id_or_number}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResourceDescriptors( - ProjectName name) { - ListMonitoredResourceDescriptorsRequest request = - ListMonitoredResourceDescriptorsRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return listMonitoredResourceDescriptors(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists monitored resource descriptors that match a filter. This method does not require a - * Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (MonitoredResourceDescriptor element : metricServiceClient.listMonitoredResourceDescriptors(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is - * `"projects/{project_id_or_number}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResourceDescriptors( - String name) { - ListMonitoredResourceDescriptorsRequest request = - ListMonitoredResourceDescriptorsRequest.newBuilder().setName(name).build(); - return listMonitoredResourceDescriptors(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists monitored resource descriptors that match a filter. This method does not require a - * Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   for (MonitoredResourceDescriptor element : metricServiceClient.listMonitoredResourceDescriptors(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResourceDescriptors( - ListMonitoredResourceDescriptorsRequest request) { - return listMonitoredResourceDescriptorsPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists monitored resource descriptors that match a filter. This method does not require a - * Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<ListMonitoredResourceDescriptorsPagedResponse> future = metricServiceClient.listMonitoredResourceDescriptorsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (MonitoredResourceDescriptor element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsPagedCallable() { - return stub.listMonitoredResourceDescriptorsPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists monitored resource descriptors that match a filter. This method does not require a - * Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   while (true) {
-   *     ListMonitoredResourceDescriptorsResponse response = metricServiceClient.listMonitoredResourceDescriptorsCallable().call(request);
-   *     for (MonitoredResourceDescriptor element : response.getResourceDescriptorsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> - listMonitoredResourceDescriptorsCallable() { - return stub.listMonitoredResourceDescriptorsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single monitored resource descriptor. This method does not require a Stackdriver - * account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.of("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
-   *   MonitoredResourceDescriptor response = metricServiceClient.getMonitoredResourceDescriptor(name);
-   * }
-   * 
- * - * @param name The monitored resource descriptor to get. The format is - * `"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"`. The - * `{resource_type}` is a predefined type, such as `cloudsql_database`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MonitoredResourceDescriptor getMonitoredResourceDescriptor( - MonitoredResourceDescriptorName name) { - - GetMonitoredResourceDescriptorRequest request = - GetMonitoredResourceDescriptorRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return getMonitoredResourceDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single monitored resource descriptor. This method does not require a Stackdriver - * account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.of("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
-   *   MonitoredResourceDescriptor response = metricServiceClient.getMonitoredResourceDescriptor(name.toString());
-   * }
-   * 
- * - * @param name The monitored resource descriptor to get. The format is - * `"projects/{project_id_or_number}/monitoredResourceDescriptors/{resource_type}"`. The - * `{resource_type}` is a predefined type, such as `cloudsql_database`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MonitoredResourceDescriptor getMonitoredResourceDescriptor(String name) { - - GetMonitoredResourceDescriptorRequest request = - GetMonitoredResourceDescriptorRequest.newBuilder().setName(name).build(); - return getMonitoredResourceDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single monitored resource descriptor. This method does not require a Stackdriver - * account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.of("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
-   *   GetMonitoredResourceDescriptorRequest request = GetMonitoredResourceDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   MonitoredResourceDescriptor response = metricServiceClient.getMonitoredResourceDescriptor(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MonitoredResourceDescriptor getMonitoredResourceDescriptor( - GetMonitoredResourceDescriptorRequest request) { - return getMonitoredResourceDescriptorCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single monitored resource descriptor. This method does not require a Stackdriver - * account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.of("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
-   *   GetMonitoredResourceDescriptorRequest request = GetMonitoredResourceDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<MonitoredResourceDescriptor> future = metricServiceClient.getMonitoredResourceDescriptorCallable().futureCall(request);
-   *   // Do something
-   *   MonitoredResourceDescriptor response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - getMonitoredResourceDescriptorCallable() { - return stub.getMonitoredResourceDescriptorCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists metric descriptors that match a filter. This method does not require a Stackdriver - * account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (MetricDescriptor element : metricServiceClient.listMetricDescriptors(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is - * `"projects/{project_id_or_number}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListMetricDescriptorsPagedResponse listMetricDescriptors(ProjectName name) { - ListMetricDescriptorsRequest request = - ListMetricDescriptorsRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return listMetricDescriptors(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists metric descriptors that match a filter. This method does not require a Stackdriver - * account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (MetricDescriptor element : metricServiceClient.listMetricDescriptors(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is - * `"projects/{project_id_or_number}"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListMetricDescriptorsPagedResponse listMetricDescriptors(String name) { - ListMetricDescriptorsRequest request = - ListMetricDescriptorsRequest.newBuilder().setName(name).build(); - return listMetricDescriptors(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists metric descriptors that match a filter. This method does not require a Stackdriver - * account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListMetricDescriptorsRequest request = ListMetricDescriptorsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   for (MetricDescriptor element : metricServiceClient.listMetricDescriptors(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListMetricDescriptorsPagedResponse listMetricDescriptors( - ListMetricDescriptorsRequest request) { - return listMetricDescriptorsPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists metric descriptors that match a filter. This method does not require a Stackdriver - * account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListMetricDescriptorsRequest request = ListMetricDescriptorsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<ListMetricDescriptorsPagedResponse> future = metricServiceClient.listMetricDescriptorsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (MetricDescriptor element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listMetricDescriptorsPagedCallable() { - return stub.listMetricDescriptorsPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists metric descriptors that match a filter. This method does not require a Stackdriver - * account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListMetricDescriptorsRequest request = ListMetricDescriptorsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   while (true) {
-   *     ListMetricDescriptorsResponse response = metricServiceClient.listMetricDescriptorsCallable().call(request);
-   *     for (MetricDescriptor element : response.getMetricDescriptorsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listMetricDescriptorsCallable() { - return stub.listMetricDescriptorsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single metric descriptor. This method does not require a Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   MetricDescriptor response = metricServiceClient.getMetricDescriptor(name);
-   * }
-   * 
- * - * @param name The metric descriptor on which to execute the request. The format is - * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. An example value of - * `{metric_id}` is `"compute.googleapis.com/instance/disk/read_bytes_count"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MetricDescriptor getMetricDescriptor(MetricDescriptorName name) { - - GetMetricDescriptorRequest request = - GetMetricDescriptorRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return getMetricDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single metric descriptor. This method does not require a Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   MetricDescriptor response = metricServiceClient.getMetricDescriptor(name.toString());
-   * }
-   * 
- * - * @param name The metric descriptor on which to execute the request. The format is - * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. An example value of - * `{metric_id}` is `"compute.googleapis.com/instance/disk/read_bytes_count"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MetricDescriptor getMetricDescriptor(String name) { - - GetMetricDescriptorRequest request = - GetMetricDescriptorRequest.newBuilder().setName(name).build(); - return getMetricDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single metric descriptor. This method does not require a Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   GetMetricDescriptorRequest request = GetMetricDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   MetricDescriptor response = metricServiceClient.getMetricDescriptor(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MetricDescriptor getMetricDescriptor(GetMetricDescriptorRequest request) { - return getMetricDescriptorCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single metric descriptor. This method does not require a Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   GetMetricDescriptorRequest request = GetMetricDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<MetricDescriptor> future = metricServiceClient.getMetricDescriptorCallable().futureCall(request);
-   *   // Do something
-   *   MetricDescriptor response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - getMetricDescriptorCallable() { - return stub.getMetricDescriptorCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new metric descriptor. User-created metric descriptors define [custom - * metrics](/monitoring/custom-metrics). - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
-   *   MetricDescriptor response = metricServiceClient.createMetricDescriptor(name, metricDescriptor);
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is - * `"projects/{project_id_or_number}"`. - * @param metricDescriptor The new [custom metric](/monitoring/custom-metrics) descriptor. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MetricDescriptor createMetricDescriptor( - ProjectName name, MetricDescriptor metricDescriptor) { - - CreateMetricDescriptorRequest request = - CreateMetricDescriptorRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setMetricDescriptor(metricDescriptor) - .build(); - return createMetricDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new metric descriptor. User-created metric descriptors define [custom - * metrics](/monitoring/custom-metrics). - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
-   *   MetricDescriptor response = metricServiceClient.createMetricDescriptor(name.toString(), metricDescriptor);
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is - * `"projects/{project_id_or_number}"`. - * @param metricDescriptor The new [custom metric](/monitoring/custom-metrics) descriptor. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MetricDescriptor createMetricDescriptor( - String name, MetricDescriptor metricDescriptor) { - - CreateMetricDescriptorRequest request = - CreateMetricDescriptorRequest.newBuilder() - .setName(name) - .setMetricDescriptor(metricDescriptor) - .build(); - return createMetricDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new metric descriptor. User-created metric descriptors define [custom - * metrics](/monitoring/custom-metrics). - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
-   *   CreateMetricDescriptorRequest request = CreateMetricDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setMetricDescriptor(metricDescriptor)
-   *     .build();
-   *   MetricDescriptor response = metricServiceClient.createMetricDescriptor(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final MetricDescriptor createMetricDescriptor(CreateMetricDescriptorRequest request) { - return createMetricDescriptorCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new metric descriptor. User-created metric descriptors define [custom - * metrics](/monitoring/custom-metrics). - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
-   *   CreateMetricDescriptorRequest request = CreateMetricDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setMetricDescriptor(metricDescriptor)
-   *     .build();
-   *   ApiFuture<MetricDescriptor> future = metricServiceClient.createMetricDescriptorCallable().futureCall(request);
-   *   // Do something
-   *   MetricDescriptor response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - createMetricDescriptorCallable() { - return stub.createMetricDescriptorCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a metric descriptor. Only user-created [custom metrics](/monitoring/custom-metrics) can - * be deleted. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   metricServiceClient.deleteMetricDescriptor(name);
-   * }
-   * 
- * - * @param name The metric descriptor on which to execute the request. The format is - * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. An example of - * `{metric_id}` is: `"custom.googleapis.com/my_test_metric"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteMetricDescriptor(MetricDescriptorName name) { - - DeleteMetricDescriptorRequest request = - DeleteMetricDescriptorRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - deleteMetricDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a metric descriptor. Only user-created [custom metrics](/monitoring/custom-metrics) can - * be deleted. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   metricServiceClient.deleteMetricDescriptor(name.toString());
-   * }
-   * 
- * - * @param name The metric descriptor on which to execute the request. The format is - * `"projects/{project_id_or_number}/metricDescriptors/{metric_id}"`. An example of - * `{metric_id}` is: `"custom.googleapis.com/my_test_metric"`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteMetricDescriptor(String name) { - - DeleteMetricDescriptorRequest request = - DeleteMetricDescriptorRequest.newBuilder().setName(name).build(); - deleteMetricDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a metric descriptor. Only user-created [custom metrics](/monitoring/custom-metrics) can - * be deleted. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   DeleteMetricDescriptorRequest request = DeleteMetricDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   metricServiceClient.deleteMetricDescriptor(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteMetricDescriptor(DeleteMetricDescriptorRequest request) { - deleteMetricDescriptorCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a metric descriptor. Only user-created [custom metrics](/monitoring/custom-metrics) can - * be deleted. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   DeleteMetricDescriptorRequest request = DeleteMetricDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = metricServiceClient.deleteMetricDescriptorCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable - deleteMetricDescriptorCallable() { - return stub.deleteMetricDescriptorCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists time series that match a filter. This method does not require a Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   String filter = "";
-   *   TimeInterval interval = TimeInterval.newBuilder().build();
-   *   ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
-   *   for (TimeSeries element : metricServiceClient.listTimeSeries(name, filter, interval, view).iterateAll()) {
-   *     // 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.labels.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.rpc.ApiException if the remote call fails - */ - public final ListTimeSeriesPagedResponse listTimeSeries( - ProjectName name, - String filter, - TimeInterval interval, - ListTimeSeriesRequest.TimeSeriesView view) { - ListTimeSeriesRequest request = - ListTimeSeriesRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .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 (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   String filter = "";
-   *   TimeInterval interval = TimeInterval.newBuilder().build();
-   *   ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
-   *   for (TimeSeries element : metricServiceClient.listTimeSeries(name.toString(), filter, interval, view).iterateAll()) {
-   *     // 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.labels.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.rpc.ApiException if the remote call fails - */ - public final ListTimeSeriesPagedResponse listTimeSeries( - String name, - String filter, - TimeInterval interval, - ListTimeSeriesRequest.TimeSeriesView view) { - 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 (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   String filter = "";
-   *   TimeInterval interval = TimeInterval.newBuilder().build();
-   *   ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
-   *   ListTimeSeriesRequest request = ListTimeSeriesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setFilter(filter)
-   *     .setInterval(interval)
-   *     .setView(view)
-   *     .build();
-   *   for (TimeSeries element : metricServiceClient.listTimeSeries(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListTimeSeriesPagedResponse listTimeSeries(ListTimeSeriesRequest request) { - return listTimeSeriesPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists time series that match a filter. This method does not require a Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   String filter = "";
-   *   TimeInterval interval = TimeInterval.newBuilder().build();
-   *   ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
-   *   ListTimeSeriesRequest request = ListTimeSeriesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setFilter(filter)
-   *     .setInterval(interval)
-   *     .setView(view)
-   *     .build();
-   *   ApiFuture<ListTimeSeriesPagedResponse> future = metricServiceClient.listTimeSeriesPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (TimeSeries element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listTimeSeriesPagedCallable() { - return stub.listTimeSeriesPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists time series that match a filter. This method does not require a Stackdriver account. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   String filter = "";
-   *   TimeInterval interval = TimeInterval.newBuilder().build();
-   *   ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
-   *   ListTimeSeriesRequest request = ListTimeSeriesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setFilter(filter)
-   *     .setInterval(interval)
-   *     .setView(view)
-   *     .build();
-   *   while (true) {
-   *     ListTimeSeriesResponse response = metricServiceClient.listTimeSeriesCallable().call(request);
-   *     for (TimeSeries element : response.getTimeSeriesList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listTimeSeriesCallable() { - return stub.listTimeSeriesCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates or adds data to one or more time series. The response is empty if all time series in - * the request were written. If any time series could not be written, a corresponding failure - * message is included in the error response. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   List<TimeSeries> timeSeries = new ArrayList<>();
-   *   metricServiceClient.createTimeSeries(name, timeSeries);
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is - * `"projects/{project_id_or_number}"`. - * @param timeSeries The new data to be added to a list of time series. Adds at most one data - * point to each of several time series. The new data point must be more recent than any other - * point in its time series. Each `TimeSeries` value must fully specify a unique time series - * by supplying all label values for the metric and the monitored resource. - *

The maximum number of `TimeSeries` objects per `Create` request is 200. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void createTimeSeries(ProjectName name, List timeSeries) { - - CreateTimeSeriesRequest request = - CreateTimeSeriesRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .addAllTimeSeries(timeSeries) - .build(); - createTimeSeries(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates or adds data to one or more time series. The response is empty if all time series in - * the request were written. If any time series could not be written, a corresponding failure - * message is included in the error response. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   List<TimeSeries> timeSeries = new ArrayList<>();
-   *   metricServiceClient.createTimeSeries(name.toString(), timeSeries);
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is - * `"projects/{project_id_or_number}"`. - * @param timeSeries The new data to be added to a list of time series. Adds at most one data - * point to each of several time series. The new data point must be more recent than any other - * point in its time series. Each `TimeSeries` value must fully specify a unique time series - * by supplying all label values for the metric and the monitored resource. - *

The maximum number of `TimeSeries` objects per `Create` request is 200. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void createTimeSeries(String name, List timeSeries) { - - CreateTimeSeriesRequest request = - CreateTimeSeriesRequest.newBuilder().setName(name).addAllTimeSeries(timeSeries).build(); - createTimeSeries(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates or adds data to one or more time series. The response is empty if all time series in - * the request were written. If any time series could not be written, a corresponding failure - * message is included in the error response. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   List<TimeSeries> timeSeries = new ArrayList<>();
-   *   CreateTimeSeriesRequest request = CreateTimeSeriesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .addAllTimeSeries(timeSeries)
-   *     .build();
-   *   metricServiceClient.createTimeSeries(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void createTimeSeries(CreateTimeSeriesRequest request) { - createTimeSeriesCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates or adds data to one or more time series. The response is empty if all time series in - * the request were written. If any time series could not be written, a corresponding failure - * message is included in the error response. - * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   List<TimeSeries> timeSeries = new ArrayList<>();
-   *   CreateTimeSeriesRequest request = CreateTimeSeriesRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .addAllTimeSeries(timeSeries)
-   *     .build();
-   *   ApiFuture<Void> future = metricServiceClient.createTimeSeriesCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable createTimeSeriesCallable() { - return stub.createTimeSeriesCallable(); - } - - @Override - public final void close() { - stub.close(); - } - - @Override - public void shutdown() { - stub.shutdown(); - } - - @Override - public boolean isShutdown() { - return stub.isShutdown(); - } - - @Override - public boolean isTerminated() { - return stub.isTerminated(); - } - - @Override - public void shutdownNow() { - stub.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return stub.awaitTermination(duration, unit); - } - - public static class ListMonitoredResourceDescriptorsPagedResponse - extends AbstractPagedListResponse< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor, - ListMonitoredResourceDescriptorsPage, - ListMonitoredResourceDescriptorsFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> - context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListMonitoredResourceDescriptorsPage.createEmptyPage() - .createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction< - ListMonitoredResourceDescriptorsPage, - ListMonitoredResourceDescriptorsPagedResponse>() { - @Override - public ListMonitoredResourceDescriptorsPagedResponse apply( - ListMonitoredResourceDescriptorsPage input) { - return new ListMonitoredResourceDescriptorsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListMonitoredResourceDescriptorsPagedResponse( - ListMonitoredResourceDescriptorsPage page) { - super(page, ListMonitoredResourceDescriptorsFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListMonitoredResourceDescriptorsPage - extends AbstractPage< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor, - ListMonitoredResourceDescriptorsPage> { - - private ListMonitoredResourceDescriptorsPage( - PageContext< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> - context, - ListMonitoredResourceDescriptorsResponse response) { - super(context, response); - } - - private static ListMonitoredResourceDescriptorsPage createEmptyPage() { - return new ListMonitoredResourceDescriptorsPage(null, null); - } - - @Override - protected ListMonitoredResourceDescriptorsPage createPage( - PageContext< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> - context, - ListMonitoredResourceDescriptorsResponse response) { - return new ListMonitoredResourceDescriptorsPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> - context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListMonitoredResourceDescriptorsFixedSizeCollection - extends AbstractFixedSizeCollection< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor, - ListMonitoredResourceDescriptorsPage, - ListMonitoredResourceDescriptorsFixedSizeCollection> { - - private ListMonitoredResourceDescriptorsFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListMonitoredResourceDescriptorsFixedSizeCollection createEmptyCollection() { - return new ListMonitoredResourceDescriptorsFixedSizeCollection(null, 0); - } - - @Override - protected ListMonitoredResourceDescriptorsFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListMonitoredResourceDescriptorsFixedSizeCollection(pages, collectionSize); - } - } - - public static class ListMetricDescriptorsPagedResponse - extends AbstractPagedListResponse< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - MetricDescriptor, - ListMetricDescriptorsPage, - ListMetricDescriptorsFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext - context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListMetricDescriptorsPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListMetricDescriptorsPagedResponse apply(ListMetricDescriptorsPage input) { - return new ListMetricDescriptorsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListMetricDescriptorsPagedResponse(ListMetricDescriptorsPage page) { - super(page, ListMetricDescriptorsFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListMetricDescriptorsPage - extends AbstractPage< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - MetricDescriptor, - ListMetricDescriptorsPage> { - - private ListMetricDescriptorsPage( - PageContext - context, - ListMetricDescriptorsResponse response) { - super(context, response); - } - - private static ListMetricDescriptorsPage createEmptyPage() { - return new ListMetricDescriptorsPage(null, null); - } - - @Override - protected ListMetricDescriptorsPage createPage( - PageContext - context, - ListMetricDescriptorsResponse response) { - return new ListMetricDescriptorsPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext - context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListMetricDescriptorsFixedSizeCollection - extends AbstractFixedSizeCollection< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - MetricDescriptor, - ListMetricDescriptorsPage, - ListMetricDescriptorsFixedSizeCollection> { - - private ListMetricDescriptorsFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListMetricDescriptorsFixedSizeCollection createEmptyCollection() { - return new ListMetricDescriptorsFixedSizeCollection(null, 0); - } - - @Override - protected ListMetricDescriptorsFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListMetricDescriptorsFixedSizeCollection(pages, collectionSize); - } - } - - public static class ListTimeSeriesPagedResponse - extends AbstractPagedListResponse< - ListTimeSeriesRequest, - ListTimeSeriesResponse, - TimeSeries, - ListTimeSeriesPage, - ListTimeSeriesFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListTimeSeriesPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListTimeSeriesPagedResponse apply(ListTimeSeriesPage input) { - return new ListTimeSeriesPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListTimeSeriesPagedResponse(ListTimeSeriesPage page) { - super(page, ListTimeSeriesFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListTimeSeriesPage - extends AbstractPage< - ListTimeSeriesRequest, ListTimeSeriesResponse, TimeSeries, ListTimeSeriesPage> { - - private ListTimeSeriesPage( - PageContext context, - ListTimeSeriesResponse response) { - super(context, response); - } - - private static ListTimeSeriesPage createEmptyPage() { - return new ListTimeSeriesPage(null, null); - } - - @Override - protected ListTimeSeriesPage createPage( - PageContext context, - ListTimeSeriesResponse response) { - return new ListTimeSeriesPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListTimeSeriesFixedSizeCollection - extends AbstractFixedSizeCollection< - ListTimeSeriesRequest, - ListTimeSeriesResponse, - TimeSeries, - ListTimeSeriesPage, - ListTimeSeriesFixedSizeCollection> { - - private ListTimeSeriesFixedSizeCollection(List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListTimeSeriesFixedSizeCollection createEmptyCollection() { - return new ListTimeSeriesFixedSizeCollection(null, 0); - } - - @Override - protected ListTimeSeriesFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListTimeSeriesFixedSizeCollection(pages, collectionSize); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java b/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java deleted file mode 100644 index a9be3cda..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMetricDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse; - -import com.google.api.MetricDescriptor; -import com.google.api.MonitoredResourceDescriptor; -import com.google.api.core.ApiFunction; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientSettings; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.monitoring.v3.stub.MetricServiceStubSettings; -import com.google.monitoring.v3.CreateMetricDescriptorRequest; -import com.google.monitoring.v3.CreateTimeSeriesRequest; -import com.google.monitoring.v3.DeleteMetricDescriptorRequest; -import com.google.monitoring.v3.GetMetricDescriptorRequest; -import com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest; -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.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link MetricServiceClient}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getMonitoredResourceDescriptor to 30 seconds: - * - *

- * 
- * MetricServiceSettings.Builder metricServiceSettingsBuilder =
- *     MetricServiceSettings.newBuilder();
- * metricServiceSettingsBuilder.getMonitoredResourceDescriptorSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * MetricServiceSettings metricServiceSettings = metricServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class MetricServiceSettings extends ClientSettings { - /** Returns the object with the settings used for calls to listMonitoredResourceDescriptors. */ - public PagedCallSettings< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsSettings() { - return ((MetricServiceStubSettings) getStubSettings()) - .listMonitoredResourceDescriptorsSettings(); - } - - /** Returns the object with the settings used for calls to getMonitoredResourceDescriptor. */ - public UnaryCallSettings - getMonitoredResourceDescriptorSettings() { - return ((MetricServiceStubSettings) getStubSettings()).getMonitoredResourceDescriptorSettings(); - } - - /** Returns the object with the settings used for calls to listMetricDescriptors. */ - public PagedCallSettings< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - ListMetricDescriptorsPagedResponse> - listMetricDescriptorsSettings() { - return ((MetricServiceStubSettings) getStubSettings()).listMetricDescriptorsSettings(); - } - - /** Returns the object with the settings used for calls to getMetricDescriptor. */ - public UnaryCallSettings - getMetricDescriptorSettings() { - return ((MetricServiceStubSettings) getStubSettings()).getMetricDescriptorSettings(); - } - - /** Returns the object with the settings used for calls to createMetricDescriptor. */ - public UnaryCallSettings - createMetricDescriptorSettings() { - return ((MetricServiceStubSettings) getStubSettings()).createMetricDescriptorSettings(); - } - - /** Returns the object with the settings used for calls to deleteMetricDescriptor. */ - public UnaryCallSettings deleteMetricDescriptorSettings() { - return ((MetricServiceStubSettings) getStubSettings()).deleteMetricDescriptorSettings(); - } - - /** Returns the object with the settings used for calls to listTimeSeries. */ - public PagedCallSettings< - ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> - listTimeSeriesSettings() { - return ((MetricServiceStubSettings) getStubSettings()).listTimeSeriesSettings(); - } - - /** Returns the object with the settings used for calls to createTimeSeries. */ - public UnaryCallSettings createTimeSeriesSettings() { - return ((MetricServiceStubSettings) getStubSettings()).createTimeSeriesSettings(); - } - - public static final MetricServiceSettings create(MetricServiceStubSettings stub) - throws IOException { - return new MetricServiceSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return MetricServiceStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return MetricServiceStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return MetricServiceStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return MetricServiceStubSettings.defaultCredentialsProviderBuilder(); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return MetricServiceStubSettings.defaultGrpcTransportProviderBuilder(); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return MetricServiceStubSettings.defaultTransportChannelProvider(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return MetricServiceStubSettings.defaultApiClientHeaderProviderBuilder(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected MetricServiceSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - } - - /** Builder for MetricServiceSettings. */ - public static class Builder extends ClientSettings.Builder { - protected Builder() throws IOException { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(MetricServiceStubSettings.newBuilder(clientContext)); - } - - private static Builder createDefault() { - return new Builder(MetricServiceStubSettings.newBuilder()); - } - - protected Builder(MetricServiceSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(MetricServiceStubSettings.Builder stubSettings) { - super(stubSettings); - } - - public MetricServiceStubSettings.Builder getStubSettingsBuilder() { - return ((MetricServiceStubSettings.Builder) getStubSettings()); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods( - getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); - return this; - } - - /** Returns the builder for the settings used for calls to listMonitoredResourceDescriptors. */ - public PagedCallSettings.Builder< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsSettings() { - return getStubSettingsBuilder().listMonitoredResourceDescriptorsSettings(); - } - - /** Returns the builder for the settings used for calls to getMonitoredResourceDescriptor. */ - public UnaryCallSettings.Builder< - GetMonitoredResourceDescriptorRequest, MonitoredResourceDescriptor> - getMonitoredResourceDescriptorSettings() { - return getStubSettingsBuilder().getMonitoredResourceDescriptorSettings(); - } - - /** Returns the builder for the settings used for calls to listMetricDescriptors. */ - public PagedCallSettings.Builder< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - ListMetricDescriptorsPagedResponse> - listMetricDescriptorsSettings() { - return getStubSettingsBuilder().listMetricDescriptorsSettings(); - } - - /** Returns the builder for the settings used for calls to getMetricDescriptor. */ - public UnaryCallSettings.Builder - getMetricDescriptorSettings() { - return getStubSettingsBuilder().getMetricDescriptorSettings(); - } - - /** Returns the builder for the settings used for calls to createMetricDescriptor. */ - public UnaryCallSettings.Builder - createMetricDescriptorSettings() { - return getStubSettingsBuilder().createMetricDescriptorSettings(); - } - - /** Returns the builder for the settings used for calls to deleteMetricDescriptor. */ - public UnaryCallSettings.Builder - deleteMetricDescriptorSettings() { - return getStubSettingsBuilder().deleteMetricDescriptorSettings(); - } - - /** Returns the builder for the settings used for calls to listTimeSeries. */ - public PagedCallSettings.Builder< - ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> - listTimeSeriesSettings() { - return getStubSettingsBuilder().listTimeSeriesSettings(); - } - - /** Returns the builder for the settings used for calls to createTimeSeries. */ - public UnaryCallSettings.Builder createTimeSeriesSettings() { - return getStubSettingsBuilder().createTimeSeriesSettings(); - } - - @Override - public MetricServiceSettings build() throws IOException { - return new MetricServiceSettings(this); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java b/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java deleted file mode 100644 index 49df0842..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java +++ /dev/null @@ -1,1611 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.paging.AbstractFixedSizeCollection; -import com.google.api.gax.paging.AbstractPage; -import com.google.api.gax.paging.AbstractPagedListResponse; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.monitoring.v3.stub.NotificationChannelServiceStub; -import com.google.cloud.monitoring.v3.stub.NotificationChannelServiceStubSettings; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.monitoring.v3.CreateNotificationChannelRequest; -import com.google.monitoring.v3.DeleteNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelDescriptorRequest; -import com.google.monitoring.v3.GetNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsRequest; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsResponse; -import com.google.monitoring.v3.ListNotificationChannelsRequest; -import com.google.monitoring.v3.ListNotificationChannelsResponse; -import com.google.monitoring.v3.NotificationChannel; -import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.monitoring.v3.NotificationChannelName; -import com.google.monitoring.v3.ProjectName; -import com.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.UpdateNotificationChannelRequest; -import com.google.monitoring.v3.VerifyNotificationChannelRequest; -import com.google.protobuf.Empty; -import com.google.protobuf.FieldMask; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND SERVICE -/** - * Service Description: The Notification Channel API provides access to configuration that controls - * how messages related to incidents are sent. - * - *

This class provides the ability to make remote calls to the backing service through method - * calls that map to API methods. Sample code to get started: - * - *

- * 
- * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
- *   NotificationChannelDescriptorName name = NotificationChannelDescriptorName.of("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
- *   NotificationChannelDescriptor response = notificationChannelServiceClient.getNotificationChannelDescriptor(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the notificationChannelServiceClient object to clean up - * resources such as threads. In the example above, try-with-resources is used, which automatically - * calls close(). - * - *

The surface of this class includes several types of Java methods for each of the API's - * methods: - * - *

    - *
  1. A "flattened" method. With this type of method, the fields of the request type have been - * converted into function parameters. It may be the case that not all fields are available as - * parameters, and not every API method will have a flattened method entry point. - *
  2. 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. - *
  3. 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. - * - *

Many parameters require resource names to be formatted in a particular way. To assist with - * these names, this class includes a format method for each type of name, and additionally a parse - * method to extract the individual identifiers contained within names that are returned. - * - *

This class can be customized by passing in a custom instance of - * NotificationChannelServiceSettings to create(). For example: - * - *

To customize credentials: - * - *

- * 
- * NotificationChannelServiceSettings notificationChannelServiceSettings =
- *     NotificationChannelServiceSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * NotificationChannelServiceClient notificationChannelServiceClient =
- *     NotificationChannelServiceClient.create(notificationChannelServiceSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * NotificationChannelServiceSettings notificationChannelServiceSettings =
- *     NotificationChannelServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
- * NotificationChannelServiceClient notificationChannelServiceClient =
- *     NotificationChannelServiceClient.create(notificationChannelServiceSettings);
- * 
- * 
- */ -@Generated("by gapic-generator") -public class NotificationChannelServiceClient implements BackgroundResource { - private final NotificationChannelServiceSettings settings; - private final NotificationChannelServiceStub stub; - - /** Constructs an instance of NotificationChannelServiceClient with default settings. */ - public static final NotificationChannelServiceClient create() throws IOException { - return create(NotificationChannelServiceSettings.newBuilder().build()); - } - - /** - * Constructs an instance of NotificationChannelServiceClient, using the given settings. The - * channels are created based on the settings passed in, or defaults for any settings that are not - * set. - */ - public static final NotificationChannelServiceClient create( - NotificationChannelServiceSettings settings) throws IOException { - return new NotificationChannelServiceClient(settings); - } - - /** - * Constructs an instance of NotificationChannelServiceClient, using the given stub for making - * calls. This is for advanced usage - prefer to use NotificationChannelServiceSettings}. - */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final NotificationChannelServiceClient create(NotificationChannelServiceStub stub) { - return new NotificationChannelServiceClient(stub); - } - - /** - * Constructs an instance of NotificationChannelServiceClient, using the given settings. This is - * protected so that it is easy to make a subclass, but otherwise, the static factory methods - * should be preferred. - */ - protected NotificationChannelServiceClient(NotificationChannelServiceSettings settings) - throws IOException { - this.settings = settings; - this.stub = ((NotificationChannelServiceStubSettings) settings.getStubSettings()).createStub(); - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected NotificationChannelServiceClient(NotificationChannelServiceStub stub) { - this.settings = null; - this.stub = stub; - } - - public final NotificationChannelServiceSettings getSettings() { - return settings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public NotificationChannelServiceStub getStub() { - return stub; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the descriptors for supported channel types. The use of descriptors makes it possible for - * new channel types to be dynamically added. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (NotificationChannelDescriptor element : notificationChannelServiceClient.listNotificationChannelDescriptors(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The REST resource name of the parent from which to retrieve the notification - * channel descriptors. The expected syntax is: - *

projects/[PROJECT_ID] - *

Note that this names the parent container in which to look for the descriptors; to - * retrieve a single descriptor by name, use the - * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] - * operation, instead. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListNotificationChannelDescriptorsPagedResponse listNotificationChannelDescriptors( - ProjectName name) { - ListNotificationChannelDescriptorsRequest request = - ListNotificationChannelDescriptorsRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return listNotificationChannelDescriptors(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the descriptors for supported channel types. The use of descriptors makes it possible for - * new channel types to be dynamically added. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (NotificationChannelDescriptor element : notificationChannelServiceClient.listNotificationChannelDescriptors(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The REST resource name of the parent from which to retrieve the notification - * channel descriptors. The expected syntax is: - *

projects/[PROJECT_ID] - *

Note that this names the parent container in which to look for the descriptors; to - * retrieve a single descriptor by name, use the - * [GetNotificationChannelDescriptor][google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor] - * operation, instead. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListNotificationChannelDescriptorsPagedResponse listNotificationChannelDescriptors( - String name) { - ListNotificationChannelDescriptorsRequest request = - ListNotificationChannelDescriptorsRequest.newBuilder().setName(name).build(); - return listNotificationChannelDescriptors(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the descriptors for supported channel types. The use of descriptors makes it possible for - * new channel types to be dynamically added. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListNotificationChannelDescriptorsRequest request = ListNotificationChannelDescriptorsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   for (NotificationChannelDescriptor element : notificationChannelServiceClient.listNotificationChannelDescriptors(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListNotificationChannelDescriptorsPagedResponse listNotificationChannelDescriptors( - ListNotificationChannelDescriptorsRequest request) { - return listNotificationChannelDescriptorsPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the descriptors for supported channel types. The use of descriptors makes it possible for - * new channel types to be dynamically added. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListNotificationChannelDescriptorsRequest request = ListNotificationChannelDescriptorsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<ListNotificationChannelDescriptorsPagedResponse> future = notificationChannelServiceClient.listNotificationChannelDescriptorsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (NotificationChannelDescriptor element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsPagedCallable() { - return stub.listNotificationChannelDescriptorsPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the descriptors for supported channel types. The use of descriptors makes it possible for - * new channel types to be dynamically added. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListNotificationChannelDescriptorsRequest request = ListNotificationChannelDescriptorsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   while (true) {
-   *     ListNotificationChannelDescriptorsResponse response = notificationChannelServiceClient.listNotificationChannelDescriptorsCallable().call(request);
-   *     for (NotificationChannelDescriptor element : response.getChannelDescriptorsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable< - ListNotificationChannelDescriptorsRequest, ListNotificationChannelDescriptorsResponse> - listNotificationChannelDescriptorsCallable() { - return stub.listNotificationChannelDescriptorsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single channel descriptor. The descriptor indicates which fields are expected / - * permitted for a notification channel of the given type. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelDescriptorName name = NotificationChannelDescriptorName.of("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
-   *   NotificationChannelDescriptor response = notificationChannelServiceClient.getNotificationChannelDescriptor(name);
-   * }
-   * 
- * - * @param name The channel type for which to execute the request. The format is - * `projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannelDescriptor getNotificationChannelDescriptor( - NotificationChannelDescriptorName name) { - - GetNotificationChannelDescriptorRequest request = - GetNotificationChannelDescriptorRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return getNotificationChannelDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single channel descriptor. The descriptor indicates which fields are expected / - * permitted for a notification channel of the given type. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelDescriptorName name = NotificationChannelDescriptorName.of("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
-   *   NotificationChannelDescriptor response = notificationChannelServiceClient.getNotificationChannelDescriptor(name.toString());
-   * }
-   * 
- * - * @param name The channel type for which to execute the request. The format is - * `projects/[PROJECT_ID]/notificationChannelDescriptors/{channel_type}`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannelDescriptor getNotificationChannelDescriptor(String name) { - - GetNotificationChannelDescriptorRequest request = - GetNotificationChannelDescriptorRequest.newBuilder().setName(name).build(); - return getNotificationChannelDescriptor(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single channel descriptor. The descriptor indicates which fields are expected / - * permitted for a notification channel of the given type. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelDescriptorName name = NotificationChannelDescriptorName.of("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
-   *   GetNotificationChannelDescriptorRequest request = GetNotificationChannelDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   NotificationChannelDescriptor response = notificationChannelServiceClient.getNotificationChannelDescriptor(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannelDescriptor getNotificationChannelDescriptor( - GetNotificationChannelDescriptorRequest request) { - return getNotificationChannelDescriptorCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single channel descriptor. The descriptor indicates which fields are expected / - * permitted for a notification channel of the given type. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelDescriptorName name = NotificationChannelDescriptorName.of("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
-   *   GetNotificationChannelDescriptorRequest request = GetNotificationChannelDescriptorRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<NotificationChannelDescriptor> future = notificationChannelServiceClient.getNotificationChannelDescriptorCallable().futureCall(request);
-   *   // Do something
-   *   NotificationChannelDescriptor response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - getNotificationChannelDescriptorCallable() { - return stub.getNotificationChannelDescriptorCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the notification channels that have been created for the project. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (NotificationChannel element : notificationChannelServiceClient.listNotificationChannels(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is `projects/[PROJECT_ID]`. - * That is, this names the container in which to look for the notification channels; it does - * not name a specific channel. To query a specific channel by REST resource name, use the - * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] - * operation. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListNotificationChannelsPagedResponse listNotificationChannels(ProjectName name) { - ListNotificationChannelsRequest request = - ListNotificationChannelsRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return listNotificationChannels(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the notification channels that have been created for the project. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   for (NotificationChannel element : notificationChannelServiceClient.listNotificationChannels(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is `projects/[PROJECT_ID]`. - * That is, this names the container in which to look for the notification channels; it does - * not name a specific channel. To query a specific channel by REST resource name, use the - * [`GetNotificationChannel`][google.monitoring.v3.NotificationChannelService.GetNotificationChannel] - * operation. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListNotificationChannelsPagedResponse listNotificationChannels(String name) { - ListNotificationChannelsRequest request = - ListNotificationChannelsRequest.newBuilder().setName(name).build(); - return listNotificationChannels(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the notification channels that have been created for the project. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListNotificationChannelsRequest request = ListNotificationChannelsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   for (NotificationChannel element : notificationChannelServiceClient.listNotificationChannels(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListNotificationChannelsPagedResponse listNotificationChannels( - ListNotificationChannelsRequest request) { - return listNotificationChannelsPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the notification channels that have been created for the project. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListNotificationChannelsRequest request = ListNotificationChannelsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<ListNotificationChannelsPagedResponse> future = notificationChannelServiceClient.listNotificationChannelsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (NotificationChannel element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listNotificationChannelsPagedCallable() { - return stub.listNotificationChannelsPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the notification channels that have been created for the project. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   ListNotificationChannelsRequest request = ListNotificationChannelsRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   while (true) {
-   *     ListNotificationChannelsResponse response = notificationChannelServiceClient.listNotificationChannelsCallable().call(request);
-   *     for (NotificationChannel element : response.getNotificationChannelsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listNotificationChannelsCallable() { - return stub.listNotificationChannelsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single notification channel. The channel includes the relevant configuration details - * with which the channel was created. However, the response may truncate or omit passwords, API - * keys, or other private key matter and thus the response may not be 100% identical to the - * information that was supplied in the call to the create method. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   NotificationChannel response = notificationChannelServiceClient.getNotificationChannel(name);
-   * }
-   * 
- * - * @param name The channel for which to execute the request. The format is - * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel getNotificationChannel(NotificationChannelName name) { - - GetNotificationChannelRequest request = - GetNotificationChannelRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return getNotificationChannel(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single notification channel. The channel includes the relevant configuration details - * with which the channel was created. However, the response may truncate or omit passwords, API - * keys, or other private key matter and thus the response may not be 100% identical to the - * information that was supplied in the call to the create method. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   NotificationChannel response = notificationChannelServiceClient.getNotificationChannel(name.toString());
-   * }
-   * 
- * - * @param name The channel for which to execute the request. The format is - * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel getNotificationChannel(String name) { - - GetNotificationChannelRequest request = - GetNotificationChannelRequest.newBuilder().setName(name).build(); - return getNotificationChannel(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single notification channel. The channel includes the relevant configuration details - * with which the channel was created. However, the response may truncate or omit passwords, API - * keys, or other private key matter and thus the response may not be 100% identical to the - * information that was supplied in the call to the create method. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   GetNotificationChannelRequest request = GetNotificationChannelRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   NotificationChannel response = notificationChannelServiceClient.getNotificationChannel(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel getNotificationChannel(GetNotificationChannelRequest request) { - return getNotificationChannelCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single notification channel. The channel includes the relevant configuration details - * with which the channel was created. However, the response may truncate or omit passwords, API - * keys, or other private key matter and thus the response may not be 100% identical to the - * information that was supplied in the call to the create method. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   GetNotificationChannelRequest request = GetNotificationChannelRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<NotificationChannel> future = notificationChannelServiceClient.getNotificationChannelCallable().futureCall(request);
-   *   // Do something
-   *   NotificationChannel response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - getNotificationChannelCallable() { - return stub.getNotificationChannelCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new notification channel, representing a single notification endpoint such as an - * email address, SMS number, or PagerDuty service. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
-   *   NotificationChannel response = notificationChannelServiceClient.createNotificationChannel(name, notificationChannel);
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is: - *

projects/[PROJECT_ID] - *

Note that this names the container into which the channel will be written. This does not - * name the newly created channel. The resulting channel's name will have a normalized version - * of this field as a prefix, but will add `/notificationChannels/[CHANNEL_ID]` to identify - * the channel. - * @param notificationChannel The definition of the `NotificationChannel` to create. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel createNotificationChannel( - ProjectName name, NotificationChannel notificationChannel) { - - CreateNotificationChannelRequest request = - CreateNotificationChannelRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setNotificationChannel(notificationChannel) - .build(); - return createNotificationChannel(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new notification channel, representing a single notification endpoint such as an - * email address, SMS number, or PagerDuty service. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
-   *   NotificationChannel response = notificationChannelServiceClient.createNotificationChannel(name.toString(), notificationChannel);
-   * }
-   * 
- * - * @param name The project on which to execute the request. The format is: - *

projects/[PROJECT_ID] - *

Note that this names the container into which the channel will be written. This does not - * name the newly created channel. The resulting channel's name will have a normalized version - * of this field as a prefix, but will add `/notificationChannels/[CHANNEL_ID]` to identify - * the channel. - * @param notificationChannel The definition of the `NotificationChannel` to create. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel createNotificationChannel( - String name, NotificationChannel notificationChannel) { - - CreateNotificationChannelRequest request = - CreateNotificationChannelRequest.newBuilder() - .setName(name) - .setNotificationChannel(notificationChannel) - .build(); - return createNotificationChannel(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new notification channel, representing a single notification endpoint such as an - * email address, SMS number, or PagerDuty service. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
-   *   CreateNotificationChannelRequest request = CreateNotificationChannelRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setNotificationChannel(notificationChannel)
-   *     .build();
-   *   NotificationChannel response = notificationChannelServiceClient.createNotificationChannel(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel createNotificationChannel( - CreateNotificationChannelRequest request) { - return createNotificationChannelCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new notification channel, representing a single notification endpoint such as an - * email address, SMS number, or PagerDuty service. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ProjectName name = ProjectName.of("[PROJECT]");
-   *   NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
-   *   CreateNotificationChannelRequest request = CreateNotificationChannelRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setNotificationChannel(notificationChannel)
-   *     .build();
-   *   ApiFuture<NotificationChannel> future = notificationChannelServiceClient.createNotificationChannelCallable().futureCall(request);
-   *   // Do something
-   *   NotificationChannel response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - createNotificationChannelCallable() { - return stub.createNotificationChannelCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates a notification channel. Fields not specified in the field mask remain unchanged. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   FieldMask updateMask = FieldMask.newBuilder().build();
-   *   NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
-   *   NotificationChannel response = notificationChannelServiceClient.updateNotificationChannel(updateMask, notificationChannel);
-   * }
-   * 
- * - * @param updateMask The fields to update. - * @param notificationChannel A description of the changes to be applied to the specified - * notification channel. The description must provide a definition for fields to be updated; - * the names of these fields should also be included in the `update_mask`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel updateNotificationChannel( - FieldMask updateMask, NotificationChannel notificationChannel) { - - UpdateNotificationChannelRequest request = - UpdateNotificationChannelRequest.newBuilder() - .setUpdateMask(updateMask) - .setNotificationChannel(notificationChannel) - .build(); - return updateNotificationChannel(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates a notification channel. Fields not specified in the field mask remain unchanged. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
-   *   UpdateNotificationChannelRequest request = UpdateNotificationChannelRequest.newBuilder()
-   *     .setNotificationChannel(notificationChannel)
-   *     .build();
-   *   NotificationChannel response = notificationChannelServiceClient.updateNotificationChannel(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel updateNotificationChannel( - UpdateNotificationChannelRequest request) { - return updateNotificationChannelCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates a notification channel. Fields not specified in the field mask remain unchanged. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
-   *   UpdateNotificationChannelRequest request = UpdateNotificationChannelRequest.newBuilder()
-   *     .setNotificationChannel(notificationChannel)
-   *     .build();
-   *   ApiFuture<NotificationChannel> future = notificationChannelServiceClient.updateNotificationChannelCallable().futureCall(request);
-   *   // Do something
-   *   NotificationChannel response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - updateNotificationChannelCallable() { - return stub.updateNotificationChannelCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a notification channel. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   boolean force = false;
-   *   notificationChannelServiceClient.deleteNotificationChannel(name, force);
-   * }
-   * 
- * - * @param name The channel for which to execute the request. The format is - * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. - * @param force If true, the notification channel will be deleted regardless of its use in alert - * policies (the policies will be updated to remove the channel). If false, channels that are - * still referenced by an existing alerting policy will fail to be deleted in a delete - * operation. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteNotificationChannel(NotificationChannelName name, boolean force) { - - DeleteNotificationChannelRequest request = - DeleteNotificationChannelRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setForce(force) - .build(); - deleteNotificationChannel(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a notification channel. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   boolean force = false;
-   *   notificationChannelServiceClient.deleteNotificationChannel(name.toString(), force);
-   * }
-   * 
- * - * @param name The channel for which to execute the request. The format is - * `projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]`. - * @param force If true, the notification channel will be deleted regardless of its use in alert - * policies (the policies will be updated to remove the channel). If false, channels that are - * still referenced by an existing alerting policy will fail to be deleted in a delete - * operation. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteNotificationChannel(String name, boolean force) { - - DeleteNotificationChannelRequest request = - DeleteNotificationChannelRequest.newBuilder().setName(name).setForce(force).build(); - deleteNotificationChannel(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a notification channel. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   DeleteNotificationChannelRequest request = DeleteNotificationChannelRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   notificationChannelServiceClient.deleteNotificationChannel(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteNotificationChannel(DeleteNotificationChannelRequest request) { - deleteNotificationChannelCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes a notification channel. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   DeleteNotificationChannelRequest request = DeleteNotificationChannelRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = notificationChannelServiceClient.deleteNotificationChannelCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable - deleteNotificationChannelCallable() { - return stub.deleteNotificationChannelCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Causes a verification code to be delivered to the channel. The code can then be supplied in - * `VerifyNotificationChannel` to verify the channel. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   notificationChannelServiceClient.sendNotificationChannelVerificationCode(name);
-   * }
-   * 
- * - * @param name The notification channel to which to send a verification code. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void sendNotificationChannelVerificationCode(NotificationChannelName name) { - - SendNotificationChannelVerificationCodeRequest request = - SendNotificationChannelVerificationCodeRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - sendNotificationChannelVerificationCode(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Causes a verification code to be delivered to the channel. The code can then be supplied in - * `VerifyNotificationChannel` to verify the channel. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   notificationChannelServiceClient.sendNotificationChannelVerificationCode(name.toString());
-   * }
-   * 
- * - * @param name The notification channel to which to send a verification code. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void sendNotificationChannelVerificationCode(String name) { - - SendNotificationChannelVerificationCodeRequest request = - SendNotificationChannelVerificationCodeRequest.newBuilder().setName(name).build(); - sendNotificationChannelVerificationCode(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Causes a verification code to be delivered to the channel. The code can then be supplied in - * `VerifyNotificationChannel` to verify the channel. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   SendNotificationChannelVerificationCodeRequest request = SendNotificationChannelVerificationCodeRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   notificationChannelServiceClient.sendNotificationChannelVerificationCode(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void sendNotificationChannelVerificationCode( - SendNotificationChannelVerificationCodeRequest request) { - sendNotificationChannelVerificationCodeCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Causes a verification code to be delivered to the channel. The code can then be supplied in - * `VerifyNotificationChannel` to verify the channel. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   SendNotificationChannelVerificationCodeRequest request = SendNotificationChannelVerificationCodeRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = notificationChannelServiceClient.sendNotificationChannelVerificationCodeCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable - sendNotificationChannelVerificationCodeCallable() { - return stub.sendNotificationChannelVerificationCodeCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Requests a verification code for an already verified channel that can then be used in a call to - * VerifyNotificationChannel() on a different channel with an equivalent identity in the same or - * in a different project. This makes it possible to copy a channel between projects without - * requiring manual reverification of the channel. If the channel is not in the verified state, - * this method will fail (in other words, this may only be used if the - * SendNotificationChannelVerificationCode and VerifyNotificationChannel paths have already been - * used to put the given channel into the verified state). - * - *

There is no guarantee that the verification codes returned by this method will be of a - * similar structure or form as the ones that are delivered to the channel via - * SendNotificationChannelVerificationCode; while VerifyNotificationChannel() will recognize both - * the codes delivered via SendNotificationChannelVerificationCode() and returned from - * GetNotificationChannelVerificationCode(), it is typically the case that the verification codes - * delivered via SendNotificationChannelVerificationCode() will be shorter and also have a shorter - * expiration (e.g. codes such as "G-123456") whereas GetVerificationCode() will typically return - * a much longer, websafe base 64 encoded string that has a longer expiration time. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   GetNotificationChannelVerificationCodeResponse response = notificationChannelServiceClient.getNotificationChannelVerificationCode(name);
-   * }
-   * 
- * - * @param name The notification channel for which a verification code is to be generated and - * retrieved. This must name a channel that is already verified; if the specified channel is - * not verified, the request will fail. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final GetNotificationChannelVerificationCodeResponse - getNotificationChannelVerificationCode(NotificationChannelName name) { - - GetNotificationChannelVerificationCodeRequest request = - GetNotificationChannelVerificationCodeRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return getNotificationChannelVerificationCode(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Requests a verification code for an already verified channel that can then be used in a call to - * VerifyNotificationChannel() on a different channel with an equivalent identity in the same or - * in a different project. This makes it possible to copy a channel between projects without - * requiring manual reverification of the channel. If the channel is not in the verified state, - * this method will fail (in other words, this may only be used if the - * SendNotificationChannelVerificationCode and VerifyNotificationChannel paths have already been - * used to put the given channel into the verified state). - * - *

There is no guarantee that the verification codes returned by this method will be of a - * similar structure or form as the ones that are delivered to the channel via - * SendNotificationChannelVerificationCode; while VerifyNotificationChannel() will recognize both - * the codes delivered via SendNotificationChannelVerificationCode() and returned from - * GetNotificationChannelVerificationCode(), it is typically the case that the verification codes - * delivered via SendNotificationChannelVerificationCode() will be shorter and also have a shorter - * expiration (e.g. codes such as "G-123456") whereas GetVerificationCode() will typically return - * a much longer, websafe base 64 encoded string that has a longer expiration time. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   GetNotificationChannelVerificationCodeResponse response = notificationChannelServiceClient.getNotificationChannelVerificationCode(name.toString());
-   * }
-   * 
- * - * @param name The notification channel for which a verification code is to be generated and - * retrieved. This must name a channel that is already verified; if the specified channel is - * not verified, the request will fail. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final GetNotificationChannelVerificationCodeResponse - getNotificationChannelVerificationCode(String name) { - - GetNotificationChannelVerificationCodeRequest request = - GetNotificationChannelVerificationCodeRequest.newBuilder().setName(name).build(); - return getNotificationChannelVerificationCode(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Requests a verification code for an already verified channel that can then be used in a call to - * VerifyNotificationChannel() on a different channel with an equivalent identity in the same or - * in a different project. This makes it possible to copy a channel between projects without - * requiring manual reverification of the channel. If the channel is not in the verified state, - * this method will fail (in other words, this may only be used if the - * SendNotificationChannelVerificationCode and VerifyNotificationChannel paths have already been - * used to put the given channel into the verified state). - * - *

There is no guarantee that the verification codes returned by this method will be of a - * similar structure or form as the ones that are delivered to the channel via - * SendNotificationChannelVerificationCode; while VerifyNotificationChannel() will recognize both - * the codes delivered via SendNotificationChannelVerificationCode() and returned from - * GetNotificationChannelVerificationCode(), it is typically the case that the verification codes - * delivered via SendNotificationChannelVerificationCode() will be shorter and also have a shorter - * expiration (e.g. codes such as "G-123456") whereas GetVerificationCode() will typically return - * a much longer, websafe base 64 encoded string that has a longer expiration time. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   GetNotificationChannelVerificationCodeRequest request = GetNotificationChannelVerificationCodeRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   GetNotificationChannelVerificationCodeResponse response = notificationChannelServiceClient.getNotificationChannelVerificationCode(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final GetNotificationChannelVerificationCodeResponse - getNotificationChannelVerificationCode( - GetNotificationChannelVerificationCodeRequest request) { - return getNotificationChannelVerificationCodeCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Requests a verification code for an already verified channel that can then be used in a call to - * VerifyNotificationChannel() on a different channel with an equivalent identity in the same or - * in a different project. This makes it possible to copy a channel between projects without - * requiring manual reverification of the channel. If the channel is not in the verified state, - * this method will fail (in other words, this may only be used if the - * SendNotificationChannelVerificationCode and VerifyNotificationChannel paths have already been - * used to put the given channel into the verified state). - * - *

There is no guarantee that the verification codes returned by this method will be of a - * similar structure or form as the ones that are delivered to the channel via - * SendNotificationChannelVerificationCode; while VerifyNotificationChannel() will recognize both - * the codes delivered via SendNotificationChannelVerificationCode() and returned from - * GetNotificationChannelVerificationCode(), it is typically the case that the verification codes - * delivered via SendNotificationChannelVerificationCode() will be shorter and also have a shorter - * expiration (e.g. codes such as "G-123456") whereas GetVerificationCode() will typically return - * a much longer, websafe base 64 encoded string that has a longer expiration time. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   GetNotificationChannelVerificationCodeRequest request = GetNotificationChannelVerificationCodeRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<GetNotificationChannelVerificationCodeResponse> future = notificationChannelServiceClient.getNotificationChannelVerificationCodeCallable().futureCall(request);
-   *   // Do something
-   *   GetNotificationChannelVerificationCodeResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeCallable() { - return stub.getNotificationChannelVerificationCodeCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Verifies a `NotificationChannel` by proving receipt of the code delivered to the channel as a - * result of calling `SendNotificationChannelVerificationCode`. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   String code = "";
-   *   NotificationChannel response = notificationChannelServiceClient.verifyNotificationChannel(name, code);
-   * }
-   * 
- * - * @param name The notification channel to verify. - * @param code The verification code that was delivered to the channel as a result of invoking the - * `SendNotificationChannelVerificationCode` API method or that was retrieved from a verified - * channel via `GetNotificationChannelVerificationCode`. For example, one might have - * "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only guaranteed that the code - * is valid UTF-8; one should not make any assumptions regarding the structure or format of - * the code). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel verifyNotificationChannel( - NotificationChannelName name, String code) { - - VerifyNotificationChannelRequest request = - VerifyNotificationChannelRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .setCode(code) - .build(); - return verifyNotificationChannel(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Verifies a `NotificationChannel` by proving receipt of the code delivered to the channel as a - * result of calling `SendNotificationChannelVerificationCode`. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   String code = "";
-   *   NotificationChannel response = notificationChannelServiceClient.verifyNotificationChannel(name.toString(), code);
-   * }
-   * 
- * - * @param name The notification channel to verify. - * @param code The verification code that was delivered to the channel as a result of invoking the - * `SendNotificationChannelVerificationCode` API method or that was retrieved from a verified - * channel via `GetNotificationChannelVerificationCode`. For example, one might have - * "G-123456" or "TKNZGhhd2EyN3I1MnRnMjRv" (in general, one is only guaranteed that the code - * is valid UTF-8; one should not make any assumptions regarding the structure or format of - * the code). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel verifyNotificationChannel(String name, String code) { - - VerifyNotificationChannelRequest request = - VerifyNotificationChannelRequest.newBuilder().setName(name).setCode(code).build(); - return verifyNotificationChannel(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Verifies a `NotificationChannel` by proving receipt of the code delivered to the channel as a - * result of calling `SendNotificationChannelVerificationCode`. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   String code = "";
-   *   VerifyNotificationChannelRequest request = VerifyNotificationChannelRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setCode(code)
-   *     .build();
-   *   NotificationChannel response = notificationChannelServiceClient.verifyNotificationChannel(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final NotificationChannel verifyNotificationChannel( - VerifyNotificationChannelRequest request) { - return verifyNotificationChannelCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Verifies a `NotificationChannel` by proving receipt of the code delivered to the channel as a - * result of calling `SendNotificationChannelVerificationCode`. - * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   String code = "";
-   *   VerifyNotificationChannelRequest request = VerifyNotificationChannelRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setCode(code)
-   *     .build();
-   *   ApiFuture<NotificationChannel> future = notificationChannelServiceClient.verifyNotificationChannelCallable().futureCall(request);
-   *   // Do something
-   *   NotificationChannel response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - verifyNotificationChannelCallable() { - return stub.verifyNotificationChannelCallable(); - } - - @Override - public final void close() { - stub.close(); - } - - @Override - public void shutdown() { - stub.shutdown(); - } - - @Override - public boolean isShutdown() { - return stub.isShutdown(); - } - - @Override - public boolean isTerminated() { - return stub.isTerminated(); - } - - @Override - public void shutdownNow() { - stub.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return stub.awaitTermination(duration, unit); - } - - public static class ListNotificationChannelDescriptorsPagedResponse - extends AbstractPagedListResponse< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor, - ListNotificationChannelDescriptorsPage, - ListNotificationChannelDescriptorsFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor> - context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListNotificationChannelDescriptorsPage.createEmptyPage() - .createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction< - ListNotificationChannelDescriptorsPage, - ListNotificationChannelDescriptorsPagedResponse>() { - @Override - public ListNotificationChannelDescriptorsPagedResponse apply( - ListNotificationChannelDescriptorsPage input) { - return new ListNotificationChannelDescriptorsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListNotificationChannelDescriptorsPagedResponse( - ListNotificationChannelDescriptorsPage page) { - super(page, ListNotificationChannelDescriptorsFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListNotificationChannelDescriptorsPage - extends AbstractPage< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor, - ListNotificationChannelDescriptorsPage> { - - private ListNotificationChannelDescriptorsPage( - PageContext< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor> - context, - ListNotificationChannelDescriptorsResponse response) { - super(context, response); - } - - private static ListNotificationChannelDescriptorsPage createEmptyPage() { - return new ListNotificationChannelDescriptorsPage(null, null); - } - - @Override - protected ListNotificationChannelDescriptorsPage createPage( - PageContext< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor> - context, - ListNotificationChannelDescriptorsResponse response) { - return new ListNotificationChannelDescriptorsPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor> - context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListNotificationChannelDescriptorsFixedSizeCollection - extends AbstractFixedSizeCollection< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor, - ListNotificationChannelDescriptorsPage, - ListNotificationChannelDescriptorsFixedSizeCollection> { - - private ListNotificationChannelDescriptorsFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListNotificationChannelDescriptorsFixedSizeCollection createEmptyCollection() { - return new ListNotificationChannelDescriptorsFixedSizeCollection(null, 0); - } - - @Override - protected ListNotificationChannelDescriptorsFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListNotificationChannelDescriptorsFixedSizeCollection(pages, collectionSize); - } - } - - public static class ListNotificationChannelsPagedResponse - extends AbstractPagedListResponse< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - NotificationChannel, - ListNotificationChannelsPage, - ListNotificationChannelsFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - NotificationChannel> - context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListNotificationChannelsPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListNotificationChannelsPagedResponse apply(ListNotificationChannelsPage input) { - return new ListNotificationChannelsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListNotificationChannelsPagedResponse(ListNotificationChannelsPage page) { - super(page, ListNotificationChannelsFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListNotificationChannelsPage - extends AbstractPage< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - NotificationChannel, - ListNotificationChannelsPage> { - - private ListNotificationChannelsPage( - PageContext< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - NotificationChannel> - context, - ListNotificationChannelsResponse response) { - super(context, response); - } - - private static ListNotificationChannelsPage createEmptyPage() { - return new ListNotificationChannelsPage(null, null); - } - - @Override - protected ListNotificationChannelsPage createPage( - PageContext< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - NotificationChannel> - context, - ListNotificationChannelsResponse response) { - return new ListNotificationChannelsPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - NotificationChannel> - context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListNotificationChannelsFixedSizeCollection - extends AbstractFixedSizeCollection< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - NotificationChannel, - ListNotificationChannelsPage, - ListNotificationChannelsFixedSizeCollection> { - - private ListNotificationChannelsFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListNotificationChannelsFixedSizeCollection createEmptyCollection() { - return new ListNotificationChannelsFixedSizeCollection(null, 0); - } - - @Override - protected ListNotificationChannelsFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListNotificationChannelsFixedSizeCollection(pages, collectionSize); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java b/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java deleted file mode 100644 index d1a3645b..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse; - -import com.google.api.core.ApiFunction; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientSettings; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.monitoring.v3.stub.NotificationChannelServiceStubSettings; -import com.google.monitoring.v3.CreateNotificationChannelRequest; -import com.google.monitoring.v3.DeleteNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelDescriptorRequest; -import com.google.monitoring.v3.GetNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsRequest; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsResponse; -import com.google.monitoring.v3.ListNotificationChannelsRequest; -import com.google.monitoring.v3.ListNotificationChannelsResponse; -import com.google.monitoring.v3.NotificationChannel; -import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.UpdateNotificationChannelRequest; -import com.google.monitoring.v3.VerifyNotificationChannelRequest; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link NotificationChannelServiceClient}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getNotificationChannelDescriptor to 30 seconds: - * - *

- * 
- * NotificationChannelServiceSettings.Builder notificationChannelServiceSettingsBuilder =
- *     NotificationChannelServiceSettings.newBuilder();
- * notificationChannelServiceSettingsBuilder.getNotificationChannelDescriptorSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * NotificationChannelServiceSettings notificationChannelServiceSettings = notificationChannelServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class NotificationChannelServiceSettings - extends ClientSettings { - /** Returns the object with the settings used for calls to listNotificationChannelDescriptors. */ - public PagedCallSettings< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .listNotificationChannelDescriptorsSettings(); - } - - /** Returns the object with the settings used for calls to getNotificationChannelDescriptor. */ - public UnaryCallSettings - getNotificationChannelDescriptorSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .getNotificationChannelDescriptorSettings(); - } - - /** Returns the object with the settings used for calls to listNotificationChannels. */ - public PagedCallSettings< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - ListNotificationChannelsPagedResponse> - listNotificationChannelsSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .listNotificationChannelsSettings(); - } - - /** Returns the object with the settings used for calls to getNotificationChannel. */ - public UnaryCallSettings - getNotificationChannelSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .getNotificationChannelSettings(); - } - - /** Returns the object with the settings used for calls to createNotificationChannel. */ - public UnaryCallSettings - createNotificationChannelSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .createNotificationChannelSettings(); - } - - /** Returns the object with the settings used for calls to updateNotificationChannel. */ - public UnaryCallSettings - updateNotificationChannelSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .updateNotificationChannelSettings(); - } - - /** Returns the object with the settings used for calls to deleteNotificationChannel. */ - public UnaryCallSettings - deleteNotificationChannelSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .deleteNotificationChannelSettings(); - } - - /** - * Returns the object with the settings used for calls to sendNotificationChannelVerificationCode. - */ - public UnaryCallSettings - sendNotificationChannelVerificationCodeSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .sendNotificationChannelVerificationCodeSettings(); - } - - /** - * Returns the object with the settings used for calls to getNotificationChannelVerificationCode. - */ - public UnaryCallSettings< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .getNotificationChannelVerificationCodeSettings(); - } - - /** Returns the object with the settings used for calls to verifyNotificationChannel. */ - public UnaryCallSettings - verifyNotificationChannelSettings() { - return ((NotificationChannelServiceStubSettings) getStubSettings()) - .verifyNotificationChannelSettings(); - } - - public static final NotificationChannelServiceSettings create( - NotificationChannelServiceStubSettings stub) throws IOException { - return new NotificationChannelServiceSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return NotificationChannelServiceStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return NotificationChannelServiceStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return NotificationChannelServiceStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return NotificationChannelServiceStubSettings.defaultCredentialsProviderBuilder(); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return NotificationChannelServiceStubSettings.defaultGrpcTransportProviderBuilder(); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return NotificationChannelServiceStubSettings.defaultTransportChannelProvider(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return NotificationChannelServiceStubSettings.defaultApiClientHeaderProviderBuilder(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected NotificationChannelServiceSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - } - - /** Builder for NotificationChannelServiceSettings. */ - public static class Builder - extends ClientSettings.Builder { - protected Builder() throws IOException { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(NotificationChannelServiceStubSettings.newBuilder(clientContext)); - } - - private static Builder createDefault() { - return new Builder(NotificationChannelServiceStubSettings.newBuilder()); - } - - protected Builder(NotificationChannelServiceSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(NotificationChannelServiceStubSettings.Builder stubSettings) { - super(stubSettings); - } - - public NotificationChannelServiceStubSettings.Builder getStubSettingsBuilder() { - return ((NotificationChannelServiceStubSettings.Builder) getStubSettings()); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods( - getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); - return this; - } - - /** - * Returns the builder for the settings used for calls to listNotificationChannelDescriptors. - */ - public PagedCallSettings.Builder< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsSettings() { - return getStubSettingsBuilder().listNotificationChannelDescriptorsSettings(); - } - - /** Returns the builder for the settings used for calls to getNotificationChannelDescriptor. */ - public UnaryCallSettings.Builder< - GetNotificationChannelDescriptorRequest, NotificationChannelDescriptor> - getNotificationChannelDescriptorSettings() { - return getStubSettingsBuilder().getNotificationChannelDescriptorSettings(); - } - - /** Returns the builder for the settings used for calls to listNotificationChannels. */ - public PagedCallSettings.Builder< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - ListNotificationChannelsPagedResponse> - listNotificationChannelsSettings() { - return getStubSettingsBuilder().listNotificationChannelsSettings(); - } - - /** Returns the builder for the settings used for calls to getNotificationChannel. */ - public UnaryCallSettings.Builder - getNotificationChannelSettings() { - return getStubSettingsBuilder().getNotificationChannelSettings(); - } - - /** Returns the builder for the settings used for calls to createNotificationChannel. */ - public UnaryCallSettings.Builder - createNotificationChannelSettings() { - return getStubSettingsBuilder().createNotificationChannelSettings(); - } - - /** Returns the builder for the settings used for calls to updateNotificationChannel. */ - public UnaryCallSettings.Builder - updateNotificationChannelSettings() { - return getStubSettingsBuilder().updateNotificationChannelSettings(); - } - - /** Returns the builder for the settings used for calls to deleteNotificationChannel. */ - public UnaryCallSettings.Builder - deleteNotificationChannelSettings() { - return getStubSettingsBuilder().deleteNotificationChannelSettings(); - } - - /** - * Returns the builder for the settings used for calls to - * sendNotificationChannelVerificationCode. - */ - public UnaryCallSettings.Builder - sendNotificationChannelVerificationCodeSettings() { - return getStubSettingsBuilder().sendNotificationChannelVerificationCodeSettings(); - } - - /** - * Returns the builder for the settings used for calls to - * getNotificationChannelVerificationCode. - */ - public UnaryCallSettings.Builder< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeSettings() { - return getStubSettingsBuilder().getNotificationChannelVerificationCodeSettings(); - } - - /** Returns the builder for the settings used for calls to verifyNotificationChannel. */ - public UnaryCallSettings.Builder - verifyNotificationChannelSettings() { - return getStubSettingsBuilder().verifyNotificationChannelSettings(); - } - - @Override - public NotificationChannelServiceSettings build() throws IOException { - return new NotificationChannelServiceSettings(this); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java b/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java deleted file mode 100644 index 2116acdd..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java +++ /dev/null @@ -1,928 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.paging.AbstractFixedSizeCollection; -import com.google.api.gax.paging.AbstractPage; -import com.google.api.gax.paging.AbstractPagedListResponse; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.monitoring.v3.stub.UptimeCheckServiceStub; -import com.google.cloud.monitoring.v3.stub.UptimeCheckServiceStubSettings; -import com.google.common.util.concurrent.MoreExecutors; -import com.google.monitoring.v3.CreateUptimeCheckConfigRequest; -import com.google.monitoring.v3.DeleteUptimeCheckConfigRequest; -import com.google.monitoring.v3.GetUptimeCheckConfigRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; -import com.google.monitoring.v3.ListUptimeCheckIpsRequest; -import com.google.monitoring.v3.ListUptimeCheckIpsResponse; -import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; -import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.monitoring.v3.UptimeCheckConfigName; -import com.google.monitoring.v3.UptimeCheckIp; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND SERVICE -/** - * Service Description: The UptimeCheckService API is used to manage (list, create, delete, edit) - * Uptime check configurations in the Stackdriver Monitoring product. An Uptime check is a piece of - * configuration that determines which resources and services to monitor for availability. These - * configurations can also be configured interactively by navigating to the [Cloud Console] - * (http://console.cloud.google.com), selecting the appropriate project, clicking on "Monitoring" on - * the left-hand side to navigate to Stackdriver, and then clicking on "Uptime". - * - *

This class provides the ability to make remote calls to the backing service through method - * calls that map to API methods. Sample code to get started: - * - *

- * 
- * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the uptimeCheckServiceClient object to clean up resources - * such as threads. In the example above, try-with-resources is used, which automatically calls - * close(). - * - *

The surface of this class includes several types of Java methods for each of the API's - * methods: - * - *

    - *
  1. A "flattened" method. With this type of method, the fields of the request type have been - * converted into function parameters. It may be the case that not all fields are available as - * parameters, and not every API method will have a flattened method entry point. - *
  2. 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. - *
  3. 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. - * - *

Many parameters require resource names to be formatted in a particular way. To assist with - * these names, this class includes a format method for each type of name, and additionally a parse - * method to extract the individual identifiers contained within names that are returned. - * - *

This class can be customized by passing in a custom instance of UptimeCheckServiceSettings to - * create(). For example: - * - *

To customize credentials: - * - *

- * 
- * UptimeCheckServiceSettings uptimeCheckServiceSettings =
- *     UptimeCheckServiceSettings.newBuilder()
- *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
- *         .build();
- * UptimeCheckServiceClient uptimeCheckServiceClient =
- *     UptimeCheckServiceClient.create(uptimeCheckServiceSettings);
- * 
- * 
- * - * To customize the endpoint: - * - *
- * 
- * UptimeCheckServiceSettings uptimeCheckServiceSettings =
- *     UptimeCheckServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
- * UptimeCheckServiceClient uptimeCheckServiceClient =
- *     UptimeCheckServiceClient.create(uptimeCheckServiceSettings);
- * 
- * 
- */ -@Generated("by gapic-generator") -public class UptimeCheckServiceClient implements BackgroundResource { - private final UptimeCheckServiceSettings settings; - private final UptimeCheckServiceStub stub; - - /** Constructs an instance of UptimeCheckServiceClient with default settings. */ - public static final UptimeCheckServiceClient create() throws IOException { - return create(UptimeCheckServiceSettings.newBuilder().build()); - } - - /** - * Constructs an instance of UptimeCheckServiceClient, using the given settings. The channels are - * created based on the settings passed in, or defaults for any settings that are not set. - */ - public static final UptimeCheckServiceClient create(UptimeCheckServiceSettings settings) - throws IOException { - return new UptimeCheckServiceClient(settings); - } - - /** - * Constructs an instance of UptimeCheckServiceClient, using the given stub for making calls. This - * is for advanced usage - prefer to use UptimeCheckServiceSettings}. - */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public static final UptimeCheckServiceClient create(UptimeCheckServiceStub stub) { - return new UptimeCheckServiceClient(stub); - } - - /** - * Constructs an instance of UptimeCheckServiceClient, using the given settings. This is protected - * so that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ - protected UptimeCheckServiceClient(UptimeCheckServiceSettings settings) throws IOException { - this.settings = settings; - this.stub = ((UptimeCheckServiceStubSettings) settings.getStubSettings()).createStub(); - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - protected UptimeCheckServiceClient(UptimeCheckServiceStub stub) { - this.settings = null; - this.stub = stub; - } - - public final UptimeCheckServiceSettings getSettings() { - return settings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public UptimeCheckServiceStub getStub() { - return stub; - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing valid Uptime check configurations for the project (leaving out any invalid - * configurations). - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
-   *   for (UptimeCheckConfig element : uptimeCheckServiceClient.listUptimeCheckConfigs(formattedParent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param parent The project whose Uptime check configurations are listed. The format is - * `projects/[PROJECT_ID]`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(String parent) { - ListUptimeCheckConfigsRequest request = - ListUptimeCheckConfigsRequest.newBuilder().setParent(parent).build(); - return listUptimeCheckConfigs(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing valid Uptime check configurations for the project (leaving out any invalid - * configurations). - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
-   *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
-   *     .setParent(formattedParent)
-   *     .build();
-   *   for (UptimeCheckConfig element : uptimeCheckServiceClient.listUptimeCheckConfigs(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs( - ListUptimeCheckConfigsRequest request) { - return listUptimeCheckConfigsPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing valid Uptime check configurations for the project (leaving out any invalid - * configurations). - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
-   *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
-   *     .setParent(formattedParent)
-   *     .build();
-   *   ApiFuture<ListUptimeCheckConfigsPagedResponse> future = uptimeCheckServiceClient.listUptimeCheckConfigsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (UptimeCheckConfig element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listUptimeCheckConfigsPagedCallable() { - return stub.listUptimeCheckConfigsPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Lists the existing valid Uptime check configurations for the project (leaving out any invalid - * configurations). - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
-   *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
-   *     .setParent(formattedParent)
-   *     .build();
-   *   while (true) {
-   *     ListUptimeCheckConfigsResponse response = uptimeCheckServiceClient.listUptimeCheckConfigsCallable().call(request);
-   *     for (UptimeCheckConfig element : response.getUptimeCheckConfigsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listUptimeCheckConfigsCallable() { - return stub.listUptimeCheckConfigsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single Uptime check configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
-   * }
-   * 
- * - * @param name The Uptime check configuration to retrieve. The format is - * `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UptimeCheckConfig getUptimeCheckConfig(UptimeCheckConfigName name) { - - GetUptimeCheckConfigRequest request = - GetUptimeCheckConfigRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - return getUptimeCheckConfig(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single Uptime check configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name.toString());
-   * }
-   * 
- * - * @param name The Uptime check configuration to retrieve. The format is - * `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UptimeCheckConfig getUptimeCheckConfig(String name) { - - GetUptimeCheckConfigRequest request = - GetUptimeCheckConfigRequest.newBuilder().setName(name).build(); - return getUptimeCheckConfig(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single Uptime check configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest request) { - return getUptimeCheckConfigCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Gets a single Uptime check configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<UptimeCheckConfig> future = uptimeCheckServiceClient.getUptimeCheckConfigCallable().futureCall(request);
-   *   // Do something
-   *   UptimeCheckConfig response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - getUptimeCheckConfigCallable() { - return stub.getUptimeCheckConfigCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new Uptime check configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.createUptimeCheckConfig(formattedParent, uptimeCheckConfig);
-   * }
-   * 
- * - * @param parent The project in which to create the Uptime check. The format is - * `projects/[PROJECT_ID]`. - * @param uptimeCheckConfig The new Uptime check configuration. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UptimeCheckConfig createUptimeCheckConfig( - String parent, UptimeCheckConfig uptimeCheckConfig) { - - CreateUptimeCheckConfigRequest request = - CreateUptimeCheckConfigRequest.newBuilder() - .setParent(parent) - .setUptimeCheckConfig(uptimeCheckConfig) - .build(); - return createUptimeCheckConfig(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new Uptime check configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder()
-   *     .setParent(formattedParent)
-   *     .setUptimeCheckConfig(uptimeCheckConfig)
-   *     .build();
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.createUptimeCheckConfig(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UptimeCheckConfig createUptimeCheckConfig(CreateUptimeCheckConfigRequest request) { - return createUptimeCheckConfigCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Creates a new Uptime check configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder()
-   *     .setParent(formattedParent)
-   *     .setUptimeCheckConfig(uptimeCheckConfig)
-   *     .build();
-   *   ApiFuture<UptimeCheckConfig> future = uptimeCheckServiceClient.createUptimeCheckConfigCallable().futureCall(request);
-   *   // Do something
-   *   UptimeCheckConfig response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - createUptimeCheckConfigCallable() { - return stub.createUptimeCheckConfigCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an Uptime check configuration. You can either replace the entire configuration with a - * new one or replace only certain fields in the current configuration by specifying the fields to - * be updated via `updateMask`. Returns the updated configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.updateUptimeCheckConfig(uptimeCheckConfig);
-   * }
-   * 
- * - * @param uptimeCheckConfig Required. If an `updateMask` has been specified, this field gives the - * values for the set of fields mentioned in the `updateMask`. If an `updateMask` has not been - * given, this Uptime check configuration replaces the current configuration. If a field is - * mentioned in `updateMask` but the corresonding field is omitted in this partial Uptime - * check configuration, it has the effect of deleting/clearing the field from the - * configuration on the server. - *

The following fields can be updated: `display_name`, `http_check`, `tcp_check`, - * `timeout`, `content_matchers`, and `selected_regions`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UptimeCheckConfig updateUptimeCheckConfig(UptimeCheckConfig uptimeCheckConfig) { - - UpdateUptimeCheckConfigRequest request = - UpdateUptimeCheckConfigRequest.newBuilder().setUptimeCheckConfig(uptimeCheckConfig).build(); - return updateUptimeCheckConfig(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an Uptime check configuration. You can either replace the entire configuration with a - * new one or replace only certain fields in the current configuration by specifying the fields to - * be updated via `updateMask`. Returns the updated configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   UpdateUptimeCheckConfigRequest request = UpdateUptimeCheckConfigRequest.newBuilder()
-   *     .setUptimeCheckConfig(uptimeCheckConfig)
-   *     .build();
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.updateUptimeCheckConfig(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final UptimeCheckConfig updateUptimeCheckConfig(UpdateUptimeCheckConfigRequest request) { - return updateUptimeCheckConfigCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Updates an Uptime check configuration. You can either replace the entire configuration with a - * new one or replace only certain fields in the current configuration by specifying the fields to - * be updated via `updateMask`. Returns the updated configuration. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   UpdateUptimeCheckConfigRequest request = UpdateUptimeCheckConfigRequest.newBuilder()
-   *     .setUptimeCheckConfig(uptimeCheckConfig)
-   *     .build();
-   *   ApiFuture<UptimeCheckConfig> future = uptimeCheckServiceClient.updateUptimeCheckConfigCallable().futureCall(request);
-   *   // Do something
-   *   UptimeCheckConfig response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - updateUptimeCheckConfigCallable() { - return stub.updateUptimeCheckConfigCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an Uptime check configuration. Note that this method will fail if the Uptime check - * configuration is referenced by an alert policy or other dependent configs that would be - * rendered invalid by the deletion. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(name);
-   * }
-   * 
- * - * @param name The Uptime check configuration to delete. The format is - * `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteUptimeCheckConfig(UptimeCheckConfigName name) { - - DeleteUptimeCheckConfigRequest request = - DeleteUptimeCheckConfigRequest.newBuilder() - .setName(name == null ? null : name.toString()) - .build(); - deleteUptimeCheckConfig(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an Uptime check configuration. Note that this method will fail if the Uptime check - * configuration is referenced by an alert policy or other dependent configs that would be - * rendered invalid by the deletion. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(name.toString());
-   * }
-   * 
- * - * @param name The Uptime check configuration to delete. The format is - * `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteUptimeCheckConfig(String name) { - - DeleteUptimeCheckConfigRequest request = - DeleteUptimeCheckConfigRequest.newBuilder().setName(name).build(); - deleteUptimeCheckConfig(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an Uptime check configuration. Note that this method will fail if the Uptime check - * configuration is referenced by an alert policy or other dependent configs that would be - * rendered invalid by the deletion. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest request) { - deleteUptimeCheckConfigCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an Uptime check configuration. Note that this method will fail if the Uptime check - * configuration is referenced by an alert policy or other dependent configs that would be - * rendered invalid by the deletion. - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = uptimeCheckServiceClient.deleteUptimeCheckConfigCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable - deleteUptimeCheckConfigCallable() { - return stub.deleteUptimeCheckConfigCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns the list of IP addresses that checkers run from - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   ListUptimeCheckIpsRequest request = ListUptimeCheckIpsRequest.newBuilder().build();
-   *   for (UptimeCheckIp element : uptimeCheckServiceClient.listUptimeCheckIps(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListUptimeCheckIpsPagedResponse listUptimeCheckIps( - ListUptimeCheckIpsRequest request) { - return listUptimeCheckIpsPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns the list of IP addresses that checkers run from - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   ListUptimeCheckIpsRequest request = ListUptimeCheckIpsRequest.newBuilder().build();
-   *   ApiFuture<ListUptimeCheckIpsPagedResponse> future = uptimeCheckServiceClient.listUptimeCheckIpsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (UptimeCheckIp element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listUptimeCheckIpsPagedCallable() { - return stub.listUptimeCheckIpsPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Returns the list of IP addresses that checkers run from - * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   ListUptimeCheckIpsRequest request = ListUptimeCheckIpsRequest.newBuilder().build();
-   *   while (true) {
-   *     ListUptimeCheckIpsResponse response = uptimeCheckServiceClient.listUptimeCheckIpsCallable().call(request);
-   *     for (UptimeCheckIp element : response.getUptimeCheckIpsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
- */ - public final UnaryCallable - listUptimeCheckIpsCallable() { - return stub.listUptimeCheckIpsCallable(); - } - - @Override - public final void close() { - stub.close(); - } - - @Override - public void shutdown() { - stub.shutdown(); - } - - @Override - public boolean isShutdown() { - return stub.isShutdown(); - } - - @Override - public boolean isTerminated() { - return stub.isTerminated(); - } - - @Override - public void shutdownNow() { - stub.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return stub.awaitTermination(duration, unit); - } - - public static class ListUptimeCheckConfigsPagedResponse - extends AbstractPagedListResponse< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - UptimeCheckConfig, - ListUptimeCheckConfigsPage, - ListUptimeCheckConfigsFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext< - ListUptimeCheckConfigsRequest, ListUptimeCheckConfigsResponse, UptimeCheckConfig> - context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListUptimeCheckConfigsPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListUptimeCheckConfigsPagedResponse apply(ListUptimeCheckConfigsPage input) { - return new ListUptimeCheckConfigsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListUptimeCheckConfigsPagedResponse(ListUptimeCheckConfigsPage page) { - super(page, ListUptimeCheckConfigsFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListUptimeCheckConfigsPage - extends AbstractPage< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - UptimeCheckConfig, - ListUptimeCheckConfigsPage> { - - private ListUptimeCheckConfigsPage( - PageContext< - ListUptimeCheckConfigsRequest, ListUptimeCheckConfigsResponse, UptimeCheckConfig> - context, - ListUptimeCheckConfigsResponse response) { - super(context, response); - } - - private static ListUptimeCheckConfigsPage createEmptyPage() { - return new ListUptimeCheckConfigsPage(null, null); - } - - @Override - protected ListUptimeCheckConfigsPage createPage( - PageContext< - ListUptimeCheckConfigsRequest, ListUptimeCheckConfigsResponse, UptimeCheckConfig> - context, - ListUptimeCheckConfigsResponse response) { - return new ListUptimeCheckConfigsPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext< - ListUptimeCheckConfigsRequest, ListUptimeCheckConfigsResponse, UptimeCheckConfig> - context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListUptimeCheckConfigsFixedSizeCollection - extends AbstractFixedSizeCollection< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - UptimeCheckConfig, - ListUptimeCheckConfigsPage, - ListUptimeCheckConfigsFixedSizeCollection> { - - private ListUptimeCheckConfigsFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListUptimeCheckConfigsFixedSizeCollection createEmptyCollection() { - return new ListUptimeCheckConfigsFixedSizeCollection(null, 0); - } - - @Override - protected ListUptimeCheckConfigsFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListUptimeCheckConfigsFixedSizeCollection(pages, collectionSize); - } - } - - public static class ListUptimeCheckIpsPagedResponse - extends AbstractPagedListResponse< - ListUptimeCheckIpsRequest, - ListUptimeCheckIpsResponse, - UptimeCheckIp, - ListUptimeCheckIpsPage, - ListUptimeCheckIpsFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListUptimeCheckIpsPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public ListUptimeCheckIpsPagedResponse apply(ListUptimeCheckIpsPage input) { - return new ListUptimeCheckIpsPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private ListUptimeCheckIpsPagedResponse(ListUptimeCheckIpsPage page) { - super(page, ListUptimeCheckIpsFixedSizeCollection.createEmptyCollection()); - } - } - - public static class ListUptimeCheckIpsPage - extends AbstractPage< - ListUptimeCheckIpsRequest, - ListUptimeCheckIpsResponse, - UptimeCheckIp, - ListUptimeCheckIpsPage> { - - private ListUptimeCheckIpsPage( - PageContext context, - ListUptimeCheckIpsResponse response) { - super(context, response); - } - - private static ListUptimeCheckIpsPage createEmptyPage() { - return new ListUptimeCheckIpsPage(null, null); - } - - @Override - protected ListUptimeCheckIpsPage createPage( - PageContext context, - ListUptimeCheckIpsResponse response) { - return new ListUptimeCheckIpsPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class ListUptimeCheckIpsFixedSizeCollection - extends AbstractFixedSizeCollection< - ListUptimeCheckIpsRequest, - ListUptimeCheckIpsResponse, - UptimeCheckIp, - ListUptimeCheckIpsPage, - ListUptimeCheckIpsFixedSizeCollection> { - - private ListUptimeCheckIpsFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static ListUptimeCheckIpsFixedSizeCollection createEmptyCollection() { - return new ListUptimeCheckIpsFixedSizeCollection(null, 0); - } - - @Override - protected ListUptimeCheckIpsFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new ListUptimeCheckIpsFixedSizeCollection(pages, collectionSize); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java b/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java deleted file mode 100644 index 22acba94..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckConfigsPagedResponse; -import static com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckIpsPagedResponse; - -import com.google.api.core.ApiFunction; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientSettings; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.monitoring.v3.stub.UptimeCheckServiceStubSettings; -import com.google.monitoring.v3.CreateUptimeCheckConfigRequest; -import com.google.monitoring.v3.DeleteUptimeCheckConfigRequest; -import com.google.monitoring.v3.GetUptimeCheckConfigRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; -import com.google.monitoring.v3.ListUptimeCheckIpsRequest; -import com.google.monitoring.v3.ListUptimeCheckIpsResponse; -import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; -import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link UptimeCheckServiceClient}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getUptimeCheckConfig to 30 seconds: - * - *

- * 
- * UptimeCheckServiceSettings.Builder uptimeCheckServiceSettingsBuilder =
- *     UptimeCheckServiceSettings.newBuilder();
- * uptimeCheckServiceSettingsBuilder.getUptimeCheckConfigSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * UptimeCheckServiceSettings uptimeCheckServiceSettings = uptimeCheckServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class UptimeCheckServiceSettings extends ClientSettings { - /** Returns the object with the settings used for calls to listUptimeCheckConfigs. */ - public PagedCallSettings< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - ListUptimeCheckConfigsPagedResponse> - listUptimeCheckConfigsSettings() { - return ((UptimeCheckServiceStubSettings) getStubSettings()).listUptimeCheckConfigsSettings(); - } - - /** Returns the object with the settings used for calls to getUptimeCheckConfig. */ - public UnaryCallSettings - getUptimeCheckConfigSettings() { - return ((UptimeCheckServiceStubSettings) getStubSettings()).getUptimeCheckConfigSettings(); - } - - /** Returns the object with the settings used for calls to createUptimeCheckConfig. */ - public UnaryCallSettings - createUptimeCheckConfigSettings() { - return ((UptimeCheckServiceStubSettings) getStubSettings()).createUptimeCheckConfigSettings(); - } - - /** Returns the object with the settings used for calls to updateUptimeCheckConfig. */ - public UnaryCallSettings - updateUptimeCheckConfigSettings() { - return ((UptimeCheckServiceStubSettings) getStubSettings()).updateUptimeCheckConfigSettings(); - } - - /** Returns the object with the settings used for calls to deleteUptimeCheckConfig. */ - public UnaryCallSettings - deleteUptimeCheckConfigSettings() { - return ((UptimeCheckServiceStubSettings) getStubSettings()).deleteUptimeCheckConfigSettings(); - } - - /** Returns the object with the settings used for calls to listUptimeCheckIps. */ - public PagedCallSettings< - ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, ListUptimeCheckIpsPagedResponse> - listUptimeCheckIpsSettings() { - return ((UptimeCheckServiceStubSettings) getStubSettings()).listUptimeCheckIpsSettings(); - } - - public static final UptimeCheckServiceSettings create(UptimeCheckServiceStubSettings stub) - throws IOException { - return new UptimeCheckServiceSettings.Builder(stub.toBuilder()).build(); - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return UptimeCheckServiceStubSettings.defaultExecutorProviderBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return UptimeCheckServiceStubSettings.getDefaultEndpoint(); - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return UptimeCheckServiceStubSettings.getDefaultServiceScopes(); - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return UptimeCheckServiceStubSettings.defaultCredentialsProviderBuilder(); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return UptimeCheckServiceStubSettings.defaultGrpcTransportProviderBuilder(); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return UptimeCheckServiceStubSettings.defaultTransportChannelProvider(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return UptimeCheckServiceStubSettings.defaultApiClientHeaderProviderBuilder(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected UptimeCheckServiceSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - } - - /** Builder for UptimeCheckServiceSettings. */ - public static class Builder extends ClientSettings.Builder { - protected Builder() throws IOException { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(UptimeCheckServiceStubSettings.newBuilder(clientContext)); - } - - private static Builder createDefault() { - return new Builder(UptimeCheckServiceStubSettings.newBuilder()); - } - - protected Builder(UptimeCheckServiceSettings settings) { - super(settings.getStubSettings().toBuilder()); - } - - protected Builder(UptimeCheckServiceStubSettings.Builder stubSettings) { - super(stubSettings); - } - - public UptimeCheckServiceStubSettings.Builder getStubSettingsBuilder() { - return ((UptimeCheckServiceStubSettings.Builder) getStubSettings()); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods( - getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); - return this; - } - - /** Returns the builder for the settings used for calls to listUptimeCheckConfigs. */ - public PagedCallSettings.Builder< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - ListUptimeCheckConfigsPagedResponse> - listUptimeCheckConfigsSettings() { - return getStubSettingsBuilder().listUptimeCheckConfigsSettings(); - } - - /** Returns the builder for the settings used for calls to getUptimeCheckConfig. */ - public UnaryCallSettings.Builder - getUptimeCheckConfigSettings() { - return getStubSettingsBuilder().getUptimeCheckConfigSettings(); - } - - /** Returns the builder for the settings used for calls to createUptimeCheckConfig. */ - public UnaryCallSettings.Builder - createUptimeCheckConfigSettings() { - return getStubSettingsBuilder().createUptimeCheckConfigSettings(); - } - - /** Returns the builder for the settings used for calls to updateUptimeCheckConfig. */ - public UnaryCallSettings.Builder - updateUptimeCheckConfigSettings() { - return getStubSettingsBuilder().updateUptimeCheckConfigSettings(); - } - - /** Returns the builder for the settings used for calls to deleteUptimeCheckConfig. */ - public UnaryCallSettings.Builder - deleteUptimeCheckConfigSettings() { - return getStubSettingsBuilder().deleteUptimeCheckConfigSettings(); - } - - /** Returns the builder for the settings used for calls to listUptimeCheckIps. */ - public PagedCallSettings.Builder< - ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, ListUptimeCheckIpsPagedResponse> - listUptimeCheckIpsSettings() { - return getStubSettingsBuilder().listUptimeCheckIpsSettings(); - } - - @Override - public UptimeCheckServiceSettings build() throws IOException { - return new UptimeCheckServiceSettings(this); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/package-info.java b/src/main/java/com/google/cloud/monitoring/v3/package-info.java deleted file mode 100644 index 4c9f41ee..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/package-info.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * A client to Stackdriver Monitoring API. - * - *

The interfaces provided are listed below, along with usage samples. - * - *

======================== AlertPolicyServiceClient ======================== - * - *

Service Description: The AlertPolicyService API is used to manage (list, create, delete, edit) - * alert policies in Stackdriver Monitoring. An alerting policy is a description of the conditions - * under which some aspect of your system is considered to be "unhealthy" and the ways to notify - * people or services about this state. In addition to using this API, alert policies can also be - * managed through [Stackdriver Monitoring](https://cloud.google.com/monitoring/docs/), which can be - * reached by clicking the "Monitoring" tab in [Cloud Console](https://console.cloud.google.com/). - * - *

Sample for AlertPolicyServiceClient: - * - *

- * 
- * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
- *   AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]");
- *   AlertPolicy response = alertPolicyServiceClient.getAlertPolicy(name);
- * }
- * 
- * 
- * - * ================== GroupServiceClient ================== - * - *

Service Description: The Group API lets you inspect and manage your - * [groups](#google.monitoring.v3.Group). - * - *

A group is a named filter that is used to identify a collection of monitored resources. Groups - * are typically used to mirror the physical and/or logical topology of the environment. Because - * group membership is computed dynamically, monitored resources that are started in the future are - * automatically placed in matching groups. By using a group to name monitored resources in, for - * example, an alert policy, the target of that alert policy is updated automatically as monitored - * resources are added and removed from the infrastructure. - * - *

Sample for GroupServiceClient: - * - *

- * 
- * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
- *   GroupName name = GroupName.of("[PROJECT]", "[GROUP]");
- *   Group response = groupServiceClient.getGroup(name);
- * }
- * 
- * 
- * - * =================== MetricServiceClient =================== - * - *

Service Description: Manages metric descriptors, monitored resource descriptors, and time - * series data. - * - *

Sample for MetricServiceClient: - * - *

- * 
- * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
- *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.of("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
- *   MonitoredResourceDescriptor response = metricServiceClient.getMonitoredResourceDescriptor(name);
- * }
- * 
- * 
- * - * ================================ NotificationChannelServiceClient - * ================================ - * - *

Service Description: The Notification Channel API provides access to configuration that - * controls how messages related to incidents are sent. - * - *

Sample for NotificationChannelServiceClient: - * - *

- * 
- * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
- *   NotificationChannelDescriptorName name = NotificationChannelDescriptorName.of("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
- *   NotificationChannelDescriptor response = notificationChannelServiceClient.getNotificationChannelDescriptor(name);
- * }
- * 
- * 
- * - * ======================== UptimeCheckServiceClient ======================== - * - *

Service Description: The UptimeCheckService API is used to manage (list, create, delete, edit) - * Uptime check configurations in the Stackdriver Monitoring product. An Uptime check is a piece of - * configuration that determines which resources and services to monitor for availability. These - * configurations can also be configured interactively by navigating to the [Cloud Console] - * (http://console.cloud.google.com), selecting the appropriate project, clicking on "Monitoring" on - * the left-hand side to navigate to Stackdriver, and then clicking on "Uptime". - * - *

Sample for UptimeCheckServiceClient: - * - *

- * 
- * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
- * }
- * 
- * 
- */ -@Generated("by gapic-generator") -package com.google.cloud.monitoring.v3; - -import javax.annotation.Generated; diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java deleted file mode 100644 index 8af23ae2..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.AlertPolicyServiceClient.ListAlertPoliciesPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.CreateAlertPolicyRequest; -import com.google.monitoring.v3.DeleteAlertPolicyRequest; -import com.google.monitoring.v3.GetAlertPolicyRequest; -import com.google.monitoring.v3.ListAlertPoliciesRequest; -import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.UpdateAlertPolicyRequest; -import com.google.protobuf.Empty; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public abstract class AlertPolicyServiceStub implements BackgroundResource { - - public UnaryCallable - listAlertPoliciesPagedCallable() { - throw new UnsupportedOperationException("Not implemented: listAlertPoliciesPagedCallable()"); - } - - public UnaryCallable - listAlertPoliciesCallable() { - throw new UnsupportedOperationException("Not implemented: listAlertPoliciesCallable()"); - } - - public UnaryCallable getAlertPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: getAlertPolicyCallable()"); - } - - public UnaryCallable createAlertPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: createAlertPolicyCallable()"); - } - - public UnaryCallable deleteAlertPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: deleteAlertPolicyCallable()"); - } - - public UnaryCallable updateAlertPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: updateAlertPolicyCallable()"); - } - - @Override - public abstract void close(); -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java b/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java deleted file mode 100644 index 6a2e2cf0..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.AlertPolicyServiceClient.ListAlertPoliciesPagedResponse; - -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GaxProperties; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.GrpcTransportChannel; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.retrying.RetrySettings; -import com.google.api.gax.rpc.ApiCallContext; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.PagedListDescriptor; -import com.google.api.gax.rpc.PagedListResponseFactory; -import com.google.api.gax.rpc.StatusCode; -import com.google.api.gax.rpc.StubSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.CreateAlertPolicyRequest; -import com.google.monitoring.v3.DeleteAlertPolicyRequest; -import com.google.monitoring.v3.GetAlertPolicyRequest; -import com.google.monitoring.v3.ListAlertPoliciesRequest; -import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.UpdateAlertPolicyRequest; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; -import org.threeten.bp.Duration; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link AlertPolicyServiceStub}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getAlertPolicy to 30 seconds: - * - *

- * 
- * AlertPolicyServiceStubSettings.Builder alertPolicyServiceSettingsBuilder =
- *     AlertPolicyServiceStubSettings.newBuilder();
- * alertPolicyServiceSettingsBuilder.getAlertPolicySettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * AlertPolicyServiceStubSettings alertPolicyServiceSettings = alertPolicyServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class AlertPolicyServiceStubSettings extends StubSettings { - /** The default scopes of the service. */ - private static final ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/cloud-platform") - .add("https://www.googleapis.com/auth/monitoring") - .add("https://www.googleapis.com/auth/monitoring.read") - .add("https://www.googleapis.com/auth/monitoring.write") - .build(); - - private final PagedCallSettings< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, ListAlertPoliciesPagedResponse> - listAlertPoliciesSettings; - private final UnaryCallSettings getAlertPolicySettings; - private final UnaryCallSettings createAlertPolicySettings; - private final UnaryCallSettings deleteAlertPolicySettings; - private final UnaryCallSettings updateAlertPolicySettings; - - /** Returns the object with the settings used for calls to listAlertPolicies. */ - public PagedCallSettings< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, ListAlertPoliciesPagedResponse> - listAlertPoliciesSettings() { - return listAlertPoliciesSettings; - } - - /** Returns the object with the settings used for calls to getAlertPolicy. */ - public UnaryCallSettings getAlertPolicySettings() { - return getAlertPolicySettings; - } - - /** Returns the object with the settings used for calls to createAlertPolicy. */ - public UnaryCallSettings createAlertPolicySettings() { - return createAlertPolicySettings; - } - - /** Returns the object with the settings used for calls to deleteAlertPolicy. */ - public UnaryCallSettings deleteAlertPolicySettings() { - return deleteAlertPolicySettings; - } - - /** Returns the object with the settings used for calls to updateAlertPolicy. */ - public UnaryCallSettings updateAlertPolicySettings() { - return updateAlertPolicySettings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public AlertPolicyServiceStub createStub() throws IOException { - if (getTransportChannelProvider() - .getTransportName() - .equals(GrpcTransportChannel.getGrpcTransportName())) { - return GrpcAlertPolicyServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); - } - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return InstantiatingExecutorProvider.newBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return "monitoring.googleapis.com:443"; - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return DEFAULT_SERVICE_SCOPES; - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return InstantiatingGrpcChannelProvider.newBuilder() - .setMaxInboundMessageSize(Integer.MAX_VALUE); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return defaultGrpcTransportProviderBuilder().build(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return ApiClientHeaderProvider.newBuilder() - .setGeneratedLibToken( - "gapic", GaxProperties.getLibraryVersion(AlertPolicyServiceStubSettings.class)) - .setTransportToken( - GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected AlertPolicyServiceStubSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - - listAlertPoliciesSettings = settingsBuilder.listAlertPoliciesSettings().build(); - getAlertPolicySettings = settingsBuilder.getAlertPolicySettings().build(); - createAlertPolicySettings = settingsBuilder.createAlertPolicySettings().build(); - deleteAlertPolicySettings = settingsBuilder.deleteAlertPolicySettings().build(); - updateAlertPolicySettings = settingsBuilder.updateAlertPolicySettings().build(); - } - - private static final PagedListDescriptor< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, AlertPolicy> - LIST_ALERT_POLICIES_PAGE_STR_DESC = - new PagedListDescriptor< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, AlertPolicy>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListAlertPoliciesRequest injectToken( - ListAlertPoliciesRequest payload, String token) { - return ListAlertPoliciesRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListAlertPoliciesRequest injectPageSize( - ListAlertPoliciesRequest payload, int pageSize) { - return ListAlertPoliciesRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListAlertPoliciesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListAlertPoliciesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListAlertPoliciesResponse payload) { - return payload.getAlertPoliciesList() != null - ? payload.getAlertPoliciesList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, ListAlertPoliciesPagedResponse> - LIST_ALERT_POLICIES_PAGE_STR_FACT = - new PagedListResponseFactory< - ListAlertPoliciesRequest, - ListAlertPoliciesResponse, - ListAlertPoliciesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListAlertPoliciesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext - pageContext = - PageContext.create( - callable, LIST_ALERT_POLICIES_PAGE_STR_DESC, request, context); - return ListAlertPoliciesPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - /** Builder for AlertPolicyServiceStubSettings. */ - public static class Builder - extends StubSettings.Builder { - private final ImmutableList> unaryMethodSettingsBuilders; - - private final PagedCallSettings.Builder< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, ListAlertPoliciesPagedResponse> - listAlertPoliciesSettings; - private final UnaryCallSettings.Builder - getAlertPolicySettings; - private final UnaryCallSettings.Builder - createAlertPolicySettings; - private final UnaryCallSettings.Builder - deleteAlertPolicySettings; - private final UnaryCallSettings.Builder - updateAlertPolicySettings; - - private static final ImmutableMap> - RETRYABLE_CODE_DEFINITIONS; - - static { - ImmutableMap.Builder> definitions = - ImmutableMap.builder(); - definitions.put( - "idempotent", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); - RETRYABLE_CODE_DEFINITIONS = definitions.build(); - } - - private static final ImmutableMap RETRY_PARAM_DEFINITIONS; - - static { - ImmutableMap.Builder definitions = ImmutableMap.builder(); - RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(20000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(20000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("default", settings); - RETRY_PARAM_DEFINITIONS = definitions.build(); - } - - protected Builder() { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(clientContext); - - listAlertPoliciesSettings = PagedCallSettings.newBuilder(LIST_ALERT_POLICIES_PAGE_STR_FACT); - - getAlertPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - createAlertPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - deleteAlertPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - updateAlertPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listAlertPoliciesSettings, - getAlertPolicySettings, - createAlertPolicySettings, - deleteAlertPolicySettings, - updateAlertPolicySettings); - - initDefaults(this); - } - - private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); - builder.setTransportChannelProvider(defaultTransportChannelProvider()); - builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); - builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); - return initDefaults(builder); - } - - private static Builder initDefaults(Builder builder) { - - builder - .listAlertPoliciesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getAlertPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .createAlertPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .deleteAlertPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .updateAlertPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - return builder; - } - - protected Builder(AlertPolicyServiceStubSettings settings) { - super(settings); - - listAlertPoliciesSettings = settings.listAlertPoliciesSettings.toBuilder(); - getAlertPolicySettings = settings.getAlertPolicySettings.toBuilder(); - createAlertPolicySettings = settings.createAlertPolicySettings.toBuilder(); - deleteAlertPolicySettings = settings.deleteAlertPolicySettings.toBuilder(); - updateAlertPolicySettings = settings.updateAlertPolicySettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listAlertPoliciesSettings, - getAlertPolicySettings, - createAlertPolicySettings, - deleteAlertPolicySettings, - updateAlertPolicySettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); - return this; - } - - public ImmutableList> unaryMethodSettingsBuilders() { - return unaryMethodSettingsBuilders; - } - - /** Returns the builder for the settings used for calls to listAlertPolicies. */ - public PagedCallSettings.Builder< - ListAlertPoliciesRequest, ListAlertPoliciesResponse, ListAlertPoliciesPagedResponse> - listAlertPoliciesSettings() { - return listAlertPoliciesSettings; - } - - /** Returns the builder for the settings used for calls to getAlertPolicy. */ - public UnaryCallSettings.Builder getAlertPolicySettings() { - return getAlertPolicySettings; - } - - /** Returns the builder for the settings used for calls to createAlertPolicy. */ - public UnaryCallSettings.Builder - createAlertPolicySettings() { - return createAlertPolicySettings; - } - - /** Returns the builder for the settings used for calls to deleteAlertPolicy. */ - public UnaryCallSettings.Builder deleteAlertPolicySettings() { - return deleteAlertPolicySettings; - } - - /** Returns the builder for the settings used for calls to updateAlertPolicy. */ - public UnaryCallSettings.Builder - updateAlertPolicySettings() { - return updateAlertPolicySettings; - } - - @Override - public AlertPolicyServiceStubSettings build() throws IOException { - return new AlertPolicyServiceStubSettings(this); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java deleted file mode 100644 index 30c3ba28..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupMembersPagedResponse; -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.monitoring.v3.CreateGroupRequest; -import com.google.monitoring.v3.DeleteGroupRequest; -import com.google.monitoring.v3.GetGroupRequest; -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.UpdateGroupRequest; -import com.google.protobuf.Empty; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public abstract class GroupServiceStub implements BackgroundResource { - - public UnaryCallable listGroupsPagedCallable() { - throw new UnsupportedOperationException("Not implemented: listGroupsPagedCallable()"); - } - - public UnaryCallable listGroupsCallable() { - throw new UnsupportedOperationException("Not implemented: listGroupsCallable()"); - } - - public UnaryCallable getGroupCallable() { - throw new UnsupportedOperationException("Not implemented: getGroupCallable()"); - } - - public UnaryCallable createGroupCallable() { - throw new UnsupportedOperationException("Not implemented: createGroupCallable()"); - } - - public UnaryCallable updateGroupCallable() { - throw new UnsupportedOperationException("Not implemented: updateGroupCallable()"); - } - - public UnaryCallable deleteGroupCallable() { - throw new UnsupportedOperationException("Not implemented: deleteGroupCallable()"); - } - - public UnaryCallable - listGroupMembersPagedCallable() { - throw new UnsupportedOperationException("Not implemented: listGroupMembersPagedCallable()"); - } - - public UnaryCallable - listGroupMembersCallable() { - throw new UnsupportedOperationException("Not implemented: listGroupMembersCallable()"); - } - - @Override - public abstract void close(); -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java deleted file mode 100644 index 091f3505..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java +++ /dev/null @@ -1,531 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupMembersPagedResponse; -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse; - -import com.google.api.MonitoredResource; -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GaxProperties; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.GrpcTransportChannel; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.retrying.RetrySettings; -import com.google.api.gax.rpc.ApiCallContext; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.PagedListDescriptor; -import com.google.api.gax.rpc.PagedListResponseFactory; -import com.google.api.gax.rpc.StatusCode; -import com.google.api.gax.rpc.StubSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.CreateGroupRequest; -import com.google.monitoring.v3.DeleteGroupRequest; -import com.google.monitoring.v3.GetGroupRequest; -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.UpdateGroupRequest; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; -import org.threeten.bp.Duration; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link GroupServiceStub}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getGroup to 30 seconds: - * - *

- * 
- * GroupServiceStubSettings.Builder groupServiceSettingsBuilder =
- *     GroupServiceStubSettings.newBuilder();
- * groupServiceSettingsBuilder.getGroupSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * GroupServiceStubSettings groupServiceSettings = groupServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class GroupServiceStubSettings extends StubSettings { - /** The default scopes of the service. */ - private static final ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/cloud-platform") - .add("https://www.googleapis.com/auth/monitoring") - .add("https://www.googleapis.com/auth/monitoring.read") - .add("https://www.googleapis.com/auth/monitoring.write") - .build(); - - private final PagedCallSettings - listGroupsSettings; - private final UnaryCallSettings getGroupSettings; - private final UnaryCallSettings createGroupSettings; - private final UnaryCallSettings updateGroupSettings; - private final UnaryCallSettings deleteGroupSettings; - private final PagedCallSettings< - ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> - listGroupMembersSettings; - - /** Returns the object with the settings used for calls to listGroups. */ - public PagedCallSettings - listGroupsSettings() { - return listGroupsSettings; - } - - /** Returns the object with the settings used for calls to getGroup. */ - public UnaryCallSettings getGroupSettings() { - return getGroupSettings; - } - - /** Returns the object with the settings used for calls to createGroup. */ - public UnaryCallSettings createGroupSettings() { - return createGroupSettings; - } - - /** Returns the object with the settings used for calls to updateGroup. */ - public UnaryCallSettings updateGroupSettings() { - return updateGroupSettings; - } - - /** Returns the object with the settings used for calls to deleteGroup. */ - public UnaryCallSettings deleteGroupSettings() { - return deleteGroupSettings; - } - - /** Returns the object with the settings used for calls to listGroupMembers. */ - public PagedCallSettings< - ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> - listGroupMembersSettings() { - return listGroupMembersSettings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public GroupServiceStub createStub() throws IOException { - if (getTransportChannelProvider() - .getTransportName() - .equals(GrpcTransportChannel.getGrpcTransportName())) { - return GrpcGroupServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); - } - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return InstantiatingExecutorProvider.newBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return "monitoring.googleapis.com:443"; - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return DEFAULT_SERVICE_SCOPES; - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return InstantiatingGrpcChannelProvider.newBuilder() - .setMaxInboundMessageSize(Integer.MAX_VALUE); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return defaultGrpcTransportProviderBuilder().build(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return ApiClientHeaderProvider.newBuilder() - .setGeneratedLibToken( - "gapic", GaxProperties.getLibraryVersion(GroupServiceStubSettings.class)) - .setTransportToken( - GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected GroupServiceStubSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - - listGroupsSettings = settingsBuilder.listGroupsSettings().build(); - getGroupSettings = settingsBuilder.getGroupSettings().build(); - createGroupSettings = settingsBuilder.createGroupSettings().build(); - updateGroupSettings = settingsBuilder.updateGroupSettings().build(); - deleteGroupSettings = settingsBuilder.deleteGroupSettings().build(); - listGroupMembersSettings = settingsBuilder.listGroupMembersSettings().build(); - } - - private static final PagedListDescriptor - LIST_GROUPS_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListGroupsRequest injectToken(ListGroupsRequest payload, String token) { - return ListGroupsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListGroupsRequest injectPageSize(ListGroupsRequest payload, int pageSize) { - return ListGroupsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListGroupsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListGroupsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListGroupsResponse payload) { - return payload.getGroupList() != null - ? payload.getGroupList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor< - ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource> - LIST_GROUP_MEMBERS_PAGE_STR_DESC = - new PagedListDescriptor< - ListGroupMembersRequest, ListGroupMembersResponse, MonitoredResource>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListGroupMembersRequest injectToken( - ListGroupMembersRequest payload, String token) { - return ListGroupMembersRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListGroupMembersRequest injectPageSize( - ListGroupMembersRequest payload, int pageSize) { - return ListGroupMembersRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListGroupMembersRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListGroupMembersResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListGroupMembersResponse payload) { - return payload.getMembersList() != null - ? payload.getMembersList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListGroupsRequest, ListGroupsResponse, ListGroupsPagedResponse> - LIST_GROUPS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListGroupsRequest, ListGroupsResponse, ListGroupsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListGroupsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_GROUPS_PAGE_STR_DESC, request, context); - return ListGroupsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> - LIST_GROUP_MEMBERS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListGroupMembersRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext - pageContext = - PageContext.create( - callable, LIST_GROUP_MEMBERS_PAGE_STR_DESC, request, context); - return ListGroupMembersPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - /** Builder for GroupServiceStubSettings. */ - public static class Builder extends StubSettings.Builder { - private final ImmutableList> unaryMethodSettingsBuilders; - - private final PagedCallSettings.Builder< - ListGroupsRequest, ListGroupsResponse, ListGroupsPagedResponse> - listGroupsSettings; - private final UnaryCallSettings.Builder getGroupSettings; - private final UnaryCallSettings.Builder createGroupSettings; - private final UnaryCallSettings.Builder updateGroupSettings; - private final UnaryCallSettings.Builder deleteGroupSettings; - private final PagedCallSettings.Builder< - ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> - listGroupMembersSettings; - - private static final ImmutableMap> - RETRYABLE_CODE_DEFINITIONS; - - static { - ImmutableMap.Builder> definitions = - ImmutableMap.builder(); - definitions.put( - "idempotent", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); - RETRYABLE_CODE_DEFINITIONS = definitions.build(); - } - - private static final ImmutableMap RETRY_PARAM_DEFINITIONS; - - static { - ImmutableMap.Builder definitions = ImmutableMap.builder(); - RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(20000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(20000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("default", settings); - RETRY_PARAM_DEFINITIONS = definitions.build(); - } - - protected Builder() { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(clientContext); - - listGroupsSettings = PagedCallSettings.newBuilder(LIST_GROUPS_PAGE_STR_FACT); - - getGroupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - createGroupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - updateGroupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - deleteGroupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - listGroupMembersSettings = PagedCallSettings.newBuilder(LIST_GROUP_MEMBERS_PAGE_STR_FACT); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listGroupsSettings, - getGroupSettings, - createGroupSettings, - updateGroupSettings, - deleteGroupSettings, - listGroupMembersSettings); - - initDefaults(this); - } - - private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); - builder.setTransportChannelProvider(defaultTransportChannelProvider()); - builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); - builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); - return initDefaults(builder); - } - - private static Builder initDefaults(Builder builder) { - - builder - .listGroupsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getGroupSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .createGroupSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .updateGroupSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .deleteGroupSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .listGroupMembersSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - return builder; - } - - protected Builder(GroupServiceStubSettings settings) { - super(settings); - - listGroupsSettings = settings.listGroupsSettings.toBuilder(); - getGroupSettings = settings.getGroupSettings.toBuilder(); - createGroupSettings = settings.createGroupSettings.toBuilder(); - updateGroupSettings = settings.updateGroupSettings.toBuilder(); - deleteGroupSettings = settings.deleteGroupSettings.toBuilder(); - listGroupMembersSettings = settings.listGroupMembersSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listGroupsSettings, - getGroupSettings, - createGroupSettings, - updateGroupSettings, - deleteGroupSettings, - listGroupMembersSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); - return this; - } - - public ImmutableList> unaryMethodSettingsBuilders() { - return unaryMethodSettingsBuilders; - } - - /** Returns the builder for the settings used for calls to listGroups. */ - public PagedCallSettings.Builder - listGroupsSettings() { - return listGroupsSettings; - } - - /** Returns the builder for the settings used for calls to getGroup. */ - public UnaryCallSettings.Builder getGroupSettings() { - return getGroupSettings; - } - - /** Returns the builder for the settings used for calls to createGroup. */ - public UnaryCallSettings.Builder createGroupSettings() { - return createGroupSettings; - } - - /** Returns the builder for the settings used for calls to updateGroup. */ - public UnaryCallSettings.Builder updateGroupSettings() { - return updateGroupSettings; - } - - /** Returns the builder for the settings used for calls to deleteGroup. */ - public UnaryCallSettings.Builder deleteGroupSettings() { - return deleteGroupSettings; - } - - /** Returns the builder for the settings used for calls to listGroupMembers. */ - public PagedCallSettings.Builder< - ListGroupMembersRequest, ListGroupMembersResponse, ListGroupMembersPagedResponse> - listGroupMembersSettings() { - return listGroupMembersSettings; - } - - @Override - public GroupServiceStubSettings build() throws IOException { - return new GroupServiceStubSettings(this); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceCallableFactory.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceCallableFactory.java deleted file mode 100644 index 959fa30b..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceCallableFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcCallableFactory; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.BatchingCallSettings; -import com.google.api.gax.rpc.BidiStreamingCallable; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientStreamingCallable; -import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallable; -import com.google.api.gax.rpc.StreamingCallSettings; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcAlertPolicyServiceCallableFactory implements GrpcStubCallableFactory { - @Override - public UnaryCallable createUnaryCallable( - GrpcCallSettings grpcCallSettings, - UnaryCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); - } - - @Override - public - UnaryCallable createPagedCallable( - GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); - } - - @Override - public UnaryCallable createBatchingCallable( - GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); - } - - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - @Override - public - OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, - ClientContext clientContext, - OperationsStub operationsStub) { - return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); - } - - @Override - public - BidiStreamingCallable createBidiStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ServerStreamingCallable createServerStreamingCallable( - GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ClientStreamingCallable createClientStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java deleted file mode 100644 index 82218990..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.AlertPolicyServiceClient.ListAlertPoliciesPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.core.BackgroundResourceAggregation; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableMap; -import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.CreateAlertPolicyRequest; -import com.google.monitoring.v3.DeleteAlertPolicyRequest; -import com.google.monitoring.v3.GetAlertPolicyRequest; -import com.google.monitoring.v3.ListAlertPoliciesRequest; -import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.UpdateAlertPolicyRequest; -import com.google.protobuf.Empty; -import io.grpc.MethodDescriptor; -import io.grpc.protobuf.ProtoUtils; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcAlertPolicyServiceStub extends AlertPolicyServiceStub { - - private static final MethodDescriptor - listAlertPoliciesMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.AlertPolicyService/ListAlertPolicies") - .setRequestMarshaller( - ProtoUtils.marshaller(ListAlertPoliciesRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListAlertPoliciesResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor - getAlertPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.AlertPolicyService/GetAlertPolicy") - .setRequestMarshaller( - ProtoUtils.marshaller(GetAlertPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(AlertPolicy.getDefaultInstance())) - .build(); - private static final MethodDescriptor - createAlertPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.AlertPolicyService/CreateAlertPolicy") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateAlertPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(AlertPolicy.getDefaultInstance())) - .build(); - private static final MethodDescriptor - deleteAlertPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.AlertPolicyService/DeleteAlertPolicy") - .setRequestMarshaller( - ProtoUtils.marshaller(DeleteAlertPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor - updateAlertPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.AlertPolicyService/UpdateAlertPolicy") - .setRequestMarshaller( - ProtoUtils.marshaller(UpdateAlertPolicyRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(AlertPolicy.getDefaultInstance())) - .build(); - - private final BackgroundResource backgroundResources; - - private final UnaryCallable - listAlertPoliciesCallable; - private final UnaryCallable - listAlertPoliciesPagedCallable; - private final UnaryCallable getAlertPolicyCallable; - private final UnaryCallable createAlertPolicyCallable; - private final UnaryCallable deleteAlertPolicyCallable; - private final UnaryCallable updateAlertPolicyCallable; - - private final GrpcStubCallableFactory callableFactory; - - public static final GrpcAlertPolicyServiceStub create(AlertPolicyServiceStubSettings settings) - throws IOException { - return new GrpcAlertPolicyServiceStub(settings, ClientContext.create(settings)); - } - - public static final GrpcAlertPolicyServiceStub create(ClientContext clientContext) - throws IOException { - return new GrpcAlertPolicyServiceStub( - AlertPolicyServiceStubSettings.newBuilder().build(), clientContext); - } - - public static final GrpcAlertPolicyServiceStub create( - ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { - return new GrpcAlertPolicyServiceStub( - AlertPolicyServiceStubSettings.newBuilder().build(), clientContext, callableFactory); - } - - /** - * Constructs an instance of GrpcAlertPolicyServiceStub, using the given settings. This is - * protected so that it is easy to make a subclass, but otherwise, the static factory methods - * should be preferred. - */ - protected GrpcAlertPolicyServiceStub( - AlertPolicyServiceStubSettings settings, ClientContext clientContext) throws IOException { - this(settings, clientContext, new GrpcAlertPolicyServiceCallableFactory()); - } - - /** - * Constructs an instance of GrpcAlertPolicyServiceStub, using the given settings. This is - * protected so that it is easy to make a subclass, but otherwise, the static factory methods - * should be preferred. - */ - protected GrpcAlertPolicyServiceStub( - AlertPolicyServiceStubSettings settings, - ClientContext clientContext, - GrpcStubCallableFactory callableFactory) - throws IOException { - this.callableFactory = callableFactory; - - GrpcCallSettings - listAlertPoliciesTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listAlertPoliciesMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListAlertPoliciesRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings getAlertPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getAlertPolicyMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetAlertPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings createAlertPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createAlertPolicyMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateAlertPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings deleteAlertPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteAlertPolicyMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteAlertPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings updateAlertPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateAlertPolicyMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateAlertPolicyRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put( - "alert_policy.name", String.valueOf(request.getAlertPolicy().getName())); - return params.build(); - } - }) - .build(); - - this.listAlertPoliciesCallable = - callableFactory.createUnaryCallable( - listAlertPoliciesTransportSettings, - settings.listAlertPoliciesSettings(), - clientContext); - this.listAlertPoliciesPagedCallable = - callableFactory.createPagedCallable( - listAlertPoliciesTransportSettings, - settings.listAlertPoliciesSettings(), - clientContext); - this.getAlertPolicyCallable = - callableFactory.createUnaryCallable( - getAlertPolicyTransportSettings, settings.getAlertPolicySettings(), clientContext); - this.createAlertPolicyCallable = - callableFactory.createUnaryCallable( - createAlertPolicyTransportSettings, - settings.createAlertPolicySettings(), - clientContext); - this.deleteAlertPolicyCallable = - callableFactory.createUnaryCallable( - deleteAlertPolicyTransportSettings, - settings.deleteAlertPolicySettings(), - clientContext); - this.updateAlertPolicyCallable = - callableFactory.createUnaryCallable( - updateAlertPolicyTransportSettings, - settings.updateAlertPolicySettings(), - clientContext); - - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); - } - - public UnaryCallable - listAlertPoliciesPagedCallable() { - return listAlertPoliciesPagedCallable; - } - - public UnaryCallable - listAlertPoliciesCallable() { - return listAlertPoliciesCallable; - } - - public UnaryCallable getAlertPolicyCallable() { - return getAlertPolicyCallable; - } - - public UnaryCallable createAlertPolicyCallable() { - return createAlertPolicyCallable; - } - - public UnaryCallable deleteAlertPolicyCallable() { - return deleteAlertPolicyCallable; - } - - public UnaryCallable updateAlertPolicyCallable() { - return updateAlertPolicyCallable; - } - - @Override - public final void close() { - shutdown(); - } - - @Override - public void shutdown() { - backgroundResources.shutdown(); - } - - @Override - public boolean isShutdown() { - return backgroundResources.isShutdown(); - } - - @Override - public boolean isTerminated() { - return backgroundResources.isTerminated(); - } - - @Override - public void shutdownNow() { - backgroundResources.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return backgroundResources.awaitTermination(duration, unit); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceCallableFactory.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceCallableFactory.java deleted file mode 100644 index 344a0b16..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceCallableFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcCallableFactory; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.BatchingCallSettings; -import com.google.api.gax.rpc.BidiStreamingCallable; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientStreamingCallable; -import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallable; -import com.google.api.gax.rpc.StreamingCallSettings; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcGroupServiceCallableFactory implements GrpcStubCallableFactory { - @Override - public UnaryCallable createUnaryCallable( - GrpcCallSettings grpcCallSettings, - UnaryCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); - } - - @Override - public - UnaryCallable createPagedCallable( - GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); - } - - @Override - public UnaryCallable createBatchingCallable( - GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); - } - - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - @Override - public - OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, - ClientContext clientContext, - OperationsStub operationsStub) { - return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); - } - - @Override - public - BidiStreamingCallable createBidiStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ServerStreamingCallable createServerStreamingCallable( - GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ClientStreamingCallable createClientStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java deleted file mode 100644 index 31ff1308..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupMembersPagedResponse; -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.core.BackgroundResourceAggregation; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableMap; -import com.google.monitoring.v3.CreateGroupRequest; -import com.google.monitoring.v3.DeleteGroupRequest; -import com.google.monitoring.v3.GetGroupRequest; -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.UpdateGroupRequest; -import com.google.protobuf.Empty; -import io.grpc.MethodDescriptor; -import io.grpc.protobuf.ProtoUtils; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcGroupServiceStub extends GroupServiceStub { - - private static final MethodDescriptor - listGroupsMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.GroupService/ListGroups") - .setRequestMarshaller(ProtoUtils.marshaller(ListGroupsRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(ListGroupsResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor getGroupMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.GroupService/GetGroup") - .setRequestMarshaller(ProtoUtils.marshaller(GetGroupRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Group.getDefaultInstance())) - .build(); - private static final MethodDescriptor createGroupMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.GroupService/CreateGroup") - .setRequestMarshaller(ProtoUtils.marshaller(CreateGroupRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Group.getDefaultInstance())) - .build(); - private static final MethodDescriptor updateGroupMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.GroupService/UpdateGroup") - .setRequestMarshaller(ProtoUtils.marshaller(UpdateGroupRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Group.getDefaultInstance())) - .build(); - private static final MethodDescriptor deleteGroupMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.GroupService/DeleteGroup") - .setRequestMarshaller(ProtoUtils.marshaller(DeleteGroupRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor - listGroupMembersMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.GroupService/ListGroupMembers") - .setRequestMarshaller( - ProtoUtils.marshaller(ListGroupMembersRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListGroupMembersResponse.getDefaultInstance())) - .build(); - - private final BackgroundResource backgroundResources; - - private final UnaryCallable listGroupsCallable; - private final UnaryCallable listGroupsPagedCallable; - private final UnaryCallable getGroupCallable; - private final UnaryCallable createGroupCallable; - private final UnaryCallable updateGroupCallable; - private final UnaryCallable deleteGroupCallable; - private final UnaryCallable - listGroupMembersCallable; - private final UnaryCallable - listGroupMembersPagedCallable; - - private final GrpcStubCallableFactory callableFactory; - - public static final GrpcGroupServiceStub create(GroupServiceStubSettings settings) - throws IOException { - return new GrpcGroupServiceStub(settings, ClientContext.create(settings)); - } - - public static final GrpcGroupServiceStub create(ClientContext clientContext) throws IOException { - return new GrpcGroupServiceStub(GroupServiceStubSettings.newBuilder().build(), clientContext); - } - - public static final GrpcGroupServiceStub create( - ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { - return new GrpcGroupServiceStub( - GroupServiceStubSettings.newBuilder().build(), clientContext, callableFactory); - } - - /** - * Constructs an instance of GrpcGroupServiceStub, using the given settings. This is protected so - * that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ - protected GrpcGroupServiceStub(GroupServiceStubSettings settings, ClientContext clientContext) - throws IOException { - this(settings, clientContext, new GrpcGroupServiceCallableFactory()); - } - - /** - * Constructs an instance of GrpcGroupServiceStub, using the given settings. This is protected so - * that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ - protected GrpcGroupServiceStub( - GroupServiceStubSettings settings, - ClientContext clientContext, - GrpcStubCallableFactory callableFactory) - throws IOException { - this.callableFactory = callableFactory; - - GrpcCallSettings listGroupsTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listGroupsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListGroupsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings getGroupTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getGroupMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetGroupRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings createGroupTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createGroupMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateGroupRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings updateGroupTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateGroupMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateGroupRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("group.name", String.valueOf(request.getGroup().getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings deleteGroupTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteGroupMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteGroupRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - listGroupMembersTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listGroupMembersMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListGroupMembersRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - - this.listGroupsCallable = - callableFactory.createUnaryCallable( - listGroupsTransportSettings, settings.listGroupsSettings(), clientContext); - this.listGroupsPagedCallable = - callableFactory.createPagedCallable( - listGroupsTransportSettings, settings.listGroupsSettings(), clientContext); - this.getGroupCallable = - callableFactory.createUnaryCallable( - getGroupTransportSettings, settings.getGroupSettings(), clientContext); - this.createGroupCallable = - callableFactory.createUnaryCallable( - createGroupTransportSettings, settings.createGroupSettings(), clientContext); - this.updateGroupCallable = - callableFactory.createUnaryCallable( - updateGroupTransportSettings, settings.updateGroupSettings(), clientContext); - this.deleteGroupCallable = - callableFactory.createUnaryCallable( - deleteGroupTransportSettings, settings.deleteGroupSettings(), clientContext); - this.listGroupMembersCallable = - callableFactory.createUnaryCallable( - listGroupMembersTransportSettings, settings.listGroupMembersSettings(), clientContext); - this.listGroupMembersPagedCallable = - callableFactory.createPagedCallable( - listGroupMembersTransportSettings, settings.listGroupMembersSettings(), clientContext); - - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); - } - - public UnaryCallable listGroupsPagedCallable() { - return listGroupsPagedCallable; - } - - public UnaryCallable listGroupsCallable() { - return listGroupsCallable; - } - - public UnaryCallable getGroupCallable() { - return getGroupCallable; - } - - public UnaryCallable createGroupCallable() { - return createGroupCallable; - } - - public UnaryCallable updateGroupCallable() { - return updateGroupCallable; - } - - public UnaryCallable deleteGroupCallable() { - return deleteGroupCallable; - } - - public UnaryCallable - listGroupMembersPagedCallable() { - return listGroupMembersPagedCallable; - } - - public UnaryCallable - listGroupMembersCallable() { - return listGroupMembersCallable; - } - - @Override - public final void close() { - shutdown(); - } - - @Override - public void shutdown() { - backgroundResources.shutdown(); - } - - @Override - public boolean isShutdown() { - return backgroundResources.isShutdown(); - } - - @Override - public boolean isTerminated() { - return backgroundResources.isTerminated(); - } - - @Override - public void shutdownNow() { - backgroundResources.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return backgroundResources.awaitTermination(duration, unit); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceCallableFactory.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceCallableFactory.java deleted file mode 100644 index a9e34bea..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceCallableFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcCallableFactory; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.BatchingCallSettings; -import com.google.api.gax.rpc.BidiStreamingCallable; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientStreamingCallable; -import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallable; -import com.google.api.gax.rpc.StreamingCallSettings; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcMetricServiceCallableFactory implements GrpcStubCallableFactory { - @Override - public UnaryCallable createUnaryCallable( - GrpcCallSettings grpcCallSettings, - UnaryCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); - } - - @Override - public - UnaryCallable createPagedCallable( - GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); - } - - @Override - public UnaryCallable createBatchingCallable( - GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); - } - - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - @Override - public - OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, - ClientContext clientContext, - OperationsStub operationsStub) { - return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); - } - - @Override - public - BidiStreamingCallable createBidiStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ServerStreamingCallable createServerStreamingCallable( - GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ClientStreamingCallable createClientStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java deleted file mode 100644 index 4c6256a8..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java +++ /dev/null @@ -1,464 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMetricDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse; - -import com.google.api.MetricDescriptor; -import com.google.api.MonitoredResourceDescriptor; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.core.BackgroundResourceAggregation; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableMap; -import com.google.monitoring.v3.CreateMetricDescriptorRequest; -import com.google.monitoring.v3.CreateTimeSeriesRequest; -import com.google.monitoring.v3.DeleteMetricDescriptorRequest; -import com.google.monitoring.v3.GetMetricDescriptorRequest; -import com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest; -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.protobuf.Empty; -import io.grpc.MethodDescriptor; -import io.grpc.protobuf.ProtoUtils; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcMetricServiceStub extends MetricServiceStub { - - private static final MethodDescriptor< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> - listMonitoredResourceDescriptorsMethodDescriptor = - MethodDescriptor - . - newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.MetricService/ListMonitoredResourceDescriptors") - .setRequestMarshaller( - ProtoUtils.marshaller( - ListMonitoredResourceDescriptorsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller( - ListMonitoredResourceDescriptorsResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor< - GetMonitoredResourceDescriptorRequest, MonitoredResourceDescriptor> - getMonitoredResourceDescriptorMethodDescriptor = - MethodDescriptor - .newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.MetricService/GetMonitoredResourceDescriptor") - .setRequestMarshaller( - ProtoUtils.marshaller(GetMonitoredResourceDescriptorRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(MonitoredResourceDescriptor.getDefaultInstance())) - .build(); - private static final MethodDescriptor - listMetricDescriptorsMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.MetricService/ListMetricDescriptors") - .setRequestMarshaller( - ProtoUtils.marshaller(ListMetricDescriptorsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListMetricDescriptorsResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor - getMetricDescriptorMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.MetricService/GetMetricDescriptor") - .setRequestMarshaller( - ProtoUtils.marshaller(GetMetricDescriptorRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(MetricDescriptor.getDefaultInstance())) - .build(); - private static final MethodDescriptor - createMetricDescriptorMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.MetricService/CreateMetricDescriptor") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateMetricDescriptorRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(MetricDescriptor.getDefaultInstance())) - .build(); - private static final MethodDescriptor - deleteMetricDescriptorMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.MetricService/DeleteMetricDescriptor") - .setRequestMarshaller( - ProtoUtils.marshaller(DeleteMetricDescriptorRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor - listTimeSeriesMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.MetricService/ListTimeSeries") - .setRequestMarshaller( - ProtoUtils.marshaller(ListTimeSeriesRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListTimeSeriesResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor - createTimeSeriesMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.MetricService/CreateTimeSeries") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateTimeSeriesRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - - private final BackgroundResource backgroundResources; - - private final UnaryCallable< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> - listMonitoredResourceDescriptorsCallable; - private final UnaryCallable< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsPagedCallable; - private final UnaryCallable - getMonitoredResourceDescriptorCallable; - private final UnaryCallable - listMetricDescriptorsCallable; - private final UnaryCallable - listMetricDescriptorsPagedCallable; - private final UnaryCallable - getMetricDescriptorCallable; - private final UnaryCallable - createMetricDescriptorCallable; - private final UnaryCallable deleteMetricDescriptorCallable; - private final UnaryCallable listTimeSeriesCallable; - private final UnaryCallable - listTimeSeriesPagedCallable; - private final UnaryCallable createTimeSeriesCallable; - - private final GrpcStubCallableFactory callableFactory; - - public static final GrpcMetricServiceStub create(MetricServiceStubSettings settings) - throws IOException { - return new GrpcMetricServiceStub(settings, ClientContext.create(settings)); - } - - public static final GrpcMetricServiceStub create(ClientContext clientContext) throws IOException { - return new GrpcMetricServiceStub(MetricServiceStubSettings.newBuilder().build(), clientContext); - } - - public static final GrpcMetricServiceStub create( - ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { - return new GrpcMetricServiceStub( - MetricServiceStubSettings.newBuilder().build(), clientContext, callableFactory); - } - - /** - * Constructs an instance of GrpcMetricServiceStub, using the given settings. This is protected so - * that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ - protected GrpcMetricServiceStub(MetricServiceStubSettings settings, ClientContext clientContext) - throws IOException { - this(settings, clientContext, new GrpcMetricServiceCallableFactory()); - } - - /** - * Constructs an instance of GrpcMetricServiceStub, using the given settings. This is protected so - * that it is easy to make a subclass, but otherwise, the static factory methods should be - * preferred. - */ - protected GrpcMetricServiceStub( - MetricServiceStubSettings settings, - ClientContext clientContext, - GrpcStubCallableFactory callableFactory) - throws IOException { - this.callableFactory = callableFactory; - - GrpcCallSettings< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> - listMonitoredResourceDescriptorsTransportSettings = - GrpcCallSettings - . - newBuilder() - .setMethodDescriptor(listMonitoredResourceDescriptorsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract( - ListMonitoredResourceDescriptorsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - getMonitoredResourceDescriptorTransportSettings = - GrpcCallSettings - .newBuilder() - .setMethodDescriptor(getMonitoredResourceDescriptorMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract( - GetMonitoredResourceDescriptorRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - listMetricDescriptorsTransportSettings = - GrpcCallSettings - .newBuilder() - .setMethodDescriptor(listMetricDescriptorsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListMetricDescriptorsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - getMetricDescriptorTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getMetricDescriptorMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetMetricDescriptorRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - createMetricDescriptorTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createMetricDescriptorMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateMetricDescriptorRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings deleteMetricDescriptorTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteMetricDescriptorMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteMetricDescriptorRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - listTimeSeriesTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listTimeSeriesMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListTimeSeriesRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings createTimeSeriesTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createTimeSeriesMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateTimeSeriesRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - - this.listMonitoredResourceDescriptorsCallable = - callableFactory.createUnaryCallable( - listMonitoredResourceDescriptorsTransportSettings, - settings.listMonitoredResourceDescriptorsSettings(), - clientContext); - this.listMonitoredResourceDescriptorsPagedCallable = - callableFactory.createPagedCallable( - listMonitoredResourceDescriptorsTransportSettings, - settings.listMonitoredResourceDescriptorsSettings(), - clientContext); - this.getMonitoredResourceDescriptorCallable = - callableFactory.createUnaryCallable( - getMonitoredResourceDescriptorTransportSettings, - settings.getMonitoredResourceDescriptorSettings(), - clientContext); - this.listMetricDescriptorsCallable = - callableFactory.createUnaryCallable( - listMetricDescriptorsTransportSettings, - settings.listMetricDescriptorsSettings(), - clientContext); - this.listMetricDescriptorsPagedCallable = - callableFactory.createPagedCallable( - listMetricDescriptorsTransportSettings, - settings.listMetricDescriptorsSettings(), - clientContext); - this.getMetricDescriptorCallable = - callableFactory.createUnaryCallable( - getMetricDescriptorTransportSettings, - settings.getMetricDescriptorSettings(), - clientContext); - this.createMetricDescriptorCallable = - callableFactory.createUnaryCallable( - createMetricDescriptorTransportSettings, - settings.createMetricDescriptorSettings(), - clientContext); - this.deleteMetricDescriptorCallable = - callableFactory.createUnaryCallable( - deleteMetricDescriptorTransportSettings, - settings.deleteMetricDescriptorSettings(), - clientContext); - this.listTimeSeriesCallable = - callableFactory.createUnaryCallable( - listTimeSeriesTransportSettings, settings.listTimeSeriesSettings(), clientContext); - this.listTimeSeriesPagedCallable = - callableFactory.createPagedCallable( - listTimeSeriesTransportSettings, settings.listTimeSeriesSettings(), clientContext); - this.createTimeSeriesCallable = - callableFactory.createUnaryCallable( - createTimeSeriesTransportSettings, settings.createTimeSeriesSettings(), clientContext); - - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); - } - - public UnaryCallable< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsPagedCallable() { - return listMonitoredResourceDescriptorsPagedCallable; - } - - public UnaryCallable< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> - listMonitoredResourceDescriptorsCallable() { - return listMonitoredResourceDescriptorsCallable; - } - - public UnaryCallable - getMonitoredResourceDescriptorCallable() { - return getMonitoredResourceDescriptorCallable; - } - - public UnaryCallable - listMetricDescriptorsPagedCallable() { - return listMetricDescriptorsPagedCallable; - } - - public UnaryCallable - listMetricDescriptorsCallable() { - return listMetricDescriptorsCallable; - } - - public UnaryCallable getMetricDescriptorCallable() { - return getMetricDescriptorCallable; - } - - public UnaryCallable - createMetricDescriptorCallable() { - return createMetricDescriptorCallable; - } - - public UnaryCallable deleteMetricDescriptorCallable() { - return deleteMetricDescriptorCallable; - } - - public UnaryCallable - listTimeSeriesPagedCallable() { - return listTimeSeriesPagedCallable; - } - - public UnaryCallable listTimeSeriesCallable() { - return listTimeSeriesCallable; - } - - public UnaryCallable createTimeSeriesCallable() { - return createTimeSeriesCallable; - } - - @Override - public final void close() { - shutdown(); - } - - @Override - public void shutdown() { - backgroundResources.shutdown(); - } - - @Override - public boolean isShutdown() { - return backgroundResources.isShutdown(); - } - - @Override - public boolean isTerminated() { - return backgroundResources.isTerminated(); - } - - @Override - public void shutdownNow() { - backgroundResources.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return backgroundResources.awaitTermination(duration, unit); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceCallableFactory.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceCallableFactory.java deleted file mode 100644 index 40f8719b..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceCallableFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcCallableFactory; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.BatchingCallSettings; -import com.google.api.gax.rpc.BidiStreamingCallable; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientStreamingCallable; -import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallable; -import com.google.api.gax.rpc.StreamingCallSettings; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcNotificationChannelServiceCallableFactory implements GrpcStubCallableFactory { - @Override - public UnaryCallable createUnaryCallable( - GrpcCallSettings grpcCallSettings, - UnaryCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); - } - - @Override - public - UnaryCallable createPagedCallable( - GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); - } - - @Override - public UnaryCallable createBatchingCallable( - GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); - } - - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - @Override - public - OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, - ClientContext clientContext, - OperationsStub operationsStub) { - return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); - } - - @Override - public - BidiStreamingCallable createBidiStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ServerStreamingCallable createServerStreamingCallable( - GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ClientStreamingCallable createClientStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java deleted file mode 100644 index 3f104869..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java +++ /dev/null @@ -1,586 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.core.BackgroundResourceAggregation; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableMap; -import com.google.monitoring.v3.CreateNotificationChannelRequest; -import com.google.monitoring.v3.DeleteNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelDescriptorRequest; -import com.google.monitoring.v3.GetNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsRequest; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsResponse; -import com.google.monitoring.v3.ListNotificationChannelsRequest; -import com.google.monitoring.v3.ListNotificationChannelsResponse; -import com.google.monitoring.v3.NotificationChannel; -import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.UpdateNotificationChannelRequest; -import com.google.monitoring.v3.VerifyNotificationChannelRequest; -import com.google.protobuf.Empty; -import io.grpc.MethodDescriptor; -import io.grpc.protobuf.ProtoUtils; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcNotificationChannelServiceStub extends NotificationChannelServiceStub { - - private static final MethodDescriptor< - ListNotificationChannelDescriptorsRequest, ListNotificationChannelDescriptorsResponse> - listNotificationChannelDescriptorsMethodDescriptor = - MethodDescriptor - . - newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/ListNotificationChannelDescriptors") - .setRequestMarshaller( - ProtoUtils.marshaller( - ListNotificationChannelDescriptorsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller( - ListNotificationChannelDescriptorsResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor< - GetNotificationChannelDescriptorRequest, NotificationChannelDescriptor> - getNotificationChannelDescriptorMethodDescriptor = - MethodDescriptor - .newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/GetNotificationChannelDescriptor") - .setRequestMarshaller( - ProtoUtils.marshaller( - GetNotificationChannelDescriptorRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(NotificationChannelDescriptor.getDefaultInstance())) - .build(); - private static final MethodDescriptor< - ListNotificationChannelsRequest, ListNotificationChannelsResponse> - listNotificationChannelsMethodDescriptor = - MethodDescriptor - .newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/ListNotificationChannels") - .setRequestMarshaller( - ProtoUtils.marshaller(ListNotificationChannelsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListNotificationChannelsResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor - getNotificationChannelMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/GetNotificationChannel") - .setRequestMarshaller( - ProtoUtils.marshaller(GetNotificationChannelRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(NotificationChannel.getDefaultInstance())) - .build(); - private static final MethodDescriptor - createNotificationChannelMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/CreateNotificationChannel") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateNotificationChannelRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(NotificationChannel.getDefaultInstance())) - .build(); - private static final MethodDescriptor - updateNotificationChannelMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/UpdateNotificationChannel") - .setRequestMarshaller( - ProtoUtils.marshaller(UpdateNotificationChannelRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(NotificationChannel.getDefaultInstance())) - .build(); - private static final MethodDescriptor - deleteNotificationChannelMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/DeleteNotificationChannel") - .setRequestMarshaller( - ProtoUtils.marshaller(DeleteNotificationChannelRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor - sendNotificationChannelVerificationCodeMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/SendNotificationChannelVerificationCode") - .setRequestMarshaller( - ProtoUtils.marshaller( - SendNotificationChannelVerificationCodeRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeMethodDescriptor = - MethodDescriptor - . - newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/GetNotificationChannelVerificationCode") - .setRequestMarshaller( - ProtoUtils.marshaller( - GetNotificationChannelVerificationCodeRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller( - GetNotificationChannelVerificationCodeResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor - verifyNotificationChannelMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - "google.monitoring.v3.NotificationChannelService/VerifyNotificationChannel") - .setRequestMarshaller( - ProtoUtils.marshaller(VerifyNotificationChannelRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(NotificationChannel.getDefaultInstance())) - .build(); - - private final BackgroundResource backgroundResources; - - private final UnaryCallable< - ListNotificationChannelDescriptorsRequest, ListNotificationChannelDescriptorsResponse> - listNotificationChannelDescriptorsCallable; - private final UnaryCallable< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsPagedCallable; - private final UnaryCallable< - GetNotificationChannelDescriptorRequest, NotificationChannelDescriptor> - getNotificationChannelDescriptorCallable; - private final UnaryCallable - listNotificationChannelsCallable; - private final UnaryCallable< - ListNotificationChannelsRequest, ListNotificationChannelsPagedResponse> - listNotificationChannelsPagedCallable; - private final UnaryCallable - getNotificationChannelCallable; - private final UnaryCallable - createNotificationChannelCallable; - private final UnaryCallable - updateNotificationChannelCallable; - private final UnaryCallable - deleteNotificationChannelCallable; - private final UnaryCallable - sendNotificationChannelVerificationCodeCallable; - private final UnaryCallable< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeCallable; - private final UnaryCallable - verifyNotificationChannelCallable; - - private final GrpcStubCallableFactory callableFactory; - - public static final GrpcNotificationChannelServiceStub create( - NotificationChannelServiceStubSettings settings) throws IOException { - return new GrpcNotificationChannelServiceStub(settings, ClientContext.create(settings)); - } - - public static final GrpcNotificationChannelServiceStub create(ClientContext clientContext) - throws IOException { - return new GrpcNotificationChannelServiceStub( - NotificationChannelServiceStubSettings.newBuilder().build(), clientContext); - } - - public static final GrpcNotificationChannelServiceStub create( - ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { - return new GrpcNotificationChannelServiceStub( - NotificationChannelServiceStubSettings.newBuilder().build(), - clientContext, - callableFactory); - } - - /** - * Constructs an instance of GrpcNotificationChannelServiceStub, using the given settings. This is - * protected so that it is easy to make a subclass, but otherwise, the static factory methods - * should be preferred. - */ - protected GrpcNotificationChannelServiceStub( - NotificationChannelServiceStubSettings settings, ClientContext clientContext) - throws IOException { - this(settings, clientContext, new GrpcNotificationChannelServiceCallableFactory()); - } - - /** - * Constructs an instance of GrpcNotificationChannelServiceStub, using the given settings. This is - * protected so that it is easy to make a subclass, but otherwise, the static factory methods - * should be preferred. - */ - protected GrpcNotificationChannelServiceStub( - NotificationChannelServiceStubSettings settings, - ClientContext clientContext, - GrpcStubCallableFactory callableFactory) - throws IOException { - this.callableFactory = callableFactory; - - GrpcCallSettings< - ListNotificationChannelDescriptorsRequest, ListNotificationChannelDescriptorsResponse> - listNotificationChannelDescriptorsTransportSettings = - GrpcCallSettings - . - newBuilder() - .setMethodDescriptor(listNotificationChannelDescriptorsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract( - ListNotificationChannelDescriptorsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - getNotificationChannelDescriptorTransportSettings = - GrpcCallSettings - . - newBuilder() - .setMethodDescriptor(getNotificationChannelDescriptorMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract( - GetNotificationChannelDescriptorRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - listNotificationChannelsTransportSettings = - GrpcCallSettings - .newBuilder() - .setMethodDescriptor(listNotificationChannelsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListNotificationChannelsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - getNotificationChannelTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getNotificationChannelMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetNotificationChannelRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - createNotificationChannelTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createNotificationChannelMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateNotificationChannelRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - updateNotificationChannelTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateNotificationChannelMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateNotificationChannelRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put( - "notification_channel.name", - String.valueOf(request.getNotificationChannel().getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - deleteNotificationChannelTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteNotificationChannelMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteNotificationChannelRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - sendNotificationChannelVerificationCodeTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(sendNotificationChannelVerificationCodeMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract( - SendNotificationChannelVerificationCodeRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeTransportSettings = - GrpcCallSettings - . - newBuilder() - .setMethodDescriptor(getNotificationChannelVerificationCodeMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract( - GetNotificationChannelVerificationCodeRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - verifyNotificationChannelTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(verifyNotificationChannelMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(VerifyNotificationChannelRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - - this.listNotificationChannelDescriptorsCallable = - callableFactory.createUnaryCallable( - listNotificationChannelDescriptorsTransportSettings, - settings.listNotificationChannelDescriptorsSettings(), - clientContext); - this.listNotificationChannelDescriptorsPagedCallable = - callableFactory.createPagedCallable( - listNotificationChannelDescriptorsTransportSettings, - settings.listNotificationChannelDescriptorsSettings(), - clientContext); - this.getNotificationChannelDescriptorCallable = - callableFactory.createUnaryCallable( - getNotificationChannelDescriptorTransportSettings, - settings.getNotificationChannelDescriptorSettings(), - clientContext); - this.listNotificationChannelsCallable = - callableFactory.createUnaryCallable( - listNotificationChannelsTransportSettings, - settings.listNotificationChannelsSettings(), - clientContext); - this.listNotificationChannelsPagedCallable = - callableFactory.createPagedCallable( - listNotificationChannelsTransportSettings, - settings.listNotificationChannelsSettings(), - clientContext); - this.getNotificationChannelCallable = - callableFactory.createUnaryCallable( - getNotificationChannelTransportSettings, - settings.getNotificationChannelSettings(), - clientContext); - this.createNotificationChannelCallable = - callableFactory.createUnaryCallable( - createNotificationChannelTransportSettings, - settings.createNotificationChannelSettings(), - clientContext); - this.updateNotificationChannelCallable = - callableFactory.createUnaryCallable( - updateNotificationChannelTransportSettings, - settings.updateNotificationChannelSettings(), - clientContext); - this.deleteNotificationChannelCallable = - callableFactory.createUnaryCallable( - deleteNotificationChannelTransportSettings, - settings.deleteNotificationChannelSettings(), - clientContext); - this.sendNotificationChannelVerificationCodeCallable = - callableFactory.createUnaryCallable( - sendNotificationChannelVerificationCodeTransportSettings, - settings.sendNotificationChannelVerificationCodeSettings(), - clientContext); - this.getNotificationChannelVerificationCodeCallable = - callableFactory.createUnaryCallable( - getNotificationChannelVerificationCodeTransportSettings, - settings.getNotificationChannelVerificationCodeSettings(), - clientContext); - this.verifyNotificationChannelCallable = - callableFactory.createUnaryCallable( - verifyNotificationChannelTransportSettings, - settings.verifyNotificationChannelSettings(), - clientContext); - - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); - } - - public UnaryCallable< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsPagedCallable() { - return listNotificationChannelDescriptorsPagedCallable; - } - - public UnaryCallable< - ListNotificationChannelDescriptorsRequest, ListNotificationChannelDescriptorsResponse> - listNotificationChannelDescriptorsCallable() { - return listNotificationChannelDescriptorsCallable; - } - - public UnaryCallable - getNotificationChannelDescriptorCallable() { - return getNotificationChannelDescriptorCallable; - } - - public UnaryCallable - listNotificationChannelsPagedCallable() { - return listNotificationChannelsPagedCallable; - } - - public UnaryCallable - listNotificationChannelsCallable() { - return listNotificationChannelsCallable; - } - - public UnaryCallable - getNotificationChannelCallable() { - return getNotificationChannelCallable; - } - - public UnaryCallable - createNotificationChannelCallable() { - return createNotificationChannelCallable; - } - - public UnaryCallable - updateNotificationChannelCallable() { - return updateNotificationChannelCallable; - } - - public UnaryCallable - deleteNotificationChannelCallable() { - return deleteNotificationChannelCallable; - } - - public UnaryCallable - sendNotificationChannelVerificationCodeCallable() { - return sendNotificationChannelVerificationCodeCallable; - } - - public UnaryCallable< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeCallable() { - return getNotificationChannelVerificationCodeCallable; - } - - public UnaryCallable - verifyNotificationChannelCallable() { - return verifyNotificationChannelCallable; - } - - @Override - public final void close() { - shutdown(); - } - - @Override - public void shutdown() { - backgroundResources.shutdown(); - } - - @Override - public boolean isShutdown() { - return backgroundResources.isShutdown(); - } - - @Override - public boolean isTerminated() { - return backgroundResources.isTerminated(); - } - - @Override - public void shutdownNow() { - backgroundResources.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return backgroundResources.awaitTermination(duration, unit); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceCallableFactory.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceCallableFactory.java deleted file mode 100644 index aa1cbcf7..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceCallableFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcCallableFactory; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.BatchingCallSettings; -import com.google.api.gax.rpc.BidiStreamingCallable; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.ClientStreamingCallable; -import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallSettings; -import com.google.api.gax.rpc.ServerStreamingCallable; -import com.google.api.gax.rpc.StreamingCallSettings; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.longrunning.stub.OperationsStub; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC callable factory implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage. - */ -@Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") -public class GrpcUptimeCheckServiceCallableFactory implements GrpcStubCallableFactory { - @Override - public UnaryCallable createUnaryCallable( - GrpcCallSettings grpcCallSettings, - UnaryCallSettings callSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); - } - - @Override - public - UnaryCallable createPagedCallable( - GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); - } - - @Override - public UnaryCallable createBatchingCallable( - GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); - } - - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") - @Override - public - OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, - ClientContext clientContext, - OperationsStub operationsStub) { - return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); - } - - @Override - public - BidiStreamingCallable createBidiStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ServerStreamingCallable createServerStreamingCallable( - GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } - - @Override - public - ClientStreamingCallable createClientStreamingCallable( - GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, - ClientContext clientContext) { - return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java deleted file mode 100644 index cf0d10b0..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckConfigsPagedResponse; -import static com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckIpsPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.core.BackgroundResourceAggregation; -import com.google.api.gax.grpc.GrpcCallSettings; -import com.google.api.gax.grpc.GrpcStubCallableFactory; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.RequestParamsExtractor; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableMap; -import com.google.monitoring.v3.CreateUptimeCheckConfigRequest; -import com.google.monitoring.v3.DeleteUptimeCheckConfigRequest; -import com.google.monitoring.v3.GetUptimeCheckConfigRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; -import com.google.monitoring.v3.ListUptimeCheckIpsRequest; -import com.google.monitoring.v3.ListUptimeCheckIpsResponse; -import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; -import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.protobuf.Empty; -import io.grpc.MethodDescriptor; -import io.grpc.protobuf.ProtoUtils; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * gRPC stub implementation for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public class GrpcUptimeCheckServiceStub extends UptimeCheckServiceStub { - - private static final MethodDescriptor< - ListUptimeCheckConfigsRequest, ListUptimeCheckConfigsResponse> - listUptimeCheckConfigsMethodDescriptor = - MethodDescriptor - .newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.UptimeCheckService/ListUptimeCheckConfigs") - .setRequestMarshaller( - ProtoUtils.marshaller(ListUptimeCheckConfigsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListUptimeCheckConfigsResponse.getDefaultInstance())) - .build(); - private static final MethodDescriptor - getUptimeCheckConfigMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.UptimeCheckService/GetUptimeCheckConfig") - .setRequestMarshaller( - ProtoUtils.marshaller(GetUptimeCheckConfigRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(UptimeCheckConfig.getDefaultInstance())) - .build(); - private static final MethodDescriptor - createUptimeCheckConfigMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.UptimeCheckService/CreateUptimeCheckConfig") - .setRequestMarshaller( - ProtoUtils.marshaller(CreateUptimeCheckConfigRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(UptimeCheckConfig.getDefaultInstance())) - .build(); - private static final MethodDescriptor - updateUptimeCheckConfigMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.UptimeCheckService/UpdateUptimeCheckConfig") - .setRequestMarshaller( - ProtoUtils.marshaller(UpdateUptimeCheckConfigRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(UptimeCheckConfig.getDefaultInstance())) - .build(); - private static final MethodDescriptor - deleteUptimeCheckConfigMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.UptimeCheckService/DeleteUptimeCheckConfig") - .setRequestMarshaller( - ProtoUtils.marshaller(DeleteUptimeCheckConfigRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - private static final MethodDescriptor - listUptimeCheckIpsMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.monitoring.v3.UptimeCheckService/ListUptimeCheckIps") - .setRequestMarshaller( - ProtoUtils.marshaller(ListUptimeCheckIpsRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(ListUptimeCheckIpsResponse.getDefaultInstance())) - .build(); - - private final BackgroundResource backgroundResources; - - private final UnaryCallable - listUptimeCheckConfigsCallable; - private final UnaryCallable - listUptimeCheckConfigsPagedCallable; - private final UnaryCallable - getUptimeCheckConfigCallable; - private final UnaryCallable - createUptimeCheckConfigCallable; - private final UnaryCallable - updateUptimeCheckConfigCallable; - private final UnaryCallable - deleteUptimeCheckConfigCallable; - private final UnaryCallable - listUptimeCheckIpsCallable; - private final UnaryCallable - listUptimeCheckIpsPagedCallable; - - private final GrpcStubCallableFactory callableFactory; - - public static final GrpcUptimeCheckServiceStub create(UptimeCheckServiceStubSettings settings) - throws IOException { - return new GrpcUptimeCheckServiceStub(settings, ClientContext.create(settings)); - } - - public static final GrpcUptimeCheckServiceStub create(ClientContext clientContext) - throws IOException { - return new GrpcUptimeCheckServiceStub( - UptimeCheckServiceStubSettings.newBuilder().build(), clientContext); - } - - public static final GrpcUptimeCheckServiceStub create( - ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { - return new GrpcUptimeCheckServiceStub( - UptimeCheckServiceStubSettings.newBuilder().build(), clientContext, callableFactory); - } - - /** - * Constructs an instance of GrpcUptimeCheckServiceStub, using the given settings. This is - * protected so that it is easy to make a subclass, but otherwise, the static factory methods - * should be preferred. - */ - protected GrpcUptimeCheckServiceStub( - UptimeCheckServiceStubSettings settings, ClientContext clientContext) throws IOException { - this(settings, clientContext, new GrpcUptimeCheckServiceCallableFactory()); - } - - /** - * Constructs an instance of GrpcUptimeCheckServiceStub, using the given settings. This is - * protected so that it is easy to make a subclass, but otherwise, the static factory methods - * should be preferred. - */ - protected GrpcUptimeCheckServiceStub( - UptimeCheckServiceStubSettings settings, - ClientContext clientContext, - GrpcStubCallableFactory callableFactory) - throws IOException { - this.callableFactory = callableFactory; - - GrpcCallSettings - listUptimeCheckConfigsTransportSettings = - GrpcCallSettings - .newBuilder() - .setMethodDescriptor(listUptimeCheckConfigsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListUptimeCheckConfigsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - getUptimeCheckConfigTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getUptimeCheckConfigMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetUptimeCheckConfigRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - createUptimeCheckConfigTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createUptimeCheckConfigMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateUptimeCheckConfigRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - updateUptimeCheckConfigTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateUptimeCheckConfigMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateUptimeCheckConfigRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put( - "uptime_check_config.name", - String.valueOf(request.getUptimeCheckConfig().getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - deleteUptimeCheckConfigTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteUptimeCheckConfigMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteUptimeCheckConfigRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - listUptimeCheckIpsTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listUptimeCheckIpsMethodDescriptor) - .build(); - - this.listUptimeCheckConfigsCallable = - callableFactory.createUnaryCallable( - listUptimeCheckConfigsTransportSettings, - settings.listUptimeCheckConfigsSettings(), - clientContext); - this.listUptimeCheckConfigsPagedCallable = - callableFactory.createPagedCallable( - listUptimeCheckConfigsTransportSettings, - settings.listUptimeCheckConfigsSettings(), - clientContext); - this.getUptimeCheckConfigCallable = - callableFactory.createUnaryCallable( - getUptimeCheckConfigTransportSettings, - settings.getUptimeCheckConfigSettings(), - clientContext); - this.createUptimeCheckConfigCallable = - callableFactory.createUnaryCallable( - createUptimeCheckConfigTransportSettings, - settings.createUptimeCheckConfigSettings(), - clientContext); - this.updateUptimeCheckConfigCallable = - callableFactory.createUnaryCallable( - updateUptimeCheckConfigTransportSettings, - settings.updateUptimeCheckConfigSettings(), - clientContext); - this.deleteUptimeCheckConfigCallable = - callableFactory.createUnaryCallable( - deleteUptimeCheckConfigTransportSettings, - settings.deleteUptimeCheckConfigSettings(), - clientContext); - this.listUptimeCheckIpsCallable = - callableFactory.createUnaryCallable( - listUptimeCheckIpsTransportSettings, - settings.listUptimeCheckIpsSettings(), - clientContext); - this.listUptimeCheckIpsPagedCallable = - callableFactory.createPagedCallable( - listUptimeCheckIpsTransportSettings, - settings.listUptimeCheckIpsSettings(), - clientContext); - - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); - } - - public UnaryCallable - listUptimeCheckConfigsPagedCallable() { - return listUptimeCheckConfigsPagedCallable; - } - - public UnaryCallable - listUptimeCheckConfigsCallable() { - return listUptimeCheckConfigsCallable; - } - - public UnaryCallable - getUptimeCheckConfigCallable() { - return getUptimeCheckConfigCallable; - } - - public UnaryCallable - createUptimeCheckConfigCallable() { - return createUptimeCheckConfigCallable; - } - - public UnaryCallable - updateUptimeCheckConfigCallable() { - return updateUptimeCheckConfigCallable; - } - - public UnaryCallable deleteUptimeCheckConfigCallable() { - return deleteUptimeCheckConfigCallable; - } - - public UnaryCallable - listUptimeCheckIpsPagedCallable() { - return listUptimeCheckIpsPagedCallable; - } - - public UnaryCallable - listUptimeCheckIpsCallable() { - return listUptimeCheckIpsCallable; - } - - @Override - public final void close() { - shutdown(); - } - - @Override - public void shutdown() { - backgroundResources.shutdown(); - } - - @Override - public boolean isShutdown() { - return backgroundResources.isShutdown(); - } - - @Override - public boolean isTerminated() { - return backgroundResources.isTerminated(); - } - - @Override - public void shutdownNow() { - backgroundResources.shutdownNow(); - } - - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return backgroundResources.awaitTermination(duration, unit); - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java deleted file mode 100644 index bff3e58d..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMetricDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse; - -import com.google.api.MetricDescriptor; -import com.google.api.MonitoredResourceDescriptor; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.monitoring.v3.CreateMetricDescriptorRequest; -import com.google.monitoring.v3.CreateTimeSeriesRequest; -import com.google.monitoring.v3.DeleteMetricDescriptorRequest; -import com.google.monitoring.v3.GetMetricDescriptorRequest; -import com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest; -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.protobuf.Empty; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public abstract class MetricServiceStub implements BackgroundResource { - - public UnaryCallable< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsPagedCallable() { - throw new UnsupportedOperationException( - "Not implemented: listMonitoredResourceDescriptorsPagedCallable()"); - } - - public UnaryCallable< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> - listMonitoredResourceDescriptorsCallable() { - throw new UnsupportedOperationException( - "Not implemented: listMonitoredResourceDescriptorsCallable()"); - } - - public UnaryCallable - getMonitoredResourceDescriptorCallable() { - throw new UnsupportedOperationException( - "Not implemented: getMonitoredResourceDescriptorCallable()"); - } - - public UnaryCallable - listMetricDescriptorsPagedCallable() { - throw new UnsupportedOperationException( - "Not implemented: listMetricDescriptorsPagedCallable()"); - } - - public UnaryCallable - listMetricDescriptorsCallable() { - throw new UnsupportedOperationException("Not implemented: listMetricDescriptorsCallable()"); - } - - public UnaryCallable getMetricDescriptorCallable() { - throw new UnsupportedOperationException("Not implemented: getMetricDescriptorCallable()"); - } - - public UnaryCallable - createMetricDescriptorCallable() { - throw new UnsupportedOperationException("Not implemented: createMetricDescriptorCallable()"); - } - - public UnaryCallable deleteMetricDescriptorCallable() { - throw new UnsupportedOperationException("Not implemented: deleteMetricDescriptorCallable()"); - } - - public UnaryCallable - listTimeSeriesPagedCallable() { - throw new UnsupportedOperationException("Not implemented: listTimeSeriesPagedCallable()"); - } - - public UnaryCallable listTimeSeriesCallable() { - throw new UnsupportedOperationException("Not implemented: listTimeSeriesCallable()"); - } - - public UnaryCallable createTimeSeriesCallable() { - throw new UnsupportedOperationException("Not implemented: createTimeSeriesCallable()"); - } - - @Override - public abstract void close(); -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java b/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java deleted file mode 100644 index 8abae5e4..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java +++ /dev/null @@ -1,724 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMetricDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse; - -import com.google.api.MetricDescriptor; -import com.google.api.MonitoredResourceDescriptor; -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GaxProperties; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.GrpcTransportChannel; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.retrying.RetrySettings; -import com.google.api.gax.rpc.ApiCallContext; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.PagedListDescriptor; -import com.google.api.gax.rpc.PagedListResponseFactory; -import com.google.api.gax.rpc.StatusCode; -import com.google.api.gax.rpc.StubSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.CreateMetricDescriptorRequest; -import com.google.monitoring.v3.CreateTimeSeriesRequest; -import com.google.monitoring.v3.DeleteMetricDescriptorRequest; -import com.google.monitoring.v3.GetMetricDescriptorRequest; -import com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest; -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; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; -import org.threeten.bp.Duration; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link MetricServiceStub}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getMonitoredResourceDescriptor to 30 seconds: - * - *

- * 
- * MetricServiceStubSettings.Builder metricServiceSettingsBuilder =
- *     MetricServiceStubSettings.newBuilder();
- * metricServiceSettingsBuilder.getMonitoredResourceDescriptorSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * MetricServiceStubSettings metricServiceSettings = metricServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class MetricServiceStubSettings extends StubSettings { - /** The default scopes of the service. */ - private static final ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/cloud-platform") - .add("https://www.googleapis.com/auth/monitoring") - .add("https://www.googleapis.com/auth/monitoring.read") - .add("https://www.googleapis.com/auth/monitoring.write") - .build(); - - private final PagedCallSettings< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsSettings; - private final UnaryCallSettings< - GetMonitoredResourceDescriptorRequest, MonitoredResourceDescriptor> - getMonitoredResourceDescriptorSettings; - private final PagedCallSettings< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - ListMetricDescriptorsPagedResponse> - listMetricDescriptorsSettings; - private final UnaryCallSettings - getMetricDescriptorSettings; - private final UnaryCallSettings - createMetricDescriptorSettings; - private final UnaryCallSettings - deleteMetricDescriptorSettings; - private final PagedCallSettings< - ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> - listTimeSeriesSettings; - private final UnaryCallSettings createTimeSeriesSettings; - - /** Returns the object with the settings used for calls to listMonitoredResourceDescriptors. */ - public PagedCallSettings< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsSettings() { - return listMonitoredResourceDescriptorsSettings; - } - - /** Returns the object with the settings used for calls to getMonitoredResourceDescriptor. */ - public UnaryCallSettings - getMonitoredResourceDescriptorSettings() { - return getMonitoredResourceDescriptorSettings; - } - - /** Returns the object with the settings used for calls to listMetricDescriptors. */ - public PagedCallSettings< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - ListMetricDescriptorsPagedResponse> - listMetricDescriptorsSettings() { - return listMetricDescriptorsSettings; - } - - /** Returns the object with the settings used for calls to getMetricDescriptor. */ - public UnaryCallSettings - getMetricDescriptorSettings() { - return getMetricDescriptorSettings; - } - - /** Returns the object with the settings used for calls to createMetricDescriptor. */ - public UnaryCallSettings - createMetricDescriptorSettings() { - return createMetricDescriptorSettings; - } - - /** Returns the object with the settings used for calls to deleteMetricDescriptor. */ - public UnaryCallSettings deleteMetricDescriptorSettings() { - return deleteMetricDescriptorSettings; - } - - /** Returns the object with the settings used for calls to listTimeSeries. */ - public PagedCallSettings< - ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> - listTimeSeriesSettings() { - return listTimeSeriesSettings; - } - - /** Returns the object with the settings used for calls to createTimeSeries. */ - public UnaryCallSettings createTimeSeriesSettings() { - return createTimeSeriesSettings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public MetricServiceStub createStub() throws IOException { - if (getTransportChannelProvider() - .getTransportName() - .equals(GrpcTransportChannel.getGrpcTransportName())) { - return GrpcMetricServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); - } - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return InstantiatingExecutorProvider.newBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return "monitoring.googleapis.com:443"; - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return DEFAULT_SERVICE_SCOPES; - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return InstantiatingGrpcChannelProvider.newBuilder() - .setMaxInboundMessageSize(Integer.MAX_VALUE); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return defaultGrpcTransportProviderBuilder().build(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return ApiClientHeaderProvider.newBuilder() - .setGeneratedLibToken( - "gapic", GaxProperties.getLibraryVersion(MetricServiceStubSettings.class)) - .setTransportToken( - GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected MetricServiceStubSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - - listMonitoredResourceDescriptorsSettings = - settingsBuilder.listMonitoredResourceDescriptorsSettings().build(); - getMonitoredResourceDescriptorSettings = - settingsBuilder.getMonitoredResourceDescriptorSettings().build(); - listMetricDescriptorsSettings = settingsBuilder.listMetricDescriptorsSettings().build(); - getMetricDescriptorSettings = settingsBuilder.getMetricDescriptorSettings().build(); - createMetricDescriptorSettings = settingsBuilder.createMetricDescriptorSettings().build(); - deleteMetricDescriptorSettings = settingsBuilder.deleteMetricDescriptorSettings().build(); - listTimeSeriesSettings = settingsBuilder.listTimeSeriesSettings().build(); - createTimeSeriesSettings = settingsBuilder.createTimeSeriesSettings().build(); - } - - private static final PagedListDescriptor< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> - LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC = - new PagedListDescriptor< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListMonitoredResourceDescriptorsRequest injectToken( - ListMonitoredResourceDescriptorsRequest payload, String token) { - return ListMonitoredResourceDescriptorsRequest.newBuilder(payload) - .setPageToken(token) - .build(); - } - - @Override - public ListMonitoredResourceDescriptorsRequest injectPageSize( - ListMonitoredResourceDescriptorsRequest payload, int pageSize) { - return ListMonitoredResourceDescriptorsRequest.newBuilder(payload) - .setPageSize(pageSize) - .build(); - } - - @Override - public Integer extractPageSize(ListMonitoredResourceDescriptorsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListMonitoredResourceDescriptorsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources( - ListMonitoredResourceDescriptorsResponse payload) { - return payload.getResourceDescriptorsList() != null - ? payload.getResourceDescriptorsList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor> - LIST_METRIC_DESCRIPTORS_PAGE_STR_DESC = - new PagedListDescriptor< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListMetricDescriptorsRequest injectToken( - ListMetricDescriptorsRequest payload, String token) { - return ListMetricDescriptorsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListMetricDescriptorsRequest injectPageSize( - ListMetricDescriptorsRequest payload, int pageSize) { - return ListMetricDescriptorsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListMetricDescriptorsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListMetricDescriptorsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources( - ListMetricDescriptorsResponse payload) { - return payload.getMetricDescriptorsList() != null - ? payload.getMetricDescriptorsList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor< - ListTimeSeriesRequest, ListTimeSeriesResponse, TimeSeries> - LIST_TIME_SERIES_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListTimeSeriesRequest injectToken(ListTimeSeriesRequest payload, String token) { - return ListTimeSeriesRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListTimeSeriesRequest injectPageSize( - ListTimeSeriesRequest payload, int pageSize) { - return ListTimeSeriesRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListTimeSeriesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListTimeSeriesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListTimeSeriesResponse payload) { - return payload.getTimeSeriesList() != null - ? payload.getTimeSeriesList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - ListMonitoredResourceDescriptorsPagedResponse> - LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - ListMonitoredResourceDescriptorsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse> - callable, - ListMonitoredResourceDescriptorsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - MonitoredResourceDescriptor> - pageContext = - PageContext.create( - callable, - LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC, - request, - context); - return ListMonitoredResourceDescriptorsPagedResponse.createAsync( - pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - ListMetricDescriptorsPagedResponse> - LIST_METRIC_DESCRIPTORS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - ListMetricDescriptorsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListMetricDescriptorsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext< - ListMetricDescriptorsRequest, ListMetricDescriptorsResponse, MetricDescriptor> - pageContext = - PageContext.create( - callable, LIST_METRIC_DESCRIPTORS_PAGE_STR_DESC, request, context); - return ListMetricDescriptorsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> - LIST_TIME_SERIES_PAGE_STR_FACT = - new PagedListResponseFactory< - ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListTimeSeriesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_TIME_SERIES_PAGE_STR_DESC, request, context); - return ListTimeSeriesPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - /** Builder for MetricServiceStubSettings. */ - public static class Builder extends StubSettings.Builder { - private final ImmutableList> unaryMethodSettingsBuilders; - - private final PagedCallSettings.Builder< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsSettings; - private final UnaryCallSettings.Builder< - GetMonitoredResourceDescriptorRequest, MonitoredResourceDescriptor> - getMonitoredResourceDescriptorSettings; - private final PagedCallSettings.Builder< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - ListMetricDescriptorsPagedResponse> - listMetricDescriptorsSettings; - private final UnaryCallSettings.Builder - getMetricDescriptorSettings; - private final UnaryCallSettings.Builder - createMetricDescriptorSettings; - private final UnaryCallSettings.Builder - deleteMetricDescriptorSettings; - private final PagedCallSettings.Builder< - ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> - listTimeSeriesSettings; - private final UnaryCallSettings.Builder - createTimeSeriesSettings; - - private static final ImmutableMap> - RETRYABLE_CODE_DEFINITIONS; - - static { - ImmutableMap.Builder> definitions = - ImmutableMap.builder(); - definitions.put( - "idempotent", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); - RETRYABLE_CODE_DEFINITIONS = definitions.build(); - } - - private static final ImmutableMap RETRY_PARAM_DEFINITIONS; - - static { - ImmutableMap.Builder definitions = ImmutableMap.builder(); - RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(20000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(20000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("default", settings); - RETRY_PARAM_DEFINITIONS = definitions.build(); - } - - protected Builder() { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(clientContext); - - listMonitoredResourceDescriptorsSettings = - PagedCallSettings.newBuilder(LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT); - - getMonitoredResourceDescriptorSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - listMetricDescriptorsSettings = - PagedCallSettings.newBuilder(LIST_METRIC_DESCRIPTORS_PAGE_STR_FACT); - - getMetricDescriptorSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - createMetricDescriptorSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - deleteMetricDescriptorSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - listTimeSeriesSettings = PagedCallSettings.newBuilder(LIST_TIME_SERIES_PAGE_STR_FACT); - - createTimeSeriesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listMonitoredResourceDescriptorsSettings, - getMonitoredResourceDescriptorSettings, - listMetricDescriptorsSettings, - getMetricDescriptorSettings, - createMetricDescriptorSettings, - deleteMetricDescriptorSettings, - listTimeSeriesSettings, - createTimeSeriesSettings); - - initDefaults(this); - } - - private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); - builder.setTransportChannelProvider(defaultTransportChannelProvider()); - builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); - builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); - return initDefaults(builder); - } - - private static Builder initDefaults(Builder builder) { - - builder - .listMonitoredResourceDescriptorsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getMonitoredResourceDescriptorSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .listMetricDescriptorsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getMetricDescriptorSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .createMetricDescriptorSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .deleteMetricDescriptorSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .listTimeSeriesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .createTimeSeriesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - return builder; - } - - protected Builder(MetricServiceStubSettings settings) { - super(settings); - - listMonitoredResourceDescriptorsSettings = - settings.listMonitoredResourceDescriptorsSettings.toBuilder(); - getMonitoredResourceDescriptorSettings = - settings.getMonitoredResourceDescriptorSettings.toBuilder(); - listMetricDescriptorsSettings = settings.listMetricDescriptorsSettings.toBuilder(); - getMetricDescriptorSettings = settings.getMetricDescriptorSettings.toBuilder(); - createMetricDescriptorSettings = settings.createMetricDescriptorSettings.toBuilder(); - deleteMetricDescriptorSettings = settings.deleteMetricDescriptorSettings.toBuilder(); - listTimeSeriesSettings = settings.listTimeSeriesSettings.toBuilder(); - createTimeSeriesSettings = settings.createTimeSeriesSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listMonitoredResourceDescriptorsSettings, - getMonitoredResourceDescriptorSettings, - listMetricDescriptorsSettings, - getMetricDescriptorSettings, - createMetricDescriptorSettings, - deleteMetricDescriptorSettings, - listTimeSeriesSettings, - createTimeSeriesSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); - return this; - } - - public ImmutableList> unaryMethodSettingsBuilders() { - return unaryMethodSettingsBuilders; - } - - /** Returns the builder for the settings used for calls to listMonitoredResourceDescriptors. */ - public PagedCallSettings.Builder< - ListMonitoredResourceDescriptorsRequest, - ListMonitoredResourceDescriptorsResponse, - ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsSettings() { - return listMonitoredResourceDescriptorsSettings; - } - - /** Returns the builder for the settings used for calls to getMonitoredResourceDescriptor. */ - public UnaryCallSettings.Builder< - GetMonitoredResourceDescriptorRequest, MonitoredResourceDescriptor> - getMonitoredResourceDescriptorSettings() { - return getMonitoredResourceDescriptorSettings; - } - - /** Returns the builder for the settings used for calls to listMetricDescriptors. */ - public PagedCallSettings.Builder< - ListMetricDescriptorsRequest, - ListMetricDescriptorsResponse, - ListMetricDescriptorsPagedResponse> - listMetricDescriptorsSettings() { - return listMetricDescriptorsSettings; - } - - /** Returns the builder for the settings used for calls to getMetricDescriptor. */ - public UnaryCallSettings.Builder - getMetricDescriptorSettings() { - return getMetricDescriptorSettings; - } - - /** Returns the builder for the settings used for calls to createMetricDescriptor. */ - public UnaryCallSettings.Builder - createMetricDescriptorSettings() { - return createMetricDescriptorSettings; - } - - /** Returns the builder for the settings used for calls to deleteMetricDescriptor. */ - public UnaryCallSettings.Builder - deleteMetricDescriptorSettings() { - return deleteMetricDescriptorSettings; - } - - /** Returns the builder for the settings used for calls to listTimeSeries. */ - public PagedCallSettings.Builder< - ListTimeSeriesRequest, ListTimeSeriesResponse, ListTimeSeriesPagedResponse> - listTimeSeriesSettings() { - return listTimeSeriesSettings; - } - - /** Returns the builder for the settings used for calls to createTimeSeries. */ - public UnaryCallSettings.Builder createTimeSeriesSettings() { - return createTimeSeriesSettings; - } - - @Override - public MetricServiceStubSettings build() throws IOException { - return new MetricServiceStubSettings(this); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java deleted file mode 100644 index ebfb6fa0..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.monitoring.v3.CreateNotificationChannelRequest; -import com.google.monitoring.v3.DeleteNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelDescriptorRequest; -import com.google.monitoring.v3.GetNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsRequest; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsResponse; -import com.google.monitoring.v3.ListNotificationChannelsRequest; -import com.google.monitoring.v3.ListNotificationChannelsResponse; -import com.google.monitoring.v3.NotificationChannel; -import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.UpdateNotificationChannelRequest; -import com.google.monitoring.v3.VerifyNotificationChannelRequest; -import com.google.protobuf.Empty; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public abstract class NotificationChannelServiceStub implements BackgroundResource { - - public UnaryCallable< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsPagedCallable() { - throw new UnsupportedOperationException( - "Not implemented: listNotificationChannelDescriptorsPagedCallable()"); - } - - public UnaryCallable< - ListNotificationChannelDescriptorsRequest, ListNotificationChannelDescriptorsResponse> - listNotificationChannelDescriptorsCallable() { - throw new UnsupportedOperationException( - "Not implemented: listNotificationChannelDescriptorsCallable()"); - } - - public UnaryCallable - getNotificationChannelDescriptorCallable() { - throw new UnsupportedOperationException( - "Not implemented: getNotificationChannelDescriptorCallable()"); - } - - public UnaryCallable - listNotificationChannelsPagedCallable() { - throw new UnsupportedOperationException( - "Not implemented: listNotificationChannelsPagedCallable()"); - } - - public UnaryCallable - listNotificationChannelsCallable() { - throw new UnsupportedOperationException("Not implemented: listNotificationChannelsCallable()"); - } - - public UnaryCallable - getNotificationChannelCallable() { - throw new UnsupportedOperationException("Not implemented: getNotificationChannelCallable()"); - } - - public UnaryCallable - createNotificationChannelCallable() { - throw new UnsupportedOperationException("Not implemented: createNotificationChannelCallable()"); - } - - public UnaryCallable - updateNotificationChannelCallable() { - throw new UnsupportedOperationException("Not implemented: updateNotificationChannelCallable()"); - } - - public UnaryCallable - deleteNotificationChannelCallable() { - throw new UnsupportedOperationException("Not implemented: deleteNotificationChannelCallable()"); - } - - public UnaryCallable - sendNotificationChannelVerificationCodeCallable() { - throw new UnsupportedOperationException( - "Not implemented: sendNotificationChannelVerificationCodeCallable()"); - } - - public UnaryCallable< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeCallable() { - throw new UnsupportedOperationException( - "Not implemented: getNotificationChannelVerificationCodeCallable()"); - } - - public UnaryCallable - verifyNotificationChannelCallable() { - throw new UnsupportedOperationException("Not implemented: verifyNotificationChannelCallable()"); - } - - @Override - public abstract void close(); -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java b/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java deleted file mode 100644 index 26b3506a..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java +++ /dev/null @@ -1,761 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse; - -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GaxProperties; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.GrpcTransportChannel; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.retrying.RetrySettings; -import com.google.api.gax.rpc.ApiCallContext; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.PagedListDescriptor; -import com.google.api.gax.rpc.PagedListResponseFactory; -import com.google.api.gax.rpc.StatusCode; -import com.google.api.gax.rpc.StubSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.CreateNotificationChannelRequest; -import com.google.monitoring.v3.DeleteNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelDescriptorRequest; -import com.google.monitoring.v3.GetNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsRequest; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsResponse; -import com.google.monitoring.v3.ListNotificationChannelsRequest; -import com.google.monitoring.v3.ListNotificationChannelsResponse; -import com.google.monitoring.v3.NotificationChannel; -import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.UpdateNotificationChannelRequest; -import com.google.monitoring.v3.VerifyNotificationChannelRequest; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; -import org.threeten.bp.Duration; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link NotificationChannelServiceStub}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getNotificationChannelDescriptor to 30 seconds: - * - *

- * 
- * NotificationChannelServiceStubSettings.Builder notificationChannelServiceSettingsBuilder =
- *     NotificationChannelServiceStubSettings.newBuilder();
- * notificationChannelServiceSettingsBuilder.getNotificationChannelDescriptorSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * NotificationChannelServiceStubSettings notificationChannelServiceSettings = notificationChannelServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class NotificationChannelServiceStubSettings - extends StubSettings { - /** The default scopes of the service. */ - private static final ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/cloud-platform") - .add("https://www.googleapis.com/auth/monitoring") - .add("https://www.googleapis.com/auth/monitoring.read") - .add("https://www.googleapis.com/auth/monitoring.write") - .build(); - - private final PagedCallSettings< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsSettings; - private final UnaryCallSettings< - GetNotificationChannelDescriptorRequest, NotificationChannelDescriptor> - getNotificationChannelDescriptorSettings; - private final PagedCallSettings< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - ListNotificationChannelsPagedResponse> - listNotificationChannelsSettings; - private final UnaryCallSettings - getNotificationChannelSettings; - private final UnaryCallSettings - createNotificationChannelSettings; - private final UnaryCallSettings - updateNotificationChannelSettings; - private final UnaryCallSettings - deleteNotificationChannelSettings; - private final UnaryCallSettings - sendNotificationChannelVerificationCodeSettings; - private final UnaryCallSettings< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeSettings; - private final UnaryCallSettings - verifyNotificationChannelSettings; - - /** Returns the object with the settings used for calls to listNotificationChannelDescriptors. */ - public PagedCallSettings< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsSettings() { - return listNotificationChannelDescriptorsSettings; - } - - /** Returns the object with the settings used for calls to getNotificationChannelDescriptor. */ - public UnaryCallSettings - getNotificationChannelDescriptorSettings() { - return getNotificationChannelDescriptorSettings; - } - - /** Returns the object with the settings used for calls to listNotificationChannels. */ - public PagedCallSettings< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - ListNotificationChannelsPagedResponse> - listNotificationChannelsSettings() { - return listNotificationChannelsSettings; - } - - /** Returns the object with the settings used for calls to getNotificationChannel. */ - public UnaryCallSettings - getNotificationChannelSettings() { - return getNotificationChannelSettings; - } - - /** Returns the object with the settings used for calls to createNotificationChannel. */ - public UnaryCallSettings - createNotificationChannelSettings() { - return createNotificationChannelSettings; - } - - /** Returns the object with the settings used for calls to updateNotificationChannel. */ - public UnaryCallSettings - updateNotificationChannelSettings() { - return updateNotificationChannelSettings; - } - - /** Returns the object with the settings used for calls to deleteNotificationChannel. */ - public UnaryCallSettings - deleteNotificationChannelSettings() { - return deleteNotificationChannelSettings; - } - - /** - * Returns the object with the settings used for calls to sendNotificationChannelVerificationCode. - */ - public UnaryCallSettings - sendNotificationChannelVerificationCodeSettings() { - return sendNotificationChannelVerificationCodeSettings; - } - - /** - * Returns the object with the settings used for calls to getNotificationChannelVerificationCode. - */ - public UnaryCallSettings< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeSettings() { - return getNotificationChannelVerificationCodeSettings; - } - - /** Returns the object with the settings used for calls to verifyNotificationChannel. */ - public UnaryCallSettings - verifyNotificationChannelSettings() { - return verifyNotificationChannelSettings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public NotificationChannelServiceStub createStub() throws IOException { - if (getTransportChannelProvider() - .getTransportName() - .equals(GrpcTransportChannel.getGrpcTransportName())) { - return GrpcNotificationChannelServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); - } - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return InstantiatingExecutorProvider.newBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return "monitoring.googleapis.com:443"; - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return DEFAULT_SERVICE_SCOPES; - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return InstantiatingGrpcChannelProvider.newBuilder() - .setMaxInboundMessageSize(Integer.MAX_VALUE); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return defaultGrpcTransportProviderBuilder().build(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return ApiClientHeaderProvider.newBuilder() - .setGeneratedLibToken( - "gapic", GaxProperties.getLibraryVersion(NotificationChannelServiceStubSettings.class)) - .setTransportToken( - GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected NotificationChannelServiceStubSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - - listNotificationChannelDescriptorsSettings = - settingsBuilder.listNotificationChannelDescriptorsSettings().build(); - getNotificationChannelDescriptorSettings = - settingsBuilder.getNotificationChannelDescriptorSettings().build(); - listNotificationChannelsSettings = settingsBuilder.listNotificationChannelsSettings().build(); - getNotificationChannelSettings = settingsBuilder.getNotificationChannelSettings().build(); - createNotificationChannelSettings = settingsBuilder.createNotificationChannelSettings().build(); - updateNotificationChannelSettings = settingsBuilder.updateNotificationChannelSettings().build(); - deleteNotificationChannelSettings = settingsBuilder.deleteNotificationChannelSettings().build(); - sendNotificationChannelVerificationCodeSettings = - settingsBuilder.sendNotificationChannelVerificationCodeSettings().build(); - getNotificationChannelVerificationCodeSettings = - settingsBuilder.getNotificationChannelVerificationCodeSettings().build(); - verifyNotificationChannelSettings = settingsBuilder.verifyNotificationChannelSettings().build(); - } - - private static final PagedListDescriptor< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor> - LIST_NOTIFICATION_CHANNEL_DESCRIPTORS_PAGE_STR_DESC = - new PagedListDescriptor< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListNotificationChannelDescriptorsRequest injectToken( - ListNotificationChannelDescriptorsRequest payload, String token) { - return ListNotificationChannelDescriptorsRequest.newBuilder(payload) - .setPageToken(token) - .build(); - } - - @Override - public ListNotificationChannelDescriptorsRequest injectPageSize( - ListNotificationChannelDescriptorsRequest payload, int pageSize) { - return ListNotificationChannelDescriptorsRequest.newBuilder(payload) - .setPageSize(pageSize) - .build(); - } - - @Override - public Integer extractPageSize(ListNotificationChannelDescriptorsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListNotificationChannelDescriptorsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources( - ListNotificationChannelDescriptorsResponse payload) { - return payload.getChannelDescriptorsList() != null - ? payload.getChannelDescriptorsList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor< - ListNotificationChannelsRequest, ListNotificationChannelsResponse, NotificationChannel> - LIST_NOTIFICATION_CHANNELS_PAGE_STR_DESC = - new PagedListDescriptor< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - NotificationChannel>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListNotificationChannelsRequest injectToken( - ListNotificationChannelsRequest payload, String token) { - return ListNotificationChannelsRequest.newBuilder(payload) - .setPageToken(token) - .build(); - } - - @Override - public ListNotificationChannelsRequest injectPageSize( - ListNotificationChannelsRequest payload, int pageSize) { - return ListNotificationChannelsRequest.newBuilder(payload) - .setPageSize(pageSize) - .build(); - } - - @Override - public Integer extractPageSize(ListNotificationChannelsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListNotificationChannelsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources( - ListNotificationChannelsResponse payload) { - return payload.getNotificationChannelsList() != null - ? payload.getNotificationChannelsList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - ListNotificationChannelDescriptorsPagedResponse> - LIST_NOTIFICATION_CHANNEL_DESCRIPTORS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - ListNotificationChannelDescriptorsPagedResponse>() { - @Override - public ApiFuture - getFuturePagedResponse( - UnaryCallable< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse> - callable, - ListNotificationChannelDescriptorsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - NotificationChannelDescriptor> - pageContext = - PageContext.create( - callable, - LIST_NOTIFICATION_CHANNEL_DESCRIPTORS_PAGE_STR_DESC, - request, - context); - return ListNotificationChannelDescriptorsPagedResponse.createAsync( - pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - ListNotificationChannelsPagedResponse> - LIST_NOTIFICATION_CHANNELS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - ListNotificationChannelsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable - callable, - ListNotificationChannelsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - NotificationChannel> - pageContext = - PageContext.create( - callable, LIST_NOTIFICATION_CHANNELS_PAGE_STR_DESC, request, context); - return ListNotificationChannelsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - /** Builder for NotificationChannelServiceStubSettings. */ - public static class Builder - extends StubSettings.Builder { - private final ImmutableList> unaryMethodSettingsBuilders; - - private final PagedCallSettings.Builder< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsSettings; - private final UnaryCallSettings.Builder< - GetNotificationChannelDescriptorRequest, NotificationChannelDescriptor> - getNotificationChannelDescriptorSettings; - private final PagedCallSettings.Builder< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - ListNotificationChannelsPagedResponse> - listNotificationChannelsSettings; - private final UnaryCallSettings.Builder - getNotificationChannelSettings; - private final UnaryCallSettings.Builder - createNotificationChannelSettings; - private final UnaryCallSettings.Builder - updateNotificationChannelSettings; - private final UnaryCallSettings.Builder - deleteNotificationChannelSettings; - private final UnaryCallSettings.Builder - sendNotificationChannelVerificationCodeSettings; - private final UnaryCallSettings.Builder< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeSettings; - private final UnaryCallSettings.Builder - verifyNotificationChannelSettings; - - private static final ImmutableMap> - RETRYABLE_CODE_DEFINITIONS; - - static { - ImmutableMap.Builder> definitions = - ImmutableMap.builder(); - definitions.put( - "idempotent", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); - RETRYABLE_CODE_DEFINITIONS = definitions.build(); - } - - private static final ImmutableMap RETRY_PARAM_DEFINITIONS; - - static { - ImmutableMap.Builder definitions = ImmutableMap.builder(); - RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(20000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(20000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("default", settings); - RETRY_PARAM_DEFINITIONS = definitions.build(); - } - - protected Builder() { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(clientContext); - - listNotificationChannelDescriptorsSettings = - PagedCallSettings.newBuilder(LIST_NOTIFICATION_CHANNEL_DESCRIPTORS_PAGE_STR_FACT); - - getNotificationChannelDescriptorSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - listNotificationChannelsSettings = - PagedCallSettings.newBuilder(LIST_NOTIFICATION_CHANNELS_PAGE_STR_FACT); - - getNotificationChannelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - createNotificationChannelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - updateNotificationChannelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - deleteNotificationChannelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - sendNotificationChannelVerificationCodeSettings = - UnaryCallSettings.newUnaryCallSettingsBuilder(); - - getNotificationChannelVerificationCodeSettings = - UnaryCallSettings.newUnaryCallSettingsBuilder(); - - verifyNotificationChannelSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listNotificationChannelDescriptorsSettings, - getNotificationChannelDescriptorSettings, - listNotificationChannelsSettings, - getNotificationChannelSettings, - createNotificationChannelSettings, - updateNotificationChannelSettings, - deleteNotificationChannelSettings, - sendNotificationChannelVerificationCodeSettings, - getNotificationChannelVerificationCodeSettings, - verifyNotificationChannelSettings); - - initDefaults(this); - } - - private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); - builder.setTransportChannelProvider(defaultTransportChannelProvider()); - builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); - builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); - return initDefaults(builder); - } - - private static Builder initDefaults(Builder builder) { - - builder - .listNotificationChannelDescriptorsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getNotificationChannelDescriptorSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .listNotificationChannelsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .createNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .updateNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .deleteNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .sendNotificationChannelVerificationCodeSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getNotificationChannelVerificationCodeSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .verifyNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - return builder; - } - - protected Builder(NotificationChannelServiceStubSettings settings) { - super(settings); - - listNotificationChannelDescriptorsSettings = - settings.listNotificationChannelDescriptorsSettings.toBuilder(); - getNotificationChannelDescriptorSettings = - settings.getNotificationChannelDescriptorSettings.toBuilder(); - listNotificationChannelsSettings = settings.listNotificationChannelsSettings.toBuilder(); - getNotificationChannelSettings = settings.getNotificationChannelSettings.toBuilder(); - createNotificationChannelSettings = settings.createNotificationChannelSettings.toBuilder(); - updateNotificationChannelSettings = settings.updateNotificationChannelSettings.toBuilder(); - deleteNotificationChannelSettings = settings.deleteNotificationChannelSettings.toBuilder(); - sendNotificationChannelVerificationCodeSettings = - settings.sendNotificationChannelVerificationCodeSettings.toBuilder(); - getNotificationChannelVerificationCodeSettings = - settings.getNotificationChannelVerificationCodeSettings.toBuilder(); - verifyNotificationChannelSettings = settings.verifyNotificationChannelSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listNotificationChannelDescriptorsSettings, - getNotificationChannelDescriptorSettings, - listNotificationChannelsSettings, - getNotificationChannelSettings, - createNotificationChannelSettings, - updateNotificationChannelSettings, - deleteNotificationChannelSettings, - sendNotificationChannelVerificationCodeSettings, - getNotificationChannelVerificationCodeSettings, - verifyNotificationChannelSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); - return this; - } - - public ImmutableList> unaryMethodSettingsBuilders() { - return unaryMethodSettingsBuilders; - } - - /** - * Returns the builder for the settings used for calls to listNotificationChannelDescriptors. - */ - public PagedCallSettings.Builder< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsResponse, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsSettings() { - return listNotificationChannelDescriptorsSettings; - } - - /** Returns the builder for the settings used for calls to getNotificationChannelDescriptor. */ - public UnaryCallSettings.Builder< - GetNotificationChannelDescriptorRequest, NotificationChannelDescriptor> - getNotificationChannelDescriptorSettings() { - return getNotificationChannelDescriptorSettings; - } - - /** Returns the builder for the settings used for calls to listNotificationChannels. */ - public PagedCallSettings.Builder< - ListNotificationChannelsRequest, - ListNotificationChannelsResponse, - ListNotificationChannelsPagedResponse> - listNotificationChannelsSettings() { - return listNotificationChannelsSettings; - } - - /** Returns the builder for the settings used for calls to getNotificationChannel. */ - public UnaryCallSettings.Builder - getNotificationChannelSettings() { - return getNotificationChannelSettings; - } - - /** Returns the builder for the settings used for calls to createNotificationChannel. */ - public UnaryCallSettings.Builder - createNotificationChannelSettings() { - return createNotificationChannelSettings; - } - - /** Returns the builder for the settings used for calls to updateNotificationChannel. */ - public UnaryCallSettings.Builder - updateNotificationChannelSettings() { - return updateNotificationChannelSettings; - } - - /** Returns the builder for the settings used for calls to deleteNotificationChannel. */ - public UnaryCallSettings.Builder - deleteNotificationChannelSettings() { - return deleteNotificationChannelSettings; - } - - /** - * Returns the builder for the settings used for calls to - * sendNotificationChannelVerificationCode. - */ - public UnaryCallSettings.Builder - sendNotificationChannelVerificationCodeSettings() { - return sendNotificationChannelVerificationCodeSettings; - } - - /** - * Returns the builder for the settings used for calls to - * getNotificationChannelVerificationCode. - */ - public UnaryCallSettings.Builder< - GetNotificationChannelVerificationCodeRequest, - GetNotificationChannelVerificationCodeResponse> - getNotificationChannelVerificationCodeSettings() { - return getNotificationChannelVerificationCodeSettings; - } - - /** Returns the builder for the settings used for calls to verifyNotificationChannel. */ - public UnaryCallSettings.Builder - verifyNotificationChannelSettings() { - return verifyNotificationChannelSettings; - } - - @Override - public NotificationChannelServiceStubSettings build() throws IOException { - return new NotificationChannelServiceStubSettings(this); - } - } -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java b/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java deleted file mode 100644 index ef9d02ff..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckConfigsPagedResponse; -import static com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckIpsPagedResponse; - -import com.google.api.core.BetaApi; -import com.google.api.gax.core.BackgroundResource; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.monitoring.v3.CreateUptimeCheckConfigRequest; -import com.google.monitoring.v3.DeleteUptimeCheckConfigRequest; -import com.google.monitoring.v3.GetUptimeCheckConfigRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; -import com.google.monitoring.v3.ListUptimeCheckIpsRequest; -import com.google.monitoring.v3.ListUptimeCheckIpsResponse; -import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; -import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.protobuf.Empty; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Base stub class for Stackdriver Monitoring API. - * - *

This class is for advanced usage and reflects the underlying API directly. - */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") -public abstract class UptimeCheckServiceStub implements BackgroundResource { - - public UnaryCallable - listUptimeCheckConfigsPagedCallable() { - throw new UnsupportedOperationException( - "Not implemented: listUptimeCheckConfigsPagedCallable()"); - } - - public UnaryCallable - listUptimeCheckConfigsCallable() { - throw new UnsupportedOperationException("Not implemented: listUptimeCheckConfigsCallable()"); - } - - public UnaryCallable - getUptimeCheckConfigCallable() { - throw new UnsupportedOperationException("Not implemented: getUptimeCheckConfigCallable()"); - } - - public UnaryCallable - createUptimeCheckConfigCallable() { - throw new UnsupportedOperationException("Not implemented: createUptimeCheckConfigCallable()"); - } - - public UnaryCallable - updateUptimeCheckConfigCallable() { - throw new UnsupportedOperationException("Not implemented: updateUptimeCheckConfigCallable()"); - } - - public UnaryCallable deleteUptimeCheckConfigCallable() { - throw new UnsupportedOperationException("Not implemented: deleteUptimeCheckConfigCallable()"); - } - - public UnaryCallable - listUptimeCheckIpsPagedCallable() { - throw new UnsupportedOperationException("Not implemented: listUptimeCheckIpsPagedCallable()"); - } - - public UnaryCallable - listUptimeCheckIpsCallable() { - throw new UnsupportedOperationException("Not implemented: listUptimeCheckIpsCallable()"); - } - - @Override - public abstract void close(); -} diff --git a/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java b/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java deleted file mode 100644 index e482d3a6..00000000 --- a/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java +++ /dev/null @@ -1,580 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3.stub; - -import static com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckConfigsPagedResponse; -import static com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckIpsPagedResponse; - -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.BetaApi; -import com.google.api.gax.core.GaxProperties; -import com.google.api.gax.core.GoogleCredentialsProvider; -import com.google.api.gax.core.InstantiatingExecutorProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.GrpcTransportChannel; -import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; -import com.google.api.gax.retrying.RetrySettings; -import com.google.api.gax.rpc.ApiCallContext; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.ClientContext; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.PagedListDescriptor; -import com.google.api.gax.rpc.PagedListResponseFactory; -import com.google.api.gax.rpc.StatusCode; -import com.google.api.gax.rpc.StubSettings; -import com.google.api.gax.rpc.TransportChannelProvider; -import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.CreateUptimeCheckConfigRequest; -import com.google.monitoring.v3.DeleteUptimeCheckConfigRequest; -import com.google.monitoring.v3.GetUptimeCheckConfigRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; -import com.google.monitoring.v3.ListUptimeCheckIpsRequest; -import com.google.monitoring.v3.ListUptimeCheckIpsResponse; -import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; -import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.monitoring.v3.UptimeCheckIp; -import com.google.protobuf.Empty; -import java.io.IOException; -import java.util.List; -import javax.annotation.Generated; -import org.threeten.bp.Duration; - -// AUTO-GENERATED DOCUMENTATION AND CLASS -/** - * Settings class to configure an instance of {@link UptimeCheckServiceStub}. - * - *

The default instance has everything set to sensible defaults: - * - *

    - *
  • The default service address (monitoring.googleapis.com) and default port (443) are used. - *
  • Credentials are acquired automatically through Application Default Credentials. - *
  • Retries are configured for idempotent methods but not for non-idempotent methods. - *
- * - *

The builder of this class is recursive, so contained classes are themselves builders. When - * build() is called, the tree of builders is called to create the complete settings object. - * - *

For example, to set the total timeout of getUptimeCheckConfig to 30 seconds: - * - *

- * 
- * UptimeCheckServiceStubSettings.Builder uptimeCheckServiceSettingsBuilder =
- *     UptimeCheckServiceStubSettings.newBuilder();
- * uptimeCheckServiceSettingsBuilder.getUptimeCheckConfigSettings().getRetrySettings().toBuilder()
- *     .setTotalTimeout(Duration.ofSeconds(30));
- * UptimeCheckServiceStubSettings uptimeCheckServiceSettings = uptimeCheckServiceSettingsBuilder.build();
- * 
- * 
- */ -@Generated("by gapic-generator") -public class UptimeCheckServiceStubSettings extends StubSettings { - /** The default scopes of the service. */ - private static final ImmutableList DEFAULT_SERVICE_SCOPES = - ImmutableList.builder() - .add("https://www.googleapis.com/auth/cloud-platform") - .add("https://www.googleapis.com/auth/monitoring") - .add("https://www.googleapis.com/auth/monitoring.read") - .add("https://www.googleapis.com/auth/monitoring.write") - .build(); - - private final PagedCallSettings< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - ListUptimeCheckConfigsPagedResponse> - listUptimeCheckConfigsSettings; - private final UnaryCallSettings - getUptimeCheckConfigSettings; - private final UnaryCallSettings - createUptimeCheckConfigSettings; - private final UnaryCallSettings - updateUptimeCheckConfigSettings; - private final UnaryCallSettings - deleteUptimeCheckConfigSettings; - private final PagedCallSettings< - ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, ListUptimeCheckIpsPagedResponse> - listUptimeCheckIpsSettings; - - /** Returns the object with the settings used for calls to listUptimeCheckConfigs. */ - public PagedCallSettings< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - ListUptimeCheckConfigsPagedResponse> - listUptimeCheckConfigsSettings() { - return listUptimeCheckConfigsSettings; - } - - /** Returns the object with the settings used for calls to getUptimeCheckConfig. */ - public UnaryCallSettings - getUptimeCheckConfigSettings() { - return getUptimeCheckConfigSettings; - } - - /** Returns the object with the settings used for calls to createUptimeCheckConfig. */ - public UnaryCallSettings - createUptimeCheckConfigSettings() { - return createUptimeCheckConfigSettings; - } - - /** Returns the object with the settings used for calls to updateUptimeCheckConfig. */ - public UnaryCallSettings - updateUptimeCheckConfigSettings() { - return updateUptimeCheckConfigSettings; - } - - /** Returns the object with the settings used for calls to deleteUptimeCheckConfig. */ - public UnaryCallSettings - deleteUptimeCheckConfigSettings() { - return deleteUptimeCheckConfigSettings; - } - - /** Returns the object with the settings used for calls to listUptimeCheckIps. */ - public PagedCallSettings< - ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, ListUptimeCheckIpsPagedResponse> - listUptimeCheckIpsSettings() { - return listUptimeCheckIpsSettings; - } - - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") - public UptimeCheckServiceStub createStub() throws IOException { - if (getTransportChannelProvider() - .getTransportName() - .equals(GrpcTransportChannel.getGrpcTransportName())) { - return GrpcUptimeCheckServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); - } - } - - /** Returns a builder for the default ExecutorProvider for this service. */ - public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { - return InstantiatingExecutorProvider.newBuilder(); - } - - /** Returns the default service endpoint. */ - public static String getDefaultEndpoint() { - return "monitoring.googleapis.com:443"; - } - - /** Returns the default service scopes. */ - public static List getDefaultServiceScopes() { - return DEFAULT_SERVICE_SCOPES; - } - - /** Returns a builder for the default credentials for this service. */ - public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { - return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); - } - - /** Returns a builder for the default ChannelProvider for this service. */ - public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { - return InstantiatingGrpcChannelProvider.newBuilder() - .setMaxInboundMessageSize(Integer.MAX_VALUE); - } - - public static TransportChannelProvider defaultTransportChannelProvider() { - return defaultGrpcTransportProviderBuilder().build(); - } - - @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { - return ApiClientHeaderProvider.newBuilder() - .setGeneratedLibToken( - "gapic", GaxProperties.getLibraryVersion(UptimeCheckServiceStubSettings.class)) - .setTransportToken( - GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder() { - return Builder.createDefault(); - } - - /** Returns a new builder for this class. */ - public static Builder newBuilder(ClientContext clientContext) { - return new Builder(clientContext); - } - - /** Returns a builder containing all the values of this settings class. */ - public Builder toBuilder() { - return new Builder(this); - } - - protected UptimeCheckServiceStubSettings(Builder settingsBuilder) throws IOException { - super(settingsBuilder); - - listUptimeCheckConfigsSettings = settingsBuilder.listUptimeCheckConfigsSettings().build(); - getUptimeCheckConfigSettings = settingsBuilder.getUptimeCheckConfigSettings().build(); - createUptimeCheckConfigSettings = settingsBuilder.createUptimeCheckConfigSettings().build(); - updateUptimeCheckConfigSettings = settingsBuilder.updateUptimeCheckConfigSettings().build(); - deleteUptimeCheckConfigSettings = settingsBuilder.deleteUptimeCheckConfigSettings().build(); - listUptimeCheckIpsSettings = settingsBuilder.listUptimeCheckIpsSettings().build(); - } - - private static final PagedListDescriptor< - ListUptimeCheckConfigsRequest, ListUptimeCheckConfigsResponse, UptimeCheckConfig> - LIST_UPTIME_CHECK_CONFIGS_PAGE_STR_DESC = - new PagedListDescriptor< - ListUptimeCheckConfigsRequest, ListUptimeCheckConfigsResponse, UptimeCheckConfig>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListUptimeCheckConfigsRequest injectToken( - ListUptimeCheckConfigsRequest payload, String token) { - return ListUptimeCheckConfigsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListUptimeCheckConfigsRequest injectPageSize( - ListUptimeCheckConfigsRequest payload, int pageSize) { - return ListUptimeCheckConfigsRequest.newBuilder(payload) - .setPageSize(pageSize) - .build(); - } - - @Override - public Integer extractPageSize(ListUptimeCheckConfigsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListUptimeCheckConfigsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources( - ListUptimeCheckConfigsResponse payload) { - return payload.getUptimeCheckConfigsList() != null - ? payload.getUptimeCheckConfigsList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor< - ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, UptimeCheckIp> - LIST_UPTIME_CHECK_IPS_PAGE_STR_DESC = - new PagedListDescriptor< - ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, UptimeCheckIp>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListUptimeCheckIpsRequest injectToken( - ListUptimeCheckIpsRequest payload, String token) { - return ListUptimeCheckIpsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListUptimeCheckIpsRequest injectPageSize( - ListUptimeCheckIpsRequest payload, int pageSize) { - return ListUptimeCheckIpsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListUptimeCheckIpsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListUptimeCheckIpsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListUptimeCheckIpsResponse payload) { - return payload.getUptimeCheckIpsList() != null - ? payload.getUptimeCheckIpsList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - ListUptimeCheckConfigsPagedResponse> - LIST_UPTIME_CHECK_CONFIGS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - ListUptimeCheckConfigsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable - callable, - ListUptimeCheckConfigsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - UptimeCheckConfig> - pageContext = - PageContext.create( - callable, LIST_UPTIME_CHECK_CONFIGS_PAGE_STR_DESC, request, context); - return ListUptimeCheckConfigsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, ListUptimeCheckIpsPagedResponse> - LIST_UPTIME_CHECK_IPS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListUptimeCheckIpsRequest, - ListUptimeCheckIpsResponse, - ListUptimeCheckIpsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListUptimeCheckIpsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext - pageContext = - PageContext.create( - callable, LIST_UPTIME_CHECK_IPS_PAGE_STR_DESC, request, context); - return ListUptimeCheckIpsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - /** Builder for UptimeCheckServiceStubSettings. */ - public static class Builder - extends StubSettings.Builder { - private final ImmutableList> unaryMethodSettingsBuilders; - - private final PagedCallSettings.Builder< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - ListUptimeCheckConfigsPagedResponse> - listUptimeCheckConfigsSettings; - private final UnaryCallSettings.Builder - getUptimeCheckConfigSettings; - private final UnaryCallSettings.Builder - createUptimeCheckConfigSettings; - private final UnaryCallSettings.Builder - updateUptimeCheckConfigSettings; - private final UnaryCallSettings.Builder - deleteUptimeCheckConfigSettings; - private final PagedCallSettings.Builder< - ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, ListUptimeCheckIpsPagedResponse> - listUptimeCheckIpsSettings; - - private static final ImmutableMap> - RETRYABLE_CODE_DEFINITIONS; - - static { - ImmutableMap.Builder> definitions = - ImmutableMap.builder(); - definitions.put( - "idempotent", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.newArrayList())); - RETRYABLE_CODE_DEFINITIONS = definitions.build(); - } - - private static final ImmutableMap RETRY_PARAM_DEFINITIONS; - - static { - ImmutableMap.Builder definitions = ImmutableMap.builder(); - RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(20000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(20000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("default", settings); - RETRY_PARAM_DEFINITIONS = definitions.build(); - } - - protected Builder() { - this((ClientContext) null); - } - - protected Builder(ClientContext clientContext) { - super(clientContext); - - listUptimeCheckConfigsSettings = - PagedCallSettings.newBuilder(LIST_UPTIME_CHECK_CONFIGS_PAGE_STR_FACT); - - getUptimeCheckConfigSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - createUptimeCheckConfigSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - updateUptimeCheckConfigSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - deleteUptimeCheckConfigSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - - listUptimeCheckIpsSettings = - PagedCallSettings.newBuilder(LIST_UPTIME_CHECK_IPS_PAGE_STR_FACT); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listUptimeCheckConfigsSettings, - getUptimeCheckConfigSettings, - createUptimeCheckConfigSettings, - updateUptimeCheckConfigSettings, - deleteUptimeCheckConfigSettings, - listUptimeCheckIpsSettings); - - initDefaults(this); - } - - private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); - builder.setTransportChannelProvider(defaultTransportChannelProvider()); - builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); - builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); - builder.setEndpoint(getDefaultEndpoint()); - return initDefaults(builder); - } - - private static Builder initDefaults(Builder builder) { - - builder - .listUptimeCheckConfigsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .getUptimeCheckConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .createUptimeCheckConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .updateUptimeCheckConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .deleteUptimeCheckConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - builder - .listUptimeCheckIpsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); - - return builder; - } - - protected Builder(UptimeCheckServiceStubSettings settings) { - super(settings); - - listUptimeCheckConfigsSettings = settings.listUptimeCheckConfigsSettings.toBuilder(); - getUptimeCheckConfigSettings = settings.getUptimeCheckConfigSettings.toBuilder(); - createUptimeCheckConfigSettings = settings.createUptimeCheckConfigSettings.toBuilder(); - updateUptimeCheckConfigSettings = settings.updateUptimeCheckConfigSettings.toBuilder(); - deleteUptimeCheckConfigSettings = settings.deleteUptimeCheckConfigSettings.toBuilder(); - listUptimeCheckIpsSettings = settings.listUptimeCheckIpsSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listUptimeCheckConfigsSettings, - getUptimeCheckConfigSettings, - createUptimeCheckConfigSettings, - updateUptimeCheckConfigSettings, - deleteUptimeCheckConfigSettings, - listUptimeCheckIpsSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' - /** - * Applies the given settings updater function to all of the unary API methods in this service. - * - *

Note: This method does not support applying settings to streaming methods. - */ - public Builder applyToAllUnaryMethods( - ApiFunction, Void> settingsUpdater) throws Exception { - super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); - return this; - } - - public ImmutableList> unaryMethodSettingsBuilders() { - return unaryMethodSettingsBuilders; - } - - /** Returns the builder for the settings used for calls to listUptimeCheckConfigs. */ - public PagedCallSettings.Builder< - ListUptimeCheckConfigsRequest, - ListUptimeCheckConfigsResponse, - ListUptimeCheckConfigsPagedResponse> - listUptimeCheckConfigsSettings() { - return listUptimeCheckConfigsSettings; - } - - /** Returns the builder for the settings used for calls to getUptimeCheckConfig. */ - public UnaryCallSettings.Builder - getUptimeCheckConfigSettings() { - return getUptimeCheckConfigSettings; - } - - /** Returns the builder for the settings used for calls to createUptimeCheckConfig. */ - public UnaryCallSettings.Builder - createUptimeCheckConfigSettings() { - return createUptimeCheckConfigSettings; - } - - /** Returns the builder for the settings used for calls to updateUptimeCheckConfig. */ - public UnaryCallSettings.Builder - updateUptimeCheckConfigSettings() { - return updateUptimeCheckConfigSettings; - } - - /** Returns the builder for the settings used for calls to deleteUptimeCheckConfig. */ - public UnaryCallSettings.Builder - deleteUptimeCheckConfigSettings() { - return deleteUptimeCheckConfigSettings; - } - - /** Returns the builder for the settings used for calls to listUptimeCheckIps. */ - public PagedCallSettings.Builder< - ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, ListUptimeCheckIpsPagedResponse> - listUptimeCheckIpsSettings() { - return listUptimeCheckIpsSettings; - } - - @Override - public UptimeCheckServiceStubSettings build() throws IOException { - return new UptimeCheckServiceStubSettings(this); - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java b/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java deleted file mode 100644 index 6b1d701f..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.AlertPolicyServiceClient.ListAlertPoliciesPagedResponse; - -import com.google.api.gax.core.NoCredentialsProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.testing.LocalChannelProvider; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.api.gax.grpc.testing.MockServiceHelper; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.InvalidArgumentException; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.AlertPolicyName; -import com.google.monitoring.v3.CreateAlertPolicyRequest; -import com.google.monitoring.v3.DeleteAlertPolicyRequest; -import com.google.monitoring.v3.GetAlertPolicyRequest; -import com.google.monitoring.v3.ListAlertPoliciesRequest; -import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.ProjectName; -import com.google.monitoring.v3.UpdateAlertPolicyRequest; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import com.google.protobuf.FieldMask; -import io.grpc.Status; -import io.grpc.StatusRuntimeException; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -@javax.annotation.Generated("by GAPIC") -public class AlertPolicyServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; - private static MockUptimeCheckService mockUptimeCheckService; - private static MockServiceHelper serviceHelper; - private AlertPolicyServiceClient client; - private LocalChannelProvider channelProvider; - - @BeforeClass - public static void startStaticServer() { - mockAlertPolicyService = new MockAlertPolicyService(); - mockGroupService = new MockGroupService(); - mockMetricService = new MockMetricService(); - mockNotificationChannelService = new MockNotificationChannelService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = - new MockServiceHelper( - "in-process-1", - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockUptimeCheckService)); - serviceHelper.start(); - } - - @AfterClass - public static void stopServer() { - serviceHelper.stop(); - } - - @Before - public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); - AlertPolicyServiceSettings settings = - AlertPolicyServiceSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = AlertPolicyServiceClient.create(settings); - } - - @After - public void tearDown() throws Exception { - client.close(); - } - - @Test - @SuppressWarnings("all") - public void listAlertPoliciesTest() { - String nextPageToken = ""; - AlertPolicy alertPoliciesElement = AlertPolicy.newBuilder().build(); - List alertPolicies = Arrays.asList(alertPoliciesElement); - ListAlertPoliciesResponse expectedResponse = - ListAlertPoliciesResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllAlertPolicies(alertPolicies) - .build(); - mockAlertPolicyService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - - ListAlertPoliciesPagedResponse pagedListResponse = client.listAlertPolicies(name); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getAlertPoliciesList().get(0), resources.get(0)); - - List actualRequests = mockAlertPolicyService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListAlertPoliciesRequest actualRequest = (ListAlertPoliciesRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listAlertPoliciesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockAlertPolicyService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - - client.listAlertPolicies(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getAlertPolicyTest() { - String name2 = "name2-1052831874"; - String displayName = "displayName1615086568"; - AlertPolicy expectedResponse = - AlertPolicy.newBuilder().setName(name2).setDisplayName(displayName).build(); - mockAlertPolicyService.addResponse(expectedResponse); - - AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]"); - - AlertPolicy actualResponse = client.getAlertPolicy(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockAlertPolicyService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetAlertPolicyRequest actualRequest = (GetAlertPolicyRequest) actualRequests.get(0); - - Assert.assertEquals(name, AlertPolicyName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getAlertPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockAlertPolicyService.addException(exception); - - try { - AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]"); - - client.getAlertPolicy(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void createAlertPolicyTest() { - String name2 = "name2-1052831874"; - String displayName = "displayName1615086568"; - AlertPolicy expectedResponse = - AlertPolicy.newBuilder().setName(name2).setDisplayName(displayName).build(); - mockAlertPolicyService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - AlertPolicy alertPolicy = AlertPolicy.newBuilder().build(); - - AlertPolicy actualResponse = client.createAlertPolicy(name, alertPolicy); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockAlertPolicyService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateAlertPolicyRequest actualRequest = (CreateAlertPolicyRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createAlertPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockAlertPolicyService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - AlertPolicy alertPolicy = AlertPolicy.newBuilder().build(); - - client.createAlertPolicy(name, alertPolicy); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void deleteAlertPolicyTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockAlertPolicyService.addResponse(expectedResponse); - - AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]"); - - client.deleteAlertPolicy(name); - - List actualRequests = mockAlertPolicyService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteAlertPolicyRequest actualRequest = (DeleteAlertPolicyRequest) actualRequests.get(0); - - Assert.assertEquals(name, AlertPolicyName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void deleteAlertPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockAlertPolicyService.addException(exception); - - try { - AlertPolicyName name = AlertPolicyName.of("[PROJECT]", "[ALERT_POLICY]"); - - client.deleteAlertPolicy(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void updateAlertPolicyTest() { - String name = "name3373707"; - String displayName = "displayName1615086568"; - AlertPolicy expectedResponse = - AlertPolicy.newBuilder().setName(name).setDisplayName(displayName).build(); - mockAlertPolicyService.addResponse(expectedResponse); - - FieldMask updateMask = FieldMask.newBuilder().build(); - AlertPolicy alertPolicy = AlertPolicy.newBuilder().build(); - - AlertPolicy actualResponse = client.updateAlertPolicy(updateMask, alertPolicy); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockAlertPolicyService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateAlertPolicyRequest actualRequest = (UpdateAlertPolicyRequest) actualRequests.get(0); - - Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); - Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void updateAlertPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockAlertPolicyService.addException(exception); - - try { - FieldMask updateMask = FieldMask.newBuilder().build(); - AlertPolicy alertPolicy = AlertPolicy.newBuilder().build(); - - client.updateAlertPolicy(updateMask, alertPolicy); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java b/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java deleted file mode 100644 index 802f5158..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupMembersPagedResponse; -import static com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse; - -import com.google.api.MonitoredResource; -import com.google.api.gax.core.NoCredentialsProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.testing.LocalChannelProvider; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.api.gax.grpc.testing.MockServiceHelper; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.InvalidArgumentException; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.CreateGroupRequest; -import com.google.monitoring.v3.DeleteGroupRequest; -import com.google.monitoring.v3.GetGroupRequest; -import com.google.monitoring.v3.Group; -import com.google.monitoring.v3.GroupName; -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.ProjectName; -import com.google.monitoring.v3.UpdateGroupRequest; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.Status; -import io.grpc.StatusRuntimeException; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -@javax.annotation.Generated("by GAPIC") -public class GroupServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; - private static MockUptimeCheckService mockUptimeCheckService; - private static MockServiceHelper serviceHelper; - private GroupServiceClient client; - private LocalChannelProvider channelProvider; - - @BeforeClass - public static void startStaticServer() { - mockAlertPolicyService = new MockAlertPolicyService(); - mockGroupService = new MockGroupService(); - mockMetricService = new MockMetricService(); - mockNotificationChannelService = new MockNotificationChannelService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = - new MockServiceHelper( - "in-process-1", - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockUptimeCheckService)); - serviceHelper.start(); - } - - @AfterClass - public static void stopServer() { - serviceHelper.stop(); - } - - @Before - public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); - GroupServiceSettings settings = - GroupServiceSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = GroupServiceClient.create(settings); - } - - @After - public void tearDown() throws Exception { - client.close(); - } - - @Test - @SuppressWarnings("all") - public void listGroupsTest() { - String nextPageToken = ""; - Group groupElement = Group.newBuilder().build(); - List group = Arrays.asList(groupElement); - ListGroupsResponse expectedResponse = - ListGroupsResponse.newBuilder().setNextPageToken(nextPageToken).addAllGroup(group).build(); - mockGroupService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - - ListGroupsPagedResponse pagedListResponse = client.listGroups(name); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getGroupList().get(0), resources.get(0)); - - List actualRequests = mockGroupService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListGroupsRequest actualRequest = (ListGroupsRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listGroupsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockGroupService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - - client.listGroups(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getGroupTest() { - GroupName name2 = GroupName.of("[PROJECT]", "[GROUP]"); - String displayName = "displayName1615086568"; - GroupName parentName = GroupName.of("[PROJECT]", "[GROUP]"); - String filter = "filter-1274492040"; - boolean isCluster = false; - Group expectedResponse = - Group.newBuilder() - .setName(name2.toString()) - .setDisplayName(displayName) - .setParentName(parentName.toString()) - .setFilter(filter) - .setIsCluster(isCluster) - .build(); - mockGroupService.addResponse(expectedResponse); - - GroupName name = GroupName.of("[PROJECT]", "[GROUP]"); - - Group actualResponse = client.getGroup(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockGroupService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetGroupRequest actualRequest = (GetGroupRequest) actualRequests.get(0); - - Assert.assertEquals(name, GroupName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getGroupExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockGroupService.addException(exception); - - try { - GroupName name = GroupName.of("[PROJECT]", "[GROUP]"); - - client.getGroup(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void createGroupTest() { - GroupName name2 = GroupName.of("[PROJECT]", "[GROUP]"); - String displayName = "displayName1615086568"; - GroupName parentName = GroupName.of("[PROJECT]", "[GROUP]"); - String filter = "filter-1274492040"; - boolean isCluster = false; - Group expectedResponse = - Group.newBuilder() - .setName(name2.toString()) - .setDisplayName(displayName) - .setParentName(parentName.toString()) - .setFilter(filter) - .setIsCluster(isCluster) - .build(); - mockGroupService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - Group group = Group.newBuilder().build(); - - Group actualResponse = client.createGroup(name, group); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockGroupService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateGroupRequest actualRequest = (CreateGroupRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertEquals(group, actualRequest.getGroup()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createGroupExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockGroupService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - Group group = Group.newBuilder().build(); - - client.createGroup(name, group); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void updateGroupTest() { - GroupName name = GroupName.of("[PROJECT]", "[GROUP]"); - String displayName = "displayName1615086568"; - GroupName parentName = GroupName.of("[PROJECT]", "[GROUP]"); - String filter = "filter-1274492040"; - boolean isCluster = false; - Group expectedResponse = - Group.newBuilder() - .setName(name.toString()) - .setDisplayName(displayName) - .setParentName(parentName.toString()) - .setFilter(filter) - .setIsCluster(isCluster) - .build(); - mockGroupService.addResponse(expectedResponse); - - Group group = Group.newBuilder().build(); - - Group actualResponse = client.updateGroup(group); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockGroupService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateGroupRequest actualRequest = (UpdateGroupRequest) actualRequests.get(0); - - Assert.assertEquals(group, actualRequest.getGroup()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void updateGroupExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockGroupService.addException(exception); - - try { - Group group = Group.newBuilder().build(); - - client.updateGroup(group); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void deleteGroupTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockGroupService.addResponse(expectedResponse); - - GroupName name = GroupName.of("[PROJECT]", "[GROUP]"); - - client.deleteGroup(name); - - List actualRequests = mockGroupService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteGroupRequest actualRequest = (DeleteGroupRequest) actualRequests.get(0); - - Assert.assertEquals(name, GroupName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void deleteGroupExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockGroupService.addException(exception); - - try { - GroupName name = GroupName.of("[PROJECT]", "[GROUP]"); - - client.deleteGroup(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void listGroupMembersTest() { - String nextPageToken = ""; - int totalSize = 705419236; - MonitoredResource membersElement = MonitoredResource.newBuilder().build(); - List members = Arrays.asList(membersElement); - ListGroupMembersResponse expectedResponse = - ListGroupMembersResponse.newBuilder() - .setNextPageToken(nextPageToken) - .setTotalSize(totalSize) - .addAllMembers(members) - .build(); - mockGroupService.addResponse(expectedResponse); - - GroupName name = GroupName.of("[PROJECT]", "[GROUP]"); - - ListGroupMembersPagedResponse pagedListResponse = client.listGroupMembers(name); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getMembersList().get(0), resources.get(0)); - - List actualRequests = mockGroupService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListGroupMembersRequest actualRequest = (ListGroupMembersRequest) actualRequests.get(0); - - Assert.assertEquals(name, GroupName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listGroupMembersExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockGroupService.addException(exception); - - try { - GroupName name = GroupName.of("[PROJECT]", "[GROUP]"); - - client.listGroupMembers(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java b/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java deleted file mode 100644 index 24a9a003..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMetricDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse; - -import com.google.api.MetricDescriptor; -import com.google.api.MonitoredResourceDescriptor; -import com.google.api.gax.core.NoCredentialsProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.testing.LocalChannelProvider; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.api.gax.grpc.testing.MockServiceHelper; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.InvalidArgumentException; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.CreateMetricDescriptorRequest; -import com.google.monitoring.v3.CreateTimeSeriesRequest; -import com.google.monitoring.v3.DeleteMetricDescriptorRequest; -import com.google.monitoring.v3.GetMetricDescriptorRequest; -import com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest; -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.MetricDescriptorName; -import com.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.monitoring.v3.ProjectName; -import com.google.monitoring.v3.TimeInterval; -import com.google.monitoring.v3.TimeSeries; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.Status; -import io.grpc.StatusRuntimeException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -@javax.annotation.Generated("by GAPIC") -public class MetricServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; - private static MockUptimeCheckService mockUptimeCheckService; - private static MockServiceHelper serviceHelper; - private MetricServiceClient client; - private LocalChannelProvider channelProvider; - - @BeforeClass - public static void startStaticServer() { - mockAlertPolicyService = new MockAlertPolicyService(); - mockGroupService = new MockGroupService(); - mockMetricService = new MockMetricService(); - mockNotificationChannelService = new MockNotificationChannelService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = - new MockServiceHelper( - "in-process-1", - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockUptimeCheckService)); - serviceHelper.start(); - } - - @AfterClass - public static void stopServer() { - serviceHelper.stop(); - } - - @Before - public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); - MetricServiceSettings settings = - MetricServiceSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = MetricServiceClient.create(settings); - } - - @After - public void tearDown() throws Exception { - client.close(); - } - - @Test - @SuppressWarnings("all") - public void listMonitoredResourceDescriptorsTest() { - String nextPageToken = ""; - MonitoredResourceDescriptor resourceDescriptorsElement = - MonitoredResourceDescriptor.newBuilder().build(); - List resourceDescriptors = - Arrays.asList(resourceDescriptorsElement); - ListMonitoredResourceDescriptorsResponse expectedResponse = - ListMonitoredResourceDescriptorsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllResourceDescriptors(resourceDescriptors) - .build(); - mockMetricService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - - ListMonitoredResourceDescriptorsPagedResponse pagedListResponse = - client.listMonitoredResourceDescriptors(name); - - List resources = - Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getResourceDescriptorsList().get(0), resources.get(0)); - - List actualRequests = mockMetricService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListMonitoredResourceDescriptorsRequest actualRequest = - (ListMonitoredResourceDescriptorsRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listMonitoredResourceDescriptorsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockMetricService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - - client.listMonitoredResourceDescriptors(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getMonitoredResourceDescriptorTest() { - String name2 = "name2-1052831874"; - String type = "type3575610"; - String displayName = "displayName1615086568"; - String description = "description-1724546052"; - MonitoredResourceDescriptor expectedResponse = - MonitoredResourceDescriptor.newBuilder() - .setName(name2) - .setType(type) - .setDisplayName(displayName) - .setDescription(description) - .build(); - mockMetricService.addResponse(expectedResponse); - - MonitoredResourceDescriptorName name = - MonitoredResourceDescriptorName.of("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]"); - - MonitoredResourceDescriptor actualResponse = client.getMonitoredResourceDescriptor(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockMetricService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetMonitoredResourceDescriptorRequest actualRequest = - (GetMonitoredResourceDescriptorRequest) actualRequests.get(0); - - Assert.assertEquals(name, MonitoredResourceDescriptorName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getMonitoredResourceDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockMetricService.addException(exception); - - try { - MonitoredResourceDescriptorName name = - MonitoredResourceDescriptorName.of("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]"); - - client.getMonitoredResourceDescriptor(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void listMetricDescriptorsTest() { - String nextPageToken = ""; - MetricDescriptor metricDescriptorsElement = MetricDescriptor.newBuilder().build(); - List metricDescriptors = Arrays.asList(metricDescriptorsElement); - ListMetricDescriptorsResponse expectedResponse = - ListMetricDescriptorsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllMetricDescriptors(metricDescriptors) - .build(); - mockMetricService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - - ListMetricDescriptorsPagedResponse pagedListResponse = client.listMetricDescriptors(name); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getMetricDescriptorsList().get(0), resources.get(0)); - - List actualRequests = mockMetricService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListMetricDescriptorsRequest actualRequest = - (ListMetricDescriptorsRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listMetricDescriptorsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockMetricService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - - client.listMetricDescriptors(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getMetricDescriptorTest() { - String name2 = "name2-1052831874"; - String type = "type3575610"; - String unit = "unit3594628"; - String description = "description-1724546052"; - String displayName = "displayName1615086568"; - MetricDescriptor expectedResponse = - MetricDescriptor.newBuilder() - .setName(name2) - .setType(type) - .setUnit(unit) - .setDescription(description) - .setDisplayName(displayName) - .build(); - mockMetricService.addResponse(expectedResponse); - - MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]"); - - MetricDescriptor actualResponse = client.getMetricDescriptor(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockMetricService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetMetricDescriptorRequest actualRequest = (GetMetricDescriptorRequest) actualRequests.get(0); - - Assert.assertEquals(name, MetricDescriptorName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getMetricDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockMetricService.addException(exception); - - try { - MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]"); - - client.getMetricDescriptor(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void createMetricDescriptorTest() { - String name2 = "name2-1052831874"; - String type = "type3575610"; - String unit = "unit3594628"; - String description = "description-1724546052"; - String displayName = "displayName1615086568"; - MetricDescriptor expectedResponse = - MetricDescriptor.newBuilder() - .setName(name2) - .setType(type) - .setUnit(unit) - .setDescription(description) - .setDisplayName(displayName) - .build(); - mockMetricService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build(); - - MetricDescriptor actualResponse = client.createMetricDescriptor(name, metricDescriptor); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockMetricService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateMetricDescriptorRequest actualRequest = - (CreateMetricDescriptorRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertEquals(metricDescriptor, actualRequest.getMetricDescriptor()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createMetricDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockMetricService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build(); - - client.createMetricDescriptor(name, metricDescriptor); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void deleteMetricDescriptorTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockMetricService.addResponse(expectedResponse); - - MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]"); - - client.deleteMetricDescriptor(name); - - List actualRequests = mockMetricService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteMetricDescriptorRequest actualRequest = - (DeleteMetricDescriptorRequest) actualRequests.get(0); - - Assert.assertEquals(name, MetricDescriptorName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void deleteMetricDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockMetricService.addException(exception); - - try { - MetricDescriptorName name = MetricDescriptorName.of("[PROJECT]", "[METRIC_DESCRIPTOR]"); - - client.deleteMetricDescriptor(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @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(); - mockMetricService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - String filter = "filter-1274492040"; - TimeInterval interval = TimeInterval.newBuilder().build(); - ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL; - - ListTimeSeriesPagedResponse pagedListResponse = - client.listTimeSeries(name, filter, interval, view); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - 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(name, ProjectName.parse(actualRequest.getName())); - Assert.assertEquals(filter, actualRequest.getFilter()); - Assert.assertEquals(interval, actualRequest.getInterval()); - Assert.assertEquals(view, actualRequest.getView()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listTimeSeriesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockMetricService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - String filter = "filter-1274492040"; - TimeInterval interval = TimeInterval.newBuilder().build(); - ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL; - - client.listTimeSeries(name, filter, interval, view); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void createTimeSeriesTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockMetricService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - List timeSeries = new ArrayList<>(); - - client.createTimeSeries(name, timeSeries); - - List actualRequests = mockMetricService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateTimeSeriesRequest actualRequest = (CreateTimeSeriesRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertEquals(timeSeries, actualRequest.getTimeSeriesList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createTimeSeriesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockMetricService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - List timeSeries = new ArrayList<>(); - - client.createTimeSeries(name, timeSeries); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java b/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java deleted file mode 100644 index 2f61f966..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; - -import com.google.common.base.Preconditions; -import com.google.monitoring.v3.ProjectName; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.junit.Test; - -@javax.annotation.Generated("by GAPIC") -public class MetricServiceSmokeTest { - private static final String PROJECT_ENV_NAME = "GOOGLE_CLOUD_PROJECT"; - private static final String LEGACY_PROJECT_ENV_NAME = "GCLOUD_PROJECT"; - - @Test - public void run() { - main(null); - } - - public static void main(String args[]) { - Logger.getLogger("").setLevel(Level.WARNING); - try { - executeNoCatch(getProjectId()); - System.out.println("OK"); - } catch (Exception e) { - System.err.println("Failed with exception:"); - e.printStackTrace(System.err); - System.exit(1); - } - } - - public static void executeNoCatch(String projectId) throws Exception { - try (MetricServiceClient client = MetricServiceClient.create()) { - ProjectName name = ProjectName.of(projectId); - - ListMonitoredResourceDescriptorsPagedResponse pagedResponse = - client.listMonitoredResourceDescriptors(name); - } - } - - private static String getProjectId() { - String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME)); - if (projectId == null) { - projectId = - System.getProperty(LEGACY_PROJECT_ENV_NAME, System.getenv(LEGACY_PROJECT_ENV_NAME)); - } - Preconditions.checkArgument(projectId != null, "A project ID is required."); - return projectId; - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyService.java b/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyService.java deleted file mode 100644 index 1a820d6d..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.protobuf.AbstractMessage; -import io.grpc.ServerServiceDefinition; -import java.util.List; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockAlertPolicyService implements MockGrpcService { - private final MockAlertPolicyServiceImpl serviceImpl; - - public MockAlertPolicyService() { - serviceImpl = new MockAlertPolicyServiceImpl(); - } - - @Override - public List getRequests() { - return serviceImpl.getRequests(); - } - - @Override - public void addResponse(AbstractMessage response) { - serviceImpl.addResponse(response); - } - - @Override - public void addException(Exception exception) { - serviceImpl.addException(exception); - } - - @Override - public ServerServiceDefinition getServiceDefinition() { - return serviceImpl.bindService(); - } - - @Override - public void reset() { - serviceImpl.reset(); - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyServiceImpl.java b/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyServiceImpl.java deleted file mode 100644 index 6fec82cd..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyServiceImpl.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.BetaApi; -import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.AlertPolicyServiceGrpc.AlertPolicyServiceImplBase; -import com.google.monitoring.v3.CreateAlertPolicyRequest; -import com.google.monitoring.v3.DeleteAlertPolicyRequest; -import com.google.monitoring.v3.GetAlertPolicyRequest; -import com.google.monitoring.v3.ListAlertPoliciesRequest; -import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.UpdateAlertPolicyRequest; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.stub.StreamObserver; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockAlertPolicyServiceImpl extends AlertPolicyServiceImplBase { - private List requests; - private Queue responses; - - public MockAlertPolicyServiceImpl() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - public List getRequests() { - return requests; - } - - public void addResponse(AbstractMessage response) { - responses.add(response); - } - - public void setResponses(List responses) { - this.responses = new LinkedList(responses); - } - - public void addException(Exception exception) { - responses.add(exception); - } - - public void reset() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - @Override - public void listAlertPolicies( - ListAlertPoliciesRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListAlertPoliciesResponse) { - requests.add(request); - responseObserver.onNext((ListAlertPoliciesResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getAlertPolicy( - GetAlertPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof AlertPolicy) { - requests.add(request); - responseObserver.onNext((AlertPolicy) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void createAlertPolicy( - CreateAlertPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof AlertPolicy) { - requests.add(request); - responseObserver.onNext((AlertPolicy) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void deleteAlertPolicy( - DeleteAlertPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void updateAlertPolicy( - UpdateAlertPolicyRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof AlertPolicy) { - requests.add(request); - responseObserver.onNext((AlertPolicy) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockGroupService.java b/src/test/java/com/google/cloud/monitoring/v3/MockGroupService.java deleted file mode 100644 index e77b5a87..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockGroupService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.protobuf.AbstractMessage; -import io.grpc.ServerServiceDefinition; -import java.util.List; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockGroupService implements MockGrpcService { - private final MockGroupServiceImpl serviceImpl; - - public MockGroupService() { - serviceImpl = new MockGroupServiceImpl(); - } - - @Override - public List getRequests() { - return serviceImpl.getRequests(); - } - - @Override - public void addResponse(AbstractMessage response) { - serviceImpl.addResponse(response); - } - - @Override - public void addException(Exception exception) { - serviceImpl.addException(exception); - } - - @Override - public ServerServiceDefinition getServiceDefinition() { - return serviceImpl.bindService(); - } - - @Override - public void reset() { - serviceImpl.reset(); - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockGroupServiceImpl.java b/src/test/java/com/google/cloud/monitoring/v3/MockGroupServiceImpl.java deleted file mode 100644 index f53588b5..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockGroupServiceImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.BetaApi; -import com.google.monitoring.v3.CreateGroupRequest; -import com.google.monitoring.v3.DeleteGroupRequest; -import com.google.monitoring.v3.GetGroupRequest; -import com.google.monitoring.v3.Group; -import com.google.monitoring.v3.GroupServiceGrpc.GroupServiceImplBase; -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.UpdateGroupRequest; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.stub.StreamObserver; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockGroupServiceImpl extends GroupServiceImplBase { - private List requests; - private Queue responses; - - public MockGroupServiceImpl() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - public List getRequests() { - return requests; - } - - public void addResponse(AbstractMessage response) { - responses.add(response); - } - - public void setResponses(List responses) { - this.responses = new LinkedList(responses); - } - - public void addException(Exception exception) { - responses.add(exception); - } - - public void reset() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - @Override - public void listGroups( - ListGroupsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListGroupsResponse) { - requests.add(request); - responseObserver.onNext((ListGroupsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getGroup(GetGroupRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Group) { - requests.add(request); - responseObserver.onNext((Group) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void createGroup(CreateGroupRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Group) { - requests.add(request); - responseObserver.onNext((Group) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void updateGroup(UpdateGroupRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Group) { - requests.add(request); - responseObserver.onNext((Group) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void deleteGroup(DeleteGroupRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void listGroupMembers( - ListGroupMembersRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListGroupMembersResponse) { - requests.add(request); - responseObserver.onNext((ListGroupMembersResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockMetricService.java b/src/test/java/com/google/cloud/monitoring/v3/MockMetricService.java deleted file mode 100644 index fee781c5..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockMetricService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.protobuf.AbstractMessage; -import io.grpc.ServerServiceDefinition; -import java.util.List; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockMetricService implements MockGrpcService { - private final MockMetricServiceImpl serviceImpl; - - public MockMetricService() { - serviceImpl = new MockMetricServiceImpl(); - } - - @Override - public List getRequests() { - return serviceImpl.getRequests(); - } - - @Override - public void addResponse(AbstractMessage response) { - serviceImpl.addResponse(response); - } - - @Override - public void addException(Exception exception) { - serviceImpl.addException(exception); - } - - @Override - public ServerServiceDefinition getServiceDefinition() { - return serviceImpl.bindService(); - } - - @Override - public void reset() { - serviceImpl.reset(); - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockMetricServiceImpl.java b/src/test/java/com/google/cloud/monitoring/v3/MockMetricServiceImpl.java deleted file mode 100644 index 9a75d1f9..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockMetricServiceImpl.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.MetricDescriptor; -import com.google.api.MonitoredResourceDescriptor; -import com.google.api.core.BetaApi; -import com.google.monitoring.v3.CreateMetricDescriptorRequest; -import com.google.monitoring.v3.CreateTimeSeriesRequest; -import com.google.monitoring.v3.DeleteMetricDescriptorRequest; -import com.google.monitoring.v3.GetMetricDescriptorRequest; -import com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest; -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.MetricServiceGrpc.MetricServiceImplBase; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.stub.StreamObserver; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockMetricServiceImpl extends MetricServiceImplBase { - private List requests; - private Queue responses; - - public MockMetricServiceImpl() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - public List getRequests() { - return requests; - } - - public void addResponse(AbstractMessage response) { - responses.add(response); - } - - public void setResponses(List responses) { - this.responses = new LinkedList(responses); - } - - public void addException(Exception exception) { - responses.add(exception); - } - - public void reset() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - @Override - public void listMonitoredResourceDescriptors( - ListMonitoredResourceDescriptorsRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListMonitoredResourceDescriptorsResponse) { - requests.add(request); - responseObserver.onNext((ListMonitoredResourceDescriptorsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getMonitoredResourceDescriptor( - GetMonitoredResourceDescriptorRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof MonitoredResourceDescriptor) { - requests.add(request); - responseObserver.onNext((MonitoredResourceDescriptor) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void listMetricDescriptors( - ListMetricDescriptorsRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListMetricDescriptorsResponse) { - requests.add(request); - responseObserver.onNext((ListMetricDescriptorsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getMetricDescriptor( - GetMetricDescriptorRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof MetricDescriptor) { - requests.add(request); - responseObserver.onNext((MetricDescriptor) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void createMetricDescriptor( - CreateMetricDescriptorRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof MetricDescriptor) { - requests.add(request); - responseObserver.onNext((MetricDescriptor) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void deleteMetricDescriptor( - DeleteMetricDescriptorRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void listTimeSeries( - ListTimeSeriesRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListTimeSeriesResponse) { - requests.add(request); - responseObserver.onNext((ListTimeSeriesResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void createTimeSeries( - CreateTimeSeriesRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelService.java b/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelService.java deleted file mode 100644 index 7667e6d6..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.protobuf.AbstractMessage; -import io.grpc.ServerServiceDefinition; -import java.util.List; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockNotificationChannelService implements MockGrpcService { - private final MockNotificationChannelServiceImpl serviceImpl; - - public MockNotificationChannelService() { - serviceImpl = new MockNotificationChannelServiceImpl(); - } - - @Override - public List getRequests() { - return serviceImpl.getRequests(); - } - - @Override - public void addResponse(AbstractMessage response) { - serviceImpl.addResponse(response); - } - - @Override - public void addException(Exception exception) { - serviceImpl.addException(exception); - } - - @Override - public ServerServiceDefinition getServiceDefinition() { - return serviceImpl.bindService(); - } - - @Override - public void reset() { - serviceImpl.reset(); - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelServiceImpl.java b/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelServiceImpl.java deleted file mode 100644 index ad688d02..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelServiceImpl.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.BetaApi; -import com.google.monitoring.v3.CreateNotificationChannelRequest; -import com.google.monitoring.v3.DeleteNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelDescriptorRequest; -import com.google.monitoring.v3.GetNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsRequest; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsResponse; -import com.google.monitoring.v3.ListNotificationChannelsRequest; -import com.google.monitoring.v3.ListNotificationChannelsResponse; -import com.google.monitoring.v3.NotificationChannel; -import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.NotificationChannelServiceGrpc.NotificationChannelServiceImplBase; -import com.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.UpdateNotificationChannelRequest; -import com.google.monitoring.v3.VerifyNotificationChannelRequest; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.stub.StreamObserver; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockNotificationChannelServiceImpl extends NotificationChannelServiceImplBase { - private List requests; - private Queue responses; - - public MockNotificationChannelServiceImpl() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - public List getRequests() { - return requests; - } - - public void addResponse(AbstractMessage response) { - responses.add(response); - } - - public void setResponses(List responses) { - this.responses = new LinkedList(responses); - } - - public void addException(Exception exception) { - responses.add(exception); - } - - public void reset() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - @Override - public void listNotificationChannelDescriptors( - ListNotificationChannelDescriptorsRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListNotificationChannelDescriptorsResponse) { - requests.add(request); - responseObserver.onNext((ListNotificationChannelDescriptorsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getNotificationChannelDescriptor( - GetNotificationChannelDescriptorRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof NotificationChannelDescriptor) { - requests.add(request); - responseObserver.onNext((NotificationChannelDescriptor) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void listNotificationChannels( - ListNotificationChannelsRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListNotificationChannelsResponse) { - requests.add(request); - responseObserver.onNext((ListNotificationChannelsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getNotificationChannel( - GetNotificationChannelRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof NotificationChannel) { - requests.add(request); - responseObserver.onNext((NotificationChannel) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void createNotificationChannel( - CreateNotificationChannelRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof NotificationChannel) { - requests.add(request); - responseObserver.onNext((NotificationChannel) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void updateNotificationChannel( - UpdateNotificationChannelRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof NotificationChannel) { - requests.add(request); - responseObserver.onNext((NotificationChannel) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void deleteNotificationChannel( - DeleteNotificationChannelRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void sendNotificationChannelVerificationCode( - SendNotificationChannelVerificationCodeRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getNotificationChannelVerificationCode( - GetNotificationChannelVerificationCodeRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof GetNotificationChannelVerificationCodeResponse) { - requests.add(request); - responseObserver.onNext((GetNotificationChannelVerificationCodeResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void verifyNotificationChannel( - VerifyNotificationChannelRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof NotificationChannel) { - requests.add(request); - responseObserver.onNext((NotificationChannel) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckService.java b/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckService.java deleted file mode 100644 index 868aa715..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.BetaApi; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.protobuf.AbstractMessage; -import io.grpc.ServerServiceDefinition; -import java.util.List; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockUptimeCheckService implements MockGrpcService { - private final MockUptimeCheckServiceImpl serviceImpl; - - public MockUptimeCheckService() { - serviceImpl = new MockUptimeCheckServiceImpl(); - } - - @Override - public List getRequests() { - return serviceImpl.getRequests(); - } - - @Override - public void addResponse(AbstractMessage response) { - serviceImpl.addResponse(response); - } - - @Override - public void addException(Exception exception) { - serviceImpl.addException(exception); - } - - @Override - public ServerServiceDefinition getServiceDefinition() { - return serviceImpl.bindService(); - } - - @Override - public void reset() { - serviceImpl.reset(); - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckServiceImpl.java b/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckServiceImpl.java deleted file mode 100644 index 1ade4591..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckServiceImpl.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import com.google.api.core.BetaApi; -import com.google.monitoring.v3.CreateUptimeCheckConfigRequest; -import com.google.monitoring.v3.DeleteUptimeCheckConfigRequest; -import com.google.monitoring.v3.GetUptimeCheckConfigRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; -import com.google.monitoring.v3.ListUptimeCheckIpsRequest; -import com.google.monitoring.v3.ListUptimeCheckIpsResponse; -import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; -import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.monitoring.v3.UptimeCheckServiceGrpc.UptimeCheckServiceImplBase; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.stub.StreamObserver; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -@javax.annotation.Generated("by GAPIC") -@BetaApi -public class MockUptimeCheckServiceImpl extends UptimeCheckServiceImplBase { - private List requests; - private Queue responses; - - public MockUptimeCheckServiceImpl() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - public List getRequests() { - return requests; - } - - public void addResponse(AbstractMessage response) { - responses.add(response); - } - - public void setResponses(List responses) { - this.responses = new LinkedList(responses); - } - - public void addException(Exception exception) { - responses.add(exception); - } - - public void reset() { - requests = new ArrayList<>(); - responses = new LinkedList<>(); - } - - @Override - public void listUptimeCheckConfigs( - ListUptimeCheckConfigsRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListUptimeCheckConfigsResponse) { - requests.add(request); - responseObserver.onNext((ListUptimeCheckConfigsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getUptimeCheckConfig( - GetUptimeCheckConfigRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof UptimeCheckConfig) { - requests.add(request); - responseObserver.onNext((UptimeCheckConfig) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void createUptimeCheckConfig( - CreateUptimeCheckConfigRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof UptimeCheckConfig) { - requests.add(request); - responseObserver.onNext((UptimeCheckConfig) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void updateUptimeCheckConfig( - UpdateUptimeCheckConfigRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof UptimeCheckConfig) { - requests.add(request); - responseObserver.onNext((UptimeCheckConfig) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void deleteUptimeCheckConfig( - DeleteUptimeCheckConfigRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext((Empty) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void listUptimeCheckIps( - ListUptimeCheckIpsRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListUptimeCheckIpsResponse) { - requests.add(request); - responseObserver.onNext((ListUptimeCheckIpsResponse) response); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java b/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java deleted file mode 100644 index e6f29121..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java +++ /dev/null @@ -1,604 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelDescriptorsPagedResponse; -import static com.google.cloud.monitoring.v3.NotificationChannelServiceClient.ListNotificationChannelsPagedResponse; - -import com.google.api.gax.core.NoCredentialsProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.testing.LocalChannelProvider; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.api.gax.grpc.testing.MockServiceHelper; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.InvalidArgumentException; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.CreateNotificationChannelRequest; -import com.google.monitoring.v3.DeleteNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelDescriptorRequest; -import com.google.monitoring.v3.GetNotificationChannelRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.GetNotificationChannelVerificationCodeResponse; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsRequest; -import com.google.monitoring.v3.ListNotificationChannelDescriptorsResponse; -import com.google.monitoring.v3.ListNotificationChannelsRequest; -import com.google.monitoring.v3.ListNotificationChannelsResponse; -import com.google.monitoring.v3.NotificationChannel; -import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.monitoring.v3.NotificationChannelName; -import com.google.monitoring.v3.ProjectName; -import com.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest; -import com.google.monitoring.v3.UpdateNotificationChannelRequest; -import com.google.monitoring.v3.VerifyNotificationChannelRequest; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import com.google.protobuf.FieldMask; -import io.grpc.Status; -import io.grpc.StatusRuntimeException; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -@javax.annotation.Generated("by GAPIC") -public class NotificationChannelServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; - private static MockUptimeCheckService mockUptimeCheckService; - private static MockServiceHelper serviceHelper; - private NotificationChannelServiceClient client; - private LocalChannelProvider channelProvider; - - @BeforeClass - public static void startStaticServer() { - mockAlertPolicyService = new MockAlertPolicyService(); - mockGroupService = new MockGroupService(); - mockMetricService = new MockMetricService(); - mockNotificationChannelService = new MockNotificationChannelService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = - new MockServiceHelper( - "in-process-1", - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockUptimeCheckService)); - serviceHelper.start(); - } - - @AfterClass - public static void stopServer() { - serviceHelper.stop(); - } - - @Before - public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); - NotificationChannelServiceSettings settings = - NotificationChannelServiceSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = NotificationChannelServiceClient.create(settings); - } - - @After - public void tearDown() throws Exception { - client.close(); - } - - @Test - @SuppressWarnings("all") - public void listNotificationChannelDescriptorsTest() { - String nextPageToken = ""; - NotificationChannelDescriptor channelDescriptorsElement = - NotificationChannelDescriptor.newBuilder().build(); - List channelDescriptors = - Arrays.asList(channelDescriptorsElement); - ListNotificationChannelDescriptorsResponse expectedResponse = - ListNotificationChannelDescriptorsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllChannelDescriptors(channelDescriptors) - .build(); - mockNotificationChannelService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - - ListNotificationChannelDescriptorsPagedResponse pagedListResponse = - client.listNotificationChannelDescriptors(name); - - List resources = - Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getChannelDescriptorsList().get(0), resources.get(0)); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListNotificationChannelDescriptorsRequest actualRequest = - (ListNotificationChannelDescriptorsRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listNotificationChannelDescriptorsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - - client.listNotificationChannelDescriptors(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getNotificationChannelDescriptorTest() { - String name2 = "name2-1052831874"; - String type = "type3575610"; - String displayName = "displayName1615086568"; - String description = "description-1724546052"; - NotificationChannelDescriptor expectedResponse = - NotificationChannelDescriptor.newBuilder() - .setName(name2) - .setType(type) - .setDisplayName(displayName) - .setDescription(description) - .build(); - mockNotificationChannelService.addResponse(expectedResponse); - - NotificationChannelDescriptorName name = - NotificationChannelDescriptorName.of("[PROJECT]", "[CHANNEL_DESCRIPTOR]"); - - NotificationChannelDescriptor actualResponse = client.getNotificationChannelDescriptor(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetNotificationChannelDescriptorRequest actualRequest = - (GetNotificationChannelDescriptorRequest) actualRequests.get(0); - - Assert.assertEquals(name, NotificationChannelDescriptorName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getNotificationChannelDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - NotificationChannelDescriptorName name = - NotificationChannelDescriptorName.of("[PROJECT]", "[CHANNEL_DESCRIPTOR]"); - - client.getNotificationChannelDescriptor(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void listNotificationChannelsTest() { - String nextPageToken = ""; - NotificationChannel notificationChannelsElement = NotificationChannel.newBuilder().build(); - List notificationChannels = Arrays.asList(notificationChannelsElement); - ListNotificationChannelsResponse expectedResponse = - ListNotificationChannelsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllNotificationChannels(notificationChannels) - .build(); - mockNotificationChannelService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - - ListNotificationChannelsPagedResponse pagedListResponse = client.listNotificationChannels(name); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getNotificationChannelsList().get(0), resources.get(0)); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListNotificationChannelsRequest actualRequest = - (ListNotificationChannelsRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listNotificationChannelsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - - client.listNotificationChannels(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getNotificationChannelTest() { - String type = "type3575610"; - String name2 = "name2-1052831874"; - String displayName = "displayName1615086568"; - String description = "description-1724546052"; - NotificationChannel expectedResponse = - NotificationChannel.newBuilder() - .setType(type) - .setName(name2) - .setDisplayName(displayName) - .setDescription(description) - .build(); - mockNotificationChannelService.addResponse(expectedResponse); - - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - - NotificationChannel actualResponse = client.getNotificationChannel(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetNotificationChannelRequest actualRequest = - (GetNotificationChannelRequest) actualRequests.get(0); - - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - - client.getNotificationChannel(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void createNotificationChannelTest() { - String type = "type3575610"; - String name2 = "name2-1052831874"; - String displayName = "displayName1615086568"; - String description = "description-1724546052"; - NotificationChannel expectedResponse = - NotificationChannel.newBuilder() - .setType(type) - .setName(name2) - .setDisplayName(displayName) - .setDescription(description) - .build(); - mockNotificationChannelService.addResponse(expectedResponse); - - ProjectName name = ProjectName.of("[PROJECT]"); - NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); - - NotificationChannel actualResponse = - client.createNotificationChannel(name, notificationChannel); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateNotificationChannelRequest actualRequest = - (CreateNotificationChannelRequest) actualRequests.get(0); - - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); - Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - ProjectName name = ProjectName.of("[PROJECT]"); - NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); - - client.createNotificationChannel(name, notificationChannel); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void updateNotificationChannelTest() { - String type = "type3575610"; - String name = "name3373707"; - String displayName = "displayName1615086568"; - String description = "description-1724546052"; - NotificationChannel expectedResponse = - NotificationChannel.newBuilder() - .setType(type) - .setName(name) - .setDisplayName(displayName) - .setDescription(description) - .build(); - mockNotificationChannelService.addResponse(expectedResponse); - - FieldMask updateMask = FieldMask.newBuilder().build(); - NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); - - NotificationChannel actualResponse = - client.updateNotificationChannel(updateMask, notificationChannel); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateNotificationChannelRequest actualRequest = - (UpdateNotificationChannelRequest) actualRequests.get(0); - - Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); - Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void updateNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - FieldMask updateMask = FieldMask.newBuilder().build(); - NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); - - client.updateNotificationChannel(updateMask, notificationChannel); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void deleteNotificationChannelTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockNotificationChannelService.addResponse(expectedResponse); - - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - boolean force = false; - - client.deleteNotificationChannel(name, force); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteNotificationChannelRequest actualRequest = - (DeleteNotificationChannelRequest) actualRequests.get(0); - - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); - Assert.assertEquals(force, actualRequest.getForce()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void deleteNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - boolean force = false; - - client.deleteNotificationChannel(name, force); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void sendNotificationChannelVerificationCodeTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockNotificationChannelService.addResponse(expectedResponse); - - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - - client.sendNotificationChannelVerificationCode(name); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SendNotificationChannelVerificationCodeRequest actualRequest = - (SendNotificationChannelVerificationCodeRequest) actualRequests.get(0); - - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void sendNotificationChannelVerificationCodeExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - - client.sendNotificationChannelVerificationCode(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getNotificationChannelVerificationCodeTest() { - String code = "code3059181"; - GetNotificationChannelVerificationCodeResponse expectedResponse = - GetNotificationChannelVerificationCodeResponse.newBuilder().setCode(code).build(); - mockNotificationChannelService.addResponse(expectedResponse); - - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - - GetNotificationChannelVerificationCodeResponse actualResponse = - client.getNotificationChannelVerificationCode(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetNotificationChannelVerificationCodeRequest actualRequest = - (GetNotificationChannelVerificationCodeRequest) actualRequests.get(0); - - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getNotificationChannelVerificationCodeExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - - client.getNotificationChannelVerificationCode(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void verifyNotificationChannelTest() { - String type = "type3575610"; - String name2 = "name2-1052831874"; - String displayName = "displayName1615086568"; - String description = "description-1724546052"; - NotificationChannel expectedResponse = - NotificationChannel.newBuilder() - .setType(type) - .setName(name2) - .setDisplayName(displayName) - .setDescription(description) - .build(); - mockNotificationChannelService.addResponse(expectedResponse); - - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - String code = "code3059181"; - - NotificationChannel actualResponse = client.verifyNotificationChannel(name, code); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockNotificationChannelService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - VerifyNotificationChannelRequest actualRequest = - (VerifyNotificationChannelRequest) actualRequests.get(0); - - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); - Assert.assertEquals(code, actualRequest.getCode()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void verifyNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockNotificationChannelService.addException(exception); - - try { - NotificationChannelName name = - NotificationChannelName.of("[PROJECT]", "[NOTIFICATION_CHANNEL]"); - String code = "code3059181"; - - client.verifyNotificationChannel(name, code); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } -} diff --git a/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java b/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java deleted file mode 100644 index 425aaf94..00000000 --- a/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Copyright 2019 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.cloud.monitoring.v3; - -import static com.google.cloud.monitoring.v3.UptimeCheckServiceClient.ListUptimeCheckConfigsPagedResponse; - -import com.google.api.gax.core.NoCredentialsProvider; -import com.google.api.gax.grpc.GaxGrpcProperties; -import com.google.api.gax.grpc.testing.LocalChannelProvider; -import com.google.api.gax.grpc.testing.MockGrpcService; -import com.google.api.gax.grpc.testing.MockServiceHelper; -import com.google.api.gax.rpc.ApiClientHeaderProvider; -import com.google.api.gax.rpc.InvalidArgumentException; -import com.google.common.collect.Lists; -import com.google.monitoring.v3.CreateUptimeCheckConfigRequest; -import com.google.monitoring.v3.DeleteUptimeCheckConfigRequest; -import com.google.monitoring.v3.GetUptimeCheckConfigRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; -import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; -import com.google.monitoring.v3.ProjectName; -import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; -import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.monitoring.v3.UptimeCheckConfigName; -import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; -import io.grpc.Status; -import io.grpc.StatusRuntimeException; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -@javax.annotation.Generated("by GAPIC") -public class UptimeCheckServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; - private static MockUptimeCheckService mockUptimeCheckService; - private static MockServiceHelper serviceHelper; - private UptimeCheckServiceClient client; - private LocalChannelProvider channelProvider; - - @BeforeClass - public static void startStaticServer() { - mockAlertPolicyService = new MockAlertPolicyService(); - mockGroupService = new MockGroupService(); - mockMetricService = new MockMetricService(); - mockNotificationChannelService = new MockNotificationChannelService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = - new MockServiceHelper( - "in-process-1", - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockUptimeCheckService)); - serviceHelper.start(); - } - - @AfterClass - public static void stopServer() { - serviceHelper.stop(); - } - - @Before - public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); - UptimeCheckServiceSettings settings = - UptimeCheckServiceSettings.newBuilder() - .setTransportChannelProvider(channelProvider) - .setCredentialsProvider(NoCredentialsProvider.create()) - .build(); - client = UptimeCheckServiceClient.create(settings); - } - - @After - public void tearDown() throws Exception { - client.close(); - } - - @Test - @SuppressWarnings("all") - public void listUptimeCheckConfigsTest() { - String nextPageToken = ""; - int totalSize = 705419236; - UptimeCheckConfig uptimeCheckConfigsElement = UptimeCheckConfig.newBuilder().build(); - List uptimeCheckConfigs = Arrays.asList(uptimeCheckConfigsElement); - ListUptimeCheckConfigsResponse expectedResponse = - ListUptimeCheckConfigsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .setTotalSize(totalSize) - .addAllUptimeCheckConfigs(uptimeCheckConfigs) - .build(); - mockUptimeCheckService.addResponse(expectedResponse); - - String formattedParent = ProjectName.format("[PROJECT]"); - - ListUptimeCheckConfigsPagedResponse pagedListResponse = - client.listUptimeCheckConfigs(formattedParent); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getUptimeCheckConfigsList().get(0), resources.get(0)); - - List actualRequests = mockUptimeCheckService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListUptimeCheckConfigsRequest actualRequest = - (ListUptimeCheckConfigsRequest) actualRequests.get(0); - - Assert.assertEquals(formattedParent, actualRequest.getParent()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void listUptimeCheckConfigsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockUptimeCheckService.addException(exception); - - try { - String formattedParent = ProjectName.format("[PROJECT]"); - - client.listUptimeCheckConfigs(formattedParent); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void getUptimeCheckConfigTest() { - String name2 = "name2-1052831874"; - String displayName = "displayName1615086568"; - boolean isInternal = true; - UptimeCheckConfig expectedResponse = - UptimeCheckConfig.newBuilder() - .setName(name2) - .setDisplayName(displayName) - .setIsInternal(isInternal) - .build(); - mockUptimeCheckService.addResponse(expectedResponse); - - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - - UptimeCheckConfig actualResponse = client.getUptimeCheckConfig(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockUptimeCheckService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetUptimeCheckConfigRequest actualRequest = (GetUptimeCheckConfigRequest) actualRequests.get(0); - - Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void getUptimeCheckConfigExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockUptimeCheckService.addException(exception); - - try { - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - - client.getUptimeCheckConfig(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void createUptimeCheckConfigTest() { - String name = "name3373707"; - String displayName = "displayName1615086568"; - boolean isInternal = true; - UptimeCheckConfig expectedResponse = - UptimeCheckConfig.newBuilder() - .setName(name) - .setDisplayName(displayName) - .setIsInternal(isInternal) - .build(); - mockUptimeCheckService.addResponse(expectedResponse); - - String formattedParent = ProjectName.format("[PROJECT]"); - UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); - - UptimeCheckConfig actualResponse = - client.createUptimeCheckConfig(formattedParent, uptimeCheckConfig); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockUptimeCheckService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateUptimeCheckConfigRequest actualRequest = - (CreateUptimeCheckConfigRequest) actualRequests.get(0); - - Assert.assertEquals(formattedParent, actualRequest.getParent()); - Assert.assertEquals(uptimeCheckConfig, actualRequest.getUptimeCheckConfig()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void createUptimeCheckConfigExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockUptimeCheckService.addException(exception); - - try { - String formattedParent = ProjectName.format("[PROJECT]"); - UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); - - client.createUptimeCheckConfig(formattedParent, uptimeCheckConfig); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void updateUptimeCheckConfigTest() { - String name = "name3373707"; - String displayName = "displayName1615086568"; - boolean isInternal = true; - UptimeCheckConfig expectedResponse = - UptimeCheckConfig.newBuilder() - .setName(name) - .setDisplayName(displayName) - .setIsInternal(isInternal) - .build(); - mockUptimeCheckService.addResponse(expectedResponse); - - UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); - - UptimeCheckConfig actualResponse = client.updateUptimeCheckConfig(uptimeCheckConfig); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockUptimeCheckService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateUptimeCheckConfigRequest actualRequest = - (UpdateUptimeCheckConfigRequest) actualRequests.get(0); - - Assert.assertEquals(uptimeCheckConfig, actualRequest.getUptimeCheckConfig()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void updateUptimeCheckConfigExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockUptimeCheckService.addException(exception); - - try { - UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); - - client.updateUptimeCheckConfig(uptimeCheckConfig); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - - @Test - @SuppressWarnings("all") - public void deleteUptimeCheckConfigTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockUptimeCheckService.addResponse(expectedResponse); - - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - - client.deleteUptimeCheckConfig(name); - - List actualRequests = mockUptimeCheckService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteUptimeCheckConfigRequest actualRequest = - (DeleteUptimeCheckConfigRequest) actualRequests.get(0); - - Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void deleteUptimeCheckConfigExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockUptimeCheckService.addException(exception); - - try { - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - - client.deleteUptimeCheckConfig(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } -}