From 3945baca9c0a2a191f97a860eef9d7fe36499665 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 28 Jan 2021 13:39:55 -0800 Subject: [PATCH] chore: migrate to microgenerator (#378) * chore: Remove spurious build warnings by deleting--include_source_info from .bazelrc Committer: @miraleung PiperOrigin-RevId: 344134135 Source-Author: Google APIs Source-Date: Tue Nov 24 14:38:21 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: b11a87f3b54be3a5e42c15020ee1e0781f86da90 Source-Link: https://github.com/googleapis/googleapis/commit/b11a87f3b54be3a5e42c15020ee1e0781f86da90 * chore: migrate java-monitoring to the Java microgenerator Committer: @miraleung PiperOrigin-RevId: 344845099 Source-Author: Google APIs Source-Date: Mon Nov 30 10:51:26 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: d04af09f7622b0a6a07497237b17fc9f987cb2ad Source-Link: https://github.com/googleapis/googleapis/commit/d04af09f7622b0a6a07497237b17fc9f987cb2ad * chore: Undo removal of --include_source_info from .bazelrc Committer: @miraleung PiperOrigin-RevId: 345067549 Source-Author: Google APIs Source-Date: Tue Dec 1 11:49:14 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 8cfc6c874574b649b4524a4ef6a0651533325a84 Source-Link: https://github.com/googleapis/googleapis/commit/8cfc6c874574b649b4524a4ef6a0651533325a84 * fix: Update gapic-generator-java to 0.0.7 Committer: @miraleung PiperOrigin-RevId: 345476969 Source-Author: Google APIs Source-Date: Thu Dec 3 10:07:32 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 7be2c821dd88109038c55c89f7dd48f092eeab9d Source-Link: https://github.com/googleapis/googleapis/commit/7be2c821dd88109038c55c89f7dd48f092eeab9d * chore: update gapic-generator-java to 0.0.8 Committer: @miraleung PiperOrigin-RevId: 346126713 Source-Author: Google APIs Source-Date: Mon Dec 7 10:39:38 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: b8b2f8c288cec1f673bf10aa5008819c1576bf2e Source-Link: https://github.com/googleapis/googleapis/commit/b8b2f8c288cec1f673bf10aa5008819c1576bf2e * chore: update gapic-generator-java to 0.0.9 Committer: @miraleung PiperOrigin-RevId: 346372957 Source-Author: Google APIs Source-Date: Tue Dec 8 11:37:30 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 857f70daef9f4c38f042fb3dfb7b8423ae18fd19 Source-Link: https://github.com/googleapis/googleapis/commit/857f70daef9f4c38f042fb3dfb7b8423ae18fd19 * chore: restore resource names * Update google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java Co-authored-by: yoshi-code-bot <70984784+yoshi-code-bot@users.noreply.github.com> * chore: format files Co-authored-by: Jeff Ching Co-authored-by: Neenu Shaji Co-authored-by: yoshi-code-bot <70984784+yoshi-code-bot@users.noreply.github.com> Co-authored-by: Neenu1995 --- .../v3/AlertPolicyServiceClient.java | 394 +++---- .../v3/AlertPolicyServiceSettings.java | 35 +- .../monitoring/v3/GroupServiceClient.java | 458 ++------ .../monitoring/v3/GroupServiceSettings.java | 35 +- .../monitoring/v3/MetricServiceClient.java | 669 +++--------- .../monitoring/v3/MetricServiceSettings.java | 35 +- .../v3/NotificationChannelServiceClient.java | 726 ++++--------- .../NotificationChannelServiceSettings.java | 35 +- .../v3/ServiceMonitoringServiceClient.java | 652 +++--------- .../v3/ServiceMonitoringServiceSettings.java | 35 +- .../v3/UptimeCheckServiceClient.java | 425 ++------ .../v3/UptimeCheckServiceSettings.java | 35 +- .../cloud/monitoring/v3/package-info.java | 76 +- .../v3/stub/AlertPolicyServiceStub.java | 9 +- .../stub/AlertPolicyServiceStubSettings.java | 364 ++----- .../monitoring/v3/stub/GroupServiceStub.java | 9 +- .../v3/stub/GroupServiceStubSettings.java | 442 +++----- ...GrpcAlertPolicyServiceCallableFactory.java | 40 +- .../v3/stub/GrpcAlertPolicyServiceStub.java | 35 +- .../stub/GrpcGroupServiceCallableFactory.java | 40 +- .../v3/stub/GrpcGroupServiceStub.java | 44 +- .../GrpcMetricServiceCallableFactory.java | 40 +- .../v3/stub/GrpcMetricServiceStub.java | 58 +- ...ficationChannelServiceCallableFactory.java | 40 +- .../GrpcNotificationChannelServiceStub.java | 54 +- ...rviceMonitoringServiceCallableFactory.java | 40 +- .../GrpcServiceMonitoringServiceStub.java | 52 +- ...GrpcUptimeCheckServiceCallableFactory.java | 40 +- .../v3/stub/GrpcUptimeCheckServiceStub.java | 46 +- .../monitoring/v3/stub/MetricServiceStub.java | 9 +- .../v3/stub/MetricServiceStubSettings.java | 423 ++++---- .../stub/NotificationChannelServiceStub.java | 9 +- ...otificationChannelServiceStubSettings.java | 607 ++++------- .../v3/stub/ServiceMonitoringServiceStub.java | 9 +- .../ServiceMonitoringServiceStubSettings.java | 549 ++++------ .../v3/stub/UptimeCheckServiceStub.java | 9 +- .../stub/UptimeCheckServiceStubSettings.java | 491 ++++----- .../v3/AlertPolicyServiceClientTest.java | 529 ++++++++-- .../monitoring/v3/GroupServiceClientTest.java | 569 ++++++++-- .../v3/MetricServiceClientTest.java | 858 ++++++++++++--- .../monitoring/v3/MetricServiceSmokeTest.java | 67 -- .../monitoring/v3/MockAlertPolicyService.java | 6 +- .../v3/MockAlertPolicyServiceImpl.java | 26 +- .../cloud/monitoring/v3/MockGroupService.java | 6 +- .../monitoring/v3/MockGroupServiceImpl.java | 30 +- .../monitoring/v3/MockMetricService.java | 6 +- .../monitoring/v3/MockMetricServiceImpl.java | 38 +- .../v3/MockNotificationChannelService.java | 6 +- .../MockNotificationChannelServiceImpl.java | 46 +- .../v3/MockServiceMonitoringService.java | 6 +- .../v3/MockServiceMonitoringServiceImpl.java | 46 +- .../monitoring/v3/MockUptimeCheckService.java | 6 +- .../v3/MockUptimeCheckServiceImpl.java | 30 +- .../NotificationChannelServiceClientTest.java | 992 +++++++++++++++--- .../ServiceMonitoringServiceClientTest.java | 752 ++++++++++--- .../v3/UptimeCheckServiceClientTest.java | 584 +++++++++-- .../google/monitoring/v3/AlertPolicyName.java | 173 +-- .../com/google/monitoring/v3/FolderName.java | 168 +++ .../com/google/monitoring/v3/GroupName.java | 173 +-- .../monitoring/v3/MetricDescriptorName.java | 187 ++-- .../v3/MonitoredResourceDescriptorName.java | 178 ++-- .../v3/NotificationChannelDescriptorName.java | 184 ++-- .../v3/NotificationChannelName.java | 183 ++-- .../monitoring/v3/OrganizationName.java | 168 +++ .../com/google/monitoring/v3/ProjectName.java | 86 +- .../v3/ServiceLevelObjectiveName.java | 194 ++-- .../com/google/monitoring/v3/ServiceName.java | 173 +-- .../monitoring/v3/UptimeCheckConfigName.java | 183 ++-- synth.metadata | 7 +- synth.py | 20 + 70 files changed, 7208 insertions(+), 6541 deletions(-) delete mode 100644 google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java create mode 100644 proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/FolderName.java create mode 100644 proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/OrganizationName.java diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java index e2734044..c22e8e5c 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -36,6 +37,8 @@ import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; +import com.google.monitoring.v3.OrganizationName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; @@ -44,7 +47,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * 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 @@ -56,16 +59,7 @@ *

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.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]");
- *   AlertPolicy response = alertPolicyServiceClient.getAlertPolicy(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the alertPolicyServiceClient object to clean up resources + *

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(). * @@ -94,28 +88,27 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * AlertPolicyServiceSettings alertPolicyServiceSettings =
  *     AlertPolicyServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * AlertPolicyServiceClient alertPolicyServiceClient =
  *     AlertPolicyServiceClient.create(alertPolicyServiceSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * AlertPolicyServiceSettings alertPolicyServiceSettings =
  *     AlertPolicyServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
  * AlertPolicyServiceClient alertPolicyServiceClient =
  *     AlertPolicyServiceClient.create(alertPolicyServiceSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ +@BetaApi @Generated("by gapic-generator") public class AlertPolicyServiceClient implements BackgroundResource { private final AlertPolicyServiceSettings settings; @@ -137,7 +130,7 @@ public static final AlertPolicyServiceClient create(AlertPolicyServiceSettings s /** * Constructs an instance of AlertPolicyServiceClient, using the given stub for making calls. This - * is for advanced usage - prefer to use AlertPolicyServiceSettings}. + * is for advanced usage - prefer using create(AlertPolicyServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final AlertPolicyServiceClient create(AlertPolicyServiceStub stub) { @@ -169,21 +162,10 @@ public AlertPolicyServiceStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing alerting policies for the project. * - *

Sample code: - * - *


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

projects/[PROJECT_ID_OR_NUMBER] *

Note that this field names the parent container in which the alerting policies to be @@ -200,20 +182,49 @@ public final ListAlertPoliciesPagedResponse listAlertPolicies(ResourceName name) return listAlertPolicies(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing alerting policies for the project. * - *

Sample code: + * @param name Required. The project whose alert policies are to be listed. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + *

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(OrganizationName 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. * - *


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

projects/[PROJECT_ID_OR_NUMBER] + *

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. * * @param name Required. The project whose alert policies are to be listed. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -228,24 +239,10 @@ public final ListAlertPoliciesPagedResponse listAlertPolicies(String name) { return listAlertPolicies(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing alerting policies for the project. * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ResourceName 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 */ @@ -253,76 +250,32 @@ public final ListAlertPoliciesPagedResponse listAlertPolicies(ListAlertPoliciesR return listAlertPoliciesPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing alerting policies for the project. * *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ResourceName 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing alerting policies for the project. * *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ResourceName 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single alerting policy. * - *

Sample code: - * - *


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

projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -333,19 +286,10 @@ public final AlertPolicy getAlertPolicy(AlertPolicyName name) { return getAlertPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single alerting policy. * - *

Sample code: - * - *


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

projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -355,22 +299,10 @@ public final AlertPolicy getAlertPolicy(String name) { return getAlertPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single alerting policy. * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[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 */ @@ -378,42 +310,20 @@ public final AlertPolicy getAlertPolicy(GetAlertPolicyRequest request) { return getAlertPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single alerting policy. * *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new alerting policy. * - *

Sample code: - * - *


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

projects/[PROJECT_ID_OR_NUMBER] *

Note that this field names the parent container in which the alerting policy will be @@ -434,19 +344,57 @@ public final AlertPolicy createAlertPolicy(ResourceName name, AlertPolicy alertP return createAlertPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new alerting policy. * - *

Sample code: + * @param name Required. The project in which to create the alerting policy. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + *

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/[ALERT_POLICY_ID]`, identifying the policy in the container. + * @param alertPolicy Required. 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(OrganizationName 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. * - *


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

projects/[PROJECT_ID_OR_NUMBER] + *

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/[ALERT_POLICY_ID]`, identifying the policy in the container. + * @param alertPolicy Required. 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. * * @param name Required. The project in which to create the alerting policy. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -465,24 +413,10 @@ public final AlertPolicy createAlertPolicy(String name, AlertPolicy alertPolicy) return createAlertPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new alerting policy. * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ResourceName 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 */ @@ -490,43 +424,20 @@ public final AlertPolicy createAlertPolicy(CreateAlertPolicyRequest request) { return createAlertPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new alerting policy. * *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   ResourceName 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes an alerting policy. * - *

Sample code: - * - *


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

projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] *

For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. @@ -540,19 +451,10 @@ public final void deleteAlertPolicy(AlertPolicyName name) { deleteAlertPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes an alerting policy. * - *

Sample code: - * - *


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

projects/[PROJECT_ID_OR_NUMBER]/alertPolicies/[ALERT_POLICY_ID] *

For more information, see [AlertPolicy][google.monitoring.v3.AlertPolicy]. @@ -563,22 +465,10 @@ public final void deleteAlertPolicy(String name) { deleteAlertPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes an alerting policy. * - *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[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 */ @@ -586,44 +476,22 @@ public final void deleteAlertPolicy(DeleteAlertPolicyRequest request) { deleteAlertPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes an alerting policy. * *

Sample code: - * - *


-   * try (AlertPolicyServiceClient alertPolicyServiceClient = AlertPolicyServiceClient.create()) {
-   *   AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[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 + // 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 @@ -653,24 +521,12 @@ public final AlertPolicy updateAlertPolicy(FieldMask updateMask, AlertPolicy ale return updateAlertPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 */ @@ -678,25 +534,13 @@ public final AlertPolicy updateAlertPolicy(UpdateAlertPolicyRequest request) { return updateAlertPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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(); diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java index 193bac9d..489ee29c 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -41,7 +42,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link AlertPolicyServiceClient}. * @@ -58,22 +59,25 @@ * *

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

- * 
+ * 
{@code
  * AlertPolicyServiceSettings.Builder alertPolicyServiceSettingsBuilder =
  *     AlertPolicyServiceSettings.newBuilder();
  * alertPolicyServiceSettingsBuilder
  *     .getAlertPolicySettings()
  *     .setRetrySettings(
- *         alertPolicyServiceSettingsBuilder.getAlertPolicySettings().getRetrySettings().toBuilder()
+ *         alertPolicyServiceSettingsBuilder
+ *             .getAlertPolicySettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * AlertPolicyServiceSettings alertPolicyServiceSettings = alertPolicyServiceSettingsBuilder.build();
- * 
- * 
+ * AlertPolicyServiceSettings alertPolicyServiceSettings = + * alertPolicyServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class AlertPolicyServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listAlertPolicies. */ public PagedCallSettings< ListAlertPoliciesRequest, ListAlertPoliciesResponse, ListAlertPoliciesPagedResponse> @@ -161,18 +165,15 @@ protected AlertPolicyServiceSettings(Builder settingsBuilder) throws IOException /** Builder for AlertPolicyServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + 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()); } @@ -181,11 +182,15 @@ protected Builder(AlertPolicyServiceStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(AlertPolicyServiceStubSettings.newBuilder()); + } + public AlertPolicyServiceStubSettings.Builder getStubSettingsBuilder() { return ((AlertPolicyServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java index a3655150..ae2f74dc 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -39,6 +40,8 @@ import com.google.monitoring.v3.ListGroupMembersResponse; import com.google.monitoring.v3.ListGroupsRequest; import com.google.monitoring.v3.ListGroupsResponse; +import com.google.monitoring.v3.OrganizationName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; import java.io.IOException; @@ -46,7 +49,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: The Group API lets you inspect and manage your * [groups](#google.monitoring.v3.Group). @@ -61,16 +64,7 @@ *

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.ofProjectGroupName("[PROJECT]", "[GROUP]");
- *   Group response = groupServiceClient.getGroup(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the groupServiceClient object to clean up resources such + *

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 @@ -98,28 +92,25 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * GroupServiceSettings groupServiceSettings =
  *     GroupServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
- * GroupServiceClient groupServiceClient =
- *     GroupServiceClient.create(groupServiceSettings);
- * 
- * 
+ * GroupServiceClient groupServiceClient = GroupServiceClient.create(groupServiceSettings); + * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * GroupServiceSettings groupServiceSettings =
  *     GroupServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
- * GroupServiceClient groupServiceClient =
- *     GroupServiceClient.create(groupServiceSettings);
- * 
- * 
+ * GroupServiceClient groupServiceClient = GroupServiceClient.create(groupServiceSettings); + * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ +@BetaApi @Generated("by gapic-generator") public class GroupServiceClient implements BackgroundResource { private final GroupServiceSettings settings; @@ -140,7 +131,7 @@ public static final GroupServiceClient create(GroupServiceSettings settings) thr /** * Constructs an instance of GroupServiceClient, using the given stub for making calls. This is - * for advanced usage - prefer to use GroupServiceSettings}. + * for advanced usage - prefer using create(GroupServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final GroupServiceClient create(GroupServiceStub stub) { @@ -172,21 +163,10 @@ public GroupServiceStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing groups. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   for (Group element : groupServiceClient.listGroups(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param name Required. 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 @@ -197,20 +177,37 @@ public final ListGroupsPagedResponse listGroups(ResourceName name) { return listGroups(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing groups. * - *

Sample code: + * @param name Required. 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(OrganizationName name) { + ListGroupsRequest request = + ListGroupsRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return listGroups(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the existing groups. * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   for (Group element : groupServiceClient.listGroups(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
+ * @param name Required. 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. * * @param name Required. The project whose groups are to be listed. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -221,24 +218,10 @@ public final ListGroupsPagedResponse listGroups(String name) { return listGroups(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing groups. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ResourceName 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 */ @@ -246,74 +229,30 @@ public final ListGroupsPagedResponse listGroups(ListGroupsRequest request) { return listGroupsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing groups. * *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ResourceName 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing groups. * *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ResourceName 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single group. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]");
-   *   Group response = groupServiceClient.getGroup(name);
-   * }
-   * 
- * * @param name Required. 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 @@ -324,19 +263,10 @@ public final Group getGroup(GroupName name) { return getGroup(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single group. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]");
-   *   Group response = groupServiceClient.getGroup(name.toString());
-   * }
-   * 
- * * @param name Required. 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 @@ -346,22 +276,10 @@ public final Group getGroup(String name) { return getGroup(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single group. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.ofProjectGroupName("[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 */ @@ -369,42 +287,20 @@ public final Group getGroup(GetGroupRequest request) { return getGroupCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single group. * *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.ofProjectGroupName("[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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new group. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   Group group = Group.newBuilder().build();
-   *   Group response = groupServiceClient.createGroup(name, group);
-   * }
-   * 
- * * @param name Required. The project in which to create the group. The format is: *

projects/[PROJECT_ID_OR_NUMBER] * @param group Required. A group definition. It is an error to define the `name` field because @@ -420,19 +316,47 @@ public final Group createGroup(ResourceName name, Group group) { return createGroup(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new group. * - *

Sample code: + * @param name Required. The project in which to create the group. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @param group Required. 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(OrganizationName 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. * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   Group group = Group.newBuilder().build();
-   *   Group response = groupServiceClient.createGroup(name.toString(), group);
-   * }
-   * 
+ * @param name Required. The project in which to create the group. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @param group Required. 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. * * @param name Required. The project in which to create the group. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -446,24 +370,10 @@ public final Group createGroup(String name, Group group) { return createGroup(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new group. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ResourceName 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 */ @@ -471,43 +381,20 @@ public final Group createGroup(CreateGroupRequest request) { return createGroupCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new group. * *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   ResourceName 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 + // 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 Required. 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 @@ -517,22 +404,10 @@ public final Group updateGroup(Group group) { return updateGroup(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 */ @@ -540,41 +415,20 @@ public final Group updateGroup(UpdateGroupRequest request) { return updateGroupCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes an existing group. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]");
-   *   groupServiceClient.deleteGroup(name);
-   * }
-   * 
- * * @param name Required. 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 @@ -585,19 +439,10 @@ public final void deleteGroup(GroupName name) { deleteGroup(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes an existing group. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]");
-   *   groupServiceClient.deleteGroup(name.toString());
-   * }
-   * 
- * * @param name Required. 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 @@ -607,22 +452,10 @@ public final void deleteGroup(String name) { deleteGroup(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes an existing group. * - *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.ofProjectGroupName("[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 */ @@ -630,43 +463,20 @@ public final void deleteGroup(DeleteGroupRequest request) { deleteGroupCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes an existing group. * *

Sample code: - * - *


-   * try (GroupServiceClient groupServiceClient = GroupServiceClient.create()) {
-   *   GroupName name = GroupName.ofProjectGroupName("[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 + // 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.ofProjectGroupName("[PROJECT]", "[GROUP]");
-   *   for (MonitoredResource element : groupServiceClient.listGroupMembers(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param name Required. 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 @@ -677,21 +487,10 @@ public final ListGroupMembersPagedResponse listGroupMembers(GroupName name) { return listGroupMembers(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectGroupName("[PROJECT]", "[GROUP]");
-   *   for (MonitoredResource element : groupServiceClient.listGroupMembers(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param name Required. 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 @@ -701,24 +500,10 @@ public final ListGroupMembersPagedResponse listGroupMembers(String name) { return listGroupMembers(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectGroupName("[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 */ @@ -726,57 +511,22 @@ public final ListGroupMembersPagedResponse listGroupMembers(ListGroupMembersRequ return listGroupMembersPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectGroupName("[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 + // 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.ofProjectGroupName("[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() { diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java index 790fb8be..be19b59c 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -44,7 +45,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link GroupServiceClient}. * @@ -61,22 +62,23 @@ * *

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

- * 
- * GroupServiceSettings.Builder groupServiceSettingsBuilder =
- *     GroupServiceSettings.newBuilder();
+ * 
{@code
+ * GroupServiceSettings.Builder groupServiceSettingsBuilder = GroupServiceSettings.newBuilder();
  * groupServiceSettingsBuilder
  *     .getGroupSettings()
  *     .setRetrySettings(
- *         groupServiceSettingsBuilder.getGroupSettings().getRetrySettings().toBuilder()
+ *         groupServiceSettingsBuilder
+ *             .getGroupSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * GroupServiceSettings groupServiceSettings = groupServiceSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class GroupServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listGroups. */ public PagedCallSettings listGroupsSettings() { @@ -170,18 +172,15 @@ protected GroupServiceSettings(Builder settingsBuilder) throws IOException { /** Builder for GroupServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + 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()); } @@ -190,11 +189,15 @@ protected Builder(GroupServiceStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(GroupServiceStubSettings.newBuilder()); + } + public GroupServiceStubSettings.Builder getStubSettingsBuilder() { return ((GroupServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java index 1c98fc62..93a63bb5 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -44,6 +45,7 @@ import com.google.monitoring.v3.ListTimeSeriesResponse; import com.google.monitoring.v3.MetricDescriptorName; import com.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.monitoring.v3.OrganizationName; import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; @@ -53,7 +55,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: Manages metric descriptors, monitored resource descriptors, and time series * data. @@ -61,16 +63,7 @@ *

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.ofProjectMonitoredResourceDescriptorName("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
- *   MonitoredResourceDescriptor response = metricServiceClient.getMonitoredResourceDescriptor(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the metricServiceClient object to clean up resources such + *

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 @@ -98,28 +91,25 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * MetricServiceSettings metricServiceSettings =
  *     MetricServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
- * MetricServiceClient metricServiceClient =
- *     MetricServiceClient.create(metricServiceSettings);
- * 
- * 
+ * MetricServiceClient metricServiceClient = MetricServiceClient.create(metricServiceSettings); + * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * MetricServiceSettings metricServiceSettings =
  *     MetricServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
- * MetricServiceClient metricServiceClient =
- *     MetricServiceClient.create(metricServiceSettings);
- * 
- * 
+ * MetricServiceClient metricServiceClient = MetricServiceClient.create(metricServiceSettings); + * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ +@BetaApi @Generated("by gapic-generator") public class MetricServiceClient implements BackgroundResource { private final MetricServiceSettings settings; @@ -141,7 +131,7 @@ public static final MetricServiceClient create(MetricServiceSettings settings) /** * Constructs an instance of MetricServiceClient, using the given stub for making calls. This is - * for advanced usage - prefer to use MetricServiceSettings}. + * for advanced usage - prefer using create(MetricServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final MetricServiceClient create(MetricServiceStub stub) { @@ -173,22 +163,11 @@ public MetricServiceStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists monitored resource descriptors that match a filter. This method does not require a * Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   for (MonitoredResourceDescriptor element : metricServiceClient.listMonitoredResourceDescriptors(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param name Required. 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 @@ -202,21 +181,46 @@ public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResource return listMonitoredResourceDescriptors(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists monitored resource descriptors that match a filter. This method does not require a * Workspace. * - *

Sample code: + * @param name Required. 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( + OrganizationName 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 + * Workspace. * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   for (MonitoredResourceDescriptor element : metricServiceClient.listMonitoredResourceDescriptors(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
+ * @param name Required. 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 + * Workspace. * * @param name Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -229,25 +233,11 @@ public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResource return listMonitoredResourceDescriptors(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists monitored resource descriptors that match a filter. This method does not require a * Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName 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 */ @@ -256,26 +246,12 @@ public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResource return listMonitoredResourceDescriptorsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists monitored resource descriptors that match a filter. This method does not require a * Workspace. * *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName 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> @@ -283,33 +259,12 @@ public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResource return stub.listMonitoredResourceDescriptorsPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists monitored resource descriptors that match a filter. This method does not require a * Workspace. * *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName 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> @@ -317,19 +272,10 @@ public final ListMonitoredResourceDescriptorsPagedResponse listMonitoredResource return stub.listMonitoredResourceDescriptorsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single monitored resource descriptor. This method does not require a Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.ofProjectMonitoredResourceDescriptorName("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
-   *   MonitoredResourceDescriptor response = metricServiceClient.getMonitoredResourceDescriptor(name);
-   * }
-   * 
- * * @param name Required. 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`. @@ -344,19 +290,10 @@ public final MonitoredResourceDescriptor getMonitoredResourceDescriptor( return getMonitoredResourceDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single monitored resource descriptor. This method does not require a Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.ofProjectMonitoredResourceDescriptorName("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
-   *   MonitoredResourceDescriptor response = metricServiceClient.getMonitoredResourceDescriptor(name.toString());
-   * }
-   * 
- * * @param name Required. 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`. @@ -368,22 +305,10 @@ public final MonitoredResourceDescriptor getMonitoredResourceDescriptor(String n return getMonitoredResourceDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single monitored resource descriptor. This method does not require a Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.ofProjectMonitoredResourceDescriptorName("[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 */ @@ -392,44 +317,21 @@ public final MonitoredResourceDescriptor getMonitoredResourceDescriptor( return getMonitoredResourceDescriptorCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single monitored resource descriptor. This method does not require a Workspace. * *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.ofProjectMonitoredResourceDescriptorName("[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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists metric descriptors that match a filter. This method does not require a Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   for (MetricDescriptor element : metricServiceClient.listMetricDescriptors(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param name Required. 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 @@ -442,20 +344,41 @@ public final ListMetricDescriptorsPagedResponse listMetricDescriptors(ResourceNa return listMetricDescriptors(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists metric descriptors that match a filter. This method does not require a Workspace. * - *

Sample code: + * @param name Required. 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(OrganizationName 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 Workspace. * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   for (MetricDescriptor element : metricServiceClient.listMetricDescriptors(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
+ * @param name Required. 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 Workspace. * * @param name Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -467,24 +390,10 @@ public final ListMetricDescriptorsPagedResponse listMetricDescriptors(String nam return listMetricDescriptors(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists metric descriptors that match a filter. This method does not require a Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName 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 */ @@ -493,76 +402,32 @@ public final ListMetricDescriptorsPagedResponse listMetricDescriptors( return listMetricDescriptorsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists metric descriptors that match a filter. This method does not require a Workspace. * *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists metric descriptors that match a filter. This method does not require a Workspace. * *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single metric descriptor. This method does not require a Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   MetricDescriptor response = metricServiceClient.getMetricDescriptor(name);
-   * }
-   * 
- * * @param name Required. 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 @@ -577,19 +442,10 @@ public final MetricDescriptor getMetricDescriptor(MetricDescriptorName name) { return getMetricDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single metric descriptor. This method does not require a Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   MetricDescriptor response = metricServiceClient.getMetricDescriptor(name.toString());
-   * }
-   * 
- * * @param name Required. 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 @@ -602,22 +458,10 @@ public final MetricDescriptor getMetricDescriptor(String name) { return getMetricDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single metric descriptor. This method does not require a Workspace. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[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 */ @@ -625,44 +469,22 @@ public final MetricDescriptor getMetricDescriptor(GetMetricDescriptorRequest req return getMetricDescriptorCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single metric descriptor. This method does not require a Workspace. * *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new metric descriptor. User-created metric descriptors define [custom * metrics](https://cloud.google.com/monitoring/custom-metrics). * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
-   *   MetricDescriptor response = metricServiceClient.createMetricDescriptor(name, metricDescriptor);
-   * }
-   * 
- * * @param name Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] * @param metricDescriptor Required. The new [custom @@ -679,20 +501,52 @@ public final MetricDescriptor createMetricDescriptor( return createMetricDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new metric descriptor. User-created metric descriptors define [custom * metrics](https://cloud.google.com/monitoring/custom-metrics). * - *

Sample code: + * @param name Required. The project on which to execute the request. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @param metricDescriptor Required. The new [custom + * metric](https://cloud.google.com/monitoring/custom-metrics) descriptor. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MetricDescriptor createMetricDescriptor( + OrganizationName 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](https://cloud.google.com/monitoring/custom-metrics). * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
-   *   MetricDescriptor response = metricServiceClient.createMetricDescriptor(name.toString(), metricDescriptor);
-   * }
-   * 
+ * @param name Required. The project on which to execute the request. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @param metricDescriptor Required. The new [custom + * metric](https://cloud.google.com/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](https://cloud.google.com/monitoring/custom-metrics). * * @param name Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -710,25 +564,11 @@ public final MetricDescriptor createMetricDescriptor( return createMetricDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new metric descriptor. User-created metric descriptors define [custom * metrics](https://cloud.google.com/monitoring/custom-metrics). * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName 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 */ @@ -736,46 +576,23 @@ public final MetricDescriptor createMetricDescriptor(CreateMetricDescriptorReque return createMetricDescriptorCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new metric descriptor. User-created metric descriptors define [custom * metrics](https://cloud.google.com/monitoring/custom-metrics). * *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   ResourceName 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a metric descriptor. Only user-created [custom * metrics](https://cloud.google.com/monitoring/custom-metrics) can be deleted. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   metricServiceClient.deleteMetricDescriptor(name);
-   * }
-   * 
- * * @param name Required. 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"`. @@ -789,20 +606,11 @@ public final void deleteMetricDescriptor(MetricDescriptorName name) { deleteMetricDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a metric descriptor. Only user-created [custom * metrics](https://cloud.google.com/monitoring/custom-metrics) can be deleted. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]");
-   *   metricServiceClient.deleteMetricDescriptor(name.toString());
-   * }
-   * 
- * * @param name Required. 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"`. @@ -814,23 +622,11 @@ public final void deleteMetricDescriptor(String name) { deleteMetricDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a metric descriptor. Only user-created [custom * metrics](https://cloud.google.com/monitoring/custom-metrics) can be deleted. * - *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[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 */ @@ -838,48 +634,22 @@ public final void deleteMetricDescriptor(DeleteMetricDescriptorRequest request) deleteMetricDescriptorCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a metric descriptor. Only user-created [custom * metrics](https://cloud.google.com/monitoring/custom-metrics) can be deleted. * *

Sample code: - * - *


-   * try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
-   *   MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists time series that match a filter. This method does not require a Workspace. * - *

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 Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] * @param filter Required. A [monitoring @@ -908,24 +678,10 @@ public final ListTimeSeriesPagedResponse listTimeSeries( return listTimeSeries(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists time series that match a filter. This method does not require a Workspace. * - *

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 Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] * @param filter Required. A [monitoring @@ -954,30 +710,10 @@ public final ListTimeSeriesPagedResponse listTimeSeries( return listTimeSeries(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists time series that match a filter. This method does not require a Workspace. * - *

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 */ @@ -985,91 +721,34 @@ public final ListTimeSeriesPagedResponse listTimeSeries(ListTimeSeriesRequest re return listTimeSeriesPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists time series that match a filter. This method does not require a Workspace. * *

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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists time series that match a filter. This method does not require a Workspace. * *

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 + // 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 Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] * @param timeSeries Required. The new data to be added to a list of time series. Adds at most one @@ -1088,22 +767,12 @@ public final void createTimeSeries(ProjectName name, List timeSeries createTimeSeries(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] * @param timeSeries Required. The new data to be added to a list of time series. Adds at most one @@ -1119,26 +788,12 @@ public final void createTimeSeries(String name, List timeSeries) { createTimeSeries(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 */ @@ -1146,27 +801,13 @@ public final void createTimeSeries(CreateTimeSeriesRequest request) { createTimeSeriesCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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(); diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java index 5aa843a9..703afe38 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -49,7 +50,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link MetricServiceClient}. * @@ -66,22 +67,23 @@ * *

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

- * 
- * MetricServiceSettings.Builder metricServiceSettingsBuilder =
- *     MetricServiceSettings.newBuilder();
+ * 
{@code
+ * MetricServiceSettings.Builder metricServiceSettingsBuilder = MetricServiceSettings.newBuilder();
  * metricServiceSettingsBuilder
  *     .getMonitoredResourceDescriptorSettings()
  *     .setRetrySettings(
- *         metricServiceSettingsBuilder.getMonitoredResourceDescriptorSettings().getRetrySettings().toBuilder()
+ *         metricServiceSettingsBuilder
+ *             .getMonitoredResourceDescriptorSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * MetricServiceSettings metricServiceSettings = metricServiceSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class MetricServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listMonitoredResourceDescriptors. */ public PagedCallSettings< ListMonitoredResourceDescriptorsRequest, @@ -196,18 +198,15 @@ protected MetricServiceSettings(Builder settingsBuilder) throws IOException { /** Builder for MetricServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + 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()); } @@ -216,11 +215,15 @@ protected Builder(MetricServiceStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(MetricServiceStubSettings.newBuilder()); + } + public MetricServiceStubSettings.Builder getStubSettingsBuilder() { return ((MetricServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java index cfe07d27..d56ce3bc 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -43,6 +44,8 @@ import com.google.monitoring.v3.NotificationChannelDescriptor; import com.google.monitoring.v3.NotificationChannelDescriptorName; import com.google.monitoring.v3.NotificationChannelName; +import com.google.monitoring.v3.OrganizationName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.monitoring.v3.VerifyNotificationChannelRequest; @@ -53,7 +56,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: The Notification Channel API provides access to configuration that controls * how messages related to incidents are sent. @@ -61,16 +64,7 @@ *

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.ofProjectChannelDescriptorName("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
- *   NotificationChannelDescriptor response = notificationChannelServiceClient.getNotificationChannelDescriptor(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the notificationChannelServiceClient object to clean up + *

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(). * @@ -99,28 +93,27 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * NotificationChannelServiceSettings notificationChannelServiceSettings =
  *     NotificationChannelServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * NotificationChannelServiceClient notificationChannelServiceClient =
  *     NotificationChannelServiceClient.create(notificationChannelServiceSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * NotificationChannelServiceSettings notificationChannelServiceSettings =
  *     NotificationChannelServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
  * NotificationChannelServiceClient notificationChannelServiceClient =
  *     NotificationChannelServiceClient.create(notificationChannelServiceSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ +@BetaApi @Generated("by gapic-generator") public class NotificationChannelServiceClient implements BackgroundResource { private final NotificationChannelServiceSettings settings; @@ -143,7 +136,7 @@ public static final NotificationChannelServiceClient create( /** * Constructs an instance of NotificationChannelServiceClient, using the given stub for making - * calls. This is for advanced usage - prefer to use NotificationChannelServiceSettings}. + * calls. This is for advanced usage - prefer using create(NotificationChannelServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final NotificationChannelServiceClient create(NotificationChannelServiceStub stub) { @@ -176,22 +169,11 @@ public NotificationChannelServiceStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   for (NotificationChannelDescriptor element : notificationChannelServiceClient.listNotificationChannelDescriptors(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param name Required. The REST resource name of the parent from which to retrieve the * notification channel descriptors. The expected syntax is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -210,21 +192,56 @@ public final ListNotificationChannelDescriptorsPagedResponse listNotificationCha return listNotificationChannelDescriptors(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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: + * @param name Required. The REST resource name of the parent from which to retrieve the + * notification channel descriptors. The expected syntax is: + *

projects/[PROJECT_ID_OR_NUMBER] + *

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( + OrganizationName 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. * - *


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

projects/[PROJECT_ID_OR_NUMBER] + *

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. * * @param name Required. The REST resource name of the parent from which to retrieve the * notification channel descriptors. The expected syntax is: @@ -242,25 +259,11 @@ public final ListNotificationChannelDescriptorsPagedResponse listNotificationCha return listNotificationChannelDescriptors(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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()) {
-   *   ResourceName 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 */ @@ -269,26 +272,12 @@ public final ListNotificationChannelDescriptorsPagedResponse listNotificationCha return listNotificationChannelDescriptorsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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()) {
-   *   ResourceName 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, @@ -297,33 +286,12 @@ public final ListNotificationChannelDescriptorsPagedResponse listNotificationCha return stub.listNotificationChannelDescriptorsPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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()) {
-   *   ResourceName 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> @@ -331,20 +299,11 @@ public final ListNotificationChannelDescriptorsPagedResponse listNotificationCha return stub.listNotificationChannelDescriptorsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectChannelDescriptorName("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
-   *   NotificationChannelDescriptor response = notificationChannelServiceClient.getNotificationChannelDescriptor(name);
-   * }
-   * 
- * * @param name Required. The channel type for which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/notificationChannelDescriptors/[CHANNEL_TYPE] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -358,20 +317,11 @@ public final NotificationChannelDescriptor getNotificationChannelDescriptor( return getNotificationChannelDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectChannelDescriptorName("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
-   *   NotificationChannelDescriptor response = notificationChannelServiceClient.getNotificationChannelDescriptor(name.toString());
-   * }
-   * 
- * * @param name Required. The channel type for which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/notificationChannelDescriptors/[CHANNEL_TYPE] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -382,23 +332,11 @@ public final NotificationChannelDescriptor getNotificationChannelDescriptor(Stri return getNotificationChannelDescriptor(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectChannelDescriptorName("[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 */ @@ -407,45 +345,22 @@ public final NotificationChannelDescriptor getNotificationChannelDescriptor( return getNotificationChannelDescriptorCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectChannelDescriptorName("[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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the notification channels that have been created for the project. * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   for (NotificationChannel element : notificationChannelServiceClient.listNotificationChannels(name).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param name Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] *

This names the container in which to look for the notification channels; it does not @@ -462,20 +377,50 @@ public final ListNotificationChannelsPagedResponse listNotificationChannels(Reso return listNotificationChannels(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the notification channels that have been created for the project. * - *

Sample code: + * @param name Required. The project on which to execute the request. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + *

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( + OrganizationName 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. * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   for (NotificationChannel element : notificationChannelServiceClient.listNotificationChannels(name.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
+ * @param name Required. The project on which to execute the request. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + *

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. * * @param name Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -491,24 +436,10 @@ public final ListNotificationChannelsPagedResponse listNotificationChannels(Stri return listNotificationChannels(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the notification channels that have been created for the project. * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ResourceName 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 */ @@ -517,79 +448,35 @@ public final ListNotificationChannelsPagedResponse listNotificationChannels( return listNotificationChannelsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the notification channels that have been created for the project. * *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ResourceName 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the notification channels that have been created for the project. * *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   ResourceName 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 + // 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.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   NotificationChannel response = notificationChannelServiceClient.getNotificationChannel(name);
-   * }
-   * 
- * * @param name Required. The channel for which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -602,22 +489,13 @@ public final NotificationChannel getNotificationChannel(NotificationChannelName return getNotificationChannel(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   NotificationChannel response = notificationChannelServiceClient.getNotificationChannel(name.toString());
-   * }
-   * 
- * * @param name Required. The channel for which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -628,25 +506,13 @@ public final NotificationChannel getNotificationChannel(String name) { return getNotificationChannel(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectNotificationChannelName("[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 */ @@ -654,7 +520,7 @@ public final NotificationChannel getNotificationChannel(GetNotificationChannelRe return getNotificationChannelCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 @@ -662,39 +528,17 @@ public final NotificationChannel getNotificationChannel(GetNotificationChannelRe * information that was supplied in the call to the create method. * *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName("[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 + // 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()) {
-   *   ResourceName name = ProjectName.of("[PROJECT]");
-   *   NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
-   *   NotificationChannel response = notificationChannelServiceClient.createNotificationChannel(name, notificationChannel);
-   * }
-   * 
- * * @param name Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] *

This names the container into which the channel will be written, this does not name the @@ -714,20 +558,58 @@ public final NotificationChannel createNotificationChannel( return createNotificationChannel(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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: + * @param name Required. The project on which to execute the request. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + *

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 Required. The definition of the `NotificationChannel` to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final NotificationChannel createNotificationChannel( + OrganizationName 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. * - *


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

projects/[PROJECT_ID_OR_NUMBER] + *

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 Required. 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. * * @param name Required. The project on which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -748,25 +630,11 @@ public final NotificationChannel createNotificationChannel( return createNotificationChannel(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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()) {
-   *   ResourceName 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 */ @@ -775,46 +643,22 @@ public final NotificationChannel createNotificationChannel( return createNotificationChannelCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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()) {
-   *   ResourceName 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 + // 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 Required. A description of the changes to be applied to the * specified notification channel. The description must provide a definition for fields to be @@ -831,22 +675,10 @@ public final NotificationChannel updateNotificationChannel( return updateNotificationChannel(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 */ @@ -855,43 +687,21 @@ public final NotificationChannel updateNotificationChannel( return updateNotificationChannelCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a notification channel. * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   boolean force = false;
-   *   notificationChannelServiceClient.deleteNotificationChannel(name, force);
-   * }
-   * 
- * * @param name Required. The channel for which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] * @param force If true, the notification channel will be deleted regardless of its use in alert @@ -909,20 +719,10 @@ public final void deleteNotificationChannel(NotificationChannelName name, boolea deleteNotificationChannel(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a notification channel. * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   boolean force = false;
-   *   notificationChannelServiceClient.deleteNotificationChannel(name.toString(), force);
-   * }
-   * 
- * * @param name Required. The channel for which to execute the request. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/notificationChannels/[CHANNEL_ID] * @param force If true, the notification channel will be deleted regardless of its use in alert @@ -937,22 +737,10 @@ public final void deleteNotificationChannel(String name, boolean force) { deleteNotificationChannel(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a notification channel. * - *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName("[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 */ @@ -960,43 +748,22 @@ public final void deleteNotificationChannel(DeleteNotificationChannelRequest req deleteNotificationChannelCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a notification channel. * *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName("[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 + // 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.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   notificationChannelServiceClient.sendNotificationChannelVerificationCode(name);
-   * }
-   * 
- * * @param name Required. The notification channel to which to send a verification code. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1008,20 +775,11 @@ public final void sendNotificationChannelVerificationCode(NotificationChannelNam sendNotificationChannelVerificationCode(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   notificationChannelServiceClient.sendNotificationChannelVerificationCode(name.toString());
-   * }
-   * 
- * * @param name Required. The notification channel to which to send a verification code. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1031,23 +789,11 @@ public final void sendNotificationChannelVerificationCode(String name) { sendNotificationChannelVerificationCode(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectNotificationChannelName("[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 */ @@ -1056,31 +802,19 @@ public final void sendNotificationChannelVerificationCode( sendNotificationChannelVerificationCodeCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectNotificationChannelName("[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 + // 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 @@ -1099,15 +833,6 @@ public final void sendNotificationChannelVerificationCode( * 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.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   GetNotificationChannelVerificationCodeResponse response = notificationChannelServiceClient.getNotificationChannelVerificationCode(name);
-   * }
-   * 
- * * @param name Required. 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. @@ -1122,7 +847,7 @@ public final void sendNotificationChannelVerificationCode( return getNotificationChannelVerificationCode(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 @@ -1141,15 +866,6 @@ public final void sendNotificationChannelVerificationCode( * 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.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   GetNotificationChannelVerificationCodeResponse response = notificationChannelServiceClient.getNotificationChannelVerificationCode(name.toString());
-   * }
-   * 
- * * @param name Required. 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. @@ -1162,7 +878,7 @@ public final void sendNotificationChannelVerificationCode( return getNotificationChannelVerificationCode(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 @@ -1181,18 +897,6 @@ public final void sendNotificationChannelVerificationCode( * 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.ofProjectNotificationChannelName("[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 */ @@ -1202,7 +906,7 @@ public final void sendNotificationChannelVerificationCode( return getNotificationChannelVerificationCodeCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 @@ -1222,18 +926,6 @@ public final void sendNotificationChannelVerificationCode( * a much longer, websafe base 64 encoded string that has a longer expiration time. * *

Sample code: - * - *


-   * try (NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.create()) {
-   *   NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName("[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, @@ -1242,21 +934,11 @@ public final void sendNotificationChannelVerificationCode( return stub.getNotificationChannelVerificationCodeCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   String code = "";
-   *   NotificationChannel response = notificationChannelServiceClient.verifyNotificationChannel(name, code);
-   * }
-   * 
- * * @param name Required. The notification channel to verify. * @param code Required. The verification code that was delivered to the channel as a result of * invoking the `SendNotificationChannelVerificationCode` API method or that was retrieved @@ -1276,21 +958,11 @@ public final NotificationChannel verifyNotificationChannel( return verifyNotificationChannel(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]");
-   *   String code = "";
-   *   NotificationChannel response = notificationChannelServiceClient.verifyNotificationChannel(name.toString(), code);
-   * }
-   * 
- * * @param name Required. The notification channel to verify. * @param code Required. The verification code that was delivered to the channel as a result of * invoking the `SendNotificationChannelVerificationCode` API method or that was retrieved @@ -1306,25 +978,11 @@ public final NotificationChannel verifyNotificationChannel(String name, String c return verifyNotificationChannel(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectNotificationChannelName("[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 */ @@ -1333,26 +991,12 @@ public final NotificationChannel verifyNotificationChannel( return verifyNotificationChannelCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectNotificationChannelName("[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() { diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java index 27781e95..2d613491 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -50,7 +51,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link NotificationChannelServiceClient}. * @@ -67,23 +68,26 @@ * *

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

- * 
+ * 
{@code
  * NotificationChannelServiceSettings.Builder notificationChannelServiceSettingsBuilder =
  *     NotificationChannelServiceSettings.newBuilder();
  * notificationChannelServiceSettingsBuilder
  *     .getNotificationChannelDescriptorSettings()
  *     .setRetrySettings(
- *         notificationChannelServiceSettingsBuilder.getNotificationChannelDescriptorSettings().getRetrySettings().toBuilder()
+ *         notificationChannelServiceSettingsBuilder
+ *             .getNotificationChannelDescriptorSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * NotificationChannelServiceSettings notificationChannelServiceSettings = notificationChannelServiceSettingsBuilder.build();
- * 
- * 
+ * NotificationChannelServiceSettings notificationChannelServiceSettings = + * notificationChannelServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class NotificationChannelServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listNotificationChannelDescriptors. */ public PagedCallSettings< ListNotificationChannelDescriptorsRequest, @@ -227,18 +231,15 @@ protected NotificationChannelServiceSettings(Builder settingsBuilder) throws IOE /** Builder for NotificationChannelServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + 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()); } @@ -247,11 +248,15 @@ protected Builder(NotificationChannelServiceStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(NotificationChannelServiceStubSettings.newBuilder()); + } + public NotificationChannelServiceStubSettings.Builder getStubSettingsBuilder() { return ((NotificationChannelServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceClient.java index 7819ccf1..60280759 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -39,6 +40,8 @@ import com.google.monitoring.v3.ListServiceLevelObjectivesResponse; import com.google.monitoring.v3.ListServicesRequest; import com.google.monitoring.v3.ListServicesResponse; +import com.google.monitoring.v3.OrganizationName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.Service; import com.google.monitoring.v3.ServiceLevelObjective; import com.google.monitoring.v3.ServiceLevelObjectiveName; @@ -51,7 +54,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: The Cloud Monitoring Service-Oriented Monitoring API has endpoints for * managing and querying aspects of a workspace's services. These include the `Service`'s monitored @@ -60,17 +63,7 @@ *

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 (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
- *   ResourceName parent = ProjectName.of("[PROJECT]");
- *   Service service = Service.newBuilder().build();
- *   Service response = serviceMonitoringServiceClient.createService(parent, service);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the serviceMonitoringServiceClient object to clean up + *

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

To customize credentials: * - *

- * 
+ * 
{@code
  * ServiceMonitoringServiceSettings serviceMonitoringServiceSettings =
  *     ServiceMonitoringServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * ServiceMonitoringServiceClient serviceMonitoringServiceClient =
  *     ServiceMonitoringServiceClient.create(serviceMonitoringServiceSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * ServiceMonitoringServiceSettings serviceMonitoringServiceSettings =
  *     ServiceMonitoringServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
  * ServiceMonitoringServiceClient serviceMonitoringServiceClient =
  *     ServiceMonitoringServiceClient.create(serviceMonitoringServiceSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ +@BetaApi @Generated("by gapic-generator") public class ServiceMonitoringServiceClient implements BackgroundResource { private final ServiceMonitoringServiceSettings settings; @@ -143,7 +135,7 @@ public static final ServiceMonitoringServiceClient create( /** * Constructs an instance of ServiceMonitoringServiceClient, using the given stub for making - * calls. This is for advanced usage - prefer to use ServiceMonitoringServiceSettings}. + * calls. This is for advanced usage - prefer using create(ServiceMonitoringServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ServiceMonitoringServiceClient create(ServiceMonitoringServiceStub stub) { @@ -176,20 +168,10 @@ public ServiceMonitoringServiceStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create a `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   Service service = Service.newBuilder().build();
-   *   Service response = serviceMonitoringServiceClient.createService(parent, service);
-   * }
-   * 
- * * @param parent Required. Resource name of the parent workspace. The format is: *

projects/[PROJECT_ID_OR_NUMBER] * @param service Required. The `Service` to create. @@ -204,19 +186,45 @@ public final Service createService(ResourceName parent, Service service) { return createService(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create a `Service`. * - *

Sample code: + * @param parent Required. Resource name of the parent workspace. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @param service Required. The `Service` to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Service createService(OrganizationName parent, Service service) { + CreateServiceRequest request = + CreateServiceRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setService(service) + .build(); + return createService(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a `Service`. * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   Service service = Service.newBuilder().build();
-   *   Service response = serviceMonitoringServiceClient.createService(parent.toString(), service);
-   * }
-   * 
+ * @param parent Required. Resource name of the parent workspace. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @param service Required. The `Service` to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Service createService(ProjectName parent, Service service) { + CreateServiceRequest request = + CreateServiceRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setService(service) + .build(); + return createService(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a `Service`. * * @param parent Required. Resource name of the parent workspace. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -229,24 +237,10 @@ public final Service createService(String parent, Service service) { return createService(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create a `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   Service service = Service.newBuilder().build();
-   *   CreateServiceRequest request = CreateServiceRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setService(service)
-   *     .build();
-   *   Service response = serviceMonitoringServiceClient.createService(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 */ @@ -254,43 +248,20 @@ public final Service createService(CreateServiceRequest request) { return createServiceCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create a `Service`. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   Service service = Service.newBuilder().build();
-   *   CreateServiceRequest request = CreateServiceRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setService(service)
-   *     .build();
-   *   ApiFuture<Service> future = serviceMonitoringServiceClient.createServiceCallable().futureCall(request);
-   *   // Do something
-   *   Service response = future.get();
-   * }
-   * 
*/ public final UnaryCallable createServiceCallable() { return stub.createServiceCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Get the named `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   Service response = serviceMonitoringServiceClient.getService(name);
-   * }
-   * 
- * * @param name Required. Resource name of the `Service`. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -301,19 +272,10 @@ public final Service getService(ServiceName name) { return getService(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Get the named `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   Service response = serviceMonitoringServiceClient.getService(name.toString());
-   * }
-   * 
- * * @param name Required. Resource name of the `Service`. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -323,22 +285,10 @@ public final Service getService(String name) { return getService(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Get the named `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   GetServiceRequest request = GetServiceRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   Service response = serviceMonitoringServiceClient.getService(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 */ @@ -346,43 +296,20 @@ public final Service getService(GetServiceRequest request) { return getServiceCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Get the named `Service`. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   GetServiceRequest request = GetServiceRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Service> future = serviceMonitoringServiceClient.getServiceCallable().futureCall(request);
-   *   // Do something
-   *   Service response = future.get();
-   * }
-   * 
*/ public final UnaryCallable getServiceCallable() { return stub.getServiceCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List `Service`s for this workspace. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   for (Service element : serviceMonitoringServiceClient.listServices(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param parent Required. Resource name of the parent containing the listed services, either a * project or a Monitoring Workspace. The formats are: *

projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER] @@ -396,20 +323,43 @@ public final ListServicesPagedResponse listServices(ResourceName parent) { return listServices(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List `Service`s for this workspace. * - *

Sample code: + * @param parent Required. Resource name of the parent containing the listed services, either a + * project or a Monitoring Workspace. The formats are: + *

projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER] + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListServicesPagedResponse listServices(OrganizationName parent) { + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listServices(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List `Service`s for this workspace. * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   for (Service element : serviceMonitoringServiceClient.listServices(parent.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
+ * @param parent Required. Resource name of the parent containing the listed services, either a + * project or a Monitoring Workspace. The formats are: + *

projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER] + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListServicesPagedResponse listServices(ProjectName parent) { + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listServices(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List `Service`s for this workspace. * * @param parent Required. Resource name of the parent containing the listed services, either a * project or a Monitoring Workspace. The formats are: @@ -421,24 +371,10 @@ public final ListServicesPagedResponse listServices(String parent) { return listServices(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List `Service`s for this workspace. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   ListServicesRequest request = ListServicesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   for (Service element : serviceMonitoringServiceClient.listServices(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 */ @@ -446,75 +382,31 @@ public final ListServicesPagedResponse listServices(ListServicesRequest request) return listServicesPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List `Service`s for this workspace. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   ListServicesRequest request = ListServicesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListServicesPagedResponse> future = serviceMonitoringServiceClient.listServicesPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (Service element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listServicesPagedCallable() { return stub.listServicesPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List `Service`s for this workspace. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   ListServicesRequest request = ListServicesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   while (true) {
-   *     ListServicesResponse response = serviceMonitoringServiceClient.listServicesCallable().call(request);
-   *     for (Service element : response.getServicesList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listServicesCallable() { return stub.listServicesCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Update this `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   Service service = Service.newBuilder().build();
-   *   Service response = serviceMonitoringServiceClient.updateService(service);
-   * }
-   * 
- * * @param service Required. The `Service` to draw updates from. The given `name` specifies the * resource to update. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -524,22 +416,10 @@ public final Service updateService(Service service) { return updateService(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Update this `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   Service service = Service.newBuilder().build();
-   *   UpdateServiceRequest request = UpdateServiceRequest.newBuilder()
-   *     .setService(service)
-   *     .build();
-   *   Service response = serviceMonitoringServiceClient.updateService(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 */ @@ -547,41 +427,20 @@ public final Service updateService(UpdateServiceRequest request) { return updateServiceCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Update this `Service`. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   Service service = Service.newBuilder().build();
-   *   UpdateServiceRequest request = UpdateServiceRequest.newBuilder()
-   *     .setService(service)
-   *     .build();
-   *   ApiFuture<Service> future = serviceMonitoringServiceClient.updateServiceCallable().futureCall(request);
-   *   // Do something
-   *   Service response = future.get();
-   * }
-   * 
*/ public final UnaryCallable updateServiceCallable() { return stub.updateServiceCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Soft delete this `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   serviceMonitoringServiceClient.deleteService(name);
-   * }
-   * 
- * * @param name Required. Resource name of the `Service` to delete. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -592,19 +451,10 @@ public final void deleteService(ServiceName name) { deleteService(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Soft delete this `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   serviceMonitoringServiceClient.deleteService(name.toString());
-   * }
-   * 
- * * @param name Required. Resource name of the `Service` to delete. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -614,22 +464,10 @@ public final void deleteService(String name) { deleteService(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Soft delete this `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   DeleteServiceRequest request = DeleteServiceRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   serviceMonitoringServiceClient.deleteService(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 */ @@ -637,42 +475,20 @@ public final void deleteService(DeleteServiceRequest request) { deleteServiceCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Soft delete this `Service`. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   DeleteServiceRequest request = DeleteServiceRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = serviceMonitoringServiceClient.deleteServiceCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
*/ public final UnaryCallable deleteServiceCallable() { return stub.deleteServiceCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create a `ServiceLevelObjective` for the given `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
-   *   ServiceLevelObjective response = serviceMonitoringServiceClient.createServiceLevelObjective(parent, serviceLevelObjective);
-   * }
-   * 
- * * @param parent Required. Resource name of the parent `Service`. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] * @param serviceLevelObjective Required. The `ServiceLevelObjective` to create. The provided @@ -689,20 +505,10 @@ public final ServiceLevelObjective createServiceLevelObjective( return createServiceLevelObjective(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create a `ServiceLevelObjective` for the given `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
-   *   ServiceLevelObjective response = serviceMonitoringServiceClient.createServiceLevelObjective(parent.toString(), serviceLevelObjective);
-   * }
-   * 
- * * @param parent Required. Resource name of the parent `Service`. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] * @param serviceLevelObjective Required. The `ServiceLevelObjective` to create. The provided @@ -719,24 +525,10 @@ public final ServiceLevelObjective createServiceLevelObjective( return createServiceLevelObjective(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create a `ServiceLevelObjective` for the given `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
-   *   CreateServiceLevelObjectiveRequest request = CreateServiceLevelObjectiveRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setServiceLevelObjective(serviceLevelObjective)
-   *     .build();
-   *   ServiceLevelObjective response = serviceMonitoringServiceClient.createServiceLevelObjective(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 */ @@ -745,44 +537,21 @@ public final ServiceLevelObjective createServiceLevelObjective( return createServiceLevelObjectiveCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create a `ServiceLevelObjective` for the given `Service`. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
-   *   CreateServiceLevelObjectiveRequest request = CreateServiceLevelObjectiveRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .setServiceLevelObjective(serviceLevelObjective)
-   *     .build();
-   *   ApiFuture<ServiceLevelObjective> future = serviceMonitoringServiceClient.createServiceLevelObjectiveCallable().futureCall(request);
-   *   // Do something
-   *   ServiceLevelObjective response = future.get();
-   * }
-   * 
*/ public final UnaryCallable createServiceLevelObjectiveCallable() { return stub.createServiceLevelObjectiveCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Get a `ServiceLevelObjective` by name. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
-   *   ServiceLevelObjective response = serviceMonitoringServiceClient.getServiceLevelObjective(name);
-   * }
-   * 
- * * @param name Required. Resource name of the `ServiceLevelObjective` to get. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -795,19 +564,10 @@ public final ServiceLevelObjective getServiceLevelObjective(ServiceLevelObjectiv return getServiceLevelObjective(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Get a `ServiceLevelObjective` by name. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
-   *   ServiceLevelObjective response = serviceMonitoringServiceClient.getServiceLevelObjective(name.toString());
-   * }
-   * 
- * * @param name Required. Resource name of the `ServiceLevelObjective` to get. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -818,22 +578,10 @@ public final ServiceLevelObjective getServiceLevelObjective(String name) { return getServiceLevelObjective(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Get a `ServiceLevelObjective` by name. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
-   *   GetServiceLevelObjectiveRequest request = GetServiceLevelObjectiveRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ServiceLevelObjective response = serviceMonitoringServiceClient.getServiceLevelObjective(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 */ @@ -842,44 +590,21 @@ public final ServiceLevelObjective getServiceLevelObjective( return getServiceLevelObjectiveCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Get a `ServiceLevelObjective` by name. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
-   *   GetServiceLevelObjectiveRequest request = GetServiceLevelObjectiveRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<ServiceLevelObjective> future = serviceMonitoringServiceClient.getServiceLevelObjectiveCallable().futureCall(request);
-   *   // Do something
-   *   ServiceLevelObjective response = future.get();
-   * }
-   * 
*/ public final UnaryCallable getServiceLevelObjectiveCallable() { return stub.getServiceLevelObjectiveCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List the `ServiceLevelObjective`s for the given `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   for (ServiceLevelObjective element : serviceMonitoringServiceClient.listServiceLevelObjectives(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param parent Required. Resource name of the parent containing the listed SLOs, either a * project or a Monitoring Workspace. The formats are: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] @@ -895,21 +620,10 @@ public final ListServiceLevelObjectivesPagedResponse listServiceLevelObjectives( return listServiceLevelObjectives(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List the `ServiceLevelObjective`s for the given `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   for (ServiceLevelObjective element : serviceMonitoringServiceClient.listServiceLevelObjectives(parent.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param parent Required. Resource name of the parent containing the listed SLOs, either a * project or a Monitoring Workspace. The formats are: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] @@ -922,24 +636,10 @@ public final ListServiceLevelObjectivesPagedResponse listServiceLevelObjectives( return listServiceLevelObjectives(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List the `ServiceLevelObjective`s for the given `Service`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   ListServiceLevelObjectivesRequest request = ListServiceLevelObjectivesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   for (ServiceLevelObjective element : serviceMonitoringServiceClient.listServiceLevelObjectives(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 */ @@ -948,25 +648,11 @@ public final ListServiceLevelObjectivesPagedResponse listServiceLevelObjectives( return listServiceLevelObjectivesPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List the `ServiceLevelObjective`s for the given `Service`. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   ListServiceLevelObjectivesRequest request = ListServiceLevelObjectivesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<ListServiceLevelObjectivesPagedResponse> future = serviceMonitoringServiceClient.listServiceLevelObjectivesPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (ServiceLevelObjective element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
*/ public final UnaryCallable< ListServiceLevelObjectivesRequest, ListServiceLevelObjectivesPagedResponse> @@ -974,51 +660,21 @@ public final ListServiceLevelObjectivesPagedResponse listServiceLevelObjectives( return stub.listServiceLevelObjectivesPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * List the `ServiceLevelObjective`s for the given `Service`. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
-   *   ListServiceLevelObjectivesRequest request = ListServiceLevelObjectivesRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   while (true) {
-   *     ListServiceLevelObjectivesResponse response = serviceMonitoringServiceClient.listServiceLevelObjectivesCallable().call(request);
-   *     for (ServiceLevelObjective element : response.getServiceLevelObjectivesList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listServiceLevelObjectivesCallable() { return stub.listServiceLevelObjectivesCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Update the given `ServiceLevelObjective`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
-   *   ServiceLevelObjective response = serviceMonitoringServiceClient.updateServiceLevelObjective(serviceLevelObjective);
-   * }
-   * 
- * * @param serviceLevelObjective Required. The `ServiceLevelObjective` to draw updates from. The * given `name` specifies the resource to update. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1032,22 +688,10 @@ public final ServiceLevelObjective updateServiceLevelObjective( return updateServiceLevelObjective(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Update the given `ServiceLevelObjective`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
-   *   UpdateServiceLevelObjectiveRequest request = UpdateServiceLevelObjectiveRequest.newBuilder()
-   *     .setServiceLevelObjective(serviceLevelObjective)
-   *     .build();
-   *   ServiceLevelObjective response = serviceMonitoringServiceClient.updateServiceLevelObjective(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 */ @@ -1056,42 +700,21 @@ public final ServiceLevelObjective updateServiceLevelObjective( return updateServiceLevelObjectiveCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Update the given `ServiceLevelObjective`. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build();
-   *   UpdateServiceLevelObjectiveRequest request = UpdateServiceLevelObjectiveRequest.newBuilder()
-   *     .setServiceLevelObjective(serviceLevelObjective)
-   *     .build();
-   *   ApiFuture<ServiceLevelObjective> future = serviceMonitoringServiceClient.updateServiceLevelObjectiveCallable().futureCall(request);
-   *   // Do something
-   *   ServiceLevelObjective response = future.get();
-   * }
-   * 
*/ public final UnaryCallable updateServiceLevelObjectiveCallable() { return stub.updateServiceLevelObjectiveCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Delete the given `ServiceLevelObjective`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
-   *   serviceMonitoringServiceClient.deleteServiceLevelObjective(name);
-   * }
-   * 
- * * @param name Required. Resource name of the `ServiceLevelObjective` to delete. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1104,19 +727,10 @@ public final void deleteServiceLevelObjective(ServiceLevelObjectiveName name) { deleteServiceLevelObjective(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Delete the given `ServiceLevelObjective`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
-   *   serviceMonitoringServiceClient.deleteServiceLevelObjective(name.toString());
-   * }
-   * 
- * * @param name Required. Resource name of the `ServiceLevelObjective` to delete. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -1127,22 +741,10 @@ public final void deleteServiceLevelObjective(String name) { deleteServiceLevelObjective(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Delete the given `ServiceLevelObjective`. * - *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
-   *   DeleteServiceLevelObjectiveRequest request = DeleteServiceLevelObjectiveRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   serviceMonitoringServiceClient.deleteServiceLevelObjective(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 */ @@ -1150,23 +752,11 @@ public final void deleteServiceLevelObjective(DeleteServiceLevelObjectiveRequest deleteServiceLevelObjectiveCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Delete the given `ServiceLevelObjective`. * *

Sample code: - * - *


-   * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
-   *   ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName("[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]");
-   *   DeleteServiceLevelObjectiveRequest request = DeleteServiceLevelObjectiveRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Void> future = serviceMonitoringServiceClient.deleteServiceLevelObjectiveCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
*/ public final UnaryCallable deleteServiceLevelObjectiveCallable() { diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceSettings.java index 1d7f696d..25243f74 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse; @@ -49,7 +50,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link ServiceMonitoringServiceClient}. * @@ -66,23 +67,26 @@ * *

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

- * 
+ * 
{@code
  * ServiceMonitoringServiceSettings.Builder serviceMonitoringServiceSettingsBuilder =
  *     ServiceMonitoringServiceSettings.newBuilder();
  * serviceMonitoringServiceSettingsBuilder
  *     .createServiceSettings()
  *     .setRetrySettings(
- *         serviceMonitoringServiceSettingsBuilder.createServiceSettings().getRetrySettings().toBuilder()
+ *         serviceMonitoringServiceSettingsBuilder
+ *             .createServiceSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * ServiceMonitoringServiceSettings serviceMonitoringServiceSettings = serviceMonitoringServiceSettingsBuilder.build();
- * 
- * 
+ * ServiceMonitoringServiceSettings serviceMonitoringServiceSettings = + * serviceMonitoringServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class ServiceMonitoringServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to createService. */ public UnaryCallSettings createServiceSettings() { return ((ServiceMonitoringServiceStubSettings) getStubSettings()).createServiceSettings(); @@ -208,18 +212,15 @@ protected ServiceMonitoringServiceSettings(Builder settingsBuilder) throws IOExc /** Builder for ServiceMonitoringServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(ServiceMonitoringServiceStubSettings.newBuilder(clientContext)); } - private static Builder createDefault() { - return new Builder(ServiceMonitoringServiceStubSettings.newBuilder()); - } - protected Builder(ServiceMonitoringServiceSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -228,11 +229,15 @@ protected Builder(ServiceMonitoringServiceStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(ServiceMonitoringServiceStubSettings.newBuilder()); + } + public ServiceMonitoringServiceStubSettings.Builder getStubSettingsBuilder() { return ((ServiceMonitoringServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java index f2a0fd02..6c91a03f 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -36,6 +37,8 @@ import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; import com.google.monitoring.v3.ListUptimeCheckIpsRequest; import com.google.monitoring.v3.ListUptimeCheckIpsResponse; +import com.google.monitoring.v3.OrganizationName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; import com.google.monitoring.v3.UptimeCheckConfigName; @@ -46,7 +49,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * 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 @@ -58,16 +61,7 @@ *

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.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the uptimeCheckServiceClient object to clean up resources + *

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(). * @@ -96,28 +90,27 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * UptimeCheckServiceSettings uptimeCheckServiceSettings =
  *     UptimeCheckServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * UptimeCheckServiceClient uptimeCheckServiceClient =
  *     UptimeCheckServiceClient.create(uptimeCheckServiceSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * UptimeCheckServiceSettings uptimeCheckServiceSettings =
  *     UptimeCheckServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
  * UptimeCheckServiceClient uptimeCheckServiceClient =
  *     UptimeCheckServiceClient.create(uptimeCheckServiceSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ +@BetaApi @Generated("by gapic-generator") public class UptimeCheckServiceClient implements BackgroundResource { private final UptimeCheckServiceSettings settings; @@ -139,7 +132,7 @@ public static final UptimeCheckServiceClient create(UptimeCheckServiceSettings s /** * Constructs an instance of UptimeCheckServiceClient, using the given stub for making calls. This - * is for advanced usage - prefer to use UptimeCheckServiceSettings}. + * is for advanced usage - prefer using create(UptimeCheckServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final UptimeCheckServiceClient create(UptimeCheckServiceStub stub) { @@ -171,22 +164,11 @@ public UptimeCheckServiceStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   for (UptimeCheckConfig element : uptimeCheckServiceClient.listUptimeCheckConfigs(parent).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param parent Required. The project whose Uptime check configurations are listed. The format * is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -200,21 +182,46 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(Resource return listUptimeCheckConfigs(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the existing valid Uptime check configurations for the project (leaving out any invalid * configurations). * - *

Sample code: + * @param parent Required. The project whose Uptime check configurations are listed. The format + * is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(OrganizationName parent) { + ListUptimeCheckConfigsRequest request = + ListUptimeCheckConfigsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listUptimeCheckConfigs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the existing valid Uptime check configurations for the project (leaving out any invalid + * configurations). * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   for (UptimeCheckConfig element : uptimeCheckServiceClient.listUptimeCheckConfigs(parent.toString()).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
+ * @param parent Required. The project whose Uptime check configurations are listed. The format + * is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(ProjectName parent) { + ListUptimeCheckConfigsRequest request = + ListUptimeCheckConfigsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listUptimeCheckConfigs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the existing valid Uptime check configurations for the project (leaving out any invalid + * configurations). * * @param parent Required. The project whose Uptime check configurations are listed. The format * is: @@ -227,25 +234,11 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(String p return listUptimeCheckConfigs(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .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 */ @@ -254,78 +247,34 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs( return listUptimeCheckConfigsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .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 + // 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()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single Uptime check configuration. * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
-   * }
-   * 
- * * @param name Required. The Uptime check configuration to retrieve. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -338,19 +287,10 @@ public final UptimeCheckConfig getUptimeCheckConfig(UptimeCheckConfigName name) return getUptimeCheckConfig(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single Uptime check configuration. * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name.toString());
-   * }
-   * 
- * * @param name Required. The Uptime check configuration to retrieve. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -361,22 +301,10 @@ public final UptimeCheckConfig getUptimeCheckConfig(String name) { return getUptimeCheckConfig(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single Uptime check configuration. * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[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 */ @@ -384,43 +312,21 @@ public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest return getUptimeCheckConfigCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a single Uptime check configuration. * *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[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 + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new Uptime check configuration. * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.createUptimeCheckConfig(parent, uptimeCheckConfig);
-   * }
-   * 
- * * @param parent Required. The project in which to create the Uptime check. The format is: *

projects/[PROJECT_ID_OR_NUMBER] * @param uptimeCheckConfig Required. The new Uptime check configuration. @@ -436,19 +342,47 @@ public final UptimeCheckConfig createUptimeCheckConfig( return createUptimeCheckConfig(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new Uptime check configuration. * - *

Sample code: + * @param parent Required. The project in which to create the Uptime check. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @param uptimeCheckConfig Required. The new Uptime check configuration. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UptimeCheckConfig createUptimeCheckConfig( + OrganizationName parent, UptimeCheckConfig uptimeCheckConfig) { + CreateUptimeCheckConfigRequest request = + CreateUptimeCheckConfigRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setUptimeCheckConfig(uptimeCheckConfig) + .build(); + return createUptimeCheckConfig(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Uptime check configuration. * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.createUptimeCheckConfig(parent.toString(), uptimeCheckConfig);
-   * }
-   * 
+ * @param parent Required. The project in which to create the Uptime check. The format is: + *

projects/[PROJECT_ID_OR_NUMBER] + * @param uptimeCheckConfig Required. The new Uptime check configuration. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UptimeCheckConfig createUptimeCheckConfig( + ProjectName parent, UptimeCheckConfig uptimeCheckConfig) { + CreateUptimeCheckConfigRequest request = + CreateUptimeCheckConfigRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setUptimeCheckConfig(uptimeCheckConfig) + .build(); + return createUptimeCheckConfig(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new Uptime check configuration. * * @param parent Required. The project in which to create the Uptime check. The format is: *

projects/[PROJECT_ID_OR_NUMBER] @@ -465,24 +399,10 @@ public final UptimeCheckConfig createUptimeCheckConfig( return createUptimeCheckConfig(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new Uptime check configuration. * - *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .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 */ @@ -490,46 +410,23 @@ public final UptimeCheckConfig createUptimeCheckConfig(CreateUptimeCheckConfigRe return createUptimeCheckConfigCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new Uptime check configuration. * *

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   ResourceName parent = ProjectName.of("[PROJECT]");
-   *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
-   *   CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .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 + // 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 @@ -546,24 +443,12 @@ public final UptimeCheckConfig updateUptimeCheckConfig(UptimeCheckConfig uptimeC return updateUptimeCheckConfig(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 */ @@ -571,46 +456,25 @@ public final UptimeCheckConfig updateUptimeCheckConfig(UpdateUptimeCheckConfigRe return updateUptimeCheckConfigCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 + // 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.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(name);
-   * }
-   * 
- * * @param name Required. The Uptime check configuration to delete. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -623,21 +487,12 @@ public final void deleteUptimeCheckConfig(UptimeCheckConfigName name) { deleteUptimeCheckConfig(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(name.toString());
-   * }
-   * 
- * * @param name Required. The Uptime check configuration to delete. The format is: *

projects/[PROJECT_ID_OR_NUMBER]/uptimeCheckConfigs/[UPTIME_CHECK_ID] * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -648,24 +503,12 @@ public final void deleteUptimeCheckConfig(String name) { deleteUptimeCheckConfig(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectUptimeCheckConfigName("[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 */ @@ -673,46 +516,23 @@ public final void deleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest request deleteUptimeCheckConfigCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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.ofProjectUptimeCheckConfigName("[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 + // 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 */ @@ -721,51 +541,22 @@ public final ListUptimeCheckIpsPagedResponse listUptimeCheckIps( return listUptimeCheckIpsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // 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 + // 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() { diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java index e0adbb59..173981e9 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -44,7 +45,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link UptimeCheckServiceClient}. * @@ -61,22 +62,25 @@ * *

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

- * 
+ * 
{@code
  * UptimeCheckServiceSettings.Builder uptimeCheckServiceSettingsBuilder =
  *     UptimeCheckServiceSettings.newBuilder();
  * uptimeCheckServiceSettingsBuilder
  *     .getUptimeCheckConfigSettings()
  *     .setRetrySettings(
- *         uptimeCheckServiceSettingsBuilder.getUptimeCheckConfigSettings().getRetrySettings().toBuilder()
+ *         uptimeCheckServiceSettingsBuilder
+ *             .getUptimeCheckConfigSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * UptimeCheckServiceSettings uptimeCheckServiceSettings = uptimeCheckServiceSettingsBuilder.build();
- * 
- * 
+ * UptimeCheckServiceSettings uptimeCheckServiceSettings = + * uptimeCheckServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class UptimeCheckServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listUptimeCheckConfigs. */ public PagedCallSettings< ListUptimeCheckConfigsRequest, @@ -177,18 +181,15 @@ protected UptimeCheckServiceSettings(Builder settingsBuilder) throws IOException /** Builder for UptimeCheckServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + 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()); } @@ -197,11 +198,15 @@ protected Builder(UptimeCheckServiceStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(UptimeCheckServiceStubSettings.newBuilder()); + } + public UptimeCheckServiceStubSettings.Builder getStubSettingsBuilder() { return ((UptimeCheckServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java index a7fffa1b..9faf2746 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -15,11 +15,9 @@ */ /** - * A client to Cloud Monitoring API. + * The interfaces provided are listed below, along with usage samples. * - *

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

======================== AlertPolicyServiceClient ======================== + *

======================= 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 @@ -30,16 +28,7 @@ * *

Sample for AlertPolicyServiceClient: * - *

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

======================= GroupServiceClient ======================= * *

Service Description: The Group API lets you inspect and manage your * [groups](#google.monitoring.v3.Group). @@ -53,49 +42,21 @@ * *

Sample for GroupServiceClient: * - *

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

======================= MetricServiceClient ======================= * *

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

Sample for MetricServiceClient: * - *

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

======================= 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.ofProjectChannelDescriptorName("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
- *   NotificationChannelDescriptor response = notificationChannelServiceClient.getNotificationChannelDescriptor(name);
- * }
- * 
- * 
- * - * ============================== ServiceMonitoringServiceClient ============================== + *

======================= ServiceMonitoringServiceClient ======================= * *

Service Description: The Cloud Monitoring Service-Oriented Monitoring API has endpoints for * managing and querying aspects of a workspace's services. These include the `Service`'s monitored @@ -103,17 +64,7 @@ * *

Sample for ServiceMonitoringServiceClient: * - *

- * 
- * try (ServiceMonitoringServiceClient serviceMonitoringServiceClient = ServiceMonitoringServiceClient.create()) {
- *   ResourceName parent = ProjectName.of("[PROJECT]");
- *   Service service = Service.newBuilder().build();
- *   Service response = serviceMonitoringServiceClient.createService(parent, service);
- * }
- * 
- * 
- * - * ======================== UptimeCheckServiceClient ======================== + *

======================= 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 @@ -123,17 +74,8 @@ * the left-hand side to navigate to Stackdriver, and then clicking on "Uptime". * *

Sample for UptimeCheckServiceClient: - * - *

- * 
- * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
- * }
- * 
- * 
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") package com.google.cloud.monitoring.v3; import javax.annotation.Generated; diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java index 9bdd015c..037a3d4f 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,11 +13,11 @@ * 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; @@ -30,14 +30,13 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Monitoring API. + * Base stub class for the AlertPolicyService service 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 diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java index 88b5a2b9..6d0c56c6 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/AlertPolicyServiceStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -56,7 +57,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link AlertPolicyServiceStub}. * @@ -73,21 +74,24 @@ * *

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

- * 
+ * 
{@code
  * AlertPolicyServiceStubSettings.Builder alertPolicyServiceSettingsBuilder =
  *     AlertPolicyServiceStubSettings.newBuilder();
  * alertPolicyServiceSettingsBuilder
  *     .getAlertPolicySettings()
  *     .setRetrySettings(
- *         alertPolicyServiceSettingsBuilder.getAlertPolicySettings().getRetrySettings().toBuilder()
+ *         alertPolicyServiceSettingsBuilder
+ *             .getAlertPolicySettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * AlertPolicyServiceStubSettings alertPolicyServiceSettings = alertPolicyServiceSettingsBuilder.build();
- * 
- * 
+ * AlertPolicyServiceStubSettings alertPolicyServiceSettings = + * alertPolicyServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public class AlertPolicyServiceStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -95,7 +99,6 @@ public class AlertPolicyServiceStubSettings extends StubSettings deleteAlertPolicySettings; private final UnaryCallSettings updateAlertPolicySettings; + 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 + ? ImmutableList.of() + : payload.getAlertPoliciesList(); + } + }; + + 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); + } + }; + /** Returns the object with the settings used for calls to listAlertPolicies. */ public PagedCallSettings< ListAlertPoliciesRequest, ListAlertPoliciesResponse, ListAlertPoliciesPagedResponse> @@ -139,10 +203,10 @@ public AlertPolicyServiceStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcAlertPolicyServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -209,72 +273,10 @@ protected AlertPolicyServiceStubSettings(Builder settingsBuilder) throws IOExcep 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; @@ -286,7 +288,6 @@ public static class Builder deleteAlertPolicySettings; private final UnaryCallSettings.Builder updateAlertPolicySettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -294,48 +295,12 @@ public static class Builder ImmutableMap.Builder> definitions = ImmutableMap.builder(); definitions.put( - "retry_policy_1_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_2_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_6_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_3_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_3_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_2_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_4_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_4_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_6_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_5_codes", + "retry_policy_8_codes", ImmutableSet.copyOf( Lists.newArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); definitions.put( - "no_retry_5_codes", ImmutableSet.copyOf(Lists.newArrayList())); + "no_retry_0_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -344,67 +309,6 @@ public static class Builder static { ImmutableMap.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(12000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(12000L)) - .setTotalTimeout(Duration.ofMillis(12000L)) - .build(); - definitions.put("no_retry_3_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_6_params", settings); - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_1_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_5_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_2_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_4_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_6_params", settings); settings = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofMillis(100L)) @@ -415,69 +319,29 @@ public static class Builder .setMaxRpcTimeout(Duration.ofMillis(30000L)) .setTotalTimeout(Duration.ofMillis(30000L)) .build(); - definitions.put("retry_policy_1_params", settings); + definitions.put("retry_policy_8_params", settings); settings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) .setInitialRpcTimeout(Duration.ofMillis(30000L)) .setRpcTimeoutMultiplier(1.0) .setMaxRpcTimeout(Duration.ofMillis(30000L)) .setTotalTimeout(Duration.ofMillis(30000L)) .build(); - definitions.put("retry_policy_2_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_3_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_5_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_4_params", settings); + definitions.put("no_retry_0_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } protected Builder() { - this((ClientContext) null); + 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 = @@ -487,68 +351,68 @@ protected Builder(ClientContext clientContext) { createAlertPolicySettings, deleteAlertPolicySettings, updateAlertPolicySettings); - initDefaults(this); } + 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); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + 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("retry_policy_5_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_8_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_8_params")); builder .getAlertPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_8_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_8_params")); builder .createAlertPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); builder .deleteAlertPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_8_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_8_params")); builder .updateAlertPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); 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' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java index 3f6d0d94..b2f2e744 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,12 +13,12 @@ * 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; @@ -33,14 +33,13 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Monitoring API. + * Base stub class for the GroupService service 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() { diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java index 7495fe75..85c487d9 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GroupServiceStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -60,7 +61,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link GroupServiceStub}. * @@ -77,21 +78,23 @@ * *

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

- * 
+ * 
{@code
  * GroupServiceStubSettings.Builder groupServiceSettingsBuilder =
  *     GroupServiceStubSettings.newBuilder();
  * groupServiceSettingsBuilder
  *     .getGroupSettings()
  *     .setRetrySettings(
- *         groupServiceSettingsBuilder.getGroupSettings().getRetrySettings().toBuilder()
+ *         groupServiceSettingsBuilder
+ *             .getGroupSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * GroupServiceStubSettings groupServiceSettings = groupServiceSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public class GroupServiceStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -99,7 +102,6 @@ public class GroupServiceStubSettings extends StubSettings @@ -112,6 +114,118 @@ public class GroupServiceStubSettings extends StubSettings listGroupMembersSettings; + 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 + ? ImmutableList.of() + : payload.getGroupList(); + } + }; + + 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 + ? ImmutableList.of() + : payload.getMembersList(); + } + }; + + 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); + } + }; + /** Returns the object with the settings used for calls to listGroups. */ public PagedCallSettings listGroupsSettings() { @@ -151,10 +265,10 @@ public GroupServiceStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcGroupServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -222,122 +336,9 @@ protected GroupServiceStubSettings(Builder settingsBuilder) throws IOException { 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; @@ -348,7 +349,6 @@ public static class Builder extends StubSettings.Builder listGroupMembersSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -362,42 +362,6 @@ public static class Builder extends StubSettings.BuildernewArrayList())); - definitions.put( - "retry_policy_6_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_3_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_3_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_2_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_4_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_4_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_6_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_5_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_5_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -406,67 +370,6 @@ public static class Builder extends StubSettings.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(12000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(12000L)) - .setTotalTimeout(Duration.ofMillis(12000L)) - .build(); - definitions.put("no_retry_3_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_6_params", settings); - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_1_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_5_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_2_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_4_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_6_params", settings); settings = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofMillis(100L)) @@ -480,68 +383,27 @@ public static class Builder extends StubSettings.Builder>of( + listGroupsSettings, + getGroupSettings, + createGroupSettings, + updateGroupSettings, + deleteGroupSettings, + listGroupMembersSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + 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("retry_policy_1_codes")) @@ -600,27 +482,7 @@ private static Builder initDefaults(Builder builder) { 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' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceCallableFactory.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceCallableFactory.java index b39f1b6a..6927319d 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceCallableFactory.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -31,18 +31,19 @@ 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.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Monitoring API. + * gRPC callable factory implementation for the AlertPolicyService service 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, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, 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, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java index 2ebcffa8..2dfdc458 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcAlertPolicyServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,11 +13,11 @@ * 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; @@ -26,6 +26,7 @@ import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; import com.google.monitoring.v3.AlertPolicy; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; @@ -41,16 +42,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Monitoring API. + * gRPC stub implementation for the AlertPolicyService service 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") +@Generated("by gapic-generator-java") public class GrpcAlertPolicyServiceStub extends AlertPolicyServiceStub { - private static final MethodDescriptor listAlertPoliciesMethodDescriptor = MethodDescriptor.newBuilder() @@ -61,6 +60,7 @@ public class GrpcAlertPolicyServiceStub extends AlertPolicyServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(ListAlertPoliciesResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getAlertPolicyMethodDescriptor = MethodDescriptor.newBuilder() @@ -70,6 +70,7 @@ public class GrpcAlertPolicyServiceStub extends AlertPolicyServiceStub { ProtoUtils.marshaller(GetAlertPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AlertPolicy.getDefaultInstance())) .build(); + private static final MethodDescriptor createAlertPolicyMethodDescriptor = MethodDescriptor.newBuilder() @@ -79,6 +80,7 @@ public class GrpcAlertPolicyServiceStub extends AlertPolicyServiceStub { ProtoUtils.marshaller(CreateAlertPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(AlertPolicy.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteAlertPolicyMethodDescriptor = MethodDescriptor.newBuilder() @@ -88,6 +90,7 @@ public class GrpcAlertPolicyServiceStub extends AlertPolicyServiceStub { ProtoUtils.marshaller(DeleteAlertPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor updateAlertPolicyMethodDescriptor = MethodDescriptor.newBuilder() @@ -98,8 +101,6 @@ public class GrpcAlertPolicyServiceStub extends AlertPolicyServiceStub { .setResponseMarshaller(ProtoUtils.marshaller(AlertPolicy.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final UnaryCallable listAlertPoliciesCallable; private final UnaryCallable @@ -109,6 +110,8 @@ public class GrpcAlertPolicyServiceStub extends AlertPolicyServiceStub { private final UnaryCallable deleteAlertPolicyCallable; private final UnaryCallable updateAlertPolicyCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcAlertPolicyServiceStub create(AlertPolicyServiceStubSettings settings) @@ -149,6 +152,7 @@ protected GrpcAlertPolicyServiceStub( GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings listAlertPoliciesTransportSettings = @@ -247,12 +251,12 @@ public Map extract(UpdateAlertPolicyRequest request) { settings.updateAlertPolicySettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - public UnaryCallable - listAlertPoliciesPagedCallable() { - return listAlertPoliciesPagedCallable; + public GrpcOperationsStub getOperationsStub() { + return operationsStub; } public UnaryCallable @@ -260,6 +264,11 @@ public Map extract(UpdateAlertPolicyRequest request) { return listAlertPoliciesCallable; } + public UnaryCallable + listAlertPoliciesPagedCallable() { + return listAlertPoliciesPagedCallable; + } + public UnaryCallable getAlertPolicyCallable() { return getAlertPolicyCallable; } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceCallableFactory.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceCallableFactory.java index 4386b88a..ed19eb69 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceCallableFactory.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -31,18 +31,19 @@ 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.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Monitoring API. + * gRPC callable factory implementation for the GroupService service 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, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, 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, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java index b49fb87f..8c1926a0 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcGroupServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,12 +13,12 @@ * 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; @@ -27,6 +27,7 @@ import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; import com.google.monitoring.v3.CreateGroupRequest; import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; @@ -44,16 +45,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Monitoring API. + * gRPC stub implementation for the GroupService service 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") +@Generated("by gapic-generator-java") public class GrpcGroupServiceStub extends GroupServiceStub { - private static final MethodDescriptor listGroupsMethodDescriptor = MethodDescriptor.newBuilder() @@ -62,6 +61,7 @@ public class GrpcGroupServiceStub extends GroupServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(ListGroupsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(ListGroupsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getGroupMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -69,6 +69,7 @@ public class GrpcGroupServiceStub extends GroupServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(GetGroupRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Group.getDefaultInstance())) .build(); + private static final MethodDescriptor createGroupMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -76,6 +77,7 @@ public class GrpcGroupServiceStub extends GroupServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(CreateGroupRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Group.getDefaultInstance())) .build(); + private static final MethodDescriptor updateGroupMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -83,6 +85,7 @@ public class GrpcGroupServiceStub extends GroupServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(UpdateGroupRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Group.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteGroupMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -90,6 +93,7 @@ public class GrpcGroupServiceStub extends GroupServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(DeleteGroupRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor listGroupMembersMethodDescriptor = MethodDescriptor.newBuilder() @@ -101,8 +105,6 @@ public class GrpcGroupServiceStub extends GroupServiceStub { ProtoUtils.marshaller(ListGroupMembersResponse.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final UnaryCallable listGroupsCallable; private final UnaryCallable listGroupsPagedCallable; private final UnaryCallable getGroupCallable; @@ -114,6 +116,8 @@ public class GrpcGroupServiceStub extends GroupServiceStub { private final UnaryCallable listGroupMembersPagedCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcGroupServiceStub create(GroupServiceStubSettings settings) @@ -152,6 +156,7 @@ protected GrpcGroupServiceStub( GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings listGroupsTransportSettings = GrpcCallSettings.newBuilder() @@ -258,17 +263,22 @@ public Map extract(ListGroupMembersRequest request) { callableFactory.createPagedCallable( listGroupMembersTransportSettings, settings.listGroupMembersSettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - public UnaryCallable listGroupsPagedCallable() { - return listGroupsPagedCallable; + public GrpcOperationsStub getOperationsStub() { + return operationsStub; } public UnaryCallable listGroupsCallable() { return listGroupsCallable; } + public UnaryCallable listGroupsPagedCallable() { + return listGroupsPagedCallable; + } + public UnaryCallable getGroupCallable() { return getGroupCallable; } @@ -285,16 +295,16 @@ public UnaryCallable deleteGroupCallable() { return deleteGroupCallable; } - public UnaryCallable - listGroupMembersPagedCallable() { - return listGroupMembersPagedCallable; - } - public UnaryCallable listGroupMembersCallable() { return listGroupMembersCallable; } + public UnaryCallable + listGroupMembersPagedCallable() { + return listGroupMembersPagedCallable; + } + @Override public final void close() { shutdown(); diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceCallableFactory.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceCallableFactory.java index 4dc4dafb..bda2d6e9 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceCallableFactory.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -31,18 +31,19 @@ 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.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Monitoring API. + * gRPC callable factory implementation for the MetricService service 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, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, 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, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java index 560a3b61..c8c3fc27 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcMetricServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -21,7 +22,6 @@ 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; @@ -30,6 +30,7 @@ import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; import com.google.monitoring.v3.CreateMetricDescriptorRequest; import com.google.monitoring.v3.CreateTimeSeriesRequest; import com.google.monitoring.v3.DeleteMetricDescriptorRequest; @@ -49,16 +50,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Monitoring API. + * gRPC stub implementation for the MetricService service 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") +@Generated("by gapic-generator-java") public class GrpcMetricServiceStub extends MetricServiceStub { - private static final MethodDescriptor< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> listMonitoredResourceDescriptorsMethodDescriptor = @@ -75,6 +74,7 @@ public class GrpcMetricServiceStub extends MetricServiceStub { ProtoUtils.marshaller( ListMonitoredResourceDescriptorsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor< GetMonitoredResourceDescriptorRequest, MonitoredResourceDescriptor> getMonitoredResourceDescriptorMethodDescriptor = @@ -88,6 +88,7 @@ public class GrpcMetricServiceStub extends MetricServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(MonitoredResourceDescriptor.getDefaultInstance())) .build(); + private static final MethodDescriptor listMetricDescriptorsMethodDescriptor = MethodDescriptor.newBuilder() @@ -98,6 +99,7 @@ public class GrpcMetricServiceStub extends MetricServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(ListMetricDescriptorsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getMetricDescriptorMethodDescriptor = MethodDescriptor.newBuilder() @@ -107,6 +109,7 @@ public class GrpcMetricServiceStub extends MetricServiceStub { ProtoUtils.marshaller(GetMetricDescriptorRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(MetricDescriptor.getDefaultInstance())) .build(); + private static final MethodDescriptor createMetricDescriptorMethodDescriptor = MethodDescriptor.newBuilder() @@ -116,6 +119,7 @@ public class GrpcMetricServiceStub extends MetricServiceStub { ProtoUtils.marshaller(CreateMetricDescriptorRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(MetricDescriptor.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteMetricDescriptorMethodDescriptor = MethodDescriptor.newBuilder() @@ -125,6 +129,7 @@ public class GrpcMetricServiceStub extends MetricServiceStub { ProtoUtils.marshaller(DeleteMetricDescriptorRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor listTimeSeriesMethodDescriptor = MethodDescriptor.newBuilder() @@ -135,6 +140,7 @@ public class GrpcMetricServiceStub extends MetricServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(ListTimeSeriesResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor createTimeSeriesMethodDescriptor = MethodDescriptor.newBuilder() @@ -145,8 +151,6 @@ public class GrpcMetricServiceStub extends MetricServiceStub { .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final UnaryCallable< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> listMonitoredResourceDescriptorsCallable; @@ -169,6 +173,8 @@ public class GrpcMetricServiceStub extends MetricServiceStub { listTimeSeriesPagedCallable; private final UnaryCallable createTimeSeriesCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcMetricServiceStub create(MetricServiceStubSettings settings) @@ -207,6 +213,7 @@ protected GrpcMetricServiceStub( GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse> @@ -376,13 +383,12 @@ public Map extract(CreateTimeSeriesRequest request) { callableFactory.createUnaryCallable( createTimeSeriesTransportSettings, settings.createTimeSeriesSettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - public UnaryCallable< - ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> - listMonitoredResourceDescriptorsPagedCallable() { - return listMonitoredResourceDescriptorsPagedCallable; + public GrpcOperationsStub getOperationsStub() { + return operationsStub; } public UnaryCallable< @@ -391,21 +397,27 @@ public Map extract(CreateTimeSeriesRequest request) { return listMonitoredResourceDescriptorsCallable; } + public UnaryCallable< + ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsPagedResponse> + listMonitoredResourceDescriptorsPagedCallable() { + return listMonitoredResourceDescriptorsPagedCallable; + } + public UnaryCallable getMonitoredResourceDescriptorCallable() { return getMonitoredResourceDescriptorCallable; } - public UnaryCallable - listMetricDescriptorsPagedCallable() { - return listMetricDescriptorsPagedCallable; - } - public UnaryCallable listMetricDescriptorsCallable() { return listMetricDescriptorsCallable; } + public UnaryCallable + listMetricDescriptorsPagedCallable() { + return listMetricDescriptorsPagedCallable; + } + public UnaryCallable getMetricDescriptorCallable() { return getMetricDescriptorCallable; } @@ -419,15 +431,15 @@ public UnaryCallable deleteMetricDescripto return deleteMetricDescriptorCallable; } + public UnaryCallable listTimeSeriesCallable() { + return listTimeSeriesCallable; + } + public UnaryCallable listTimeSeriesPagedCallable() { return listTimeSeriesPagedCallable; } - public UnaryCallable listTimeSeriesCallable() { - return listTimeSeriesCallable; - } - public UnaryCallable createTimeSeriesCallable() { return createTimeSeriesCallable; } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceCallableFactory.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceCallableFactory.java index a37b34b8..535dc63f 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceCallableFactory.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -31,18 +31,19 @@ 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.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Monitoring API. + * gRPC callable factory implementation for the NotificationChannelService service 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, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, 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, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java index 05634628..6e0210b9 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcNotificationChannelServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,12 +13,12 @@ * 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; @@ -27,6 +27,7 @@ import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; import com.google.monitoring.v3.CreateNotificationChannelRequest; import com.google.monitoring.v3.DeleteNotificationChannelRequest; import com.google.monitoring.v3.GetNotificationChannelDescriptorRequest; @@ -50,16 +51,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Monitoring API. + * gRPC stub implementation for the NotificationChannelService service 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") +@Generated("by gapic-generator-java") public class GrpcNotificationChannelServiceStub extends NotificationChannelServiceStub { - private static final MethodDescriptor< ListNotificationChannelDescriptorsRequest, ListNotificationChannelDescriptorsResponse> listNotificationChannelDescriptorsMethodDescriptor = @@ -77,6 +76,7 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi ProtoUtils.marshaller( ListNotificationChannelDescriptorsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor< GetNotificationChannelDescriptorRequest, NotificationChannelDescriptor> getNotificationChannelDescriptorMethodDescriptor = @@ -91,6 +91,7 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi .setResponseMarshaller( ProtoUtils.marshaller(NotificationChannelDescriptor.getDefaultInstance())) .build(); + private static final MethodDescriptor< ListNotificationChannelsRequest, ListNotificationChannelsResponse> listNotificationChannelsMethodDescriptor = @@ -104,6 +105,7 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi .setResponseMarshaller( ProtoUtils.marshaller(ListNotificationChannelsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getNotificationChannelMethodDescriptor = MethodDescriptor.newBuilder() @@ -115,6 +117,7 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi .setResponseMarshaller( ProtoUtils.marshaller(NotificationChannel.getDefaultInstance())) .build(); + private static final MethodDescriptor createNotificationChannelMethodDescriptor = MethodDescriptor.newBuilder() @@ -126,6 +129,7 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi .setResponseMarshaller( ProtoUtils.marshaller(NotificationChannel.getDefaultInstance())) .build(); + private static final MethodDescriptor updateNotificationChannelMethodDescriptor = MethodDescriptor.newBuilder() @@ -137,6 +141,7 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi .setResponseMarshaller( ProtoUtils.marshaller(NotificationChannel.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteNotificationChannelMethodDescriptor = MethodDescriptor.newBuilder() @@ -147,6 +152,7 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi ProtoUtils.marshaller(DeleteNotificationChannelRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor sendNotificationChannelVerificationCodeMethodDescriptor = MethodDescriptor.newBuilder() @@ -158,6 +164,7 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi SendNotificationChannelVerificationCodeRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor< GetNotificationChannelVerificationCodeRequest, GetNotificationChannelVerificationCodeResponse> @@ -176,6 +183,7 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi ProtoUtils.marshaller( GetNotificationChannelVerificationCodeResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor verifyNotificationChannelMethodDescriptor = MethodDescriptor.newBuilder() @@ -188,8 +196,6 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi ProtoUtils.marshaller(NotificationChannel.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final UnaryCallable< ListNotificationChannelDescriptorsRequest, ListNotificationChannelDescriptorsResponse> listNotificationChannelDescriptorsCallable; @@ -222,6 +228,8 @@ public class GrpcNotificationChannelServiceStub extends NotificationChannelServi private final UnaryCallable verifyNotificationChannelCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcNotificationChannelServiceStub create( @@ -265,6 +273,7 @@ protected GrpcNotificationChannelServiceStub( GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings< ListNotificationChannelDescriptorsRequest, ListNotificationChannelDescriptorsResponse> @@ -486,14 +495,12 @@ public Map extract(VerifyNotificationChannelRequest request) { settings.verifyNotificationChannelSettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - public UnaryCallable< - ListNotificationChannelDescriptorsRequest, - ListNotificationChannelDescriptorsPagedResponse> - listNotificationChannelDescriptorsPagedCallable() { - return listNotificationChannelDescriptorsPagedCallable; + public GrpcOperationsStub getOperationsStub() { + return operationsStub; } public UnaryCallable< @@ -502,21 +509,28 @@ public Map extract(VerifyNotificationChannelRequest request) { return listNotificationChannelDescriptorsCallable; } + public UnaryCallable< + ListNotificationChannelDescriptorsRequest, + ListNotificationChannelDescriptorsPagedResponse> + listNotificationChannelDescriptorsPagedCallable() { + return listNotificationChannelDescriptorsPagedCallable; + } + public UnaryCallable getNotificationChannelDescriptorCallable() { return getNotificationChannelDescriptorCallable; } - public UnaryCallable - listNotificationChannelsPagedCallable() { - return listNotificationChannelsPagedCallable; - } - public UnaryCallable listNotificationChannelsCallable() { return listNotificationChannelsCallable; } + public UnaryCallable + listNotificationChannelsPagedCallable() { + return listNotificationChannelsPagedCallable; + } + public UnaryCallable getNotificationChannelCallable() { return getNotificationChannelCallable; diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcServiceMonitoringServiceCallableFactory.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcServiceMonitoringServiceCallableFactory.java index a662131c..911fd530 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcServiceMonitoringServiceCallableFactory.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcServiceMonitoringServiceCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -31,18 +31,19 @@ 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.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Monitoring API. + * gRPC callable factory implementation for the ServiceMonitoringService service 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 GrpcServiceMonitoringServiceCallableFactory implements GrpcStubCallableFactory { + @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, 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, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcServiceMonitoringServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcServiceMonitoringServiceStub.java index aa5b0f88..07809926 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcServiceMonitoringServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcServiceMonitoringServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,12 +13,12 @@ * 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.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse; import static com.google.cloud.monitoring.v3.ServiceMonitoringServiceClient.ListServicesPagedResponse; -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; @@ -27,6 +27,7 @@ import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; import com.google.monitoring.v3.CreateServiceLevelObjectiveRequest; import com.google.monitoring.v3.CreateServiceRequest; import com.google.monitoring.v3.DeleteServiceLevelObjectiveRequest; @@ -49,16 +50,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Monitoring API. + * gRPC stub implementation for the ServiceMonitoringService service 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") +@Generated("by gapic-generator-java") public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceStub { - private static final MethodDescriptor createServiceMethodDescriptor = MethodDescriptor.newBuilder() @@ -68,6 +67,7 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt ProtoUtils.marshaller(CreateServiceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Service.getDefaultInstance())) .build(); + private static final MethodDescriptor getServiceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -75,6 +75,7 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt .setRequestMarshaller(ProtoUtils.marshaller(GetServiceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Service.getDefaultInstance())) .build(); + private static final MethodDescriptor listServicesMethodDescriptor = MethodDescriptor.newBuilder() @@ -84,6 +85,7 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt .setResponseMarshaller( ProtoUtils.marshaller(ListServicesResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor updateServiceMethodDescriptor = MethodDescriptor.newBuilder() @@ -93,6 +95,7 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt ProtoUtils.marshaller(UpdateServiceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Service.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteServiceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -100,6 +103,7 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt .setRequestMarshaller(ProtoUtils.marshaller(DeleteServiceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor createServiceLevelObjectiveMethodDescriptor = MethodDescriptor.newBuilder() @@ -111,6 +115,7 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt .setResponseMarshaller( ProtoUtils.marshaller(ServiceLevelObjective.getDefaultInstance())) .build(); + private static final MethodDescriptor getServiceLevelObjectiveMethodDescriptor = MethodDescriptor.newBuilder() @@ -122,6 +127,7 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt .setResponseMarshaller( ProtoUtils.marshaller(ServiceLevelObjective.getDefaultInstance())) .build(); + private static final MethodDescriptor< ListServiceLevelObjectivesRequest, ListServiceLevelObjectivesResponse> listServiceLevelObjectivesMethodDescriptor = @@ -135,6 +141,7 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt .setResponseMarshaller( ProtoUtils.marshaller(ListServiceLevelObjectivesResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor updateServiceLevelObjectiveMethodDescriptor = MethodDescriptor.newBuilder() @@ -146,6 +153,7 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt .setResponseMarshaller( ProtoUtils.marshaller(ServiceLevelObjective.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteServiceLevelObjectiveMethodDescriptor = MethodDescriptor.newBuilder() @@ -157,8 +165,6 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final UnaryCallable createServiceCallable; private final UnaryCallable getServiceCallable; private final UnaryCallable listServicesCallable; @@ -180,6 +186,8 @@ public class GrpcServiceMonitoringServiceStub extends ServiceMonitoringServiceSt private final UnaryCallable deleteServiceLevelObjectiveCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcServiceMonitoringServiceStub create( @@ -221,6 +229,7 @@ protected GrpcServiceMonitoringServiceStub( GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings createServiceTransportSettings = GrpcCallSettings.newBuilder() @@ -414,7 +423,12 @@ public Map extract( settings.deleteServiceLevelObjectiveSettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; } public UnaryCallable createServiceCallable() { @@ -425,14 +439,14 @@ public UnaryCallable getServiceCallable() { return getServiceCallable; } - public UnaryCallable listServicesPagedCallable() { - return listServicesPagedCallable; - } - public UnaryCallable listServicesCallable() { return listServicesCallable; } + public UnaryCallable listServicesPagedCallable() { + return listServicesPagedCallable; + } + public UnaryCallable updateServiceCallable() { return updateServiceCallable; } @@ -451,16 +465,16 @@ public UnaryCallable deleteServiceCallable() { return getServiceLevelObjectiveCallable; } - public UnaryCallable - listServiceLevelObjectivesPagedCallable() { - return listServiceLevelObjectivesPagedCallable; - } - public UnaryCallable listServiceLevelObjectivesCallable() { return listServiceLevelObjectivesCallable; } + public UnaryCallable + listServiceLevelObjectivesPagedCallable() { + return listServiceLevelObjectivesPagedCallable; + } + public UnaryCallable updateServiceLevelObjectiveCallable() { return updateServiceLevelObjectiveCallable; diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceCallableFactory.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceCallableFactory.java index 1b039464..2dce676e 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceCallableFactory.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * 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; @@ -31,18 +31,19 @@ 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.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Monitoring API. + * gRPC callable factory implementation for the UptimeCheckService service 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, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, 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, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java index 01f4f296..b0ec8b54 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/GrpcUptimeCheckServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,12 +13,12 @@ * 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; @@ -27,6 +27,7 @@ import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; import com.google.monitoring.v3.CreateUptimeCheckConfigRequest; import com.google.monitoring.v3.DeleteUptimeCheckConfigRequest; import com.google.monitoring.v3.GetUptimeCheckConfigRequest; @@ -44,16 +45,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Monitoring API. + * gRPC stub implementation for the UptimeCheckService service 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") +@Generated("by gapic-generator-java") public class GrpcUptimeCheckServiceStub extends UptimeCheckServiceStub { - private static final MethodDescriptor< ListUptimeCheckConfigsRequest, ListUptimeCheckConfigsResponse> listUptimeCheckConfigsMethodDescriptor = @@ -66,6 +65,7 @@ public class GrpcUptimeCheckServiceStub extends UptimeCheckServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(ListUptimeCheckConfigsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getUptimeCheckConfigMethodDescriptor = MethodDescriptor.newBuilder() @@ -75,6 +75,7 @@ public class GrpcUptimeCheckServiceStub extends UptimeCheckServiceStub { ProtoUtils.marshaller(GetUptimeCheckConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(UptimeCheckConfig.getDefaultInstance())) .build(); + private static final MethodDescriptor createUptimeCheckConfigMethodDescriptor = MethodDescriptor.newBuilder() @@ -84,6 +85,7 @@ public class GrpcUptimeCheckServiceStub extends UptimeCheckServiceStub { ProtoUtils.marshaller(CreateUptimeCheckConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(UptimeCheckConfig.getDefaultInstance())) .build(); + private static final MethodDescriptor updateUptimeCheckConfigMethodDescriptor = MethodDescriptor.newBuilder() @@ -93,6 +95,7 @@ public class GrpcUptimeCheckServiceStub extends UptimeCheckServiceStub { ProtoUtils.marshaller(UpdateUptimeCheckConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(UptimeCheckConfig.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteUptimeCheckConfigMethodDescriptor = MethodDescriptor.newBuilder() @@ -102,6 +105,7 @@ public class GrpcUptimeCheckServiceStub extends UptimeCheckServiceStub { ProtoUtils.marshaller(DeleteUptimeCheckConfigRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) .build(); + private static final MethodDescriptor listUptimeCheckIpsMethodDescriptor = MethodDescriptor.newBuilder() @@ -113,8 +117,6 @@ public class GrpcUptimeCheckServiceStub extends UptimeCheckServiceStub { ProtoUtils.marshaller(ListUptimeCheckIpsResponse.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final UnaryCallable listUptimeCheckConfigsCallable; private final UnaryCallable @@ -132,6 +134,8 @@ public class GrpcUptimeCheckServiceStub extends UptimeCheckServiceStub { private final UnaryCallable listUptimeCheckIpsPagedCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcUptimeCheckServiceStub create(UptimeCheckServiceStubSettings settings) @@ -172,6 +176,7 @@ protected GrpcUptimeCheckServiceStub( GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings listUptimeCheckConfigsTransportSettings = @@ -293,12 +298,12 @@ public Map extract(DeleteUptimeCheckConfigRequest request) { settings.listUptimeCheckIpsSettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - public UnaryCallable - listUptimeCheckConfigsPagedCallable() { - return listUptimeCheckConfigsPagedCallable; + public GrpcOperationsStub getOperationsStub() { + return operationsStub; } public UnaryCallable @@ -306,6 +311,11 @@ public Map extract(DeleteUptimeCheckConfigRequest request) { return listUptimeCheckConfigsCallable; } + public UnaryCallable + listUptimeCheckConfigsPagedCallable() { + return listUptimeCheckConfigsPagedCallable; + } + public UnaryCallable getUptimeCheckConfigCallable() { return getUptimeCheckConfigCallable; @@ -325,16 +335,16 @@ public UnaryCallable deleteUptimeCheckCon return deleteUptimeCheckConfigCallable; } - public UnaryCallable - listUptimeCheckIpsPagedCallable() { - return listUptimeCheckIpsPagedCallable; - } - public UnaryCallable listUptimeCheckIpsCallable() { return listUptimeCheckIpsCallable; } + public UnaryCallable + listUptimeCheckIpsPagedCallable() { + return listUptimeCheckIpsPagedCallable; + } + @Override public final void close() { shutdown(); diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java index a7025349..4dd035da 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -21,7 +22,6 @@ 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; @@ -38,14 +38,13 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Monitoring API. + * Base stub class for the MetricService service 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< diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java index 71875650..40ce9a5d 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/MetricServiceStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -65,7 +66,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link MetricServiceStub}. * @@ -82,21 +83,23 @@ * *

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

- * 
+ * 
{@code
  * MetricServiceStubSettings.Builder metricServiceSettingsBuilder =
  *     MetricServiceStubSettings.newBuilder();
  * metricServiceSettingsBuilder
  *     .getMonitoredResourceDescriptorSettings()
  *     .setRetrySettings(
- *         metricServiceSettingsBuilder.getMonitoredResourceDescriptorSettings().getRetrySettings().toBuilder()
+ *         metricServiceSettingsBuilder
+ *             .getMonitoredResourceDescriptorSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * MetricServiceStubSettings metricServiceSettings = metricServiceSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public class MetricServiceStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -131,140 +134,6 @@ public class MetricServiceStubSettings extends StubSettings 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, @@ -308,9 +177,9 @@ public String extractNextToken(ListMonitoredResourceDescriptorsResponse payload) @Override public Iterable extractResources( ListMonitoredResourceDescriptorsResponse payload) { - return payload.getResourceDescriptorsList() != null - ? payload.getResourceDescriptorsList() - : ImmutableList.of(); + return payload.getResourceDescriptorsList() == null + ? ImmutableList.of() + : payload.getResourceDescriptorsList(); } }; @@ -349,9 +218,9 @@ public String extractNextToken(ListMetricDescriptorsResponse payload) { @Override public Iterable extractResources( ListMetricDescriptorsResponse payload) { - return payload.getMetricDescriptorsList() != null - ? payload.getMetricDescriptorsList() - : ImmutableList.of(); + return payload.getMetricDescriptorsList() == null + ? ImmutableList.of() + : payload.getMetricDescriptorsList(); } }; @@ -387,9 +256,9 @@ public String extractNextToken(ListTimeSeriesResponse payload) { @Override public Iterable extractResources(ListTimeSeriesResponse payload) { - return payload.getTimeSeriesList() != null - ? payload.getTimeSeriesList() - : ImmutableList.of(); + return payload.getTimeSeriesList() == null + ? ImmutableList.of() + : payload.getTimeSeriesList(); } }; @@ -467,10 +336,143 @@ public ApiFuture getFuturePagedResponse( } }; + /** 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); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", 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(); + } + /** Builder for MetricServiceStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final PagedCallSettings.Builder< ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse, @@ -495,7 +497,6 @@ public static class Builder extends StubSettings.Builder createTimeSeriesSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -503,11 +504,10 @@ public static class Builder extends StubSettings.Builder> definitions = ImmutableMap.builder(); definitions.put( - "retry_policy_6_codes", + "retry_policy_9_codes", ImmutableSet.copyOf( Lists.newArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); definitions.put( "no_retry_3_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); @@ -518,14 +518,6 @@ public static class Builder extends StubSettings.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(12000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(12000L)) - .setTotalTimeout(Duration.ofMillis(12000L)) - .build(); - definitions.put("no_retry_3_params", settings); settings = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofMillis(100L)) @@ -536,14 +528,20 @@ public static class Builder extends StubSettings.Builder>of( + listMonitoredResourceDescriptorsSettings, + getMonitoredResourceDescriptorSettings, + listMetricDescriptorsSettings, + getMetricDescriptorSettings, + createMetricDescriptorSettings, + deleteMetricDescriptorSettings, + listTimeSeriesSettings, + createTimeSeriesSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + 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("retry_policy_6_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_9_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_9_params")); builder .getMonitoredResourceDescriptorSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_9_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_9_params")); builder .listMetricDescriptorsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_9_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_9_params")); builder .getMetricDescriptorSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_9_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_9_params")); builder .createMetricDescriptorSettings() @@ -619,13 +636,13 @@ private static Builder initDefaults(Builder builder) { builder .deleteMetricDescriptorSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_9_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_9_params")); builder .listTimeSeriesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_9_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_9_params")); builder .createTimeSeriesSettings() @@ -635,33 +652,7 @@ private static Builder initDefaults(Builder builder) { 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' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java index 3d65e9b8..4e3a368e 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,12 +13,12 @@ * 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; @@ -39,14 +39,13 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Monitoring API. + * Base stub class for the NotificationChannelService service 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< diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java index 3727644b..19ef0300 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/NotificationChannelServiceStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -65,7 +66,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link NotificationChannelServiceStub}. * @@ -82,21 +83,24 @@ * *

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

- * 
+ * 
{@code
  * NotificationChannelServiceStubSettings.Builder notificationChannelServiceSettingsBuilder =
  *     NotificationChannelServiceStubSettings.newBuilder();
  * notificationChannelServiceSettingsBuilder
  *     .getNotificationChannelDescriptorSettings()
  *     .setRetrySettings(
- *         notificationChannelServiceSettingsBuilder.getNotificationChannelDescriptorSettings().getRetrySettings().toBuilder()
+ *         notificationChannelServiceSettingsBuilder
+ *             .getNotificationChannelDescriptorSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * NotificationChannelServiceStubSettings notificationChannelServiceSettings = notificationChannelServiceSettingsBuilder.build();
- * 
- * 
+ * NotificationChannelServiceStubSettings notificationChannelServiceSettings = + * notificationChannelServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public class NotificationChannelServiceStubSettings extends StubSettings { /** The default scopes of the service. */ @@ -105,7 +109,6 @@ public class NotificationChannelServiceStubSettings .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< @@ -138,6 +141,163 @@ public class NotificationChannelServiceStubSettings private final UnaryCallSettings verifyNotificationChannelSettings; + 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 + ? ImmutableList.of() + : payload.getChannelDescriptorsList(); + } + }; + + 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 + ? ImmutableList.of() + : payload.getNotificationChannelsList(); + } + }; + + 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); + } + }; + /** Returns the object with the settings used for calls to listNotificationChannelDescriptors. */ public PagedCallSettings< ListNotificationChannelDescriptorsRequest, @@ -216,10 +376,10 @@ public NotificationChannelServiceStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcNotificationChannelServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -295,168 +455,10 @@ protected NotificationChannelServiceStubSettings(Builder settingsBuilder) throws 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, @@ -486,56 +488,19 @@ public static class Builder getNotificationChannelVerificationCodeSettings; private final UnaryCallSettings.Builder verifyNotificationChannelSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; static { ImmutableMap.Builder> definitions = ImmutableMap.builder(); - definitions.put( - "retry_policy_1_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_2_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_6_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_3_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_3_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_2_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); definitions.put( "retry_policy_4_codes", ImmutableSet.copyOf( Lists.newArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); definitions.put( - "no_retry_4_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_6_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_5_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_5_codes", ImmutableSet.copyOf(Lists.newArrayList())); + "no_retry_10_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -544,14 +509,6 @@ public static class Builder static { ImmutableMap.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(12000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(12000L)) - .setTotalTimeout(Duration.ofMillis(12000L)) - .build(); - definitions.put("no_retry_3_params", settings); settings = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofMillis(100L)) @@ -562,109 +519,20 @@ public static class Builder .setMaxRpcTimeout(Duration.ofMillis(30000L)) .setTotalTimeout(Duration.ofMillis(30000L)) .build(); - definitions.put("retry_policy_6_params", settings); - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_1_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_5_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_2_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_4_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_6_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_1_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_2_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_3_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_5_params", settings); + definitions.put("retry_policy_4_params", settings); settings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) .setInitialRpcTimeout(Duration.ofMillis(30000L)) .setRpcTimeoutMultiplier(1.0) .setMaxRpcTimeout(Duration.ofMillis(30000L)) .setTotalTimeout(Duration.ofMillis(30000L)) .build(); - definitions.put("retry_policy_4_params", settings); + definitions.put("no_retry_10_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } protected Builder() { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { @@ -672,26 +540,17 @@ protected Builder(ClientContext 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 = @@ -706,107 +565,107 @@ protected Builder(ClientContext clientContext) { sendNotificationChannelVerificationCodeSettings, getNotificationChannelVerificationCodeSettings, verifyNotificationChannelSettings); - initDefaults(this); } + 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); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + 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("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .getNotificationChannelDescriptorSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .listNotificationChannelsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .getNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .createNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_5_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_5_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_10_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_10_params")); builder .updateNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_5_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_5_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_10_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_10_params")); builder .deleteNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .sendNotificationChannelVerificationCodeSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_5_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_5_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_10_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_10_params")); builder .getNotificationChannelVerificationCodeSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); builder .verifyNotificationChannelSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); 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' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/ServiceMonitoringServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/ServiceMonitoringServiceStub.java index dbe1fc11..a6ec07cc 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/ServiceMonitoringServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/ServiceMonitoringServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,12 +13,12 @@ * 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.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse; import static com.google.cloud.monitoring.v3.ServiceMonitoringServiceClient.ListServicesPagedResponse; -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.CreateServiceLevelObjectiveRequest; @@ -38,14 +38,13 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Monitoring API. + * Base stub class for the ServiceMonitoringService service 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 ServiceMonitoringServiceStub implements BackgroundResource { public UnaryCallable createServiceCallable() { diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/ServiceMonitoringServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/ServiceMonitoringServiceStubSettings.java index d9b25d86..303aa3ad 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/ServiceMonitoringServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/ServiceMonitoringServiceStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse; @@ -64,7 +65,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link ServiceMonitoringServiceStub}. * @@ -81,21 +82,24 @@ * *

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

- * 
+ * 
{@code
  * ServiceMonitoringServiceStubSettings.Builder serviceMonitoringServiceSettingsBuilder =
  *     ServiceMonitoringServiceStubSettings.newBuilder();
  * serviceMonitoringServiceSettingsBuilder
  *     .createServiceSettings()
  *     .setRetrySettings(
- *         serviceMonitoringServiceSettingsBuilder.createServiceSettings().getRetrySettings().toBuilder()
+ *         serviceMonitoringServiceSettingsBuilder
+ *             .createServiceSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * ServiceMonitoringServiceStubSettings serviceMonitoringServiceSettings = serviceMonitoringServiceSettingsBuilder.build();
- * 
- * 
+ * ServiceMonitoringServiceStubSettings serviceMonitoringServiceSettings = + * serviceMonitoringServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public class ServiceMonitoringServiceStubSettings extends StubSettings { /** The default scopes of the service. */ @@ -104,7 +108,6 @@ public class ServiceMonitoringServiceStubSettings .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 UnaryCallSettings createServiceSettings; @@ -128,6 +131,136 @@ public class ServiceMonitoringServiceStubSettings private final UnaryCallSettings deleteServiceLevelObjectiveSettings; + private static final PagedListDescriptor + LIST_SERVICES_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListServicesRequest injectToken(ListServicesRequest payload, String token) { + return ListServicesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListServicesRequest injectPageSize(ListServicesRequest payload, int pageSize) { + return ListServicesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListServicesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListServicesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListServicesResponse payload) { + return payload.getServicesList() == null + ? ImmutableList.of() + : payload.getServicesList(); + } + }; + + private static final PagedListDescriptor< + ListServiceLevelObjectivesRequest, + ListServiceLevelObjectivesResponse, + ServiceLevelObjective> + LIST_SERVICE_LEVEL_OBJECTIVES_PAGE_STR_DESC = + new PagedListDescriptor< + ListServiceLevelObjectivesRequest, + ListServiceLevelObjectivesResponse, + ServiceLevelObjective>() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListServiceLevelObjectivesRequest injectToken( + ListServiceLevelObjectivesRequest payload, String token) { + return ListServiceLevelObjectivesRequest.newBuilder(payload) + .setPageToken(token) + .build(); + } + + @Override + public ListServiceLevelObjectivesRequest injectPageSize( + ListServiceLevelObjectivesRequest payload, int pageSize) { + return ListServiceLevelObjectivesRequest.newBuilder(payload) + .setPageSize(pageSize) + .build(); + } + + @Override + public Integer extractPageSize(ListServiceLevelObjectivesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListServiceLevelObjectivesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources( + ListServiceLevelObjectivesResponse payload) { + return payload.getServiceLevelObjectivesList() == null + ? ImmutableList.of() + : payload.getServiceLevelObjectivesList(); + } + }; + + private static final PagedListResponseFactory< + ListServicesRequest, ListServicesResponse, ListServicesPagedResponse> + LIST_SERVICES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListServicesRequest, ListServicesResponse, ListServicesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListServicesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_SERVICES_PAGE_STR_DESC, request, context); + return ListServicesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + ListServiceLevelObjectivesRequest, + ListServiceLevelObjectivesResponse, + ListServiceLevelObjectivesPagedResponse> + LIST_SERVICE_LEVEL_OBJECTIVES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListServiceLevelObjectivesRequest, + ListServiceLevelObjectivesResponse, + ListServiceLevelObjectivesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable + callable, + ListServiceLevelObjectivesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext< + ListServiceLevelObjectivesRequest, + ListServiceLevelObjectivesResponse, + ServiceLevelObjective> + pageContext = + PageContext.create( + callable, LIST_SERVICE_LEVEL_OBJECTIVES_PAGE_STR_DESC, request, context); + return ListServiceLevelObjectivesPagedResponse.createAsync( + pageContext, futureResponse); + } + }; + /** Returns the object with the settings used for calls to createService. */ public UnaryCallSettings createServiceSettings() { return createServiceSettings; @@ -193,10 +326,10 @@ public ServiceMonitoringServiceStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcServiceMonitoringServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -272,141 +405,10 @@ protected ServiceMonitoringServiceStubSettings(Builder settingsBuilder) throws I settingsBuilder.deleteServiceLevelObjectiveSettings().build(); } - private static final PagedListDescriptor - LIST_SERVICES_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListServicesRequest injectToken(ListServicesRequest payload, String token) { - return ListServicesRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListServicesRequest injectPageSize(ListServicesRequest payload, int pageSize) { - return ListServicesRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListServicesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListServicesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListServicesResponse payload) { - return payload.getServicesList() != null - ? payload.getServicesList() - : ImmutableList.of(); - } - }; - - private static final PagedListDescriptor< - ListServiceLevelObjectivesRequest, - ListServiceLevelObjectivesResponse, - ServiceLevelObjective> - LIST_SERVICE_LEVEL_OBJECTIVES_PAGE_STR_DESC = - new PagedListDescriptor< - ListServiceLevelObjectivesRequest, - ListServiceLevelObjectivesResponse, - ServiceLevelObjective>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListServiceLevelObjectivesRequest injectToken( - ListServiceLevelObjectivesRequest payload, String token) { - return ListServiceLevelObjectivesRequest.newBuilder(payload) - .setPageToken(token) - .build(); - } - - @Override - public ListServiceLevelObjectivesRequest injectPageSize( - ListServiceLevelObjectivesRequest payload, int pageSize) { - return ListServiceLevelObjectivesRequest.newBuilder(payload) - .setPageSize(pageSize) - .build(); - } - - @Override - public Integer extractPageSize(ListServiceLevelObjectivesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListServiceLevelObjectivesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources( - ListServiceLevelObjectivesResponse payload) { - return payload.getServiceLevelObjectivesList() != null - ? payload.getServiceLevelObjectivesList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListServicesRequest, ListServicesResponse, ListServicesPagedResponse> - LIST_SERVICES_PAGE_STR_FACT = - new PagedListResponseFactory< - ListServicesRequest, ListServicesResponse, ListServicesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListServicesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_SERVICES_PAGE_STR_DESC, request, context); - return ListServicesPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - ListServiceLevelObjectivesRequest, - ListServiceLevelObjectivesResponse, - ListServiceLevelObjectivesPagedResponse> - LIST_SERVICE_LEVEL_OBJECTIVES_PAGE_STR_FACT = - new PagedListResponseFactory< - ListServiceLevelObjectivesRequest, - ListServiceLevelObjectivesResponse, - ListServiceLevelObjectivesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable - callable, - ListServiceLevelObjectivesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext< - ListServiceLevelObjectivesRequest, - ListServiceLevelObjectivesResponse, - ServiceLevelObjective> - pageContext = - PageContext.create( - callable, LIST_SERVICE_LEVEL_OBJECTIVES_PAGE_STR_DESC, request, context); - return ListServiceLevelObjectivesPagedResponse.createAsync( - pageContext, futureResponse); - } - }; - /** Builder for ServiceMonitoringServiceStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final UnaryCallSettings.Builder createServiceSettings; private final UnaryCallSettings.Builder getServiceSettings; private final PagedCallSettings.Builder< @@ -429,7 +431,6 @@ public static class Builder updateServiceLevelObjectiveSettings; private final UnaryCallSettings.Builder deleteServiceLevelObjectiveSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -437,48 +438,12 @@ public static class Builder ImmutableMap.Builder> definitions = ImmutableMap.builder(); definitions.put( - "retry_policy_1_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_2_codes", ImmutableSet.copyOf(Lists.newArrayList())); + "no_retry_5_codes", ImmutableSet.copyOf(Lists.newArrayList())); definitions.put( "retry_policy_6_codes", ImmutableSet.copyOf( Lists.newArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_3_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_3_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_2_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_4_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_4_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_6_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_5_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_5_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -487,35 +452,6 @@ public static class Builder static { ImmutableMap.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(12000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(12000L)) - .setTotalTimeout(Duration.ofMillis(12000L)) - .build(); - definitions.put("no_retry_3_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_6_params", settings); - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_1_params", settings); settings = RetrySettings.newBuilder() .setInitialRpcTimeout(Duration.ofMillis(30000L)) @@ -524,63 +460,6 @@ public static class Builder .setTotalTimeout(Duration.ofMillis(30000L)) .build(); definitions.put("no_retry_5_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_2_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_4_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_6_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_1_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_2_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_3_params", settings); settings = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofMillis(100L)) @@ -591,47 +470,27 @@ public static class Builder .setMaxRpcTimeout(Duration.ofMillis(30000L)) .setTotalTimeout(Duration.ofMillis(30000L)) .build(); - definitions.put("retry_policy_5_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_4_params", settings); + definitions.put("retry_policy_6_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } protected Builder() { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(clientContext); createServiceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - getServiceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - listServicesSettings = PagedCallSettings.newBuilder(LIST_SERVICES_PAGE_STR_FACT); - updateServiceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - deleteServiceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - createServiceLevelObjectiveSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - getServiceLevelObjectiveSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - listServiceLevelObjectivesSettings = PagedCallSettings.newBuilder(LIST_SERVICE_LEVEL_OBJECTIVES_PAGE_STR_FACT); - updateServiceLevelObjectiveSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - deleteServiceLevelObjectiveSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = @@ -646,106 +505,106 @@ protected Builder(ClientContext clientContext) { listServiceLevelObjectivesSettings, updateServiceLevelObjectiveSettings, deleteServiceLevelObjectiveSettings); - initDefaults(this); } + protected Builder(ServiceMonitoringServiceStubSettings settings) { + super(settings); + + createServiceSettings = settings.createServiceSettings.toBuilder(); + getServiceSettings = settings.getServiceSettings.toBuilder(); + listServicesSettings = settings.listServicesSettings.toBuilder(); + updateServiceSettings = settings.updateServiceSettings.toBuilder(); + deleteServiceSettings = settings.deleteServiceSettings.toBuilder(); + createServiceLevelObjectiveSettings = + settings.createServiceLevelObjectiveSettings.toBuilder(); + getServiceLevelObjectiveSettings = settings.getServiceLevelObjectiveSettings.toBuilder(); + listServiceLevelObjectivesSettings = settings.listServiceLevelObjectivesSettings.toBuilder(); + updateServiceLevelObjectiveSettings = + settings.updateServiceLevelObjectiveSettings.toBuilder(); + deleteServiceLevelObjectiveSettings = + settings.deleteServiceLevelObjectiveSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + createServiceSettings, + getServiceSettings, + listServicesSettings, + updateServiceSettings, + deleteServiceSettings, + createServiceLevelObjectiveSettings, + getServiceLevelObjectiveSettings, + listServiceLevelObjectivesSettings, + updateServiceLevelObjectiveSettings, + deleteServiceLevelObjectiveSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + 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 .createServiceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_4_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_4_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_5_params")); builder .getServiceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); builder .listServicesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); builder .updateServiceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_4_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_4_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_5_params")); builder .deleteServiceSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); builder .createServiceLevelObjectiveSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_4_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_4_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_5_params")); builder .getServiceLevelObjectiveSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); builder .listServiceLevelObjectivesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); builder .updateServiceLevelObjectiveSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_4_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_4_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_5_params")); builder .deleteServiceLevelObjectiveSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params")); return builder; } - protected Builder(ServiceMonitoringServiceStubSettings settings) { - super(settings); - - createServiceSettings = settings.createServiceSettings.toBuilder(); - getServiceSettings = settings.getServiceSettings.toBuilder(); - listServicesSettings = settings.listServicesSettings.toBuilder(); - updateServiceSettings = settings.updateServiceSettings.toBuilder(); - deleteServiceSettings = settings.deleteServiceSettings.toBuilder(); - createServiceLevelObjectiveSettings = - settings.createServiceLevelObjectiveSettings.toBuilder(); - getServiceLevelObjectiveSettings = settings.getServiceLevelObjectiveSettings.toBuilder(); - listServiceLevelObjectivesSettings = settings.listServiceLevelObjectivesSettings.toBuilder(); - updateServiceLevelObjectiveSettings = - settings.updateServiceLevelObjectiveSettings.toBuilder(); - deleteServiceLevelObjectiveSettings = - settings.deleteServiceLevelObjectiveSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - createServiceSettings, - getServiceSettings, - listServicesSettings, - updateServiceSettings, - deleteServiceSettings, - createServiceLevelObjectiveSettings, - getServiceLevelObjectiveSettings, - listServiceLevelObjectivesSettings, - updateServiceLevelObjectiveSettings, - deleteServiceLevelObjectiveSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java index fbde4c1b..a93469d3 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,12 +13,12 @@ * 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; @@ -33,14 +33,13 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Monitoring API. + * Base stub class for the UptimeCheckService service 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 diff --git a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java index 2c8fbec6..ed25592a 100644 --- a/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java +++ b/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/stub/UptimeCheckServiceStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -60,7 +61,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link UptimeCheckServiceStub}. * @@ -77,21 +78,24 @@ * *

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

- * 
+ * 
{@code
  * UptimeCheckServiceStubSettings.Builder uptimeCheckServiceSettingsBuilder =
  *     UptimeCheckServiceStubSettings.newBuilder();
  * uptimeCheckServiceSettingsBuilder
  *     .getUptimeCheckConfigSettings()
  *     .setRetrySettings(
- *         uptimeCheckServiceSettingsBuilder.getUptimeCheckConfigSettings().getRetrySettings().toBuilder()
+ *         uptimeCheckServiceSettingsBuilder
+ *             .getUptimeCheckConfigSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * UptimeCheckServiceStubSettings uptimeCheckServiceSettings = uptimeCheckServiceSettingsBuilder.build();
- * 
- * 
+ * UptimeCheckServiceStubSettings uptimeCheckServiceSettings = + * uptimeCheckServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public class UptimeCheckServiceStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -99,7 +103,6 @@ public class UptimeCheckServiceStubSettings extends StubSettings 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 = @@ -273,9 +159,9 @@ public String extractNextToken(ListUptimeCheckConfigsResponse payload) { @Override public Iterable extractResources( ListUptimeCheckConfigsResponse payload) { - return payload.getUptimeCheckConfigsList() != null - ? payload.getUptimeCheckConfigsList() - : ImmutableList.of(); + return payload.getUptimeCheckConfigsList() == null + ? ImmutableList.of() + : payload.getUptimeCheckConfigsList(); } }; @@ -313,9 +199,9 @@ public String extractNextToken(ListUptimeCheckIpsResponse payload) { @Override public Iterable extractResources(ListUptimeCheckIpsResponse payload) { - return payload.getUptimeCheckIpsList() != null - ? payload.getUptimeCheckIpsList() - : ImmutableList.of(); + return payload.getUptimeCheckIpsList() == null + ? ImmutableList.of() + : payload.getUptimeCheckIpsList(); } }; @@ -367,11 +253,127 @@ public ApiFuture getFuturePagedResponse( } }; + /** 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); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", 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(); + } + /** Builder for UptimeCheckServiceStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final PagedCallSettings.Builder< ListUptimeCheckConfigsRequest, ListUptimeCheckConfigsResponse, @@ -388,7 +390,6 @@ public static class Builder private final PagedCallSettings.Builder< ListUptimeCheckIpsRequest, ListUptimeCheckIpsResponse, ListUptimeCheckIpsPagedResponse> listUptimeCheckIpsSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -396,48 +397,12 @@ public static class Builder ImmutableMap.Builder> definitions = ImmutableMap.builder(); definitions.put( - "retry_policy_1_codes", + "retry_policy_7_codes", ImmutableSet.copyOf( Lists.newArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); definitions.put( - "no_retry_2_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_6_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_3_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_3_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_2_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_4_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_4_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_6_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "retry_policy_5_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "no_retry_5_codes", ImmutableSet.copyOf(Lists.newArrayList())); + "no_retry_11_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -446,14 +411,6 @@ public static class Builder static { ImmutableMap.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(12000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(12000L)) - .setTotalTimeout(Duration.ofMillis(12000L)) - .build(); - definitions.put("no_retry_3_params", settings); settings = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.ofMillis(100L)) @@ -464,17 +421,7 @@ public static class Builder .setMaxRpcTimeout(Duration.ofMillis(30000L)) .setTotalTimeout(Duration.ofMillis(30000L)) .build(); - definitions.put("retry_policy_6_params", settings); - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_1_params", settings); + definitions.put("retry_policy_7_params", settings); settings = RetrySettings.newBuilder() .setInitialRpcTimeout(Duration.ofMillis(30000L)) @@ -482,91 +429,12 @@ public static class Builder .setMaxRpcTimeout(Duration.ofMillis(30000L)) .setTotalTimeout(Duration.ofMillis(30000L)) .build(); - definitions.put("no_retry_5_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_2_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_4_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("no_retry_6_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_1_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_2_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_3_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_5_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(30000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) - .build(); - definitions.put("retry_policy_4_params", settings); + definitions.put("no_retry_11_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } protected Builder() { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { @@ -574,15 +442,10 @@ protected Builder(ClientContext 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); @@ -594,75 +457,75 @@ protected Builder(ClientContext clientContext) { updateUptimeCheckConfigSettings, deleteUptimeCheckConfigSettings, listUptimeCheckIpsSettings); - initDefaults(this); } + 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); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + 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("retry_policy_4_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_7_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_7_params")); builder .getUptimeCheckConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_7_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_7_params")); builder .createUptimeCheckConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_6_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_6_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_11_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_11_params")); builder .updateUptimeCheckConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_6_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_6_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_11_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_11_params")); builder .deleteUptimeCheckConfigSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_7_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_7_params")); builder .listUptimeCheckIpsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_7_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_7_params")); 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' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java index 5de2f150..e336f108 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -24,27 +25,32 @@ 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.api.resourcenames.ResourceName; 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.FolderName; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; +import com.google.monitoring.v3.MutationRecord; +import com.google.monitoring.v3.OrganizationName; import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.AbstractMessage; +import com.google.protobuf.BoolValue; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; -import io.grpc.Status; +import com.google.rpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.UUID; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -52,48 +58,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class AlertPolicyServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; - private static MockServiceMonitoringService mockServiceMonitoringService; - private static MockUptimeCheckService mockUptimeCheckService; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private AlertPolicyServiceClient client; + private static MockAlertPolicyService mockAlertPolicyService; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockAlertPolicyService = new MockAlertPolicyService(); - mockGroupService = new MockGroupService(); - mockMetricService = new MockMetricService(); - mockNotificationChannelService = new MockNotificationChannelService(); - mockServiceMonitoringService = new MockServiceMonitoringService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( - UUID.randomUUID().toString(), - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockServiceMonitoringService, - mockUptimeCheckService)); - serviceHelper.start(); + UUID.randomUUID().toString(), Arrays.asList(mockAlertPolicyService)); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); AlertPolicyServiceSettings settings = AlertPolicyServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -108,31 +97,29 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void listAlertPoliciesTest() { - String nextPageToken = ""; - AlertPolicy alertPoliciesElement = AlertPolicy.newBuilder().build(); - List alertPolicies = Arrays.asList(alertPoliciesElement); + public void listAlertPoliciesTest() throws Exception { + AlertPolicy responsesElement = AlertPolicy.newBuilder().build(); ListAlertPoliciesResponse expectedResponse = ListAlertPoliciesResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllAlertPolicies(alertPolicies) + .setNextPageToken("") + .addAllAlertPolicies(Arrays.asList(responsesElement)) .build(); mockAlertPolicyService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); 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); + ListAlertPoliciesRequest actualRequest = ((ListAlertPoliciesRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -140,28 +127,166 @@ public void listAlertPoliciesTest() { } @Test - @SuppressWarnings("all") public void listAlertPoliciesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAlertPolicyService.addException(exception); + + try { + FolderName name = FolderName.of("[FOLDER]"); + client.listAlertPolicies(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAlertPoliciesTest2() throws Exception { + AlertPolicy responsesElement = AlertPolicy.newBuilder().build(); + ListAlertPoliciesResponse expectedResponse = + ListAlertPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllAlertPolicies(Arrays.asList(responsesElement)) + .build(); + mockAlertPolicyService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + + 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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listAlertPoliciesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAlertPolicyService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + client.listAlertPolicies(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAlertPoliciesTest3() throws Exception { + AlertPolicy responsesElement = AlertPolicy.newBuilder().build(); + ListAlertPoliciesResponse expectedResponse = + ListAlertPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllAlertPolicies(Arrays.asList(responsesElement)) + .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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listAlertPoliciesExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockAlertPolicyService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + ProjectName name = ProjectName.of("[PROJECT]"); + client.listAlertPolicies(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAlertPoliciesTest4() throws Exception { + AlertPolicy responsesElement = AlertPolicy.newBuilder().build(); + ListAlertPoliciesResponse expectedResponse = + ListAlertPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllAlertPolicies(Arrays.asList(responsesElement)) + .build(); + mockAlertPolicyService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listAlertPoliciesExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAlertPolicyService.addException(exception); + + try { + String name = "name3373707"; client.listAlertPolicies(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getAlertPolicyTest() { - AlertPolicyName name2 = AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); - String displayName = "displayName1615086568"; + public void getAlertPolicyTest() throws Exception { AlertPolicy expectedResponse = - AlertPolicy.newBuilder().setName(name2.toString()).setDisplayName(displayName).build(); + AlertPolicy.newBuilder() + .setName( + AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()) + .setDisplayName("displayName1714148973") + .putAllUserLabels(new HashMap()) + .addAllConditions(new ArrayList()) + .setEnabled(BoolValue.newBuilder().build()) + .setValidity(Status.newBuilder().build()) + .addAllNotificationChannels(new ArrayList()) + .setCreationRecord(MutationRecord.newBuilder().build()) + .setMutationRecord(MutationRecord.newBuilder().build()) + .build(); mockAlertPolicyService.addResponse(expectedResponse); AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); @@ -171,9 +296,9 @@ public void getAlertPolicyTest() { List actualRequests = mockAlertPolicyService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetAlertPolicyRequest actualRequest = (GetAlertPolicyRequest) actualRequests.get(0); + GetAlertPolicyRequest actualRequest = ((GetAlertPolicyRequest) actualRequests.get(0)); - Assert.assertEquals(name, AlertPolicyName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -181,32 +306,85 @@ public void getAlertPolicyTest() { } @Test - @SuppressWarnings("all") public void getAlertPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockAlertPolicyService.addException(exception); try { AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); + client.getAlertPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAlertPolicyTest2() throws Exception { + AlertPolicy expectedResponse = + AlertPolicy.newBuilder() + .setName( + AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()) + .setDisplayName("displayName1714148973") + .putAllUserLabels(new HashMap()) + .addAllConditions(new ArrayList()) + .setEnabled(BoolValue.newBuilder().build()) + .setValidity(Status.newBuilder().build()) + .addAllNotificationChannels(new ArrayList()) + .setCreationRecord(MutationRecord.newBuilder().build()) + .setMutationRecord(MutationRecord.newBuilder().build()) + .build(); + mockAlertPolicyService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + @Test + public void getAlertPolicyExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAlertPolicyService.addException(exception); + + try { + String name = "name3373707"; client.getAlertPolicy(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void createAlertPolicyTest() { - AlertPolicyName name2 = AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); - String displayName = "displayName1615086568"; + public void createAlertPolicyTest() throws Exception { AlertPolicy expectedResponse = - AlertPolicy.newBuilder().setName(name2.toString()).setDisplayName(displayName).build(); + AlertPolicy.newBuilder() + .setName( + AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()) + .setDisplayName("displayName1714148973") + .putAllUserLabels(new HashMap()) + .addAllConditions(new ArrayList()) + .setEnabled(BoolValue.newBuilder().build()) + .setValidity(Status.newBuilder().build()) + .addAllNotificationChannels(new ArrayList()) + .setCreationRecord(MutationRecord.newBuilder().build()) + .setMutationRecord(MutationRecord.newBuilder().build()) + .build(); mockAlertPolicyService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); AlertPolicy alertPolicy = AlertPolicy.newBuilder().build(); AlertPolicy actualResponse = client.createAlertPolicy(name, alertPolicy); @@ -214,9 +392,9 @@ public void createAlertPolicyTest() { List actualRequests = mockAlertPolicyService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateAlertPolicyRequest actualRequest = (CreateAlertPolicyRequest) actualRequests.get(0); + CreateAlertPolicyRequest actualRequest = ((CreateAlertPolicyRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -225,25 +403,172 @@ public void createAlertPolicyTest() { } @Test - @SuppressWarnings("all") public void createAlertPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockAlertPolicyService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); AlertPolicy alertPolicy = AlertPolicy.newBuilder().build(); + client.createAlertPolicy(name, alertPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createAlertPolicyTest2() throws Exception { + AlertPolicy expectedResponse = + AlertPolicy.newBuilder() + .setName( + AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()) + .setDisplayName("displayName1714148973") + .putAllUserLabels(new HashMap()) + .addAllConditions(new ArrayList()) + .setEnabled(BoolValue.newBuilder().build()) + .setValidity(Status.newBuilder().build()) + .addAllNotificationChannels(new ArrayList()) + .setCreationRecord(MutationRecord.newBuilder().build()) + .setMutationRecord(MutationRecord.newBuilder().build()) + .build(); + mockAlertPolicyService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + 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.toString(), actualRequest.getName()); + Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + @Test + public void createAlertPolicyExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAlertPolicyService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + AlertPolicy alertPolicy = AlertPolicy.newBuilder().build(); client.createAlertPolicy(name, alertPolicy); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteAlertPolicyTest() { + public void createAlertPolicyTest3() throws Exception { + AlertPolicy expectedResponse = + AlertPolicy.newBuilder() + .setName( + AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()) + .setDisplayName("displayName1714148973") + .putAllUserLabels(new HashMap()) + .addAllConditions(new ArrayList()) + .setEnabled(BoolValue.newBuilder().build()) + .setValidity(Status.newBuilder().build()) + .addAllNotificationChannels(new ArrayList()) + .setCreationRecord(MutationRecord.newBuilder().build()) + .setMutationRecord(MutationRecord.newBuilder().build()) + .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.toString(), actualRequest.getName()); + Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createAlertPolicyExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + public void createAlertPolicyTest4() throws Exception { + AlertPolicy expectedResponse = + AlertPolicy.newBuilder() + .setName( + AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()) + .setDisplayName("displayName1714148973") + .putAllUserLabels(new HashMap()) + .addAllConditions(new ArrayList()) + .setEnabled(BoolValue.newBuilder().build()) + .setValidity(Status.newBuilder().build()) + .addAllNotificationChannels(new ArrayList()) + .setCreationRecord(MutationRecord.newBuilder().build()) + .setMutationRecord(MutationRecord.newBuilder().build()) + .build(); + mockAlertPolicyService.addResponse(expectedResponse); + + String name = "name3373707"; + 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, actualRequest.getName()); + Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createAlertPolicyExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAlertPolicyService.addException(exception); + + try { + String name = "name3373707"; + AlertPolicy alertPolicy = AlertPolicy.newBuilder().build(); + client.createAlertPolicy(name, alertPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAlertPolicyTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockAlertPolicyService.addResponse(expectedResponse); @@ -253,9 +578,9 @@ public void deleteAlertPolicyTest() { List actualRequests = mockAlertPolicyService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - DeleteAlertPolicyRequest actualRequest = (DeleteAlertPolicyRequest) actualRequests.get(0); + DeleteAlertPolicyRequest actualRequest = ((DeleteAlertPolicyRequest) actualRequests.get(0)); - Assert.assertEquals(name, AlertPolicyName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -263,29 +588,69 @@ public void deleteAlertPolicyTest() { } @Test - @SuppressWarnings("all") public void deleteAlertPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockAlertPolicyService.addException(exception); try { AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); + client.deleteAlertPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void deleteAlertPolicyTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockAlertPolicyService.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteAlertPolicy(name); + + List actualRequests = mockAlertPolicyService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteAlertPolicyRequest actualRequest = ((DeleteAlertPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteAlertPolicyExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAlertPolicyService.addException(exception); + + try { + String name = "name3373707"; client.deleteAlertPolicy(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void updateAlertPolicyTest() { - AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]"); - String displayName = "displayName1615086568"; + public void updateAlertPolicyTest() throws Exception { AlertPolicy expectedResponse = - AlertPolicy.newBuilder().setName(name.toString()).setDisplayName(displayName).build(); + AlertPolicy.newBuilder() + .setName( + AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()) + .setDisplayName("displayName1714148973") + .putAllUserLabels(new HashMap()) + .addAllConditions(new ArrayList()) + .setEnabled(BoolValue.newBuilder().build()) + .setValidity(Status.newBuilder().build()) + .addAllNotificationChannels(new ArrayList()) + .setCreationRecord(MutationRecord.newBuilder().build()) + .setMutationRecord(MutationRecord.newBuilder().build()) + .build(); mockAlertPolicyService.addResponse(expectedResponse); FieldMask updateMask = FieldMask.newBuilder().build(); @@ -296,7 +661,7 @@ public void updateAlertPolicyTest() { List actualRequests = mockAlertPolicyService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - UpdateAlertPolicyRequest actualRequest = (UpdateAlertPolicyRequest) actualRequests.get(0); + UpdateAlertPolicyRequest actualRequest = ((UpdateAlertPolicyRequest) actualRequests.get(0)); Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy()); @@ -307,19 +672,17 @@ public void updateAlertPolicyTest() { } @Test - @SuppressWarnings("all") public void updateAlertPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + // Expected exception. } } } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java index 13315a40..c2bb623e 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -26,10 +27,10 @@ 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.api.resourcenames.ResourceName; import com.google.common.collect.Lists; import com.google.monitoring.v3.CreateGroupRequest; import com.google.monitoring.v3.DeleteGroupRequest; +import com.google.monitoring.v3.FolderName; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; import com.google.monitoring.v3.GroupName; @@ -37,17 +38,17 @@ import com.google.monitoring.v3.ListGroupMembersResponse; import com.google.monitoring.v3.ListGroupsRequest; import com.google.monitoring.v3.ListGroupsResponse; +import com.google.monitoring.v3.OrganizationName; 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 java.util.Objects; import java.util.UUID; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -55,48 +56,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class GroupServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; - private static MockServiceMonitoringService mockServiceMonitoringService; - private static MockUptimeCheckService mockUptimeCheckService; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private GroupServiceClient client; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { - mockAlertPolicyService = new MockAlertPolicyService(); mockGroupService = new MockGroupService(); - mockMetricService = new MockMetricService(); - mockNotificationChannelService = new MockNotificationChannelService(); - mockServiceMonitoringService = new MockServiceMonitoringService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( - UUID.randomUUID().toString(), - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockServiceMonitoringService, - mockUptimeCheckService)); - serviceHelper.start(); + UUID.randomUUID().toString(), Arrays.asList(mockGroupService)); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); GroupServiceSettings settings = GroupServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -111,28 +95,29 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void listGroupsTest() { - String nextPageToken = ""; - Group groupElement = Group.newBuilder().build(); - List group = Arrays.asList(groupElement); + public void listGroupsTest() throws Exception { + Group responsesElement = Group.newBuilder().build(); ListGroupsResponse expectedResponse = - ListGroupsResponse.newBuilder().setNextPageToken(nextPageToken).addAllGroup(group).build(); + ListGroupsResponse.newBuilder() + .setNextPageToken("") + .addAllGroup(Arrays.asList(responsesElement)) + .build(); mockGroupService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); 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); + ListGroupsRequest actualRequest = ((ListGroupsRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -140,36 +125,160 @@ public void listGroupsTest() { } @Test - @SuppressWarnings("all") public void listGroupsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockGroupService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); + client.listGroups(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listGroupsTest2() throws Exception { + Group responsesElement = Group.newBuilder().build(); + ListGroupsResponse expectedResponse = + ListGroupsResponse.newBuilder() + .setNextPageToken("") + .addAllGroup(Arrays.asList(responsesElement)) + .build(); + mockGroupService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + + 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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listGroupsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockGroupService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); client.listGroups(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getGroupTest() { - GroupName name2 = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]"); - String displayName = "displayName1615086568"; - String parentName = "parentName1015022848"; - String filter = "filter-1274492040"; - boolean isCluster = false; + public void listGroupsTest3() throws Exception { + Group responsesElement = Group.newBuilder().build(); + ListGroupsResponse expectedResponse = + ListGroupsResponse.newBuilder() + .setNextPageToken("") + .addAllGroup(Arrays.asList(responsesElement)) + .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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listGroupsExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + public void listGroupsTest4() throws Exception { + Group responsesElement = Group.newBuilder().build(); + ListGroupsResponse expectedResponse = + ListGroupsResponse.newBuilder() + .setNextPageToken("") + .addAllGroup(Arrays.asList(responsesElement)) + .build(); + mockGroupService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listGroupsExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockGroupService.addException(exception); + + try { + String name = "name3373707"; + client.listGroups(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGroupTest() throws Exception { Group expectedResponse = Group.newBuilder() - .setName(name2.toString()) - .setDisplayName(displayName) - .setParentName(parentName) - .setFilter(filter) - .setIsCluster(isCluster) + .setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()) + .setDisplayName("displayName1714148973") + .setParentName("parentName-244870571") + .setFilter("filter-1274492040") + .setIsCluster(true) .build(); mockGroupService.addResponse(expectedResponse); @@ -180,9 +289,9 @@ public void getGroupTest() { List actualRequests = mockGroupService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetGroupRequest actualRequest = (GetGroupRequest) actualRequests.get(0); + GetGroupRequest actualRequest = ((GetGroupRequest) actualRequests.get(0)); - Assert.assertEquals(name, GroupName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -190,40 +299,74 @@ public void getGroupTest() { } @Test - @SuppressWarnings("all") public void getGroupExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockGroupService.addException(exception); try { GroupName name = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]"); + client.getGroup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGroupTest2() throws Exception { + Group expectedResponse = + Group.newBuilder() + .setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()) + .setDisplayName("displayName1714148973") + .setParentName("parentName-244870571") + .setFilter("filter-1274492040") + .setIsCluster(true) + .build(); + mockGroupService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getGroupExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockGroupService.addException(exception); + + try { + String name = "name3373707"; client.getGroup(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void createGroupTest() { - GroupName name2 = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]"); - String displayName = "displayName1615086568"; - String parentName = "parentName1015022848"; - String filter = "filter-1274492040"; - boolean isCluster = false; + public void createGroupTest() throws Exception { Group expectedResponse = Group.newBuilder() - .setName(name2.toString()) - .setDisplayName(displayName) - .setParentName(parentName) - .setFilter(filter) - .setIsCluster(isCluster) + .setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()) + .setDisplayName("displayName1714148973") + .setParentName("parentName-244870571") + .setFilter("filter-1274492040") + .setIsCluster(true) .build(); mockGroupService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); Group group = Group.newBuilder().build(); Group actualResponse = client.createGroup(name, group); @@ -231,9 +374,9 @@ public void createGroupTest() { List actualRequests = mockGroupService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateGroupRequest actualRequest = (CreateGroupRequest) actualRequests.get(0); + CreateGroupRequest actualRequest = ((CreateGroupRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertEquals(group, actualRequest.getGroup()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -242,37 +385,164 @@ public void createGroupTest() { } @Test - @SuppressWarnings("all") public void createGroupExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockGroupService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); Group group = Group.newBuilder().build(); + client.createGroup(name, group); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void createGroupTest2() throws Exception { + Group expectedResponse = + Group.newBuilder() + .setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()) + .setDisplayName("displayName1714148973") + .setParentName("parentName-244870571") + .setFilter("filter-1274492040") + .setIsCluster(true) + .build(); + mockGroupService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + 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.toString(), actualRequest.getName()); + Assert.assertEquals(group, actualRequest.getGroup()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createGroupExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockGroupService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + Group group = Group.newBuilder().build(); client.createGroup(name, group); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void updateGroupTest() { - GroupName name = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]"); - String displayName = "displayName1615086568"; - String parentName = "parentName1015022848"; - String filter = "filter-1274492040"; - boolean isCluster = false; + public void createGroupTest3() throws Exception { + Group expectedResponse = + Group.newBuilder() + .setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()) + .setDisplayName("displayName1714148973") + .setParentName("parentName-244870571") + .setFilter("filter-1274492040") + .setIsCluster(true) + .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.toString(), actualRequest.getName()); + Assert.assertEquals(group, actualRequest.getGroup()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createGroupExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + public void createGroupTest4() throws Exception { + Group expectedResponse = + Group.newBuilder() + .setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()) + .setDisplayName("displayName1714148973") + .setParentName("parentName-244870571") + .setFilter("filter-1274492040") + .setIsCluster(true) + .build(); + mockGroupService.addResponse(expectedResponse); + + String name = "name3373707"; + 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, actualRequest.getName()); + Assert.assertEquals(group, actualRequest.getGroup()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createGroupExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockGroupService.addException(exception); + + try { + String name = "name3373707"; + Group group = Group.newBuilder().build(); + client.createGroup(name, group); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateGroupTest() throws Exception { Group expectedResponse = Group.newBuilder() - .setName(name.toString()) - .setDisplayName(displayName) - .setParentName(parentName) - .setFilter(filter) - .setIsCluster(isCluster) + .setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()) + .setDisplayName("displayName1714148973") + .setParentName("parentName-244870571") + .setFilter("filter-1274492040") + .setIsCluster(true) .build(); mockGroupService.addResponse(expectedResponse); @@ -283,7 +553,7 @@ public void updateGroupTest() { List actualRequests = mockGroupService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - UpdateGroupRequest actualRequest = (UpdateGroupRequest) actualRequests.get(0); + UpdateGroupRequest actualRequest = ((UpdateGroupRequest) actualRequests.get(0)); Assert.assertEquals(group, actualRequest.getGroup()); Assert.assertTrue( @@ -293,24 +563,21 @@ public void updateGroupTest() { } @Test - @SuppressWarnings("all") public void updateGroupExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteGroupTest() { + public void deleteGroupTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockGroupService.addResponse(expectedResponse); @@ -320,9 +587,9 @@ public void deleteGroupTest() { List actualRequests = mockGroupService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - DeleteGroupRequest actualRequest = (DeleteGroupRequest) actualRequests.get(0); + DeleteGroupRequest actualRequest = ((DeleteGroupRequest) actualRequests.get(0)); - Assert.assertEquals(name, GroupName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -330,33 +597,60 @@ public void deleteGroupTest() { } @Test - @SuppressWarnings("all") public void deleteGroupExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockGroupService.addException(exception); try { GroupName name = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]"); + client.deleteGroup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteGroupTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockGroupService.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteGroup(name); + + List actualRequests = mockGroupService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteGroupRequest actualRequest = ((DeleteGroupRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteGroupExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockGroupService.addException(exception); + try { + String name = "name3373707"; client.deleteGroup(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listGroupMembersTest() { - String nextPageToken = ""; - int totalSize = 705419236; - MonitoredResource membersElement = MonitoredResource.newBuilder().build(); - List members = Arrays.asList(membersElement); + public void listGroupMembersTest() throws Exception { + MonitoredResource responsesElement = MonitoredResource.newBuilder().build(); ListGroupMembersResponse expectedResponse = ListGroupMembersResponse.newBuilder() - .setNextPageToken(nextPageToken) - .setTotalSize(totalSize) - .addAllMembers(members) + .setNextPageToken("") + .addAllMembers(Arrays.asList(responsesElement)) .build(); mockGroupService.addResponse(expectedResponse); @@ -365,14 +659,15 @@ public void listGroupMembersTest() { 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); + ListGroupMembersRequest actualRequest = ((ListGroupMembersRequest) actualRequests.get(0)); - Assert.assertEquals(name, GroupName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -380,18 +675,60 @@ public void listGroupMembersTest() { } @Test - @SuppressWarnings("all") public void listGroupMembersExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockGroupService.addException(exception); try { GroupName name = GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]"); + client.listGroupMembers(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listGroupMembersTest2() throws Exception { + MonitoredResource responsesElement = MonitoredResource.newBuilder().build(); + ListGroupMembersResponse expectedResponse = + ListGroupMembersResponse.newBuilder() + .setNextPageToken("") + .addAllMembers(Arrays.asList(responsesElement)) + .build(); + mockGroupService.addResponse(expectedResponse); + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listGroupMembersExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockGroupService.addException(exception); + + try { + String name = "name3373707"; client.listGroupMembers(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java index d1d3b6b2..28006a31 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,12 +13,14 @@ * 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.LabelDescriptor; import com.google.api.MetricDescriptor; import com.google.api.MonitoredResourceDescriptor; import com.google.api.gax.core.NoCredentialsProvider; @@ -28,11 +30,11 @@ 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.api.resourcenames.ResourceName; 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.FolderName; import com.google.monitoring.v3.GetMetricDescriptorRequest; import com.google.monitoring.v3.GetMonitoredResourceDescriptorRequest; import com.google.monitoring.v3.ListMetricDescriptorsRequest; @@ -43,19 +45,19 @@ import com.google.monitoring.v3.ListTimeSeriesResponse; import com.google.monitoring.v3.MetricDescriptorName; import com.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.monitoring.v3.OrganizationName; 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 java.util.Objects; import java.util.UUID; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -63,48 +65,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class MetricServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; - private static MockServiceMonitoringService mockServiceMonitoringService; - private static MockUptimeCheckService mockUptimeCheckService; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private MetricServiceClient client; + private static MockMetricService mockMetricService; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { - mockAlertPolicyService = new MockAlertPolicyService(); - mockGroupService = new MockGroupService(); mockMetricService = new MockMetricService(); - mockNotificationChannelService = new MockNotificationChannelService(); - mockServiceMonitoringService = new MockServiceMonitoringService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( - UUID.randomUUID().toString(), - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockServiceMonitoringService, - mockUptimeCheckService)); - serviceHelper.start(); + UUID.randomUUID().toString(), Arrays.asList(mockMetricService)); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); MetricServiceSettings settings = MetricServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -119,36 +104,32 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void listMonitoredResourceDescriptorsTest() { - String nextPageToken = ""; - MonitoredResourceDescriptor resourceDescriptorsElement = - MonitoredResourceDescriptor.newBuilder().build(); - List resourceDescriptors = - Arrays.asList(resourceDescriptorsElement); + public void listMonitoredResourceDescriptorsTest() throws Exception { + MonitoredResourceDescriptor responsesElement = MonitoredResourceDescriptor.newBuilder().build(); ListMonitoredResourceDescriptorsResponse expectedResponse = ListMonitoredResourceDescriptorsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllResourceDescriptors(resourceDescriptors) + .setNextPageToken("") + .addAllResourceDescriptors(Arrays.asList(responsesElement)) .build(); mockMetricService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); 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); + ((ListMonitoredResourceDescriptorsRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -156,34 +137,169 @@ public void listMonitoredResourceDescriptorsTest() { } @Test - @SuppressWarnings("all") public void listMonitoredResourceDescriptorsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + FolderName name = FolderName.of("[FOLDER]"); + client.listMonitoredResourceDescriptors(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMonitoredResourceDescriptorsTest2() throws Exception { + MonitoredResourceDescriptor responsesElement = MonitoredResourceDescriptor.newBuilder().build(); + ListMonitoredResourceDescriptorsResponse expectedResponse = + ListMonitoredResourceDescriptorsResponse.newBuilder() + .setNextPageToken("") + .addAllResourceDescriptors(Arrays.asList(responsesElement)) + .build(); + mockMetricService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + + 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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listMonitoredResourceDescriptorsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + client.listMonitoredResourceDescriptors(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMonitoredResourceDescriptorsTest3() throws Exception { + MonitoredResourceDescriptor responsesElement = MonitoredResourceDescriptor.newBuilder().build(); + ListMonitoredResourceDescriptorsResponse expectedResponse = + ListMonitoredResourceDescriptorsResponse.newBuilder() + .setNextPageToken("") + .addAllResourceDescriptors(Arrays.asList(responsesElement)) + .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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listMonitoredResourceDescriptorsExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockMetricService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + ProjectName name = ProjectName.of("[PROJECT]"); + client.listMonitoredResourceDescriptors(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listMonitoredResourceDescriptorsTest4() throws Exception { + MonitoredResourceDescriptor responsesElement = MonitoredResourceDescriptor.newBuilder().build(); + ListMonitoredResourceDescriptorsResponse expectedResponse = + ListMonitoredResourceDescriptorsResponse.newBuilder() + .setNextPageToken("") + .addAllResourceDescriptors(Arrays.asList(responsesElement)) + .build(); + mockMetricService.addResponse(expectedResponse); + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listMonitoredResourceDescriptorsExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + String name = "name3373707"; client.listMonitoredResourceDescriptors(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getMonitoredResourceDescriptorTest() { - String name2 = "name2-1052831874"; - String type = "type3575610"; - String displayName = "displayName1615086568"; - String description = "description-1724546052"; + public void getMonitoredResourceDescriptorTest() throws Exception { MonitoredResourceDescriptor expectedResponse = MonitoredResourceDescriptor.newBuilder() - .setName(name2) - .setType(type) - .setDisplayName(displayName) - .setDescription(description) + .setName("name3373707") + .setType("type3575610") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllLabels(new ArrayList()) .build(); mockMetricService.addResponse(expectedResponse); @@ -197,9 +313,9 @@ public void getMonitoredResourceDescriptorTest() { List actualRequests = mockMetricService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetMonitoredResourceDescriptorRequest actualRequest = - (GetMonitoredResourceDescriptorRequest) actualRequests.get(0); + ((GetMonitoredResourceDescriptorRequest) actualRequests.get(0)); - Assert.assertEquals(name, MonitoredResourceDescriptorName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -207,50 +323,89 @@ public void getMonitoredResourceDescriptorTest() { } @Test - @SuppressWarnings("all") public void getMonitoredResourceDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockMetricService.addException(exception); try { MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.ofProjectMonitoredResourceDescriptorName( "[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]"); + client.getMonitoredResourceDescriptor(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void getMonitoredResourceDescriptorTest2() throws Exception { + MonitoredResourceDescriptor expectedResponse = + MonitoredResourceDescriptor.newBuilder() + .setName("name3373707") + .setType("type3575610") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllLabels(new ArrayList()) + .build(); + mockMetricService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getMonitoredResourceDescriptorExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + String name = "name3373707"; client.getMonitoredResourceDescriptor(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listMetricDescriptorsTest() { - String nextPageToken = ""; - MetricDescriptor metricDescriptorsElement = MetricDescriptor.newBuilder().build(); - List metricDescriptors = Arrays.asList(metricDescriptorsElement); + public void listMetricDescriptorsTest() throws Exception { + MetricDescriptor responsesElement = MetricDescriptor.newBuilder().build(); ListMetricDescriptorsResponse expectedResponse = ListMetricDescriptorsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllMetricDescriptors(metricDescriptors) + .setNextPageToken("") + .addAllMetricDescriptors(Arrays.asList(responsesElement)) .build(); mockMetricService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); 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); + ((ListMetricDescriptorsRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -258,36 +413,165 @@ public void listMetricDescriptorsTest() { } @Test - @SuppressWarnings("all") public void listMetricDescriptorsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockMetricService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); + client.listMetricDescriptors(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void listMetricDescriptorsTest2() throws Exception { + MetricDescriptor responsesElement = MetricDescriptor.newBuilder().build(); + ListMetricDescriptorsResponse expectedResponse = + ListMetricDescriptorsResponse.newBuilder() + .setNextPageToken("") + .addAllMetricDescriptors(Arrays.asList(responsesElement)) + .build(); + mockMetricService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + + 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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listMetricDescriptorsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); client.listMetricDescriptors(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // 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"; + public void listMetricDescriptorsTest3() throws Exception { + MetricDescriptor responsesElement = MetricDescriptor.newBuilder().build(); + ListMetricDescriptorsResponse expectedResponse = + ListMetricDescriptorsResponse.newBuilder() + .setNextPageToken("") + .addAllMetricDescriptors(Arrays.asList(responsesElement)) + .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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listMetricDescriptorsExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + public void listMetricDescriptorsTest4() throws Exception { + MetricDescriptor responsesElement = MetricDescriptor.newBuilder().build(); + ListMetricDescriptorsResponse expectedResponse = + ListMetricDescriptorsResponse.newBuilder() + .setNextPageToken("") + .addAllMetricDescriptors(Arrays.asList(responsesElement)) + .build(); + mockMetricService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listMetricDescriptorsExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + String name = "name3373707"; + client.listMetricDescriptors(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getMetricDescriptorTest() throws Exception { MetricDescriptor expectedResponse = MetricDescriptor.newBuilder() - .setName(name2) - .setType(type) - .setUnit(unit) - .setDescription(description) - .setDisplayName(displayName) + .setName("name3373707") + .setType("type3575610") + .addAllLabels(new ArrayList()) + .setUnit("unit3594628") + .setDescription("description-1724546052") + .setDisplayName("displayName1714148973") + .addAllMonitoredResourceTypes(new ArrayList()) .build(); mockMetricService.addResponse(expectedResponse); @@ -299,9 +583,9 @@ public void getMetricDescriptorTest() { List actualRequests = mockMetricService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetMetricDescriptorRequest actualRequest = (GetMetricDescriptorRequest) actualRequests.get(0); + GetMetricDescriptorRequest actualRequest = ((GetMetricDescriptorRequest) actualRequests.get(0)); - Assert.assertEquals(name, MetricDescriptorName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -309,41 +593,79 @@ public void getMetricDescriptorTest() { } @Test - @SuppressWarnings("all") public void getMetricDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockMetricService.addException(exception); try { MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]"); + client.getMetricDescriptor(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getMetricDescriptorTest2() throws Exception { + MetricDescriptor expectedResponse = + MetricDescriptor.newBuilder() + .setName("name3373707") + .setType("type3575610") + .addAllLabels(new ArrayList()) + .setUnit("unit3594628") + .setDescription("description-1724546052") + .setDisplayName("displayName1714148973") + .addAllMonitoredResourceTypes(new ArrayList()) + .build(); + mockMetricService.addResponse(expectedResponse); + + String name = "name3373707"; + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getMetricDescriptorExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + String name = "name3373707"; client.getMetricDescriptor(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // 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"; + public void createMetricDescriptorTest() throws Exception { MetricDescriptor expectedResponse = MetricDescriptor.newBuilder() - .setName(name2) - .setType(type) - .setUnit(unit) - .setDescription(description) - .setDisplayName(displayName) + .setName("name3373707") + .setType("type3575610") + .addAllLabels(new ArrayList()) + .setUnit("unit3594628") + .setDescription("description-1724546052") + .setDisplayName("displayName1714148973") + .addAllMonitoredResourceTypes(new ArrayList()) .build(); mockMetricService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build(); MetricDescriptor actualResponse = client.createMetricDescriptor(name, metricDescriptor); @@ -352,9 +674,9 @@ public void createMetricDescriptorTest() { List actualRequests = mockMetricService.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateMetricDescriptorRequest actualRequest = - (CreateMetricDescriptorRequest) actualRequests.get(0); + ((CreateMetricDescriptorRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertEquals(metricDescriptor, actualRequest.getMetricDescriptor()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -363,25 +685,166 @@ public void createMetricDescriptorTest() { } @Test - @SuppressWarnings("all") public void createMetricDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockMetricService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build(); + client.createMetricDescriptor(name, metricDescriptor); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMetricDescriptorTest2() throws Exception { + MetricDescriptor expectedResponse = + MetricDescriptor.newBuilder() + .setName("name3373707") + .setType("type3575610") + .addAllLabels(new ArrayList()) + .setUnit("unit3594628") + .setDescription("description-1724546052") + .setDisplayName("displayName1714148973") + .addAllMonitoredResourceTypes(new ArrayList()) + .build(); + mockMetricService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + 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.toString(), actualRequest.getName()); + Assert.assertEquals(metricDescriptor, actualRequest.getMetricDescriptor()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createMetricDescriptorExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build(); + client.createMetricDescriptor(name, metricDescriptor); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createMetricDescriptorTest3() throws Exception { + MetricDescriptor expectedResponse = + MetricDescriptor.newBuilder() + .setName("name3373707") + .setType("type3575610") + .addAllLabels(new ArrayList()) + .setUnit("unit3594628") + .setDescription("description-1724546052") + .setDisplayName("displayName1714148973") + .addAllMonitoredResourceTypes(new ArrayList()) + .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.toString(), actualRequest.getName()); + Assert.assertEquals(metricDescriptor, actualRequest.getMetricDescriptor()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createMetricDescriptorExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + public void createMetricDescriptorTest4() throws Exception { + MetricDescriptor expectedResponse = + MetricDescriptor.newBuilder() + .setName("name3373707") + .setType("type3575610") + .addAllLabels(new ArrayList()) + .setUnit("unit3594628") + .setDescription("description-1724546052") + .setDisplayName("displayName1714148973") + .addAllMonitoredResourceTypes(new ArrayList()) + .build(); + mockMetricService.addResponse(expectedResponse); + + String name = "name3373707"; + 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, actualRequest.getName()); + Assert.assertEquals(metricDescriptor, actualRequest.getMetricDescriptor()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createMetricDescriptorExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + try { + String name = "name3373707"; + MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build(); client.createMetricDescriptor(name, metricDescriptor); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteMetricDescriptorTest() { + public void deleteMetricDescriptorTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockMetricService.addResponse(expectedResponse); @@ -393,9 +856,9 @@ public void deleteMetricDescriptorTest() { List actualRequests = mockMetricService.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteMetricDescriptorRequest actualRequest = - (DeleteMetricDescriptorRequest) actualRequests.get(0); + ((DeleteMetricDescriptorRequest) actualRequests.get(0)); - Assert.assertEquals(name, MetricDescriptorName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -403,52 +866,83 @@ public void deleteMetricDescriptorTest() { } @Test - @SuppressWarnings("all") public void deleteMetricDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockMetricService.addException(exception); try { MetricDescriptorName name = MetricDescriptorName.ofProjectMetricDescriptorName("[PROJECT]", "[METRIC_DESCRIPTOR]"); + client.deleteMetricDescriptor(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void deleteMetricDescriptorTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockMetricService.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteMetricDescriptor(name); + + List actualRequests = mockMetricService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteMetricDescriptorRequest actualRequest = + ((DeleteMetricDescriptorRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteMetricDescriptorExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + String name = "name3373707"; client.deleteMetricDescriptor(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listTimeSeriesTest() { - String nextPageToken = ""; - TimeSeries timeSeriesElement = TimeSeries.newBuilder().build(); - List timeSeries = Arrays.asList(timeSeriesElement); + public void listTimeSeriesTest() throws Exception { + TimeSeries responsesElement = TimeSeries.newBuilder().build(); ListTimeSeriesResponse expectedResponse = ListTimeSeriesResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllTimeSeries(timeSeries) + .setNextPageToken("") + .addAllTimeSeries(Arrays.asList(responsesElement)) .build(); mockMetricService.addResponse(expectedResponse); ProjectName name = ProjectName.of("[PROJECT]"); String filter = "filter-1274492040"; TimeInterval interval = TimeInterval.newBuilder().build(); - ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL; + ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0); 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); + ListTimeSeriesRequest actualRequest = ((ListTimeSeriesRequest) actualRequests.get(0)); - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertEquals(filter, actualRequest.getFilter()); Assert.assertEquals(interval, actualRequest.getInterval()); Assert.assertEquals(view, actualRequest.getView()); @@ -459,27 +953,78 @@ public void listTimeSeriesTest() { } @Test - @SuppressWarnings("all") public void listTimeSeriesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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; + ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0); + client.listTimeSeries(name, filter, interval, view); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void listTimeSeriesTest2() throws Exception { + TimeSeries responsesElement = TimeSeries.newBuilder().build(); + ListTimeSeriesResponse expectedResponse = + ListTimeSeriesResponse.newBuilder() + .setNextPageToken("") + .addAllTimeSeries(Arrays.asList(responsesElement)) + .build(); + mockMetricService.addResponse(expectedResponse); + + String name = "name3373707"; + String filter = "filter-1274492040"; + TimeInterval interval = TimeInterval.newBuilder().build(); + ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0); + + 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, 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 + public void listTimeSeriesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + String name = "name3373707"; + String filter = "filter-1274492040"; + TimeInterval interval = TimeInterval.newBuilder().build(); + ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0); client.listTimeSeries(name, filter, interval, view); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void createTimeSeriesTest() { + public void createTimeSeriesTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockMetricService.addResponse(expectedResponse); @@ -490,9 +1035,9 @@ public void createTimeSeriesTest() { List actualRequests = mockMetricService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateTimeSeriesRequest actualRequest = (CreateTimeSeriesRequest) actualRequests.get(0); + CreateTimeSeriesRequest actualRequest = ((CreateTimeSeriesRequest) actualRequests.get(0)); - Assert.assertEquals(name, ProjectName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertEquals(timeSeries, actualRequest.getTimeSeriesList()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -501,19 +1046,54 @@ public void createTimeSeriesTest() { } @Test - @SuppressWarnings("all") public void createTimeSeriesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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. + } + } + @Test + public void createTimeSeriesTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockMetricService.addResponse(expectedResponse); + + String name = "name3373707"; + 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, actualRequest.getName()); + Assert.assertEquals(timeSeries, actualRequest.getTimeSeriesList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createTimeSeriesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockMetricService.addException(exception); + + try { + String name = "name3373707"; + List timeSeries = new ArrayList<>(); client.createTimeSeries(name, timeSeries); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java deleted file mode 100644 index d3c0719c..00000000 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020 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.api.resourcenames.ResourceName; -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()) { - ResourceName 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/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyService.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyService.java index d36b3e40..05e59737 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyService.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockAlertPolicyService implements MockGrpcService { private final MockAlertPolicyServiceImpl serviceImpl; diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyServiceImpl.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyServiceImpl.java index 0d8f02ad..03c8d352 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyServiceImpl.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyServiceImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -31,9 +32,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockAlertPolicyServiceImpl extends AlertPolicyServiceImplBase { private List requests; private Queue responses; @@ -71,10 +73,10 @@ public void listAlertPolicies( Object response = responses.remove(); if (response instanceof ListAlertPoliciesResponse) { requests.add(request); - responseObserver.onNext((ListAlertPoliciesResponse) response); + responseObserver.onNext(((ListAlertPoliciesResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -86,10 +88,10 @@ public void getAlertPolicy( Object response = responses.remove(); if (response instanceof AlertPolicy) { requests.add(request); - responseObserver.onNext((AlertPolicy) response); + responseObserver.onNext(((AlertPolicy) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -101,10 +103,10 @@ public void createAlertPolicy( Object response = responses.remove(); if (response instanceof AlertPolicy) { requests.add(request); - responseObserver.onNext((AlertPolicy) response); + responseObserver.onNext(((AlertPolicy) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -116,10 +118,10 @@ public void deleteAlertPolicy( Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -131,10 +133,10 @@ public void updateAlertPolicy( Object response = responses.remove(); if (response instanceof AlertPolicy) { requests.add(request); - responseObserver.onNext((AlertPolicy) response); + responseObserver.onNext(((AlertPolicy) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockGroupService.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockGroupService.java index 525f2b38..94ef54d6 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockGroupService.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockGroupService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockGroupService implements MockGrpcService { private final MockGroupServiceImpl serviceImpl; diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockGroupServiceImpl.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockGroupServiceImpl.java index 4e36fdc9..a951cb5b 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockGroupServiceImpl.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockGroupServiceImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -33,9 +34,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockGroupServiceImpl extends GroupServiceImplBase { private List requests; private Queue responses; @@ -72,10 +74,10 @@ public void listGroups( Object response = responses.remove(); if (response instanceof ListGroupsResponse) { requests.add(request); - responseObserver.onNext((ListGroupsResponse) response); + responseObserver.onNext(((ListGroupsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -86,10 +88,10 @@ public void getGroup(GetGroupRequest request, StreamObserver responseObse Object response = responses.remove(); if (response instanceof Group) { requests.add(request); - responseObserver.onNext((Group) response); + responseObserver.onNext(((Group) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -100,10 +102,10 @@ public void createGroup(CreateGroupRequest request, StreamObserver respon Object response = responses.remove(); if (response instanceof Group) { requests.add(request); - responseObserver.onNext((Group) response); + responseObserver.onNext(((Group) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -114,10 +116,10 @@ public void updateGroup(UpdateGroupRequest request, StreamObserver respon Object response = responses.remove(); if (response instanceof Group) { requests.add(request); - responseObserver.onNext((Group) response); + responseObserver.onNext(((Group) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -128,10 +130,10 @@ public void deleteGroup(DeleteGroupRequest request, StreamObserver respon Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -143,10 +145,10 @@ public void listGroupMembers( Object response = responses.remove(); if (response instanceof ListGroupMembersResponse) { requests.add(request); - responseObserver.onNext((ListGroupMembersResponse) response); + responseObserver.onNext(((ListGroupMembersResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockMetricService.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockMetricService.java index 48df8e51..1c072ef3 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockMetricService.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockMetricService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockMetricService implements MockGrpcService { private final MockMetricServiceImpl serviceImpl; diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockMetricServiceImpl.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockMetricServiceImpl.java index 0736d77e..ba75eed1 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockMetricServiceImpl.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockMetricServiceImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -37,9 +38,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockMetricServiceImpl extends MetricServiceImplBase { private List requests; private Queue responses; @@ -77,10 +79,10 @@ public void listMonitoredResourceDescriptors( Object response = responses.remove(); if (response instanceof ListMonitoredResourceDescriptorsResponse) { requests.add(request); - responseObserver.onNext((ListMonitoredResourceDescriptorsResponse) response); + responseObserver.onNext(((ListMonitoredResourceDescriptorsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -93,10 +95,10 @@ public void getMonitoredResourceDescriptor( Object response = responses.remove(); if (response instanceof MonitoredResourceDescriptor) { requests.add(request); - responseObserver.onNext((MonitoredResourceDescriptor) response); + responseObserver.onNext(((MonitoredResourceDescriptor) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -109,10 +111,10 @@ public void listMetricDescriptors( Object response = responses.remove(); if (response instanceof ListMetricDescriptorsResponse) { requests.add(request); - responseObserver.onNext((ListMetricDescriptorsResponse) response); + responseObserver.onNext(((ListMetricDescriptorsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -124,10 +126,10 @@ public void getMetricDescriptor( Object response = responses.remove(); if (response instanceof MetricDescriptor) { requests.add(request); - responseObserver.onNext((MetricDescriptor) response); + responseObserver.onNext(((MetricDescriptor) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -139,10 +141,10 @@ public void createMetricDescriptor( Object response = responses.remove(); if (response instanceof MetricDescriptor) { requests.add(request); - responseObserver.onNext((MetricDescriptor) response); + responseObserver.onNext(((MetricDescriptor) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -154,10 +156,10 @@ public void deleteMetricDescriptor( Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -169,10 +171,10 @@ public void listTimeSeries( Object response = responses.remove(); if (response instanceof ListTimeSeriesResponse) { requests.add(request); - responseObserver.onNext((ListTimeSeriesResponse) response); + responseObserver.onNext(((ListTimeSeriesResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -184,10 +186,10 @@ public void createTimeSeries( Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelService.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelService.java index 40b34afc..5def5105 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelService.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockNotificationChannelService implements MockGrpcService { private final MockNotificationChannelServiceImpl serviceImpl; diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelServiceImpl.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelServiceImpl.java index 253d57a4..7c62fa27 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelServiceImpl.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockNotificationChannelServiceImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -39,9 +40,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockNotificationChannelServiceImpl extends NotificationChannelServiceImplBase { private List requests; private Queue responses; @@ -79,10 +81,10 @@ public void listNotificationChannelDescriptors( Object response = responses.remove(); if (response instanceof ListNotificationChannelDescriptorsResponse) { requests.add(request); - responseObserver.onNext((ListNotificationChannelDescriptorsResponse) response); + responseObserver.onNext(((ListNotificationChannelDescriptorsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -95,10 +97,10 @@ public void getNotificationChannelDescriptor( Object response = responses.remove(); if (response instanceof NotificationChannelDescriptor) { requests.add(request); - responseObserver.onNext((NotificationChannelDescriptor) response); + responseObserver.onNext(((NotificationChannelDescriptor) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -111,10 +113,10 @@ public void listNotificationChannels( Object response = responses.remove(); if (response instanceof ListNotificationChannelsResponse) { requests.add(request); - responseObserver.onNext((ListNotificationChannelsResponse) response); + responseObserver.onNext(((ListNotificationChannelsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -126,10 +128,10 @@ public void getNotificationChannel( Object response = responses.remove(); if (response instanceof NotificationChannel) { requests.add(request); - responseObserver.onNext((NotificationChannel) response); + responseObserver.onNext(((NotificationChannel) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -142,10 +144,10 @@ public void createNotificationChannel( Object response = responses.remove(); if (response instanceof NotificationChannel) { requests.add(request); - responseObserver.onNext((NotificationChannel) response); + responseObserver.onNext(((NotificationChannel) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -158,10 +160,10 @@ public void updateNotificationChannel( Object response = responses.remove(); if (response instanceof NotificationChannel) { requests.add(request); - responseObserver.onNext((NotificationChannel) response); + responseObserver.onNext(((NotificationChannel) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -173,10 +175,10 @@ public void deleteNotificationChannel( Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -189,10 +191,10 @@ public void sendNotificationChannelVerificationCode( Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -205,10 +207,10 @@ public void getNotificationChannelVerificationCode( Object response = responses.remove(); if (response instanceof GetNotificationChannelVerificationCodeResponse) { requests.add(request); - responseObserver.onNext((GetNotificationChannelVerificationCodeResponse) response); + responseObserver.onNext(((GetNotificationChannelVerificationCodeResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -221,10 +223,10 @@ public void verifyNotificationChannel( Object response = responses.remove(); if (response instanceof NotificationChannel) { requests.add(request); - responseObserver.onNext((NotificationChannel) response); + responseObserver.onNext(((NotificationChannel) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockServiceMonitoringService.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockServiceMonitoringService.java index 84fe572a..42044515 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockServiceMonitoringService.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockServiceMonitoringService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockServiceMonitoringService implements MockGrpcService { private final MockServiceMonitoringServiceImpl serviceImpl; diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockServiceMonitoringServiceImpl.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockServiceMonitoringServiceImpl.java index b6eb6444..96f726fe 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockServiceMonitoringServiceImpl.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockServiceMonitoringServiceImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -38,9 +39,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockServiceMonitoringServiceImpl extends ServiceMonitoringServiceImplBase { private List requests; private Queue responses; @@ -77,10 +79,10 @@ public void createService( Object response = responses.remove(); if (response instanceof Service) { requests.add(request); - responseObserver.onNext((Service) response); + responseObserver.onNext(((Service) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -91,10 +93,10 @@ public void getService(GetServiceRequest request, StreamObserver respon Object response = responses.remove(); if (response instanceof Service) { requests.add(request); - responseObserver.onNext((Service) response); + responseObserver.onNext(((Service) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -106,10 +108,10 @@ public void listServices( Object response = responses.remove(); if (response instanceof ListServicesResponse) { requests.add(request); - responseObserver.onNext((ListServicesResponse) response); + responseObserver.onNext(((ListServicesResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -121,10 +123,10 @@ public void updateService( Object response = responses.remove(); if (response instanceof Service) { requests.add(request); - responseObserver.onNext((Service) response); + responseObserver.onNext(((Service) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -135,10 +137,10 @@ public void deleteService(DeleteServiceRequest request, StreamObserver re Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -151,10 +153,10 @@ public void createServiceLevelObjective( Object response = responses.remove(); if (response instanceof ServiceLevelObjective) { requests.add(request); - responseObserver.onNext((ServiceLevelObjective) response); + responseObserver.onNext(((ServiceLevelObjective) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -167,10 +169,10 @@ public void getServiceLevelObjective( Object response = responses.remove(); if (response instanceof ServiceLevelObjective) { requests.add(request); - responseObserver.onNext((ServiceLevelObjective) response); + responseObserver.onNext(((ServiceLevelObjective) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -183,10 +185,10 @@ public void listServiceLevelObjectives( Object response = responses.remove(); if (response instanceof ListServiceLevelObjectivesResponse) { requests.add(request); - responseObserver.onNext((ListServiceLevelObjectivesResponse) response); + responseObserver.onNext(((ListServiceLevelObjectivesResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -199,10 +201,10 @@ public void updateServiceLevelObjective( Object response = responses.remove(); if (response instanceof ServiceLevelObjective) { requests.add(request); - responseObserver.onNext((ServiceLevelObjective) response); + responseObserver.onNext(((ServiceLevelObjective) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -214,10 +216,10 @@ public void deleteServiceLevelObjective( Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckService.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckService.java index 12aa5ea1..26741d7d 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckService.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockUptimeCheckService implements MockGrpcService { private final MockUptimeCheckServiceImpl serviceImpl; diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckServiceImpl.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckServiceImpl.java index 69a6a94f..9d7e168c 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckServiceImpl.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockUptimeCheckServiceImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -33,9 +34,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockUptimeCheckServiceImpl extends UptimeCheckServiceImplBase { private List requests; private Queue responses; @@ -73,10 +75,10 @@ public void listUptimeCheckConfigs( Object response = responses.remove(); if (response instanceof ListUptimeCheckConfigsResponse) { requests.add(request); - responseObserver.onNext((ListUptimeCheckConfigsResponse) response); + responseObserver.onNext(((ListUptimeCheckConfigsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -88,10 +90,10 @@ public void getUptimeCheckConfig( Object response = responses.remove(); if (response instanceof UptimeCheckConfig) { requests.add(request); - responseObserver.onNext((UptimeCheckConfig) response); + responseObserver.onNext(((UptimeCheckConfig) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -103,10 +105,10 @@ public void createUptimeCheckConfig( Object response = responses.remove(); if (response instanceof UptimeCheckConfig) { requests.add(request); - responseObserver.onNext((UptimeCheckConfig) response); + responseObserver.onNext(((UptimeCheckConfig) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -118,10 +120,10 @@ public void updateUptimeCheckConfig( Object response = responses.remove(); if (response instanceof UptimeCheckConfig) { requests.add(request); - responseObserver.onNext((UptimeCheckConfig) response); + responseObserver.onNext(((UptimeCheckConfig) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -133,10 +135,10 @@ public void deleteUptimeCheckConfig( Object response = responses.remove(); if (response instanceof Empty) { requests.add(request); - responseObserver.onNext((Empty) response); + responseObserver.onNext(((Empty) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -149,10 +151,10 @@ public void listUptimeCheckIps( Object response = responses.remove(); if (response instanceof ListUptimeCheckIpsResponse) { requests.add(request); - responseObserver.onNext((ListUptimeCheckIpsResponse) response); + responseObserver.onNext(((ListUptimeCheckIpsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java index 4221f6a3..5ab50400 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,11 +13,13 @@ * 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.LabelDescriptor; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.testing.LocalChannelProvider; @@ -25,10 +27,10 @@ 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.api.resourcenames.ResourceName; import com.google.common.collect.Lists; import com.google.monitoring.v3.CreateNotificationChannelRequest; import com.google.monitoring.v3.DeleteNotificationChannelRequest; +import com.google.monitoring.v3.FolderName; import com.google.monitoring.v3.GetNotificationChannelDescriptorRequest; import com.google.monitoring.v3.GetNotificationChannelRequest; import com.google.monitoring.v3.GetNotificationChannelVerificationCodeRequest; @@ -41,20 +43,25 @@ import com.google.monitoring.v3.NotificationChannelDescriptor; import com.google.monitoring.v3.NotificationChannelDescriptorName; import com.google.monitoring.v3.NotificationChannelName; +import com.google.monitoring.v3.OrganizationName; import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.SendNotificationChannelVerificationCodeRequest; +import com.google.monitoring.v3.ServiceTier; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.monitoring.v3.VerifyNotificationChannelRequest; import com.google.protobuf.AbstractMessage; +import com.google.protobuf.BoolValue; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; -import io.grpc.Status; +import com.google.protobuf.Timestamp; import io.grpc.StatusRuntimeException; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.UUID; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -62,48 +69,32 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class NotificationChannelServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; + private static MockServiceHelper mockServiceHelper; private static MockNotificationChannelService mockNotificationChannelService; - private static MockServiceMonitoringService mockServiceMonitoringService; - 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(); - mockServiceMonitoringService = new MockServiceMonitoringService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockServiceMonitoringService, - mockUptimeCheckService)); - serviceHelper.start(); + Arrays.asList(mockNotificationChannelService)); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); NotificationChannelServiceSettings settings = NotificationChannelServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -118,36 +109,33 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void listNotificationChannelDescriptorsTest() { - String nextPageToken = ""; - NotificationChannelDescriptor channelDescriptorsElement = + public void listNotificationChannelDescriptorsTest() throws Exception { + NotificationChannelDescriptor responsesElement = NotificationChannelDescriptor.newBuilder().build(); - List channelDescriptors = - Arrays.asList(channelDescriptorsElement); ListNotificationChannelDescriptorsResponse expectedResponse = ListNotificationChannelDescriptorsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllChannelDescriptors(channelDescriptors) + .setNextPageToken("") + .addAllChannelDescriptors(Arrays.asList(responsesElement)) .build(); mockNotificationChannelService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); 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); + ((ListNotificationChannelDescriptorsRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -155,36 +143,176 @@ public void listNotificationChannelDescriptorsTest() { } @Test - @SuppressWarnings("all") public void listNotificationChannelDescriptorsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); + client.listNotificationChannelDescriptors(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNotificationChannelDescriptorsTest2() throws Exception { + NotificationChannelDescriptor responsesElement = + NotificationChannelDescriptor.newBuilder().build(); + ListNotificationChannelDescriptorsResponse expectedResponse = + ListNotificationChannelDescriptorsResponse.newBuilder() + .setNextPageToken("") + .addAllChannelDescriptors(Arrays.asList(responsesElement)) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + + 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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listNotificationChannelDescriptorsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); client.listNotificationChannelDescriptors(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getNotificationChannelDescriptorTest() { - NotificationChannelDescriptorName name2 = - NotificationChannelDescriptorName.ofProjectChannelDescriptorName( - "[PROJECT]", "[CHANNEL_DESCRIPTOR]"); - String type = "type3575610"; - String displayName = "displayName1615086568"; - String description = "description-1724546052"; + public void listNotificationChannelDescriptorsTest3() throws Exception { + NotificationChannelDescriptor responsesElement = + NotificationChannelDescriptor.newBuilder().build(); + ListNotificationChannelDescriptorsResponse expectedResponse = + ListNotificationChannelDescriptorsResponse.newBuilder() + .setNextPageToken("") + .addAllChannelDescriptors(Arrays.asList(responsesElement)) + .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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listNotificationChannelDescriptorsExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + public void listNotificationChannelDescriptorsTest4() throws Exception { + NotificationChannelDescriptor responsesElement = + NotificationChannelDescriptor.newBuilder().build(); + ListNotificationChannelDescriptorsResponse expectedResponse = + ListNotificationChannelDescriptorsResponse.newBuilder() + .setNextPageToken("") + .addAllChannelDescriptors(Arrays.asList(responsesElement)) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listNotificationChannelDescriptorsExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + String name = "name3373707"; + client.listNotificationChannelDescriptors(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNotificationChannelDescriptorTest() throws Exception { NotificationChannelDescriptor expectedResponse = NotificationChannelDescriptor.newBuilder() - .setName(name2.toString()) - .setType(type) - .setDisplayName(displayName) - .setDescription(description) + .setName( + NotificationChannelDescriptorName.ofProjectChannelDescriptorName( + "[PROJECT]", "[CHANNEL_DESCRIPTOR]") + .toString()) + .setType("type3575610") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllLabels(new ArrayList()) + .addAllSupportedTiers(new ArrayList()) .build(); mockNotificationChannelService.addResponse(expectedResponse); @@ -198,9 +326,9 @@ public void getNotificationChannelDescriptorTest() { List actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetNotificationChannelDescriptorRequest actualRequest = - (GetNotificationChannelDescriptorRequest) actualRequests.get(0); + ((GetNotificationChannelDescriptorRequest) actualRequests.get(0)); - Assert.assertEquals(name, NotificationChannelDescriptorName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -208,50 +336,93 @@ public void getNotificationChannelDescriptorTest() { } @Test - @SuppressWarnings("all") public void getNotificationChannelDescriptorExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { NotificationChannelDescriptorName name = NotificationChannelDescriptorName.ofProjectChannelDescriptorName( "[PROJECT]", "[CHANNEL_DESCRIPTOR]"); + client.getNotificationChannelDescriptor(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNotificationChannelDescriptorTest2() throws Exception { + NotificationChannelDescriptor expectedResponse = + NotificationChannelDescriptor.newBuilder() + .setName( + NotificationChannelDescriptorName.ofProjectChannelDescriptorName( + "[PROJECT]", "[CHANNEL_DESCRIPTOR]") + .toString()) + .setType("type3575610") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .addAllLabels(new ArrayList()) + .addAllSupportedTiers(new ArrayList()) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + String name = "name3373707"; + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getNotificationChannelDescriptorExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + String name = "name3373707"; client.getNotificationChannelDescriptor(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listNotificationChannelsTest() { - String nextPageToken = ""; - NotificationChannel notificationChannelsElement = NotificationChannel.newBuilder().build(); - List notificationChannels = Arrays.asList(notificationChannelsElement); + public void listNotificationChannelsTest() throws Exception { + NotificationChannel responsesElement = NotificationChannel.newBuilder().build(); ListNotificationChannelsResponse expectedResponse = ListNotificationChannelsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllNotificationChannels(notificationChannels) + .setNextPageToken("") + .addAllNotificationChannels(Arrays.asList(responsesElement)) .build(); mockNotificationChannelService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); 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); + ((ListNotificationChannelsRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -259,36 +430,168 @@ public void listNotificationChannelsTest() { } @Test - @SuppressWarnings("all") public void listNotificationChannelsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); + client.listNotificationChannels(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNotificationChannelsTest2() throws Exception { + NotificationChannel responsesElement = NotificationChannel.newBuilder().build(); + ListNotificationChannelsResponse expectedResponse = + ListNotificationChannelsResponse.newBuilder() + .setNextPageToken("") + .addAllNotificationChannels(Arrays.asList(responsesElement)) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + + 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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listNotificationChannelsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); client.listNotificationChannels(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getNotificationChannelTest() { - String type = "type3575610"; - NotificationChannelName name2 = - NotificationChannelName.ofProjectNotificationChannelName( - "[PROJECT]", "[NOTIFICATION_CHANNEL]"); - String displayName = "displayName1615086568"; - String description = "description-1724546052"; + public void listNotificationChannelsTest3() throws Exception { + NotificationChannel responsesElement = NotificationChannel.newBuilder().build(); + ListNotificationChannelsResponse expectedResponse = + ListNotificationChannelsResponse.newBuilder() + .setNextPageToken("") + .addAllNotificationChannels(Arrays.asList(responsesElement)) + .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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listNotificationChannelsExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + public void listNotificationChannelsTest4() throws Exception { + NotificationChannel responsesElement = NotificationChannel.newBuilder().build(); + ListNotificationChannelsResponse expectedResponse = + ListNotificationChannelsResponse.newBuilder() + .setNextPageToken("") + .addAllNotificationChannels(Arrays.asList(responsesElement)) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listNotificationChannelsExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + String name = "name3373707"; + client.listNotificationChannels(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNotificationChannelTest() throws Exception { NotificationChannel expectedResponse = NotificationChannel.newBuilder() - .setType(type) - .setName(name2.toString()) - .setDisplayName(displayName) - .setDescription(description) + .setType("type3575610") + .setName( + NotificationChannelName.ofProjectNotificationChannelName( + "[PROJECT]", "[NOTIFICATION_CHANNEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .putAllLabels(new HashMap()) + .putAllUserLabels(new HashMap()) + .setEnabled(BoolValue.newBuilder().build()) .build(); mockNotificationChannelService.addResponse(expectedResponse); @@ -302,9 +605,9 @@ public void getNotificationChannelTest() { List actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetNotificationChannelRequest actualRequest = - (GetNotificationChannelRequest) actualRequests.get(0); + ((GetNotificationChannelRequest) actualRequests.get(0)); - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -312,42 +615,87 @@ public void getNotificationChannelTest() { } @Test - @SuppressWarnings("all") public void getNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName( "[PROJECT]", "[NOTIFICATION_CHANNEL]"); + client.getNotificationChannel(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNotificationChannelTest2() throws Exception { + NotificationChannel expectedResponse = + NotificationChannel.newBuilder() + .setType("type3575610") + .setName( + NotificationChannelName.ofProjectNotificationChannelName( + "[PROJECT]", "[NOTIFICATION_CHANNEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .putAllLabels(new HashMap()) + .putAllUserLabels(new HashMap()) + .setEnabled(BoolValue.newBuilder().build()) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getNotificationChannelExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + try { + String name = "name3373707"; client.getNotificationChannel(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void createNotificationChannelTest() { - String type = "type3575610"; - NotificationChannelName name2 = - NotificationChannelName.ofProjectNotificationChannelName( - "[PROJECT]", "[NOTIFICATION_CHANNEL]"); - String displayName = "displayName1615086568"; - String description = "description-1724546052"; + public void createNotificationChannelTest() throws Exception { NotificationChannel expectedResponse = NotificationChannel.newBuilder() - .setType(type) - .setName(name2.toString()) - .setDisplayName(displayName) - .setDescription(description) + .setType("type3575610") + .setName( + NotificationChannelName.ofProjectNotificationChannelName( + "[PROJECT]", "[NOTIFICATION_CHANNEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .putAllLabels(new HashMap()) + .putAllUserLabels(new HashMap()) + .setEnabled(BoolValue.newBuilder().build()) .build(); mockNotificationChannelService.addResponse(expectedResponse); - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); NotificationChannel actualResponse = @@ -357,9 +705,9 @@ public void createNotificationChannelTest() { List actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateNotificationChannelRequest actualRequest = - (CreateNotificationChannelRequest) actualRequests.get(0); + ((CreateNotificationChannelRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(name), Objects.toString(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -368,37 +716,190 @@ public void createNotificationChannelTest() { } @Test - @SuppressWarnings("all") public void createNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { - ResourceName name = ProjectName.of("[PROJECT]"); + FolderName name = FolderName.of("[FOLDER]"); NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); + client.createNotificationChannel(name, notificationChannel); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void createNotificationChannelTest2() throws Exception { + NotificationChannel expectedResponse = + NotificationChannel.newBuilder() + .setType("type3575610") + .setName( + NotificationChannelName.ofProjectNotificationChannelName( + "[PROJECT]", "[NOTIFICATION_CHANNEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .putAllLabels(new HashMap()) + .putAllUserLabels(new HashMap()) + .setEnabled(BoolValue.newBuilder().build()) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + 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.toString(), actualRequest.getName()); + Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createNotificationChannelExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + OrganizationName name = OrganizationName.of("[ORGANIZATION]"); + NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); client.createNotificationChannel(name, notificationChannel); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void updateNotificationChannelTest() { - String type = "type3575610"; - NotificationChannelName name = - NotificationChannelName.ofProjectNotificationChannelName( - "[PROJECT]", "[NOTIFICATION_CHANNEL]"); - String displayName = "displayName1615086568"; - String description = "description-1724546052"; + public void createNotificationChannelTest3() throws Exception { + NotificationChannel expectedResponse = + NotificationChannel.newBuilder() + .setType("type3575610") + .setName( + NotificationChannelName.ofProjectNotificationChannelName( + "[PROJECT]", "[NOTIFICATION_CHANNEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .putAllLabels(new HashMap()) + .putAllUserLabels(new HashMap()) + .setEnabled(BoolValue.newBuilder().build()) + .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.toString(), actualRequest.getName()); + Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createNotificationChannelExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + public void createNotificationChannelTest4() throws Exception { + NotificationChannel expectedResponse = + NotificationChannel.newBuilder() + .setType("type3575610") + .setName( + NotificationChannelName.ofProjectNotificationChannelName( + "[PROJECT]", "[NOTIFICATION_CHANNEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .putAllLabels(new HashMap()) + .putAllUserLabels(new HashMap()) + .setEnabled(BoolValue.newBuilder().build()) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + String name = "name3373707"; + 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, actualRequest.getName()); + Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createNotificationChannelExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + String name = "name3373707"; + NotificationChannel notificationChannel = NotificationChannel.newBuilder().build(); + client.createNotificationChannel(name, notificationChannel); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateNotificationChannelTest() throws Exception { NotificationChannel expectedResponse = NotificationChannel.newBuilder() - .setType(type) - .setName(name.toString()) - .setDisplayName(displayName) - .setDescription(description) + .setType("type3575610") + .setName( + NotificationChannelName.ofProjectNotificationChannelName( + "[PROJECT]", "[NOTIFICATION_CHANNEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .putAllLabels(new HashMap()) + .putAllUserLabels(new HashMap()) + .setEnabled(BoolValue.newBuilder().build()) .build(); mockNotificationChannelService.addResponse(expectedResponse); @@ -412,7 +913,7 @@ public void updateNotificationChannelTest() { List actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); UpdateNotificationChannelRequest actualRequest = - (UpdateNotificationChannelRequest) actualRequests.get(0); + ((UpdateNotificationChannelRequest) actualRequests.get(0)); Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel()); @@ -423,41 +924,38 @@ public void updateNotificationChannelTest() { } @Test - @SuppressWarnings("all") public void updateNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteNotificationChannelTest() { + public void deleteNotificationChannelTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockNotificationChannelService.addResponse(expectedResponse); NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName( "[PROJECT]", "[NOTIFICATION_CHANNEL]"); - boolean force = false; + boolean force = true; client.deleteNotificationChannel(name, force); List actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteNotificationChannelRequest actualRequest = - (DeleteNotificationChannelRequest) actualRequests.get(0); + ((DeleteNotificationChannelRequest) actualRequests.get(0)); - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertEquals(force, actualRequest.getForce()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -466,27 +964,62 @@ public void deleteNotificationChannelTest() { } @Test - @SuppressWarnings("all") public void deleteNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName( "[PROJECT]", "[NOTIFICATION_CHANNEL]"); - boolean force = false; + boolean force = true; + client.deleteNotificationChannel(name, force); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteNotificationChannelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockNotificationChannelService.addResponse(expectedResponse); + String name = "name3373707"; + boolean force = true; + + client.deleteNotificationChannel(name, force); + + List actualRequests = mockNotificationChannelService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteNotificationChannelRequest actualRequest = + ((DeleteNotificationChannelRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertEquals(force, actualRequest.getForce()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteNotificationChannelExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + String name = "name3373707"; + boolean force = true; client.deleteNotificationChannel(name, force); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void sendNotificationChannelVerificationCodeTest() { + public void sendNotificationChannelVerificationCodeTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockNotificationChannelService.addResponse(expectedResponse); @@ -499,9 +1032,9 @@ public void sendNotificationChannelVerificationCodeTest() { List actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); SendNotificationChannelVerificationCodeRequest actualRequest = - (SendNotificationChannelVerificationCodeRequest) actualRequests.get(0); + ((SendNotificationChannelVerificationCodeRequest) actualRequests.get(0)); - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -509,29 +1042,63 @@ public void sendNotificationChannelVerificationCodeTest() { } @Test - @SuppressWarnings("all") public void sendNotificationChannelVerificationCodeExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName( "[PROJECT]", "[NOTIFICATION_CHANNEL]"); + client.sendNotificationChannelVerificationCode(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void sendNotificationChannelVerificationCodeTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockNotificationChannelService.addResponse(expectedResponse); + + String name = "name3373707"; + client.sendNotificationChannelVerificationCode(name); + + List actualRequests = mockNotificationChannelService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + SendNotificationChannelVerificationCodeRequest actualRequest = + ((SendNotificationChannelVerificationCodeRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void sendNotificationChannelVerificationCodeExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + String name = "name3373707"; client.sendNotificationChannelVerificationCode(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getNotificationChannelVerificationCodeTest() { - String code = "code3059181"; + public void getNotificationChannelVerificationCodeTest() throws Exception { GetNotificationChannelVerificationCodeResponse expectedResponse = - GetNotificationChannelVerificationCodeResponse.newBuilder().setCode(code).build(); + GetNotificationChannelVerificationCodeResponse.newBuilder() + .setCode("code3059181") + .setExpireTime(Timestamp.newBuilder().build()) + .build(); mockNotificationChannelService.addResponse(expectedResponse); NotificationChannelName name = @@ -545,9 +1112,9 @@ public void getNotificationChannelVerificationCodeTest() { List actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetNotificationChannelVerificationCodeRequest actualRequest = - (GetNotificationChannelVerificationCodeRequest) actualRequests.get(0); + ((GetNotificationChannelVerificationCodeRequest) actualRequests.get(0)); - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -555,38 +1122,76 @@ public void getNotificationChannelVerificationCodeTest() { } @Test - @SuppressWarnings("all") public void getNotificationChannelVerificationCodeExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { NotificationChannelName name = NotificationChannelName.ofProjectNotificationChannelName( "[PROJECT]", "[NOTIFICATION_CHANNEL]"); + client.getNotificationChannelVerificationCode(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNotificationChannelVerificationCodeTest2() throws Exception { + GetNotificationChannelVerificationCodeResponse expectedResponse = + GetNotificationChannelVerificationCodeResponse.newBuilder() + .setCode("code3059181") + .setExpireTime(Timestamp.newBuilder().build()) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + String name = "name3373707"; + + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getNotificationChannelVerificationCodeExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + String name = "name3373707"; client.getNotificationChannelVerificationCode(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void verifyNotificationChannelTest() { - String type = "type3575610"; - NotificationChannelName name2 = - NotificationChannelName.ofProjectNotificationChannelName( - "[PROJECT]", "[NOTIFICATION_CHANNEL]"); - String displayName = "displayName1615086568"; - String description = "description-1724546052"; + public void verifyNotificationChannelTest() throws Exception { NotificationChannel expectedResponse = NotificationChannel.newBuilder() - .setType(type) - .setName(name2.toString()) - .setDisplayName(displayName) - .setDescription(description) + .setType("type3575610") + .setName( + NotificationChannelName.ofProjectNotificationChannelName( + "[PROJECT]", "[NOTIFICATION_CHANNEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .putAllLabels(new HashMap()) + .putAllUserLabels(new HashMap()) + .setEnabled(BoolValue.newBuilder().build()) .build(); mockNotificationChannelService.addResponse(expectedResponse); @@ -601,9 +1206,9 @@ public void verifyNotificationChannelTest() { List actualRequests = mockNotificationChannelService.getRequests(); Assert.assertEquals(1, actualRequests.size()); VerifyNotificationChannelRequest actualRequest = - (VerifyNotificationChannelRequest) actualRequests.get(0); + ((VerifyNotificationChannelRequest) actualRequests.get(0)); - Assert.assertEquals(name, NotificationChannelName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertEquals(code, actualRequest.getCode()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -612,9 +1217,8 @@ public void verifyNotificationChannelTest() { } @Test - @SuppressWarnings("all") public void verifyNotificationChannelExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockNotificationChannelService.addException(exception); try { @@ -622,11 +1226,61 @@ public void verifyNotificationChannelExceptionTest() throws Exception { NotificationChannelName.ofProjectNotificationChannelName( "[PROJECT]", "[NOTIFICATION_CHANNEL]"); String code = "code3059181"; + client.verifyNotificationChannel(name, code); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void verifyNotificationChannelTest2() throws Exception { + NotificationChannel expectedResponse = + NotificationChannel.newBuilder() + .setType("type3575610") + .setName( + NotificationChannelName.ofProjectNotificationChannelName( + "[PROJECT]", "[NOTIFICATION_CHANNEL]") + .toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .putAllLabels(new HashMap()) + .putAllUserLabels(new HashMap()) + .setEnabled(BoolValue.newBuilder().build()) + .build(); + mockNotificationChannelService.addResponse(expectedResponse); + + String name = "name3373707"; + 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, actualRequest.getName()); + Assert.assertEquals(code, actualRequest.getCode()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void verifyNotificationChannelExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockNotificationChannelService.addException(exception); + + try { + String name = "name3373707"; + String code = "code3059181"; client.verifyNotificationChannel(name, code); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceClientTest.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceClientTest.java index d60736c1..a90de8c6 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceClientTest.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/ServiceMonitoringServiceClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse; @@ -25,20 +26,22 @@ 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.api.resourcenames.ResourceName; import com.google.common.collect.Lists; import com.google.monitoring.v3.CreateServiceLevelObjectiveRequest; import com.google.monitoring.v3.CreateServiceRequest; import com.google.monitoring.v3.DeleteServiceLevelObjectiveRequest; import com.google.monitoring.v3.DeleteServiceRequest; +import com.google.monitoring.v3.FolderName; import com.google.monitoring.v3.GetServiceLevelObjectiveRequest; import com.google.monitoring.v3.GetServiceRequest; import com.google.monitoring.v3.ListServiceLevelObjectivesRequest; import com.google.monitoring.v3.ListServiceLevelObjectivesResponse; import com.google.monitoring.v3.ListServicesRequest; import com.google.monitoring.v3.ListServicesResponse; +import com.google.monitoring.v3.OrganizationName; import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.Service; +import com.google.monitoring.v3.ServiceLevelIndicator; import com.google.monitoring.v3.ServiceLevelObjective; import com.google.monitoring.v3.ServiceLevelObjectiveName; import com.google.monitoring.v3.ServiceName; @@ -46,13 +49,12 @@ import com.google.monitoring.v3.UpdateServiceRequest; 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 java.util.Objects; import java.util.UUID; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -60,48 +62,32 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class ServiceMonitoringServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; + private static MockServiceHelper mockServiceHelper; private static MockServiceMonitoringService mockServiceMonitoringService; - private static MockUptimeCheckService mockUptimeCheckService; - private static MockServiceHelper serviceHelper; private ServiceMonitoringServiceClient client; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { - mockAlertPolicyService = new MockAlertPolicyService(); - mockGroupService = new MockGroupService(); - mockMetricService = new MockMetricService(); - mockNotificationChannelService = new MockNotificationChannelService(); mockServiceMonitoringService = new MockServiceMonitoringService(); - mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockServiceMonitoringService, - mockUptimeCheckService)); - serviceHelper.start(); + Arrays.asList(mockServiceMonitoringService)); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); ServiceMonitoringServiceSettings settings = ServiceMonitoringServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -116,15 +102,15 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void createServiceTest() { - ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]"); - String displayName = "displayName1615086568"; + public void createServiceTest() throws Exception { Service expectedResponse = - Service.newBuilder().setName(name.toString()).setDisplayName(displayName).build(); + Service.newBuilder() + .setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()) + .setDisplayName("displayName1714148973") + .build(); mockServiceMonitoringService.addResponse(expectedResponse); - ResourceName parent = ProjectName.of("[PROJECT]"); + FolderName parent = FolderName.of("[FOLDER]"); Service service = Service.newBuilder().build(); Service actualResponse = client.createService(parent, service); @@ -132,9 +118,9 @@ public void createServiceTest() { List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateServiceRequest actualRequest = (CreateServiceRequest) actualRequests.get(0); + CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(parent), Objects.toString(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertEquals(service, actualRequest.getService()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -143,29 +129,153 @@ public void createServiceTest() { } @Test - @SuppressWarnings("all") public void createServiceExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + Service service = Service.newBuilder().build(); + client.createService(parent, service); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServiceTest2() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()) + .setDisplayName("displayName1714148973") + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Service service = Service.newBuilder().build(); + + Service actualResponse = client.createService(parent, service); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(service, actualRequest.getService()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createServiceExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Service service = Service.newBuilder().build(); + client.createService(parent, service); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServiceTest3() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()) + .setDisplayName("displayName1714148973") + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + Service service = Service.newBuilder().build(); + + Service actualResponse = client.createService(parent, service); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(service, actualRequest.getService()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createServiceExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { - ResourceName parent = ProjectName.of("[PROJECT]"); + ProjectName parent = ProjectName.of("[PROJECT]"); Service service = Service.newBuilder().build(); + client.createService(parent, service); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServiceTest4() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()) + .setDisplayName("displayName1714148973") + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + Service service = Service.newBuilder().build(); + + Service actualResponse = client.createService(parent, service); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateServiceRequest actualRequest = ((CreateServiceRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(service, actualRequest.getService()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + @Test + public void createServiceExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + + try { + String parent = "parent-995424086"; + Service service = Service.newBuilder().build(); client.createService(parent, service); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getServiceTest() { - ServiceName name2 = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]"); - String displayName = "displayName1615086568"; + public void getServiceTest() throws Exception { Service expectedResponse = - Service.newBuilder().setName(name2.toString()).setDisplayName(displayName).build(); + Service.newBuilder() + .setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()) + .setDisplayName("displayName1714148973") + .build(); mockServiceMonitoringService.addResponse(expectedResponse); ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]"); @@ -175,9 +285,9 @@ public void getServiceTest() { List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetServiceRequest actualRequest = (GetServiceRequest) actualRequests.get(0); + GetServiceRequest actualRequest = ((GetServiceRequest) actualRequests.get(0)); - Assert.assertEquals(name, ServiceName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -185,47 +295,82 @@ public void getServiceTest() { } @Test - @SuppressWarnings("all") public void getServiceExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]"); + client.getService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServiceTest2() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()) + .setDisplayName("displayName1714148973") + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + String name = "name3373707"; + + Service actualResponse = client.getService(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetServiceRequest actualRequest = ((GetServiceRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getServiceExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + try { + String name = "name3373707"; client.getService(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listServicesTest() { - String nextPageToken = ""; - Service servicesElement = Service.newBuilder().build(); - List services = Arrays.asList(servicesElement); + public void listServicesTest() throws Exception { + Service responsesElement = Service.newBuilder().build(); ListServicesResponse expectedResponse = ListServicesResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllServices(services) + .setNextPageToken("") + .addAllServices(Arrays.asList(responsesElement)) .build(); mockServiceMonitoringService.addResponse(expectedResponse); - ResourceName parent = ProjectName.of("[PROJECT]"); + FolderName parent = FolderName.of("[FOLDER]"); ListServicesPagedResponse pagedListResponse = client.listServices(parent); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0)); List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListServicesRequest actualRequest = (ListServicesRequest) actualRequests.get(0); + ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(parent), Objects.toString(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -233,28 +378,158 @@ public void listServicesTest() { } @Test - @SuppressWarnings("all") public void listServicesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { - ResourceName parent = ProjectName.of("[PROJECT]"); + FolderName parent = FolderName.of("[FOLDER]"); + client.listServices(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServicesTest2() throws Exception { + Service responsesElement = Service.newBuilder().build(); + ListServicesResponse expectedResponse = + ListServicesResponse.newBuilder() + .setNextPageToken("") + .addAllServices(Arrays.asList(responsesElement)) + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListServicesPagedResponse pagedListResponse = client.listServices(parent); + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0)); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listServicesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); client.listServices(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void updateServiceTest() { - ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]"); - String displayName = "displayName1615086568"; + public void listServicesTest3() throws Exception { + Service responsesElement = Service.newBuilder().build(); + ListServicesResponse expectedResponse = + ListServicesResponse.newBuilder() + .setNextPageToken("") + .addAllServices(Arrays.asList(responsesElement)) + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListServicesPagedResponse pagedListResponse = client.listServices(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0)); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listServicesExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listServices(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServicesTest4() throws Exception { + Service responsesElement = Service.newBuilder().build(); + ListServicesResponse expectedResponse = + ListServicesResponse.newBuilder() + .setNextPageToken("") + .addAllServices(Arrays.asList(responsesElement)) + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListServicesPagedResponse pagedListResponse = client.listServices(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0)); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListServicesRequest actualRequest = ((ListServicesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listServicesExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + + try { + String parent = "parent-995424086"; + client.listServices(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateServiceTest() throws Exception { Service expectedResponse = - Service.newBuilder().setName(name.toString()).setDisplayName(displayName).build(); + Service.newBuilder() + .setName(ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]").toString()) + .setDisplayName("displayName1714148973") + .build(); mockServiceMonitoringService.addResponse(expectedResponse); Service service = Service.newBuilder().build(); @@ -264,7 +539,7 @@ public void updateServiceTest() { List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - UpdateServiceRequest actualRequest = (UpdateServiceRequest) actualRequests.get(0); + UpdateServiceRequest actualRequest = ((UpdateServiceRequest) actualRequests.get(0)); Assert.assertEquals(service, actualRequest.getService()); Assert.assertTrue( @@ -274,24 +549,21 @@ public void updateServiceTest() { } @Test - @SuppressWarnings("all") public void updateServiceExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { Service service = Service.newBuilder().build(); - client.updateService(service); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteServiceTest() { + public void deleteServiceTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockServiceMonitoringService.addResponse(expectedResponse); @@ -301,9 +573,9 @@ public void deleteServiceTest() { List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - DeleteServiceRequest actualRequest = (DeleteServiceRequest) actualRequests.get(0); + DeleteServiceRequest actualRequest = ((DeleteServiceRequest) actualRequests.get(0)); - Assert.assertEquals(name, ServiceName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -311,34 +583,64 @@ public void deleteServiceTest() { } @Test - @SuppressWarnings("all") public void deleteServiceExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { ServiceName name = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]"); + client.deleteService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServiceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteService(name); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteServiceRequest actualRequest = ((DeleteServiceRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteServiceExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + try { + String name = "name3373707"; client.deleteService(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void createServiceLevelObjectiveTest() { - ServiceLevelObjectiveName name = - ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( - "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]"); - String displayName = "displayName1615086568"; - double goal = 317825.0; + public void createServiceLevelObjectiveTest() throws Exception { ServiceLevelObjective expectedResponse = ServiceLevelObjective.newBuilder() - .setName(name.toString()) - .setDisplayName(displayName) - .setGoal(goal) + .setName( + ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( + "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]") + .toString()) + .setDisplayName("displayName1714148973") + .setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()) + .setGoal(3178259) .build(); mockServiceMonitoringService.addResponse(expectedResponse); @@ -352,9 +654,9 @@ public void createServiceLevelObjectiveTest() { List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateServiceLevelObjectiveRequest actualRequest = - (CreateServiceLevelObjectiveRequest) actualRequests.get(0); + ((CreateServiceLevelObjectiveRequest) actualRequests.get(0)); - Assert.assertEquals(parent, ServiceName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertEquals(serviceLevelObjective, actualRequest.getServiceLevelObjective()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -363,35 +665,80 @@ public void createServiceLevelObjectiveTest() { } @Test - @SuppressWarnings("all") public void createServiceLevelObjectiveExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]"); ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build(); + client.createServiceLevelObjective(parent, serviceLevelObjective); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServiceLevelObjectiveTest2() throws Exception { + ServiceLevelObjective expectedResponse = + ServiceLevelObjective.newBuilder() + .setName( + ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( + "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]") + .toString()) + .setDisplayName("displayName1714148973") + .setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()) + .setGoal(3178259) + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build(); + + ServiceLevelObjective actualResponse = + client.createServiceLevelObjective(parent, serviceLevelObjective); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateServiceLevelObjectiveRequest actualRequest = + ((CreateServiceLevelObjectiveRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(serviceLevelObjective, actualRequest.getServiceLevelObjective()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + @Test + public void createServiceLevelObjectiveExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + + try { + String parent = "parent-995424086"; + ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build(); client.createServiceLevelObjective(parent, serviceLevelObjective); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getServiceLevelObjectiveTest() { - ServiceLevelObjectiveName name2 = - ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( - "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]"); - String displayName = "displayName1615086568"; - double goal = 317825.0; + public void getServiceLevelObjectiveTest() throws Exception { ServiceLevelObjective expectedResponse = ServiceLevelObjective.newBuilder() - .setName(name2.toString()) - .setDisplayName(displayName) - .setGoal(goal) + .setName( + ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( + "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]") + .toString()) + .setDisplayName("displayName1714148973") + .setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()) + .setGoal(3178259) .build(); mockServiceMonitoringService.addResponse(expectedResponse); @@ -405,9 +752,9 @@ public void getServiceLevelObjectiveTest() { List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetServiceLevelObjectiveRequest actualRequest = - (GetServiceLevelObjectiveRequest) actualRequests.get(0); + ((GetServiceLevelObjectiveRequest) actualRequests.get(0)); - Assert.assertEquals(name, ServiceLevelObjectiveName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -415,35 +762,73 @@ public void getServiceLevelObjectiveTest() { } @Test - @SuppressWarnings("all") public void getServiceLevelObjectiveExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]"); + client.getServiceLevelObjective(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServiceLevelObjectiveTest2() throws Exception { + ServiceLevelObjective expectedResponse = + ServiceLevelObjective.newBuilder() + .setName( + ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( + "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]") + .toString()) + .setDisplayName("displayName1714148973") + .setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()) + .setGoal(3178259) + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + String name = "name3373707"; + + ServiceLevelObjective actualResponse = client.getServiceLevelObjective(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetServiceLevelObjectiveRequest actualRequest = + ((GetServiceLevelObjectiveRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getServiceLevelObjectiveExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + try { + String name = "name3373707"; client.getServiceLevelObjective(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listServiceLevelObjectivesTest() { - String nextPageToken = ""; - ServiceLevelObjective serviceLevelObjectivesElement = - ServiceLevelObjective.newBuilder().build(); - List serviceLevelObjectives = - Arrays.asList(serviceLevelObjectivesElement); + public void listServiceLevelObjectivesTest() throws Exception { + ServiceLevelObjective responsesElement = ServiceLevelObjective.newBuilder().build(); ListServiceLevelObjectivesResponse expectedResponse = ListServiceLevelObjectivesResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllServiceLevelObjectives(serviceLevelObjectives) + .setNextPageToken("") + .addAllServiceLevelObjectives(Arrays.asList(responsesElement)) .build(); mockServiceMonitoringService.addResponse(expectedResponse); @@ -453,15 +838,16 @@ public void listServiceLevelObjectivesTest() { client.listServiceLevelObjectives(parent); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getServiceLevelObjectivesList().get(0), resources.get(0)); List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); ListServiceLevelObjectivesRequest actualRequest = - (ListServiceLevelObjectivesRequest) actualRequests.get(0); + ((ListServiceLevelObjectivesRequest) actualRequests.get(0)); - Assert.assertEquals(parent, ServiceName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -469,34 +855,76 @@ public void listServiceLevelObjectivesTest() { } @Test - @SuppressWarnings("all") public void listServiceLevelObjectivesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]"); + client.listServiceLevelObjectives(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServiceLevelObjectivesTest2() throws Exception { + ServiceLevelObjective responsesElement = ServiceLevelObjective.newBuilder().build(); + ListServiceLevelObjectivesResponse expectedResponse = + ListServiceLevelObjectivesResponse.newBuilder() + .setNextPageToken("") + .addAllServiceLevelObjectives(Arrays.asList(responsesElement)) + .build(); + mockServiceMonitoringService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListServiceLevelObjectivesPagedResponse pagedListResponse = + client.listServiceLevelObjectives(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServiceLevelObjectivesList().get(0), resources.get(0)); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListServiceLevelObjectivesRequest actualRequest = + ((ListServiceLevelObjectivesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listServiceLevelObjectivesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + + try { + String parent = "parent-995424086"; client.listServiceLevelObjectives(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void updateServiceLevelObjectiveTest() { - ServiceLevelObjectiveName name = - ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( - "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]"); - String displayName = "displayName1615086568"; - double goal = 317825.0; + public void updateServiceLevelObjectiveTest() throws Exception { ServiceLevelObjective expectedResponse = ServiceLevelObjective.newBuilder() - .setName(name.toString()) - .setDisplayName(displayName) - .setGoal(goal) + .setName( + ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( + "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]") + .toString()) + .setDisplayName("displayName1714148973") + .setServiceLevelIndicator(ServiceLevelIndicator.newBuilder().build()) + .setGoal(3178259) .build(); mockServiceMonitoringService.addResponse(expectedResponse); @@ -509,7 +937,7 @@ public void updateServiceLevelObjectiveTest() { List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); UpdateServiceLevelObjectiveRequest actualRequest = - (UpdateServiceLevelObjectiveRequest) actualRequests.get(0); + ((UpdateServiceLevelObjectiveRequest) actualRequests.get(0)); Assert.assertEquals(serviceLevelObjective, actualRequest.getServiceLevelObjective()); Assert.assertTrue( @@ -519,24 +947,21 @@ public void updateServiceLevelObjectiveTest() { } @Test - @SuppressWarnings("all") public void updateServiceLevelObjectiveExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { ServiceLevelObjective serviceLevelObjective = ServiceLevelObjective.newBuilder().build(); - client.updateServiceLevelObjective(serviceLevelObjective); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteServiceLevelObjectiveTest() { + public void deleteServiceLevelObjectiveTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockServiceMonitoringService.addResponse(expectedResponse); @@ -549,9 +974,9 @@ public void deleteServiceLevelObjectiveTest() { List actualRequests = mockServiceMonitoringService.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteServiceLevelObjectiveRequest actualRequest = - (DeleteServiceLevelObjectiveRequest) actualRequests.get(0); + ((DeleteServiceLevelObjectiveRequest) actualRequests.get(0)); - Assert.assertEquals(name, ServiceLevelObjectiveName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -559,20 +984,53 @@ public void deleteServiceLevelObjectiveTest() { } @Test - @SuppressWarnings("all") public void deleteServiceLevelObjectiveExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockServiceMonitoringService.addException(exception); try { ServiceLevelObjectiveName name = ServiceLevelObjectiveName.ofProjectServiceServiceLevelObjectiveName( "[PROJECT]", "[SERVICE]", "[SERVICE_LEVEL_OBJECTIVE]"); + client.deleteServiceLevelObjective(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServiceLevelObjectiveTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockServiceMonitoringService.addResponse(expectedResponse); + String name = "name3373707"; + + client.deleteServiceLevelObjective(name); + + List actualRequests = mockServiceMonitoringService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteServiceLevelObjectiveRequest actualRequest = + ((DeleteServiceLevelObjectiveRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteServiceLevelObjectiveExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockServiceMonitoringService.addException(exception); + + try { + String name = "name3373707"; client.deleteServiceLevelObjective(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java index 8a1be4af..d7f4fa42 100644 --- a/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java +++ b/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * 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; @@ -25,29 +26,33 @@ 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.api.resourcenames.ResourceName; import com.google.common.collect.Lists; import com.google.monitoring.v3.CreateUptimeCheckConfigRequest; import com.google.monitoring.v3.DeleteUptimeCheckConfigRequest; +import com.google.monitoring.v3.FolderName; import com.google.monitoring.v3.GetUptimeCheckConfigRequest; +import com.google.monitoring.v3.InternalChecker; 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.OrganizationName; 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.monitoring.v3.UptimeCheckIp; +import com.google.monitoring.v3.UptimeCheckRegion; import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Duration; 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 java.util.Objects; import java.util.UUID; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -55,48 +60,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class UptimeCheckServiceClientTest { - private static MockAlertPolicyService mockAlertPolicyService; - private static MockGroupService mockGroupService; - private static MockMetricService mockMetricService; - private static MockNotificationChannelService mockNotificationChannelService; - private static MockServiceMonitoringService mockServiceMonitoringService; + private static MockServiceHelper mockServiceHelper; 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(); - mockServiceMonitoringService = new MockServiceMonitoringService(); mockUptimeCheckService = new MockUptimeCheckService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( - UUID.randomUUID().toString(), - Arrays.asList( - mockAlertPolicyService, - mockGroupService, - mockMetricService, - mockNotificationChannelService, - mockServiceMonitoringService, - mockUptimeCheckService)); - serviceHelper.start(); + UUID.randomUUID().toString(), Arrays.asList(mockUptimeCheckService)); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); UptimeCheckServiceSettings settings = UptimeCheckServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -111,34 +99,30 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void listUptimeCheckConfigsTest() { - String nextPageToken = ""; - int totalSize = 705419236; - UptimeCheckConfig uptimeCheckConfigsElement = UptimeCheckConfig.newBuilder().build(); - List uptimeCheckConfigs = Arrays.asList(uptimeCheckConfigsElement); + public void listUptimeCheckConfigsTest() throws Exception { + UptimeCheckConfig responsesElement = UptimeCheckConfig.newBuilder().build(); ListUptimeCheckConfigsResponse expectedResponse = ListUptimeCheckConfigsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .setTotalSize(totalSize) - .addAllUptimeCheckConfigs(uptimeCheckConfigs) + .setNextPageToken("") + .addAllUptimeCheckConfigs(Arrays.asList(responsesElement)) .build(); mockUptimeCheckService.addResponse(expectedResponse); - ResourceName parent = ProjectName.of("[PROJECT]"); + FolderName parent = FolderName.of("[FOLDER]"); ListUptimeCheckConfigsPagedResponse pagedListResponse = client.listUptimeCheckConfigs(parent); 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); + ((ListUptimeCheckConfigsRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(parent), Objects.toString(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -146,33 +130,169 @@ public void listUptimeCheckConfigsTest() { } @Test - @SuppressWarnings("all") public void listUptimeCheckConfigsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockUptimeCheckService.addException(exception); try { - ResourceName parent = ProjectName.of("[PROJECT]"); + FolderName parent = FolderName.of("[FOLDER]"); + client.listUptimeCheckConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listUptimeCheckConfigsTest2() throws Exception { + UptimeCheckConfig responsesElement = UptimeCheckConfig.newBuilder().build(); + ListUptimeCheckConfigsResponse expectedResponse = + ListUptimeCheckConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllUptimeCheckConfigs(Arrays.asList(responsesElement)) + .build(); + mockUptimeCheckService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListUptimeCheckConfigsPagedResponse pagedListResponse = client.listUptimeCheckConfigs(parent); + + 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(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listUptimeCheckConfigsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockUptimeCheckService.addException(exception); + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); client.listUptimeCheckConfigs(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getUptimeCheckConfigTest() { - UptimeCheckConfigName name2 = - UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - String displayName = "displayName1615086568"; - boolean isInternal = true; + public void listUptimeCheckConfigsTest3() throws Exception { + UptimeCheckConfig responsesElement = UptimeCheckConfig.newBuilder().build(); + ListUptimeCheckConfigsResponse expectedResponse = + ListUptimeCheckConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllUptimeCheckConfigs(Arrays.asList(responsesElement)) + .build(); + mockUptimeCheckService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListUptimeCheckConfigsPagedResponse pagedListResponse = client.listUptimeCheckConfigs(parent); + + 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(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listUptimeCheckConfigsExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockUptimeCheckService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listUptimeCheckConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listUptimeCheckConfigsTest4() throws Exception { + UptimeCheckConfig responsesElement = UptimeCheckConfig.newBuilder().build(); + ListUptimeCheckConfigsResponse expectedResponse = + ListUptimeCheckConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllUptimeCheckConfigs(Arrays.asList(responsesElement)) + .build(); + mockUptimeCheckService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListUptimeCheckConfigsPagedResponse pagedListResponse = client.listUptimeCheckConfigs(parent); + + 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(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listUptimeCheckConfigsExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockUptimeCheckService.addException(exception); + + try { + String parent = "parent-995424086"; + client.listUptimeCheckConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getUptimeCheckConfigTest() throws Exception { UptimeCheckConfig expectedResponse = UptimeCheckConfig.newBuilder() - .setName(name2.toString()) - .setDisplayName(displayName) - .setIsInternal(isInternal) + .setName( + UptimeCheckConfigName.ofProjectUptimeCheckConfigName( + "[PROJECT]", "[UPTIME_CHECK_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setPeriod(Duration.newBuilder().build()) + .setTimeout(Duration.newBuilder().build()) + .addAllContentMatchers(new ArrayList()) + .addAllSelectedRegions(new ArrayList()) + .setIsInternal(true) + .addAllInternalCheckers(new ArrayList()) .build(); mockUptimeCheckService.addResponse(expectedResponse); @@ -184,9 +304,10 @@ public void getUptimeCheckConfigTest() { List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetUptimeCheckConfigRequest actualRequest = (GetUptimeCheckConfigRequest) actualRequests.get(0); + GetUptimeCheckConfigRequest actualRequest = + ((GetUptimeCheckConfigRequest) actualRequests.get(0)); - Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -194,39 +315,89 @@ public void getUptimeCheckConfigTest() { } @Test - @SuppressWarnings("all") public void getUptimeCheckConfigExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockUptimeCheckService.addException(exception); try { UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName( "[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + client.getUptimeCheckConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getUptimeCheckConfigTest2() throws Exception { + UptimeCheckConfig expectedResponse = + UptimeCheckConfig.newBuilder() + .setName( + UptimeCheckConfigName.ofProjectUptimeCheckConfigName( + "[PROJECT]", "[UPTIME_CHECK_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setPeriod(Duration.newBuilder().build()) + .setTimeout(Duration.newBuilder().build()) + .addAllContentMatchers(new ArrayList()) + .addAllSelectedRegions(new ArrayList()) + .setIsInternal(true) + .addAllInternalCheckers(new ArrayList()) + .build(); + mockUptimeCheckService.addResponse(expectedResponse); + + String name = "name3373707"; + 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, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getUptimeCheckConfigExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockUptimeCheckService.addException(exception); + + try { + String name = "name3373707"; client.getUptimeCheckConfig(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void createUptimeCheckConfigTest() { - UptimeCheckConfigName name = - UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - String displayName = "displayName1615086568"; - boolean isInternal = true; + public void createUptimeCheckConfigTest() throws Exception { UptimeCheckConfig expectedResponse = UptimeCheckConfig.newBuilder() - .setName(name.toString()) - .setDisplayName(displayName) - .setIsInternal(isInternal) + .setName( + UptimeCheckConfigName.ofProjectUptimeCheckConfigName( + "[PROJECT]", "[UPTIME_CHECK_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setPeriod(Duration.newBuilder().build()) + .setTimeout(Duration.newBuilder().build()) + .addAllContentMatchers(new ArrayList()) + .addAllSelectedRegions(new ArrayList()) + .setIsInternal(true) + .addAllInternalCheckers(new ArrayList()) .build(); mockUptimeCheckService.addResponse(expectedResponse); - ResourceName parent = ProjectName.of("[PROJECT]"); + FolderName parent = FolderName.of("[FOLDER]"); UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); UptimeCheckConfig actualResponse = client.createUptimeCheckConfig(parent, uptimeCheckConfig); @@ -235,9 +406,9 @@ public void createUptimeCheckConfigTest() { List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateUptimeCheckConfigRequest actualRequest = - (CreateUptimeCheckConfigRequest) actualRequests.get(0); + ((CreateUptimeCheckConfigRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(parent), Objects.toString(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertEquals(uptimeCheckConfig, actualRequest.getUptimeCheckConfig()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -246,34 +417,191 @@ public void createUptimeCheckConfigTest() { } @Test - @SuppressWarnings("all") public void createUptimeCheckConfigExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockUptimeCheckService.addException(exception); try { - ResourceName parent = ProjectName.of("[PROJECT]"); + FolderName parent = FolderName.of("[FOLDER]"); UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); + client.createUptimeCheckConfig(parent, uptimeCheckConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void createUptimeCheckConfigTest2() throws Exception { + UptimeCheckConfig expectedResponse = + UptimeCheckConfig.newBuilder() + .setName( + UptimeCheckConfigName.ofProjectUptimeCheckConfigName( + "[PROJECT]", "[UPTIME_CHECK_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setPeriod(Duration.newBuilder().build()) + .setTimeout(Duration.newBuilder().build()) + .addAllContentMatchers(new ArrayList()) + .addAllSelectedRegions(new ArrayList()) + .setIsInternal(true) + .addAllInternalCheckers(new ArrayList()) + .build(); + mockUptimeCheckService.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); + + UptimeCheckConfig actualResponse = client.createUptimeCheckConfig(parent, uptimeCheckConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockUptimeCheckService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateUptimeCheckConfigRequest actualRequest = + ((CreateUptimeCheckConfigRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(uptimeCheckConfig, actualRequest.getUptimeCheckConfig()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createUptimeCheckConfigExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockUptimeCheckService.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); client.createUptimeCheckConfig(parent, uptimeCheckConfig); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void updateUptimeCheckConfigTest() { - UptimeCheckConfigName name = - UptimeCheckConfigName.ofProjectUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - String displayName = "displayName1615086568"; - boolean isInternal = true; + public void createUptimeCheckConfigTest3() throws Exception { + UptimeCheckConfig expectedResponse = + UptimeCheckConfig.newBuilder() + .setName( + UptimeCheckConfigName.ofProjectUptimeCheckConfigName( + "[PROJECT]", "[UPTIME_CHECK_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setPeriod(Duration.newBuilder().build()) + .setTimeout(Duration.newBuilder().build()) + .addAllContentMatchers(new ArrayList()) + .addAllSelectedRegions(new ArrayList()) + .setIsInternal(true) + .addAllInternalCheckers(new ArrayList()) + .build(); + mockUptimeCheckService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); + + UptimeCheckConfig actualResponse = client.createUptimeCheckConfig(parent, uptimeCheckConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockUptimeCheckService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateUptimeCheckConfigRequest actualRequest = + ((CreateUptimeCheckConfigRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(uptimeCheckConfig, actualRequest.getUptimeCheckConfig()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createUptimeCheckConfigExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockUptimeCheckService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); + client.createUptimeCheckConfig(parent, uptimeCheckConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createUptimeCheckConfigTest4() throws Exception { + UptimeCheckConfig expectedResponse = + UptimeCheckConfig.newBuilder() + .setName( + UptimeCheckConfigName.ofProjectUptimeCheckConfigName( + "[PROJECT]", "[UPTIME_CHECK_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setPeriod(Duration.newBuilder().build()) + .setTimeout(Duration.newBuilder().build()) + .addAllContentMatchers(new ArrayList()) + .addAllSelectedRegions(new ArrayList()) + .setIsInternal(true) + .addAllInternalCheckers(new ArrayList()) + .build(); + mockUptimeCheckService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); + + UptimeCheckConfig actualResponse = client.createUptimeCheckConfig(parent, uptimeCheckConfig); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockUptimeCheckService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateUptimeCheckConfigRequest actualRequest = + ((CreateUptimeCheckConfigRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(uptimeCheckConfig, actualRequest.getUptimeCheckConfig()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createUptimeCheckConfigExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockUptimeCheckService.addException(exception); + + try { + String parent = "parent-995424086"; + UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); + client.createUptimeCheckConfig(parent, uptimeCheckConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateUptimeCheckConfigTest() throws Exception { UptimeCheckConfig expectedResponse = UptimeCheckConfig.newBuilder() - .setName(name.toString()) - .setDisplayName(displayName) - .setIsInternal(isInternal) + .setName( + UptimeCheckConfigName.ofProjectUptimeCheckConfigName( + "[PROJECT]", "[UPTIME_CHECK_CONFIG]") + .toString()) + .setDisplayName("displayName1714148973") + .setPeriod(Duration.newBuilder().build()) + .setTimeout(Duration.newBuilder().build()) + .addAllContentMatchers(new ArrayList()) + .addAllSelectedRegions(new ArrayList()) + .setIsInternal(true) + .addAllInternalCheckers(new ArrayList()) .build(); mockUptimeCheckService.addResponse(expectedResponse); @@ -285,7 +613,7 @@ public void updateUptimeCheckConfigTest() { List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); UpdateUptimeCheckConfigRequest actualRequest = - (UpdateUptimeCheckConfigRequest) actualRequests.get(0); + ((UpdateUptimeCheckConfigRequest) actualRequests.get(0)); Assert.assertEquals(uptimeCheckConfig, actualRequest.getUptimeCheckConfig()); Assert.assertTrue( @@ -295,24 +623,21 @@ public void updateUptimeCheckConfigTest() { } @Test - @SuppressWarnings("all") public void updateUptimeCheckConfigExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.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 + // Expected exception. } } @Test - @SuppressWarnings("all") - public void deleteUptimeCheckConfigTest() { + public void deleteUptimeCheckConfigTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); mockUptimeCheckService.addResponse(expectedResponse); @@ -324,9 +649,9 @@ public void deleteUptimeCheckConfigTest() { List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteUptimeCheckConfigRequest actualRequest = - (DeleteUptimeCheckConfigRequest) actualRequests.get(0); + ((DeleteUptimeCheckConfigRequest) actualRequests.get(0)); - Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -334,48 +659,85 @@ public void deleteUptimeCheckConfigTest() { } @Test - @SuppressWarnings("all") public void deleteUptimeCheckConfigExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockUptimeCheckService.addException(exception); try { UptimeCheckConfigName name = UptimeCheckConfigName.ofProjectUptimeCheckConfigName( "[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + client.deleteUptimeCheckConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void deleteUptimeCheckConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockUptimeCheckService.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteUptimeCheckConfig(name); + + List actualRequests = mockUptimeCheckService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteUptimeCheckConfigRequest actualRequest = + ((DeleteUptimeCheckConfigRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteUptimeCheckConfigExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockUptimeCheckService.addException(exception); + + try { + String name = "name3373707"; client.deleteUptimeCheckConfig(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void listUptimeCheckIpsTest() { - String nextPageToken = ""; - UptimeCheckIp uptimeCheckIpsElement = UptimeCheckIp.newBuilder().build(); - List uptimeCheckIps = Arrays.asList(uptimeCheckIpsElement); + public void listUptimeCheckIpsTest() throws Exception { + UptimeCheckIp responsesElement = UptimeCheckIp.newBuilder().build(); ListUptimeCheckIpsResponse expectedResponse = ListUptimeCheckIpsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllUptimeCheckIps(uptimeCheckIps) + .setNextPageToken("") + .addAllUptimeCheckIps(Arrays.asList(responsesElement)) .build(); mockUptimeCheckService.addResponse(expectedResponse); - ListUptimeCheckIpsRequest request = ListUptimeCheckIpsRequest.newBuilder().build(); + ListUptimeCheckIpsRequest request = + ListUptimeCheckIpsRequest.newBuilder() + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); ListUptimeCheckIpsPagedResponse pagedListResponse = client.listUptimeCheckIps(request); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getUptimeCheckIpsList().get(0), resources.get(0)); List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListUptimeCheckIpsRequest actualRequest = (ListUptimeCheckIpsRequest) actualRequests.get(0); + ListUptimeCheckIpsRequest actualRequest = ((ListUptimeCheckIpsRequest) actualRequests.get(0)); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -383,18 +745,20 @@ public void listUptimeCheckIpsTest() { } @Test - @SuppressWarnings("all") public void listUptimeCheckIpsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockUptimeCheckService.addException(exception); try { - ListUptimeCheckIpsRequest request = ListUptimeCheckIpsRequest.newBuilder().build(); - + ListUptimeCheckIpsRequest request = + ListUptimeCheckIpsRequest.newBuilder() + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); client.listUptimeCheckIps(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/AlertPolicyName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/AlertPolicyName.java index a51e2e27..1d050416 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/AlertPolicyName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/AlertPolicyName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -26,63 +26,72 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class AlertPolicyName implements ResourceName { - - @Deprecated - protected AlertPolicyName() {} - - private static final PathTemplate PROJECT_ALERT_POLICY_PATH_TEMPLATE = + private static final PathTemplate PROJECT_ALERT_POLICY = PathTemplate.createWithoutUrlEncoding("projects/{project}/alertPolicies/{alert_policy}"); - private static final PathTemplate ORGANIZATION_ALERT_POLICY_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_ALERT_POLICY = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/alertPolicies/{alert_policy}"); - private static final PathTemplate FOLDER_ALERT_POLICY_PATH_TEMPLATE = + private static final PathTemplate FOLDER_ALERT_POLICY = PathTemplate.createWithoutUrlEncoding("folders/{folder}/alertPolicies/{alert_policy}"); - private volatile Map fieldValuesMap; private PathTemplate pathTemplate; private String fixedValue; + private final String project; + private final String alertPolicy; + private final String organization; + private final String folder; - private String project; - private String alertPolicy; - private String organization; - private String folder; - - public String getProject() { - return project; - } - - public String getAlertPolicy() { - return alertPolicy; - } - - public String getOrganization() { - return organization; - } - - public String getFolder() { - return folder; + @Deprecated + protected AlertPolicyName() { + project = null; + alertPolicy = null; + organization = null; + folder = null; } private AlertPolicyName(Builder builder) { project = Preconditions.checkNotNull(builder.getProject()); alertPolicy = Preconditions.checkNotNull(builder.getAlertPolicy()); - pathTemplate = PROJECT_ALERT_POLICY_PATH_TEMPLATE; + organization = null; + folder = null; + pathTemplate = PROJECT_ALERT_POLICY; } private AlertPolicyName(OrganizationAlertPolicyBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); alertPolicy = Preconditions.checkNotNull(builder.getAlertPolicy()); - pathTemplate = ORGANIZATION_ALERT_POLICY_PATH_TEMPLATE; + project = null; + folder = null; + pathTemplate = ORGANIZATION_ALERT_POLICY; } private AlertPolicyName(FolderAlertPolicyBuilder builder) { folder = Preconditions.checkNotNull(builder.getFolder()); alertPolicy = Preconditions.checkNotNull(builder.getAlertPolicy()); - pathTemplate = FOLDER_ALERT_POLICY_PATH_TEMPLATE; + project = null; + organization = null; + pathTemplate = FOLDER_ALERT_POLICY; + } + + public String getProject() { + return project; + } + + public String getAlertPolicy() { + return alertPolicy; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; } public static Builder newBuilder() { @@ -109,12 +118,12 @@ public Builder toBuilder() { } public static AlertPolicyName of(String project, String alertPolicy) { - return newProjectAlertPolicyBuilder().setProject(project).setAlertPolicy(alertPolicy).build(); + return newBuilder().setProject(project).setAlertPolicy(alertPolicy).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") public static AlertPolicyName ofProjectAlertPolicyName(String project, String alertPolicy) { - return newProjectAlertPolicyBuilder().setProject(project).setAlertPolicy(alertPolicy).build(); + return newBuilder().setProject(project).setAlertPolicy(alertPolicy).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") @@ -162,18 +171,18 @@ public static AlertPolicyName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (PROJECT_ALERT_POLICY_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = PROJECT_ALERT_POLICY_PATH_TEMPLATE.match(formattedString); + if (PROJECT_ALERT_POLICY.matches(formattedString)) { + Map matchMap = PROJECT_ALERT_POLICY.match(formattedString); return ofProjectAlertPolicyName(matchMap.get("project"), matchMap.get("alert_policy")); - } else if (ORGANIZATION_ALERT_POLICY_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = ORGANIZATION_ALERT_POLICY_PATH_TEMPLATE.match(formattedString); + } else if (ORGANIZATION_ALERT_POLICY.matches(formattedString)) { + Map matchMap = ORGANIZATION_ALERT_POLICY.match(formattedString); return ofOrganizationAlertPolicyName( matchMap.get("organization"), matchMap.get("alert_policy")); - } else if (FOLDER_ALERT_POLICY_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = FOLDER_ALERT_POLICY_PATH_TEMPLATE.match(formattedString); + } else if (FOLDER_ALERT_POLICY.matches(formattedString)) { + Map matchMap = FOLDER_ALERT_POLICY.match(formattedString); return ofFolderAlertPolicyName(matchMap.get("folder"), matchMap.get("alert_policy")); } - throw new ValidationException("JobName.parse: formattedString not in valid format"); + throw new ValidationException("AlertPolicyName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -197,9 +206,9 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PROJECT_ALERT_POLICY_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_ALERT_POLICY_PATH_TEMPLATE.matches(formattedString) - || FOLDER_ALERT_POLICY_PATH_TEMPLATE.matches(formattedString); + return PROJECT_ALERT_POLICY.matches(formattedString) + || ORGANIZATION_ALERT_POLICY.matches(formattedString) + || FOLDER_ALERT_POLICY.matches(formattedString); } @Override @@ -236,9 +245,39 @@ public String toString() { return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + AlertPolicyName that = ((AlertPolicyName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.alertPolicy, that.alertPolicy) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(alertPolicy); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + /** Builder for projects/{project}/alertPolicies/{alert_policy}. */ public static class Builder { - private String project; private String alertPolicy; @@ -264,9 +303,8 @@ public Builder setAlertPolicy(String alertPolicy) { private Builder(AlertPolicyName alertPolicyName) { Preconditions.checkArgument( - alertPolicyName.pathTemplate == PROJECT_ALERT_POLICY_PATH_TEMPLATE, - "toBuilder is only supported when AlertPolicyName has the pattern of " - + "projects/{project}/alertPolicies/{alert_policy}."); + Objects.equals(alertPolicyName.pathTemplate, PROJECT_ALERT_POLICY), + "toBuilder is only supported when AlertPolicyName has the pattern of projects/{project}/alertPolicies/{alert_policy}"); project = alertPolicyName.project; alertPolicy = alertPolicyName.alertPolicy; } @@ -279,11 +317,10 @@ public AlertPolicyName build() { /** Builder for organizations/{organization}/alertPolicies/{alert_policy}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class OrganizationAlertPolicyBuilder { - private String organization; private String alertPolicy; - private OrganizationAlertPolicyBuilder() {} + protected OrganizationAlertPolicyBuilder() {} public String getOrganization() { return organization; @@ -311,11 +348,10 @@ public AlertPolicyName build() { /** Builder for folders/{folder}/alertPolicies/{alert_policy}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class FolderAlertPolicyBuilder { - private String folder; private String alertPolicy; - private FolderAlertPolicyBuilder() {} + protected FolderAlertPolicyBuilder() {} public String getFolder() { return folder; @@ -339,35 +375,4 @@ public AlertPolicyName build() { return new AlertPolicyName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - AlertPolicyName that = (AlertPolicyName) o; - return (Objects.equals(this.project, that.project)) - && (Objects.equals(this.alertPolicy, that.alertPolicy)) - && (Objects.equals(this.organization, that.organization)) - && (Objects.equals(this.folder, that.folder)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(alertPolicy); - h *= 1000003; - h ^= Objects.hashCode(organization); - h *= 1000003; - h ^= Objects.hashCode(folder); - return h; - } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/FolderName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/FolderName.java new file mode 100644 index 00000000..a95180d5 --- /dev/null +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/FolderName.java @@ -0,0 +1,168 @@ +/* + * Copyright 2020 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.monitoring.v3; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class FolderName implements ResourceName { + private static final PathTemplate FOLDER = + PathTemplate.createWithoutUrlEncoding("folders/{folder}"); + private volatile Map fieldValuesMap; + private final String folder; + + @Deprecated + protected FolderName() { + folder = null; + } + + private FolderName(Builder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + } + + public String getFolder() { + return folder; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static FolderName of(String folder) { + return newBuilder().setFolder(folder).build(); + } + + public static String format(String folder) { + return newBuilder().setFolder(folder).build().toString(); + } + + public static FolderName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + FOLDER.validatedMatch( + formattedString, "FolderName.parse: formattedString not in valid format"); + return of(matchMap.get("folder")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (FolderName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return FOLDER.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (folder != null) { + fieldMapBuilder.put("folder", folder); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return FOLDER.instantiate("folder", folder); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + FolderName that = ((FolderName) o); + return Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + + /** Builder for folders/{folder}. */ + public static class Builder { + private String folder; + + protected Builder() {} + + public String getFolder() { + return folder; + } + + public Builder setFolder(String folder) { + this.folder = folder; + return this; + } + + private Builder(FolderName folderName) { + folder = folderName.folder; + } + + public FolderName build() { + return new FolderName(this); + } + } +} diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/GroupName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/GroupName.java index 77d84dac..dcf09029 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/GroupName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/GroupName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -26,62 +26,71 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class GroupName implements ResourceName { - - @Deprecated - protected GroupName() {} - - private static final PathTemplate PROJECT_GROUP_PATH_TEMPLATE = + private static final PathTemplate PROJECT_GROUP = PathTemplate.createWithoutUrlEncoding("projects/{project}/groups/{group}"); - private static final PathTemplate ORGANIZATION_GROUP_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_GROUP = PathTemplate.createWithoutUrlEncoding("organizations/{organization}/groups/{group}"); - private static final PathTemplate FOLDER_GROUP_PATH_TEMPLATE = + private static final PathTemplate FOLDER_GROUP = PathTemplate.createWithoutUrlEncoding("folders/{folder}/groups/{group}"); - private volatile Map fieldValuesMap; private PathTemplate pathTemplate; private String fixedValue; + private final String project; + private final String group; + private final String organization; + private final String folder; - private String project; - private String group; - private String organization; - private String folder; - - public String getProject() { - return project; - } - - public String getGroup() { - return group; - } - - public String getOrganization() { - return organization; - } - - public String getFolder() { - return folder; + @Deprecated + protected GroupName() { + project = null; + group = null; + organization = null; + folder = null; } private GroupName(Builder builder) { project = Preconditions.checkNotNull(builder.getProject()); group = Preconditions.checkNotNull(builder.getGroup()); - pathTemplate = PROJECT_GROUP_PATH_TEMPLATE; + organization = null; + folder = null; + pathTemplate = PROJECT_GROUP; } private GroupName(OrganizationGroupBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); group = Preconditions.checkNotNull(builder.getGroup()); - pathTemplate = ORGANIZATION_GROUP_PATH_TEMPLATE; + project = null; + folder = null; + pathTemplate = ORGANIZATION_GROUP; } private GroupName(FolderGroupBuilder builder) { folder = Preconditions.checkNotNull(builder.getFolder()); group = Preconditions.checkNotNull(builder.getGroup()); - pathTemplate = FOLDER_GROUP_PATH_TEMPLATE; + project = null; + organization = null; + pathTemplate = FOLDER_GROUP; + } + + public String getProject() { + return project; + } + + public String getGroup() { + return group; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; } public static Builder newBuilder() { @@ -108,12 +117,12 @@ public Builder toBuilder() { } public static GroupName of(String project, String group) { - return newProjectGroupBuilder().setProject(project).setGroup(group).build(); + return newBuilder().setProject(project).setGroup(group).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") public static GroupName ofProjectGroupName(String project, String group) { - return newProjectGroupBuilder().setProject(project).setGroup(group).build(); + return newBuilder().setProject(project).setGroup(group).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") @@ -153,17 +162,17 @@ public static GroupName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (PROJECT_GROUP_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = PROJECT_GROUP_PATH_TEMPLATE.match(formattedString); + if (PROJECT_GROUP.matches(formattedString)) { + Map matchMap = PROJECT_GROUP.match(formattedString); return ofProjectGroupName(matchMap.get("project"), matchMap.get("group")); - } else if (ORGANIZATION_GROUP_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = ORGANIZATION_GROUP_PATH_TEMPLATE.match(formattedString); + } else if (ORGANIZATION_GROUP.matches(formattedString)) { + Map matchMap = ORGANIZATION_GROUP.match(formattedString); return ofOrganizationGroupName(matchMap.get("organization"), matchMap.get("group")); - } else if (FOLDER_GROUP_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = FOLDER_GROUP_PATH_TEMPLATE.match(formattedString); + } else if (FOLDER_GROUP.matches(formattedString)) { + Map matchMap = FOLDER_GROUP.match(formattedString); return ofFolderGroupName(matchMap.get("folder"), matchMap.get("group")); } - throw new ValidationException("JobName.parse: formattedString not in valid format"); + throw new ValidationException("GroupName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -187,9 +196,9 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PROJECT_GROUP_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_GROUP_PATH_TEMPLATE.matches(formattedString) - || FOLDER_GROUP_PATH_TEMPLATE.matches(formattedString); + return PROJECT_GROUP.matches(formattedString) + || ORGANIZATION_GROUP.matches(formattedString) + || FOLDER_GROUP.matches(formattedString); } @Override @@ -226,9 +235,39 @@ public String toString() { return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + GroupName that = ((GroupName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.group, that.group) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(group); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + /** Builder for projects/{project}/groups/{group}. */ public static class Builder { - private String project; private String group; @@ -254,9 +293,8 @@ public Builder setGroup(String group) { private Builder(GroupName groupName) { Preconditions.checkArgument( - groupName.pathTemplate == PROJECT_GROUP_PATH_TEMPLATE, - "toBuilder is only supported when GroupName has the pattern of " - + "projects/{project}/groups/{group}."); + Objects.equals(groupName.pathTemplate, PROJECT_GROUP), + "toBuilder is only supported when GroupName has the pattern of projects/{project}/groups/{group}"); project = groupName.project; group = groupName.group; } @@ -269,11 +307,10 @@ public GroupName build() { /** Builder for organizations/{organization}/groups/{group}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class OrganizationGroupBuilder { - private String organization; private String group; - private OrganizationGroupBuilder() {} + protected OrganizationGroupBuilder() {} public String getOrganization() { return organization; @@ -301,11 +338,10 @@ public GroupName build() { /** Builder for folders/{folder}/groups/{group}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class FolderGroupBuilder { - private String folder; private String group; - private FolderGroupBuilder() {} + protected FolderGroupBuilder() {} public String getFolder() { return folder; @@ -329,35 +365,4 @@ public GroupName build() { return new GroupName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - GroupName that = (GroupName) o; - return (Objects.equals(this.project, that.project)) - && (Objects.equals(this.group, that.group)) - && (Objects.equals(this.organization, that.organization)) - && (Objects.equals(this.folder, that.folder)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(group); - h *= 1000003; - h ^= Objects.hashCode(organization); - h *= 1000003; - h ^= Objects.hashCode(folder); - return h; - } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/MetricDescriptorName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/MetricDescriptorName.java index ab9106e3..77d9f447 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/MetricDescriptorName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/MetricDescriptorName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -26,65 +26,74 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class MetricDescriptorName implements ResourceName { - - @Deprecated - protected MetricDescriptorName() {} - - private static final PathTemplate PROJECT_METRIC_DESCRIPTOR_PATH_TEMPLATE = + private static final PathTemplate PROJECT_METRIC_DESCRIPTOR = PathTemplate.createWithoutUrlEncoding( "projects/{project}/metricDescriptors/{metric_descriptor=**}"); - private static final PathTemplate ORGANIZATION_METRIC_DESCRIPTOR_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_METRIC_DESCRIPTOR = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/metricDescriptors/{metric_descriptor=**}"); - private static final PathTemplate FOLDER_METRIC_DESCRIPTOR_PATH_TEMPLATE = + private static final PathTemplate FOLDER_METRIC_DESCRIPTOR = PathTemplate.createWithoutUrlEncoding( "folders/{folder}/metricDescriptors/{metric_descriptor=**}"); - private volatile Map fieldValuesMap; private PathTemplate pathTemplate; private String fixedValue; + private final String project; + private final String metricDescriptor; + private final String organization; + private final String folder; - private String project; - private String metricDescriptor; - private String organization; - private String folder; - - public String getProject() { - return project; - } - - public String getMetricDescriptor() { - return metricDescriptor; - } - - public String getOrganization() { - return organization; - } - - public String getFolder() { - return folder; + @Deprecated + protected MetricDescriptorName() { + project = null; + metricDescriptor = null; + organization = null; + folder = null; } private MetricDescriptorName(Builder builder) { project = Preconditions.checkNotNull(builder.getProject()); metricDescriptor = Preconditions.checkNotNull(builder.getMetricDescriptor()); - pathTemplate = PROJECT_METRIC_DESCRIPTOR_PATH_TEMPLATE; + organization = null; + folder = null; + pathTemplate = PROJECT_METRIC_DESCRIPTOR; } private MetricDescriptorName(OrganizationMetricDescriptorBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); metricDescriptor = Preconditions.checkNotNull(builder.getMetricDescriptor()); - pathTemplate = ORGANIZATION_METRIC_DESCRIPTOR_PATH_TEMPLATE; + project = null; + folder = null; + pathTemplate = ORGANIZATION_METRIC_DESCRIPTOR; } private MetricDescriptorName(FolderMetricDescriptorBuilder builder) { folder = Preconditions.checkNotNull(builder.getFolder()); metricDescriptor = Preconditions.checkNotNull(builder.getMetricDescriptor()); - pathTemplate = FOLDER_METRIC_DESCRIPTOR_PATH_TEMPLATE; + project = null; + organization = null; + pathTemplate = FOLDER_METRIC_DESCRIPTOR; + } + + public String getProject() { + return project; + } + + public String getMetricDescriptor() { + return metricDescriptor; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; } public static Builder newBuilder() { @@ -111,19 +120,13 @@ public Builder toBuilder() { } public static MetricDescriptorName of(String project, String metricDescriptor) { - return newProjectMetricDescriptorBuilder() - .setProject(project) - .setMetricDescriptor(metricDescriptor) - .build(); + return newBuilder().setProject(project).setMetricDescriptor(metricDescriptor).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") public static MetricDescriptorName ofProjectMetricDescriptorName( String project, String metricDescriptor) { - return newProjectMetricDescriptorBuilder() - .setProject(project) - .setMetricDescriptor(metricDescriptor) - .build(); + return newBuilder().setProject(project).setMetricDescriptor(metricDescriptor).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") @@ -184,21 +187,21 @@ public static MetricDescriptorName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (PROJECT_METRIC_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = PROJECT_METRIC_DESCRIPTOR_PATH_TEMPLATE.match(formattedString); + if (PROJECT_METRIC_DESCRIPTOR.matches(formattedString)) { + Map matchMap = PROJECT_METRIC_DESCRIPTOR.match(formattedString); return ofProjectMetricDescriptorName( matchMap.get("project"), matchMap.get("metric_descriptor")); - } else if (ORGANIZATION_METRIC_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - ORGANIZATION_METRIC_DESCRIPTOR_PATH_TEMPLATE.match(formattedString); + } else if (ORGANIZATION_METRIC_DESCRIPTOR.matches(formattedString)) { + Map matchMap = ORGANIZATION_METRIC_DESCRIPTOR.match(formattedString); return ofOrganizationMetricDescriptorName( matchMap.get("organization"), matchMap.get("metric_descriptor")); - } else if (FOLDER_METRIC_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = FOLDER_METRIC_DESCRIPTOR_PATH_TEMPLATE.match(formattedString); + } else if (FOLDER_METRIC_DESCRIPTOR.matches(formattedString)) { + Map matchMap = FOLDER_METRIC_DESCRIPTOR.match(formattedString); return ofFolderMetricDescriptorName( matchMap.get("folder"), matchMap.get("metric_descriptor")); } - throw new ValidationException("JobName.parse: formattedString not in valid format"); + throw new ValidationException( + "MetricDescriptorName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -222,9 +225,9 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PROJECT_METRIC_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_METRIC_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString) - || FOLDER_METRIC_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString); + return PROJECT_METRIC_DESCRIPTOR.matches(formattedString) + || ORGANIZATION_METRIC_DESCRIPTOR.matches(formattedString) + || FOLDER_METRIC_DESCRIPTOR.matches(formattedString); } @Override @@ -261,9 +264,39 @@ public String toString() { return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } - /** Builder for projects/{project}/metricDescriptors/{metric_descriptor=**}. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + MetricDescriptorName that = ((MetricDescriptorName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.metricDescriptor, that.metricDescriptor) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(metricDescriptor); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + /** Builder for projects/{project}/metricDescriptors/{metric_descriptor=**}. */ + public static class Builder { private String project; private String metricDescriptor; @@ -289,9 +322,8 @@ public Builder setMetricDescriptor(String metricDescriptor) { private Builder(MetricDescriptorName metricDescriptorName) { Preconditions.checkArgument( - metricDescriptorName.pathTemplate == PROJECT_METRIC_DESCRIPTOR_PATH_TEMPLATE, - "toBuilder is only supported when MetricDescriptorName has the pattern of " - + "projects/{project}/metricDescriptors/{metric_descriptor=**}."); + Objects.equals(metricDescriptorName.pathTemplate, PROJECT_METRIC_DESCRIPTOR), + "toBuilder is only supported when MetricDescriptorName has the pattern of projects/{project}/metricDescriptors/{metric_descriptor=**}"); project = metricDescriptorName.project; metricDescriptor = metricDescriptorName.metricDescriptor; } @@ -301,14 +333,13 @@ public MetricDescriptorName build() { } } - /** Builder for organizations/{organization}/metricDescriptors/{metric_descriptor=**}. */ + /** Builder for organizations/{organization}/metricDescriptors/{metric_descriptor=**}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class OrganizationMetricDescriptorBuilder { - private String organization; private String metricDescriptor; - private OrganizationMetricDescriptorBuilder() {} + protected OrganizationMetricDescriptorBuilder() {} public String getOrganization() { return organization; @@ -333,14 +364,13 @@ public MetricDescriptorName build() { } } - /** Builder for folders/{folder}/metricDescriptors/{metric_descriptor=**}. */ + /** Builder for folders/{folder}/metricDescriptors/{metric_descriptor=**}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class FolderMetricDescriptorBuilder { - private String folder; private String metricDescriptor; - private FolderMetricDescriptorBuilder() {} + protected FolderMetricDescriptorBuilder() {} public String getFolder() { return folder; @@ -364,35 +394,4 @@ public MetricDescriptorName build() { return new MetricDescriptorName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - MetricDescriptorName that = (MetricDescriptorName) o; - return (Objects.equals(this.project, that.project)) - && (Objects.equals(this.metricDescriptor, that.metricDescriptor)) - && (Objects.equals(this.organization, that.organization)) - && (Objects.equals(this.folder, that.folder)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(metricDescriptor); - h *= 1000003; - h ^= Objects.hashCode(organization); - h *= 1000003; - h ^= Objects.hashCode(folder); - return h; - } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/MonitoredResourceDescriptorName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/MonitoredResourceDescriptorName.java index f96dbc72..1a154764 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/MonitoredResourceDescriptorName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/MonitoredResourceDescriptorName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -26,68 +26,77 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class MonitoredResourceDescriptorName implements ResourceName { - - @Deprecated - protected MonitoredResourceDescriptorName() {} - - private static final PathTemplate PROJECT_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = + private static final PathTemplate PROJECT_MONITORED_RESOURCE_DESCRIPTOR = PathTemplate.createWithoutUrlEncoding( "projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}"); - private static final PathTemplate ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/monitoredResourceDescriptors/{monitored_resource_descriptor}"); - private static final PathTemplate FOLDER_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = + private static final PathTemplate FOLDER_MONITORED_RESOURCE_DESCRIPTOR = PathTemplate.createWithoutUrlEncoding( "folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor}"); - private volatile Map fieldValuesMap; private PathTemplate pathTemplate; private String fixedValue; + private final String project; + private final String monitoredResourceDescriptor; + private final String organization; + private final String folder; - private String project; - private String monitoredResourceDescriptor; - private String organization; - private String folder; - - public String getProject() { - return project; - } - - public String getMonitoredResourceDescriptor() { - return monitoredResourceDescriptor; - } - - public String getOrganization() { - return organization; - } - - public String getFolder() { - return folder; + @Deprecated + protected MonitoredResourceDescriptorName() { + project = null; + monitoredResourceDescriptor = null; + organization = null; + folder = null; } private MonitoredResourceDescriptorName(Builder builder) { project = Preconditions.checkNotNull(builder.getProject()); monitoredResourceDescriptor = Preconditions.checkNotNull(builder.getMonitoredResourceDescriptor()); - pathTemplate = PROJECT_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE; + organization = null; + folder = null; + pathTemplate = PROJECT_MONITORED_RESOURCE_DESCRIPTOR; } private MonitoredResourceDescriptorName(OrganizationMonitoredResourceDescriptorBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); monitoredResourceDescriptor = Preconditions.checkNotNull(builder.getMonitoredResourceDescriptor()); - pathTemplate = ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE; + project = null; + folder = null; + pathTemplate = ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR; } private MonitoredResourceDescriptorName(FolderMonitoredResourceDescriptorBuilder builder) { folder = Preconditions.checkNotNull(builder.getFolder()); monitoredResourceDescriptor = Preconditions.checkNotNull(builder.getMonitoredResourceDescriptor()); - pathTemplate = FOLDER_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE; + project = null; + organization = null; + pathTemplate = FOLDER_MONITORED_RESOURCE_DESCRIPTOR; + } + + public String getProject() { + return project; + } + + public String getMonitoredResourceDescriptor() { + return monitoredResourceDescriptor; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; } public static Builder newBuilder() { @@ -117,7 +126,7 @@ public Builder toBuilder() { public static MonitoredResourceDescriptorName of( String project, String monitoredResourceDescriptor) { - return newProjectMonitoredResourceDescriptorBuilder() + return newBuilder() .setProject(project) .setMonitoredResourceDescriptor(monitoredResourceDescriptor) .build(); @@ -126,7 +135,7 @@ public static MonitoredResourceDescriptorName of( @BetaApi("The static create methods are not stable yet and may be changed in the future.") public static MonitoredResourceDescriptorName ofProjectMonitoredResourceDescriptorName( String project, String monitoredResourceDescriptor) { - return newProjectMonitoredResourceDescriptorBuilder() + return newBuilder() .setProject(project) .setMonitoredResourceDescriptor(monitoredResourceDescriptor) .build(); @@ -192,23 +201,22 @@ public static MonitoredResourceDescriptorName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (PROJECT_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - PROJECT_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(formattedString); + if (PROJECT_MONITORED_RESOURCE_DESCRIPTOR.matches(formattedString)) { + Map matchMap = PROJECT_MONITORED_RESOURCE_DESCRIPTOR.match(formattedString); return ofProjectMonitoredResourceDescriptorName( matchMap.get("project"), matchMap.get("monitored_resource_descriptor")); - } else if (ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString)) { + } else if (ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR.matches(formattedString)) { Map matchMap = - ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(formattedString); + ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR.match(formattedString); return ofOrganizationMonitoredResourceDescriptorName( matchMap.get("organization"), matchMap.get("monitored_resource_descriptor")); - } else if (FOLDER_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - FOLDER_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.match(formattedString); + } else if (FOLDER_MONITORED_RESOURCE_DESCRIPTOR.matches(formattedString)) { + Map matchMap = FOLDER_MONITORED_RESOURCE_DESCRIPTOR.match(formattedString); return ofFolderMonitoredResourceDescriptorName( matchMap.get("folder"), matchMap.get("monitored_resource_descriptor")); } - throw new ValidationException("JobName.parse: formattedString not in valid format"); + throw new ValidationException( + "MonitoredResourceDescriptorName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -232,9 +240,9 @@ public static List toStringList(List va } public static boolean isParsableFrom(String formattedString) { - return PROJECT_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString) - || FOLDER_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString); + return PROJECT_MONITORED_RESOURCE_DESCRIPTOR.matches(formattedString) + || ORGANIZATION_MONITORED_RESOURCE_DESCRIPTOR.matches(formattedString) + || FOLDER_MONITORED_RESOURCE_DESCRIPTOR.matches(formattedString); } @Override @@ -271,11 +279,41 @@ public String toString() { return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + MonitoredResourceDescriptorName that = ((MonitoredResourceDescriptorName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.monitoredResourceDescriptor, that.monitoredResourceDescriptor) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(monitoredResourceDescriptor); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + /** * Builder for projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}. */ public static class Builder { - private String project; private String monitoredResourceDescriptor; @@ -301,10 +339,9 @@ public Builder setMonitoredResourceDescriptor(String monitoredResourceDescriptor private Builder(MonitoredResourceDescriptorName monitoredResourceDescriptorName) { Preconditions.checkArgument( - monitoredResourceDescriptorName.pathTemplate - == PROJECT_MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE, - "toBuilder is only supported when MonitoredResourceDescriptorName has the pattern of " - + "projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}."); + Objects.equals( + monitoredResourceDescriptorName.pathTemplate, PROJECT_MONITORED_RESOURCE_DESCRIPTOR), + "toBuilder is only supported when MonitoredResourceDescriptorName has the pattern of projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}"); project = monitoredResourceDescriptorName.project; monitoredResourceDescriptor = monitoredResourceDescriptorName.monitoredResourceDescriptor; } @@ -320,11 +357,10 @@ public MonitoredResourceDescriptorName build() { */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class OrganizationMonitoredResourceDescriptorBuilder { - private String organization; private String monitoredResourceDescriptor; - private OrganizationMonitoredResourceDescriptorBuilder() {} + protected OrganizationMonitoredResourceDescriptorBuilder() {} public String getOrganization() { return organization; @@ -353,11 +389,10 @@ public MonitoredResourceDescriptorName build() { /** Builder for folders/{folder}/monitoredResourceDescriptors/{monitored_resource_descriptor}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class FolderMonitoredResourceDescriptorBuilder { - private String folder; private String monitoredResourceDescriptor; - private FolderMonitoredResourceDescriptorBuilder() {} + protected FolderMonitoredResourceDescriptorBuilder() {} public String getFolder() { return folder; @@ -382,35 +417,4 @@ public MonitoredResourceDescriptorName build() { return new MonitoredResourceDescriptorName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - MonitoredResourceDescriptorName that = (MonitoredResourceDescriptorName) o; - return (Objects.equals(this.project, that.project)) - && (Objects.equals(this.monitoredResourceDescriptor, that.monitoredResourceDescriptor)) - && (Objects.equals(this.organization, that.organization)) - && (Objects.equals(this.folder, that.folder)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(monitoredResourceDescriptor); - h *= 1000003; - h ^= Objects.hashCode(organization); - h *= 1000003; - h ^= Objects.hashCode(folder); - return h; - } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannelDescriptorName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannelDescriptorName.java index fcd572eb..e7d52f3b 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannelDescriptorName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannelDescriptorName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -26,65 +26,74 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class NotificationChannelDescriptorName implements ResourceName { - - @Deprecated - protected NotificationChannelDescriptorName() {} - - private static final PathTemplate PROJECT_CHANNEL_DESCRIPTOR_PATH_TEMPLATE = + private static final PathTemplate PROJECT_CHANNEL_DESCRIPTOR = PathTemplate.createWithoutUrlEncoding( "projects/{project}/notificationChannelDescriptors/{channel_descriptor}"); - private static final PathTemplate ORGANIZATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_CHANNEL_DESCRIPTOR = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/notificationChannelDescriptors/{channel_descriptor}"); - private static final PathTemplate FOLDER_CHANNEL_DESCRIPTOR_PATH_TEMPLATE = + private static final PathTemplate FOLDER_CHANNEL_DESCRIPTOR = PathTemplate.createWithoutUrlEncoding( "folders/{folder}/notificationChannelDescriptors/{channel_descriptor}"); - private volatile Map fieldValuesMap; private PathTemplate pathTemplate; private String fixedValue; + private final String project; + private final String channelDescriptor; + private final String organization; + private final String folder; - private String project; - private String channelDescriptor; - private String organization; - private String folder; - - public String getProject() { - return project; - } - - public String getChannelDescriptor() { - return channelDescriptor; - } - - public String getOrganization() { - return organization; - } - - public String getFolder() { - return folder; + @Deprecated + protected NotificationChannelDescriptorName() { + project = null; + channelDescriptor = null; + organization = null; + folder = null; } private NotificationChannelDescriptorName(Builder builder) { project = Preconditions.checkNotNull(builder.getProject()); channelDescriptor = Preconditions.checkNotNull(builder.getChannelDescriptor()); - pathTemplate = PROJECT_CHANNEL_DESCRIPTOR_PATH_TEMPLATE; + organization = null; + folder = null; + pathTemplate = PROJECT_CHANNEL_DESCRIPTOR; } private NotificationChannelDescriptorName(OrganizationChannelDescriptorBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); channelDescriptor = Preconditions.checkNotNull(builder.getChannelDescriptor()); - pathTemplate = ORGANIZATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE; + project = null; + folder = null; + pathTemplate = ORGANIZATION_CHANNEL_DESCRIPTOR; } private NotificationChannelDescriptorName(FolderChannelDescriptorBuilder builder) { folder = Preconditions.checkNotNull(builder.getFolder()); channelDescriptor = Preconditions.checkNotNull(builder.getChannelDescriptor()); - pathTemplate = FOLDER_CHANNEL_DESCRIPTOR_PATH_TEMPLATE; + project = null; + organization = null; + pathTemplate = FOLDER_CHANNEL_DESCRIPTOR; + } + + public String getProject() { + return project; + } + + public String getChannelDescriptor() { + return channelDescriptor; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; } public static Builder newBuilder() { @@ -111,19 +120,13 @@ public Builder toBuilder() { } public static NotificationChannelDescriptorName of(String project, String channelDescriptor) { - return newProjectChannelDescriptorBuilder() - .setProject(project) - .setChannelDescriptor(channelDescriptor) - .build(); + return newBuilder().setProject(project).setChannelDescriptor(channelDescriptor).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") public static NotificationChannelDescriptorName ofProjectChannelDescriptorName( String project, String channelDescriptor) { - return newProjectChannelDescriptorBuilder() - .setProject(project) - .setChannelDescriptor(channelDescriptor) - .build(); + return newBuilder().setProject(project).setChannelDescriptor(channelDescriptor).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") @@ -185,22 +188,21 @@ public static NotificationChannelDescriptorName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (PROJECT_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - PROJECT_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.match(formattedString); + if (PROJECT_CHANNEL_DESCRIPTOR.matches(formattedString)) { + Map matchMap = PROJECT_CHANNEL_DESCRIPTOR.match(formattedString); return ofProjectChannelDescriptorName( matchMap.get("project"), matchMap.get("channel_descriptor")); - } else if (ORGANIZATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - ORGANIZATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.match(formattedString); + } else if (ORGANIZATION_CHANNEL_DESCRIPTOR.matches(formattedString)) { + Map matchMap = ORGANIZATION_CHANNEL_DESCRIPTOR.match(formattedString); return ofOrganizationChannelDescriptorName( matchMap.get("organization"), matchMap.get("channel_descriptor")); - } else if (FOLDER_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = FOLDER_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.match(formattedString); + } else if (FOLDER_CHANNEL_DESCRIPTOR.matches(formattedString)) { + Map matchMap = FOLDER_CHANNEL_DESCRIPTOR.match(formattedString); return ofFolderChannelDescriptorName( matchMap.get("folder"), matchMap.get("channel_descriptor")); } - throw new ValidationException("JobName.parse: formattedString not in valid format"); + throw new ValidationException( + "NotificationChannelDescriptorName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -224,9 +226,9 @@ public static List toStringList(List } public static boolean isParsableFrom(String formattedString) { - return PROJECT_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString) - || FOLDER_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.matches(formattedString); + return PROJECT_CHANNEL_DESCRIPTOR.matches(formattedString) + || ORGANIZATION_CHANNEL_DESCRIPTOR.matches(formattedString) + || FOLDER_CHANNEL_DESCRIPTOR.matches(formattedString); } @Override @@ -263,9 +265,39 @@ public String toString() { return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + NotificationChannelDescriptorName that = ((NotificationChannelDescriptorName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.channelDescriptor, that.channelDescriptor) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(channelDescriptor); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + /** Builder for projects/{project}/notificationChannelDescriptors/{channel_descriptor}. */ public static class Builder { - private String project; private String channelDescriptor; @@ -291,10 +323,9 @@ public Builder setChannelDescriptor(String channelDescriptor) { private Builder(NotificationChannelDescriptorName notificationChannelDescriptorName) { Preconditions.checkArgument( - notificationChannelDescriptorName.pathTemplate - == PROJECT_CHANNEL_DESCRIPTOR_PATH_TEMPLATE, - "toBuilder is only supported when NotificationChannelDescriptorName has the pattern of " - + "projects/{project}/notificationChannelDescriptors/{channel_descriptor}."); + Objects.equals( + notificationChannelDescriptorName.pathTemplate, PROJECT_CHANNEL_DESCRIPTOR), + "toBuilder is only supported when NotificationChannelDescriptorName has the pattern of projects/{project}/notificationChannelDescriptors/{channel_descriptor}"); project = notificationChannelDescriptorName.project; channelDescriptor = notificationChannelDescriptorName.channelDescriptor; } @@ -309,11 +340,10 @@ public NotificationChannelDescriptorName build() { */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class OrganizationChannelDescriptorBuilder { - private String organization; private String channelDescriptor; - private OrganizationChannelDescriptorBuilder() {} + protected OrganizationChannelDescriptorBuilder() {} public String getOrganization() { return organization; @@ -341,11 +371,10 @@ public NotificationChannelDescriptorName build() { /** Builder for folders/{folder}/notificationChannelDescriptors/{channel_descriptor}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class FolderChannelDescriptorBuilder { - private String folder; private String channelDescriptor; - private FolderChannelDescriptorBuilder() {} + protected FolderChannelDescriptorBuilder() {} public String getFolder() { return folder; @@ -369,35 +398,4 @@ public NotificationChannelDescriptorName build() { return new NotificationChannelDescriptorName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - NotificationChannelDescriptorName that = (NotificationChannelDescriptorName) o; - return (Objects.equals(this.project, that.project)) - && (Objects.equals(this.channelDescriptor, that.channelDescriptor)) - && (Objects.equals(this.organization, that.organization)) - && (Objects.equals(this.folder, that.folder)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(channelDescriptor); - h *= 1000003; - h ^= Objects.hashCode(organization); - h *= 1000003; - h ^= Objects.hashCode(folder); - return h; - } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannelName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannelName.java index 6fbee4bd..06bcc0e7 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannelName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannelName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -26,65 +26,74 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class NotificationChannelName implements ResourceName { - - @Deprecated - protected NotificationChannelName() {} - - private static final PathTemplate PROJECT_NOTIFICATION_CHANNEL_PATH_TEMPLATE = + private static final PathTemplate PROJECT_NOTIFICATION_CHANNEL = PathTemplate.createWithoutUrlEncoding( "projects/{project}/notificationChannels/{notification_channel}"); - private static final PathTemplate ORGANIZATION_NOTIFICATION_CHANNEL_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_NOTIFICATION_CHANNEL = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/notificationChannels/{notification_channel}"); - private static final PathTemplate FOLDER_NOTIFICATION_CHANNEL_PATH_TEMPLATE = + private static final PathTemplate FOLDER_NOTIFICATION_CHANNEL = PathTemplate.createWithoutUrlEncoding( "folders/{folder}/notificationChannels/{notification_channel}"); - private volatile Map fieldValuesMap; private PathTemplate pathTemplate; private String fixedValue; + private final String project; + private final String notificationChannel; + private final String organization; + private final String folder; - private String project; - private String notificationChannel; - private String organization; - private String folder; - - public String getProject() { - return project; - } - - public String getNotificationChannel() { - return notificationChannel; - } - - public String getOrganization() { - return organization; - } - - public String getFolder() { - return folder; + @Deprecated + protected NotificationChannelName() { + project = null; + notificationChannel = null; + organization = null; + folder = null; } private NotificationChannelName(Builder builder) { project = Preconditions.checkNotNull(builder.getProject()); notificationChannel = Preconditions.checkNotNull(builder.getNotificationChannel()); - pathTemplate = PROJECT_NOTIFICATION_CHANNEL_PATH_TEMPLATE; + organization = null; + folder = null; + pathTemplate = PROJECT_NOTIFICATION_CHANNEL; } private NotificationChannelName(OrganizationNotificationChannelBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); notificationChannel = Preconditions.checkNotNull(builder.getNotificationChannel()); - pathTemplate = ORGANIZATION_NOTIFICATION_CHANNEL_PATH_TEMPLATE; + project = null; + folder = null; + pathTemplate = ORGANIZATION_NOTIFICATION_CHANNEL; } private NotificationChannelName(FolderNotificationChannelBuilder builder) { folder = Preconditions.checkNotNull(builder.getFolder()); notificationChannel = Preconditions.checkNotNull(builder.getNotificationChannel()); - pathTemplate = FOLDER_NOTIFICATION_CHANNEL_PATH_TEMPLATE; + project = null; + organization = null; + pathTemplate = FOLDER_NOTIFICATION_CHANNEL; + } + + public String getProject() { + return project; + } + + public String getNotificationChannel() { + return notificationChannel; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; } public static Builder newBuilder() { @@ -111,19 +120,13 @@ public Builder toBuilder() { } public static NotificationChannelName of(String project, String notificationChannel) { - return newProjectNotificationChannelBuilder() - .setProject(project) - .setNotificationChannel(notificationChannel) - .build(); + return newBuilder().setProject(project).setNotificationChannel(notificationChannel).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") public static NotificationChannelName ofProjectNotificationChannelName( String project, String notificationChannel) { - return newProjectNotificationChannelBuilder() - .setProject(project) - .setNotificationChannel(notificationChannel) - .build(); + return newBuilder().setProject(project).setNotificationChannel(notificationChannel).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") @@ -186,23 +189,21 @@ public static NotificationChannelName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (PROJECT_NOTIFICATION_CHANNEL_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - PROJECT_NOTIFICATION_CHANNEL_PATH_TEMPLATE.match(formattedString); + if (PROJECT_NOTIFICATION_CHANNEL.matches(formattedString)) { + Map matchMap = PROJECT_NOTIFICATION_CHANNEL.match(formattedString); return ofProjectNotificationChannelName( matchMap.get("project"), matchMap.get("notification_channel")); - } else if (ORGANIZATION_NOTIFICATION_CHANNEL_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - ORGANIZATION_NOTIFICATION_CHANNEL_PATH_TEMPLATE.match(formattedString); + } else if (ORGANIZATION_NOTIFICATION_CHANNEL.matches(formattedString)) { + Map matchMap = ORGANIZATION_NOTIFICATION_CHANNEL.match(formattedString); return ofOrganizationNotificationChannelName( matchMap.get("organization"), matchMap.get("notification_channel")); - } else if (FOLDER_NOTIFICATION_CHANNEL_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - FOLDER_NOTIFICATION_CHANNEL_PATH_TEMPLATE.match(formattedString); + } else if (FOLDER_NOTIFICATION_CHANNEL.matches(formattedString)) { + Map matchMap = FOLDER_NOTIFICATION_CHANNEL.match(formattedString); return ofFolderNotificationChannelName( matchMap.get("folder"), matchMap.get("notification_channel")); } - throw new ValidationException("JobName.parse: formattedString not in valid format"); + throw new ValidationException( + "NotificationChannelName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -226,9 +227,9 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PROJECT_NOTIFICATION_CHANNEL_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_NOTIFICATION_CHANNEL_PATH_TEMPLATE.matches(formattedString) - || FOLDER_NOTIFICATION_CHANNEL_PATH_TEMPLATE.matches(formattedString); + return PROJECT_NOTIFICATION_CHANNEL.matches(formattedString) + || ORGANIZATION_NOTIFICATION_CHANNEL.matches(formattedString) + || FOLDER_NOTIFICATION_CHANNEL.matches(formattedString); } @Override @@ -265,9 +266,39 @@ public String toString() { return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + NotificationChannelName that = ((NotificationChannelName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.notificationChannel, that.notificationChannel) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(notificationChannel); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + /** Builder for projects/{project}/notificationChannels/{notification_channel}. */ public static class Builder { - private String project; private String notificationChannel; @@ -293,9 +324,8 @@ public Builder setNotificationChannel(String notificationChannel) { private Builder(NotificationChannelName notificationChannelName) { Preconditions.checkArgument( - notificationChannelName.pathTemplate == PROJECT_NOTIFICATION_CHANNEL_PATH_TEMPLATE, - "toBuilder is only supported when NotificationChannelName has the pattern of " - + "projects/{project}/notificationChannels/{notification_channel}."); + Objects.equals(notificationChannelName.pathTemplate, PROJECT_NOTIFICATION_CHANNEL), + "toBuilder is only supported when NotificationChannelName has the pattern of projects/{project}/notificationChannels/{notification_channel}"); project = notificationChannelName.project; notificationChannel = notificationChannelName.notificationChannel; } @@ -308,11 +338,10 @@ public NotificationChannelName build() { /** Builder for organizations/{organization}/notificationChannels/{notification_channel}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class OrganizationNotificationChannelBuilder { - private String organization; private String notificationChannel; - private OrganizationNotificationChannelBuilder() {} + protected OrganizationNotificationChannelBuilder() {} public String getOrganization() { return organization; @@ -341,11 +370,10 @@ public NotificationChannelName build() { /** Builder for folders/{folder}/notificationChannels/{notification_channel}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class FolderNotificationChannelBuilder { - private String folder; private String notificationChannel; - private FolderNotificationChannelBuilder() {} + protected FolderNotificationChannelBuilder() {} public String getFolder() { return folder; @@ -369,35 +397,4 @@ public NotificationChannelName build() { return new NotificationChannelName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - NotificationChannelName that = (NotificationChannelName) o; - return (Objects.equals(this.project, that.project)) - && (Objects.equals(this.notificationChannel, that.notificationChannel)) - && (Objects.equals(this.organization, that.organization)) - && (Objects.equals(this.folder, that.folder)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(notificationChannel); - h *= 1000003; - h ^= Objects.hashCode(organization); - h *= 1000003; - h ^= Objects.hashCode(folder); - return h; - } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/OrganizationName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/OrganizationName.java new file mode 100644 index 00000000..21f0098b --- /dev/null +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/OrganizationName.java @@ -0,0 +1,168 @@ +/* + * Copyright 2020 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.monitoring.v3; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class OrganizationName implements ResourceName { + private static final PathTemplate ORGANIZATION = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}"); + private volatile Map fieldValuesMap; + private final String organization; + + @Deprecated + protected OrganizationName() { + organization = null; + } + + private OrganizationName(Builder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + } + + public String getOrganization() { + return organization; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static OrganizationName of(String organization) { + return newBuilder().setOrganization(organization).build(); + } + + public static String format(String organization) { + return newBuilder().setOrganization(organization).build().toString(); + } + + public static OrganizationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + ORGANIZATION.validatedMatch( + formattedString, "OrganizationName.parse: formattedString not in valid format"); + return of(matchMap.get("organization")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (OrganizationName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return ORGANIZATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (organization != null) { + fieldMapBuilder.put("organization", organization); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return ORGANIZATION.instantiate("organization", organization); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + OrganizationName that = ((OrganizationName) o); + return Objects.equals(this.organization, that.organization); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(organization); + return h; + } + + /** Builder for organizations/{organization}. */ + public static class Builder { + private String organization; + + protected Builder() {} + + public String getOrganization() { + return organization; + } + + public Builder setOrganization(String organization) { + this.organization = organization; + return this; + } + + private Builder(OrganizationName organizationName) { + organization = organizationName.organization; + } + + public OrganizationName build() { + return new OrganizationName(this); + } + } +} diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ProjectName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ProjectName.java index 3a0163f8..6f74608d 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ProjectName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ProjectName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -23,18 +23,26 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class ProjectName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT = PathTemplate.createWithoutUrlEncoding("projects/{project}"); - private volatile Map fieldValuesMap; - private final String project; + @Deprecated + protected ProjectName() { + project = null; + } + + private ProjectName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + } + public String getProject() { return project; } @@ -47,10 +55,6 @@ public Builder toBuilder() { return new Builder(this); } - private ProjectName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - } - public static ProjectName of(String project) { return newBuilder().setProject(project).build(); } @@ -64,7 +68,7 @@ public static ProjectName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT.validatedMatch( formattedString, "ProjectName.parse: formattedString not in valid format"); return of(matchMap.get("project")); } @@ -78,7 +82,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (ProjectName value : values) { if (value == null) { list.add(""); @@ -90,15 +94,18 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); + if (project != null) { + fieldMapBuilder.put("project", project); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -112,14 +119,35 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate("project", project); + return PROJECT.instantiate("project", project); } - /** Builder for ProjectName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ProjectName that = ((ProjectName) o); + return Objects.equals(this.project, that.project); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + return h; + } + + /** Builder for projects/{project}. */ + public static class Builder { private String project; + protected Builder() {} + public String getProject() { return project; } @@ -129,8 +157,6 @@ public Builder setProject(String project) { return this; } - private Builder() {} - private Builder(ProjectName projectName) { project = projectName.project; } @@ -139,24 +165,4 @@ public ProjectName build() { return new ProjectName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ProjectName) { - ProjectName that = (ProjectName) o; - return (this.project.equals(that.project)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - return h; - } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ServiceLevelObjectiveName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ServiceLevelObjectiveName.java index fea632a7..a30dceb9 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ServiceLevelObjectiveName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ServiceLevelObjectiveName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -26,33 +26,64 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class ServiceLevelObjectiveName implements ResourceName { - - @Deprecated - protected ServiceLevelObjectiveName() {} - - private static final PathTemplate PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE = + private static final PathTemplate PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE = PathTemplate.createWithoutUrlEncoding( "projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}"); - private static final PathTemplate ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}"); - private static final PathTemplate FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE = + private static final PathTemplate FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE = PathTemplate.createWithoutUrlEncoding( "folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}"); - private volatile Map fieldValuesMap; private PathTemplate pathTemplate; private String fixedValue; + private final String project; + private final String service; + private final String serviceLevelObjective; + private final String organization; + private final String folder; + + @Deprecated + protected ServiceLevelObjectiveName() { + project = null; + service = null; + serviceLevelObjective = null; + organization = null; + folder = null; + } - private String project; - private String service; - private String serviceLevelObjective; - private String organization; - private String folder; + private ServiceLevelObjectiveName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + service = Preconditions.checkNotNull(builder.getService()); + serviceLevelObjective = Preconditions.checkNotNull(builder.getServiceLevelObjective()); + organization = null; + folder = null; + pathTemplate = PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE; + } + + private ServiceLevelObjectiveName(OrganizationServiceServiceLevelObjectiveBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + service = Preconditions.checkNotNull(builder.getService()); + serviceLevelObjective = Preconditions.checkNotNull(builder.getServiceLevelObjective()); + project = null; + folder = null; + pathTemplate = ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE; + } + + private ServiceLevelObjectiveName(FolderServiceServiceLevelObjectiveBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + service = Preconditions.checkNotNull(builder.getService()); + serviceLevelObjective = Preconditions.checkNotNull(builder.getServiceLevelObjective()); + project = null; + organization = null; + pathTemplate = FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE; + } public String getProject() { return project; @@ -74,27 +105,6 @@ public String getFolder() { return folder; } - private ServiceLevelObjectiveName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - service = Preconditions.checkNotNull(builder.getService()); - serviceLevelObjective = Preconditions.checkNotNull(builder.getServiceLevelObjective()); - pathTemplate = PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE; - } - - private ServiceLevelObjectiveName(OrganizationServiceServiceLevelObjectiveBuilder builder) { - organization = Preconditions.checkNotNull(builder.getOrganization()); - service = Preconditions.checkNotNull(builder.getService()); - serviceLevelObjective = Preconditions.checkNotNull(builder.getServiceLevelObjective()); - pathTemplate = ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE; - } - - private ServiceLevelObjectiveName(FolderServiceServiceLevelObjectiveBuilder builder) { - folder = Preconditions.checkNotNull(builder.getFolder()); - service = Preconditions.checkNotNull(builder.getService()); - serviceLevelObjective = Preconditions.checkNotNull(builder.getServiceLevelObjective()); - pathTemplate = FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE; - } - public static Builder newBuilder() { return new Builder(); } @@ -122,7 +132,7 @@ public Builder toBuilder() { public static ServiceLevelObjectiveName of( String project, String service, String serviceLevelObjective) { - return newProjectServiceServiceLevelObjectiveBuilder() + return newBuilder() .setProject(project) .setService(service) .setServiceLevelObjective(serviceLevelObjective) @@ -132,7 +142,7 @@ public static ServiceLevelObjectiveName of( @BetaApi("The static create methods are not stable yet and may be changed in the future.") public static ServiceLevelObjectiveName ofProjectServiceServiceLevelObjectiveName( String project, String service, String serviceLevelObjective) { - return newProjectServiceServiceLevelObjectiveBuilder() + return newBuilder() .setProject(project) .setService(service) .setServiceLevelObjective(serviceLevelObjective) @@ -205,28 +215,26 @@ public static ServiceLevelObjectiveName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE.match(formattedString); + if (PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE.matches(formattedString)) { + Map matchMap = PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE.match(formattedString); return ofProjectServiceServiceLevelObjectiveName( matchMap.get("project"), matchMap.get("service"), matchMap.get("service_level_objective")); - } else if (ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE.matches( - formattedString)) { + } else if (ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE.matches(formattedString)) { Map matchMap = - ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE.match(formattedString); + ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE.match(formattedString); return ofOrganizationServiceServiceLevelObjectiveName( matchMap.get("organization"), matchMap.get("service"), matchMap.get("service_level_objective")); - } else if (FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE.match(formattedString); + } else if (FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE.matches(formattedString)) { + Map matchMap = FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE.match(formattedString); return ofFolderServiceServiceLevelObjectiveName( matchMap.get("folder"), matchMap.get("service"), matchMap.get("service_level_objective")); } - throw new ValidationException("JobName.parse: formattedString not in valid format"); + throw new ValidationException( + "ServiceLevelObjectiveName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -250,9 +258,9 @@ public static List toStringList(List values) } public static boolean isParsableFrom(String formattedString) { - return PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE.matches(formattedString) - || FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE.matches(formattedString); + return PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE.matches(formattedString) + || ORGANIZATION_SERVICE_SERVICE_LEVEL_OBJECTIVE.matches(formattedString) + || FOLDER_SERVICE_SERVICE_LEVEL_OBJECTIVE.matches(formattedString); } @Override @@ -292,12 +300,45 @@ public String toString() { return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ServiceLevelObjectiveName that = ((ServiceLevelObjectiveName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.service, that.service) + && Objects.equals(this.serviceLevelObjective, that.serviceLevelObjective) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(service); + h *= 1000003; + h ^= Objects.hashCode(serviceLevelObjective); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + /** * Builder for * projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}. */ public static class Builder { - private String project; private String service; private String serviceLevelObjective; @@ -333,10 +374,9 @@ public Builder setServiceLevelObjective(String serviceLevelObjective) { private Builder(ServiceLevelObjectiveName serviceLevelObjectiveName) { Preconditions.checkArgument( - serviceLevelObjectiveName.pathTemplate - == PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE_PATH_TEMPLATE, - "toBuilder is only supported when ServiceLevelObjectiveName has the pattern of " - + "projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}."); + Objects.equals( + serviceLevelObjectiveName.pathTemplate, PROJECT_SERVICE_SERVICE_LEVEL_OBJECTIVE), + "toBuilder is only supported when ServiceLevelObjectiveName has the pattern of projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}"); project = serviceLevelObjectiveName.project; service = serviceLevelObjectiveName.service; serviceLevelObjective = serviceLevelObjectiveName.serviceLevelObjective; @@ -353,12 +393,11 @@ public ServiceLevelObjectiveName build() { */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class OrganizationServiceServiceLevelObjectiveBuilder { - private String organization; private String service; private String serviceLevelObjective; - private OrganizationServiceServiceLevelObjectiveBuilder() {} + protected OrganizationServiceServiceLevelObjectiveBuilder() {} public String getOrganization() { return organization; @@ -399,12 +438,11 @@ public ServiceLevelObjectiveName build() { */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class FolderServiceServiceLevelObjectiveBuilder { - private String folder; private String service; private String serviceLevelObjective; - private FolderServiceServiceLevelObjectiveBuilder() {} + protected FolderServiceServiceLevelObjectiveBuilder() {} public String getFolder() { return folder; @@ -438,38 +476,4 @@ public ServiceLevelObjectiveName build() { return new ServiceLevelObjectiveName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - ServiceLevelObjectiveName that = (ServiceLevelObjectiveName) o; - return (Objects.equals(this.project, that.project)) - && (Objects.equals(this.service, that.service)) - && (Objects.equals(this.serviceLevelObjective, that.serviceLevelObjective)) - && (Objects.equals(this.organization, that.organization)) - && (Objects.equals(this.folder, that.folder)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(service); - h *= 1000003; - h ^= Objects.hashCode(serviceLevelObjective); - h *= 1000003; - h ^= Objects.hashCode(organization); - h *= 1000003; - h ^= Objects.hashCode(folder); - return h; - } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ServiceName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ServiceName.java index 9070e6dc..f9bee3af 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ServiceName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ServiceName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -26,62 +26,71 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class ServiceName implements ResourceName { - - @Deprecated - protected ServiceName() {} - - private static final PathTemplate PROJECT_SERVICE_PATH_TEMPLATE = + private static final PathTemplate PROJECT_SERVICE = PathTemplate.createWithoutUrlEncoding("projects/{project}/services/{service}"); - private static final PathTemplate ORGANIZATION_SERVICE_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_SERVICE = PathTemplate.createWithoutUrlEncoding("organizations/{organization}/services/{service}"); - private static final PathTemplate FOLDER_SERVICE_PATH_TEMPLATE = + private static final PathTemplate FOLDER_SERVICE = PathTemplate.createWithoutUrlEncoding("folders/{folder}/services/{service}"); - private volatile Map fieldValuesMap; private PathTemplate pathTemplate; private String fixedValue; + private final String project; + private final String service; + private final String organization; + private final String folder; - private String project; - private String service; - private String organization; - private String folder; - - public String getProject() { - return project; - } - - public String getService() { - return service; - } - - public String getOrganization() { - return organization; - } - - public String getFolder() { - return folder; + @Deprecated + protected ServiceName() { + project = null; + service = null; + organization = null; + folder = null; } private ServiceName(Builder builder) { project = Preconditions.checkNotNull(builder.getProject()); service = Preconditions.checkNotNull(builder.getService()); - pathTemplate = PROJECT_SERVICE_PATH_TEMPLATE; + organization = null; + folder = null; + pathTemplate = PROJECT_SERVICE; } private ServiceName(OrganizationServiceBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); service = Preconditions.checkNotNull(builder.getService()); - pathTemplate = ORGANIZATION_SERVICE_PATH_TEMPLATE; + project = null; + folder = null; + pathTemplate = ORGANIZATION_SERVICE; } private ServiceName(FolderServiceBuilder builder) { folder = Preconditions.checkNotNull(builder.getFolder()); service = Preconditions.checkNotNull(builder.getService()); - pathTemplate = FOLDER_SERVICE_PATH_TEMPLATE; + project = null; + organization = null; + pathTemplate = FOLDER_SERVICE; + } + + public String getProject() { + return project; + } + + public String getService() { + return service; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; } public static Builder newBuilder() { @@ -108,12 +117,12 @@ public Builder toBuilder() { } public static ServiceName of(String project, String service) { - return newProjectServiceBuilder().setProject(project).setService(service).build(); + return newBuilder().setProject(project).setService(service).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") public static ServiceName ofProjectServiceName(String project, String service) { - return newProjectServiceBuilder().setProject(project).setService(service).build(); + return newBuilder().setProject(project).setService(service).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") @@ -156,17 +165,17 @@ public static ServiceName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (PROJECT_SERVICE_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = PROJECT_SERVICE_PATH_TEMPLATE.match(formattedString); + if (PROJECT_SERVICE.matches(formattedString)) { + Map matchMap = PROJECT_SERVICE.match(formattedString); return ofProjectServiceName(matchMap.get("project"), matchMap.get("service")); - } else if (ORGANIZATION_SERVICE_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = ORGANIZATION_SERVICE_PATH_TEMPLATE.match(formattedString); + } else if (ORGANIZATION_SERVICE.matches(formattedString)) { + Map matchMap = ORGANIZATION_SERVICE.match(formattedString); return ofOrganizationServiceName(matchMap.get("organization"), matchMap.get("service")); - } else if (FOLDER_SERVICE_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = FOLDER_SERVICE_PATH_TEMPLATE.match(formattedString); + } else if (FOLDER_SERVICE.matches(formattedString)) { + Map matchMap = FOLDER_SERVICE.match(formattedString); return ofFolderServiceName(matchMap.get("folder"), matchMap.get("service")); } - throw new ValidationException("JobName.parse: formattedString not in valid format"); + throw new ValidationException("ServiceName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -190,9 +199,9 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PROJECT_SERVICE_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_SERVICE_PATH_TEMPLATE.matches(formattedString) - || FOLDER_SERVICE_PATH_TEMPLATE.matches(formattedString); + return PROJECT_SERVICE.matches(formattedString) + || ORGANIZATION_SERVICE.matches(formattedString) + || FOLDER_SERVICE.matches(formattedString); } @Override @@ -229,9 +238,39 @@ public String toString() { return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ServiceName that = ((ServiceName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.service, that.service) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(service); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + /** Builder for projects/{project}/services/{service}. */ public static class Builder { - private String project; private String service; @@ -257,9 +296,8 @@ public Builder setService(String service) { private Builder(ServiceName serviceName) { Preconditions.checkArgument( - serviceName.pathTemplate == PROJECT_SERVICE_PATH_TEMPLATE, - "toBuilder is only supported when ServiceName has the pattern of " - + "projects/{project}/services/{service}."); + Objects.equals(serviceName.pathTemplate, PROJECT_SERVICE), + "toBuilder is only supported when ServiceName has the pattern of projects/{project}/services/{service}"); project = serviceName.project; service = serviceName.service; } @@ -272,11 +310,10 @@ public ServiceName build() { /** Builder for organizations/{organization}/services/{service}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class OrganizationServiceBuilder { - private String organization; private String service; - private OrganizationServiceBuilder() {} + protected OrganizationServiceBuilder() {} public String getOrganization() { return organization; @@ -304,11 +341,10 @@ public ServiceName build() { /** Builder for folders/{folder}/services/{service}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class FolderServiceBuilder { - private String folder; private String service; - private FolderServiceBuilder() {} + protected FolderServiceBuilder() {} public String getFolder() { return folder; @@ -332,35 +368,4 @@ public ServiceName build() { return new ServiceName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - ServiceName that = (ServiceName) o; - return (Objects.equals(this.project, that.project)) - && (Objects.equals(this.service, that.service)) - && (Objects.equals(this.organization, that.organization)) - && (Objects.equals(this.folder, that.folder)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(service); - h *= 1000003; - h ^= Objects.hashCode(organization); - h *= 1000003; - h ^= Objects.hashCode(folder); - return h; - } } diff --git a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/UptimeCheckConfigName.java b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/UptimeCheckConfigName.java index a00ec050..f51da5f1 100644 --- a/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/UptimeCheckConfigName.java +++ b/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/UptimeCheckConfigName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -26,65 +26,74 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class UptimeCheckConfigName implements ResourceName { - - @Deprecated - protected UptimeCheckConfigName() {} - - private static final PathTemplate PROJECT_UPTIME_CHECK_CONFIG_PATH_TEMPLATE = + private static final PathTemplate PROJECT_UPTIME_CHECK_CONFIG = PathTemplate.createWithoutUrlEncoding( "projects/{project}/uptimeCheckConfigs/{uptime_check_config}"); - private static final PathTemplate ORGANIZATION_UPTIME_CHECK_CONFIG_PATH_TEMPLATE = + private static final PathTemplate ORGANIZATION_UPTIME_CHECK_CONFIG = PathTemplate.createWithoutUrlEncoding( "organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}"); - private static final PathTemplate FOLDER_UPTIME_CHECK_CONFIG_PATH_TEMPLATE = + private static final PathTemplate FOLDER_UPTIME_CHECK_CONFIG = PathTemplate.createWithoutUrlEncoding( "folders/{folder}/uptimeCheckConfigs/{uptime_check_config}"); - private volatile Map fieldValuesMap; private PathTemplate pathTemplate; private String fixedValue; + private final String project; + private final String uptimeCheckConfig; + private final String organization; + private final String folder; - private String project; - private String uptimeCheckConfig; - private String organization; - private String folder; - - public String getProject() { - return project; - } - - public String getUptimeCheckConfig() { - return uptimeCheckConfig; - } - - public String getOrganization() { - return organization; - } - - public String getFolder() { - return folder; + @Deprecated + protected UptimeCheckConfigName() { + project = null; + uptimeCheckConfig = null; + organization = null; + folder = null; } private UptimeCheckConfigName(Builder builder) { project = Preconditions.checkNotNull(builder.getProject()); uptimeCheckConfig = Preconditions.checkNotNull(builder.getUptimeCheckConfig()); - pathTemplate = PROJECT_UPTIME_CHECK_CONFIG_PATH_TEMPLATE; + organization = null; + folder = null; + pathTemplate = PROJECT_UPTIME_CHECK_CONFIG; } private UptimeCheckConfigName(OrganizationUptimeCheckConfigBuilder builder) { organization = Preconditions.checkNotNull(builder.getOrganization()); uptimeCheckConfig = Preconditions.checkNotNull(builder.getUptimeCheckConfig()); - pathTemplate = ORGANIZATION_UPTIME_CHECK_CONFIG_PATH_TEMPLATE; + project = null; + folder = null; + pathTemplate = ORGANIZATION_UPTIME_CHECK_CONFIG; } private UptimeCheckConfigName(FolderUptimeCheckConfigBuilder builder) { folder = Preconditions.checkNotNull(builder.getFolder()); uptimeCheckConfig = Preconditions.checkNotNull(builder.getUptimeCheckConfig()); - pathTemplate = FOLDER_UPTIME_CHECK_CONFIG_PATH_TEMPLATE; + project = null; + organization = null; + pathTemplate = FOLDER_UPTIME_CHECK_CONFIG; + } + + public String getProject() { + return project; + } + + public String getUptimeCheckConfig() { + return uptimeCheckConfig; + } + + public String getOrganization() { + return organization; + } + + public String getFolder() { + return folder; } public static Builder newBuilder() { @@ -111,19 +120,13 @@ public Builder toBuilder() { } public static UptimeCheckConfigName of(String project, String uptimeCheckConfig) { - return newProjectUptimeCheckConfigBuilder() - .setProject(project) - .setUptimeCheckConfig(uptimeCheckConfig) - .build(); + return newBuilder().setProject(project).setUptimeCheckConfig(uptimeCheckConfig).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") public static UptimeCheckConfigName ofProjectUptimeCheckConfigName( String project, String uptimeCheckConfig) { - return newProjectUptimeCheckConfigBuilder() - .setProject(project) - .setUptimeCheckConfig(uptimeCheckConfig) - .build(); + return newBuilder().setProject(project).setUptimeCheckConfig(uptimeCheckConfig).build(); } @BetaApi("The static create methods are not stable yet and may be changed in the future.") @@ -185,23 +188,21 @@ public static UptimeCheckConfigName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - if (PROJECT_UPTIME_CHECK_CONFIG_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - PROJECT_UPTIME_CHECK_CONFIG_PATH_TEMPLATE.match(formattedString); + if (PROJECT_UPTIME_CHECK_CONFIG.matches(formattedString)) { + Map matchMap = PROJECT_UPTIME_CHECK_CONFIG.match(formattedString); return ofProjectUptimeCheckConfigName( matchMap.get("project"), matchMap.get("uptime_check_config")); - } else if (ORGANIZATION_UPTIME_CHECK_CONFIG_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - ORGANIZATION_UPTIME_CHECK_CONFIG_PATH_TEMPLATE.match(formattedString); + } else if (ORGANIZATION_UPTIME_CHECK_CONFIG.matches(formattedString)) { + Map matchMap = ORGANIZATION_UPTIME_CHECK_CONFIG.match(formattedString); return ofOrganizationUptimeCheckConfigName( matchMap.get("organization"), matchMap.get("uptime_check_config")); - } else if (FOLDER_UPTIME_CHECK_CONFIG_PATH_TEMPLATE.matches(formattedString)) { - Map matchMap = - FOLDER_UPTIME_CHECK_CONFIG_PATH_TEMPLATE.match(formattedString); + } else if (FOLDER_UPTIME_CHECK_CONFIG.matches(formattedString)) { + Map matchMap = FOLDER_UPTIME_CHECK_CONFIG.match(formattedString); return ofFolderUptimeCheckConfigName( matchMap.get("folder"), matchMap.get("uptime_check_config")); } - throw new ValidationException("JobName.parse: formattedString not in valid format"); + throw new ValidationException( + "UptimeCheckConfigName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -225,9 +226,9 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PROJECT_UPTIME_CHECK_CONFIG_PATH_TEMPLATE.matches(formattedString) - || ORGANIZATION_UPTIME_CHECK_CONFIG_PATH_TEMPLATE.matches(formattedString) - || FOLDER_UPTIME_CHECK_CONFIG_PATH_TEMPLATE.matches(formattedString); + return PROJECT_UPTIME_CHECK_CONFIG.matches(formattedString) + || ORGANIZATION_UPTIME_CHECK_CONFIG.matches(formattedString) + || FOLDER_UPTIME_CHECK_CONFIG.matches(formattedString); } @Override @@ -264,9 +265,39 @@ public String toString() { return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + UptimeCheckConfigName that = ((UptimeCheckConfigName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.uptimeCheckConfig, that.uptimeCheckConfig) + && Objects.equals(this.organization, that.organization) + && Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(uptimeCheckConfig); + h *= 1000003; + h ^= Objects.hashCode(organization); + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + /** Builder for projects/{project}/uptimeCheckConfigs/{uptime_check_config}. */ public static class Builder { - private String project; private String uptimeCheckConfig; @@ -292,9 +323,8 @@ public Builder setUptimeCheckConfig(String uptimeCheckConfig) { private Builder(UptimeCheckConfigName uptimeCheckConfigName) { Preconditions.checkArgument( - uptimeCheckConfigName.pathTemplate == PROJECT_UPTIME_CHECK_CONFIG_PATH_TEMPLATE, - "toBuilder is only supported when UptimeCheckConfigName has the pattern of " - + "projects/{project}/uptimeCheckConfigs/{uptime_check_config}."); + Objects.equals(uptimeCheckConfigName.pathTemplate, PROJECT_UPTIME_CHECK_CONFIG), + "toBuilder is only supported when UptimeCheckConfigName has the pattern of projects/{project}/uptimeCheckConfigs/{uptime_check_config}"); project = uptimeCheckConfigName.project; uptimeCheckConfig = uptimeCheckConfigName.uptimeCheckConfig; } @@ -307,11 +337,10 @@ public UptimeCheckConfigName build() { /** Builder for organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class OrganizationUptimeCheckConfigBuilder { - private String organization; private String uptimeCheckConfig; - private OrganizationUptimeCheckConfigBuilder() {} + protected OrganizationUptimeCheckConfigBuilder() {} public String getOrganization() { return organization; @@ -339,11 +368,10 @@ public UptimeCheckConfigName build() { /** Builder for folders/{folder}/uptimeCheckConfigs/{uptime_check_config}. */ @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") public static class FolderUptimeCheckConfigBuilder { - private String folder; private String uptimeCheckConfig; - private FolderUptimeCheckConfigBuilder() {} + protected FolderUptimeCheckConfigBuilder() {} public String getFolder() { return folder; @@ -367,35 +395,4 @@ public UptimeCheckConfigName build() { return new UptimeCheckConfigName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - UptimeCheckConfigName that = (UptimeCheckConfigName) o; - return (Objects.equals(this.project, that.project)) - && (Objects.equals(this.uptimeCheckConfig, that.uptimeCheckConfig)) - && (Objects.equals(this.organization, that.organization)) - && (Objects.equals(this.folder, that.folder)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(uptimeCheckConfig); - h *= 1000003; - h ^= Objects.hashCode(organization); - h *= 1000003; - h ^= Objects.hashCode(folder); - return h; - } } diff --git a/synth.metadata b/synth.metadata index fc2e32d5..f2b5e2d1 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "7c577e89f1c84545113b393b7d7964473251d123", - "internalRef": "318542700" + "sha": "857f70daef9f4c38f042fb3dfb7b8423ae18fd19", + "internalRef": "346372957" } }, { @@ -140,7 +140,6 @@ "google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java", "google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java", "google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java", - "google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java", "google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyService.java", "google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockAlertPolicyServiceImpl.java", "google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MockGroupService.java", @@ -214,6 +213,7 @@ "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabels.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsOrBuilder.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsProto.java", + "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/FolderName.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/GetAlertPolicyRequest.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/GetAlertPolicyRequestOrBuilder.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/GetGroupRequest.java", @@ -309,6 +309,7 @@ "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannelOrBuilder.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationProto.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationServiceProto.java", + "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/OrganizationName.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/Point.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/PointOrBuilder.java", "proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/ProjectName.java", diff --git a/synth.py b/synth.py index 43e7983f..cc1c473c 100644 --- a/synth.py +++ b/synth.py @@ -14,6 +14,7 @@ """This script is used to synthesize generated parts of this library.""" +import synthtool as s import synthtool.languages.java as java AUTOSYNTH_MULTIPLE_COMMITS = True @@ -21,6 +22,19 @@ service = 'monitoring' versions = ['v3'] +def fix_resource(client, version, name): + s.replace( + [f'google-cloud-monitoring/**/{version}/{client}.java'], + f'import com.google.monitoring.{version}.{name}', + 'import com.google.api.resourcenames.ResourceName', + ) + + s.replace( + [f'google-cloud-monitoring/**/{version}/{client}.java'], + name, + 'ResourceName', + ) + for version in versions: java.bazel_library( service=service, @@ -28,5 +42,11 @@ proto_path=f'google/{service}/{version}', bazel_target=f'//google/{service}/{version}:google-cloud-{service}-{version}-java', ) + fix_resource('AlertPolicyServiceClient', version, 'FolderName') + fix_resource('GroupServiceClient', version, 'FolderName') + fix_resource('MetricServiceClient', version, 'FolderName') + fix_resource('NotificationChannelServiceClient', version, 'FolderName') + fix_resource('ServiceMonitoringServiceClient', version, 'FolderName') + fix_resource('UptimeCheckServiceClient', version, 'FolderName') java.common_templates()