From 1ff07b026e890793b5e64be58ba67869492f196f Mon Sep 17 00:00:00 2001 From: Andrea Lin Date: Tue, 26 Mar 2019 09:43:40 -0700 Subject: [PATCH 1/7] regen monitoring with STATIC_TYPES --- .../monitoring/v3/NotificationChannel.java | 6 +- .../v3/AlertPolicyServiceClient.java | 4 +- .../monitoring/v3/GroupServiceClient.java | 4 +- .../monitoring/v3/MetricServiceClient.java | 6 +- .../v3/NotificationChannelServiceClient.java | 6 +- .../v3/UptimeCheckServiceClient.java | 83 +++++++++++++++---- .../cloud/monitoring/v3/package-info.java | 4 +- .../v3/AlertPolicyServiceClientTest.java | 4 +- .../monitoring/v3/GroupServiceClientTest.java | 4 +- .../v3/MetricServiceClientTest.java | 6 +- .../monitoring/v3/MetricServiceSmokeTest.java | 2 +- .../NotificationChannelServiceClientTest.java | 6 +- .../v3/UptimeCheckServiceClientTest.java | 24 +++--- 13 files changed, 106 insertions(+), 53 deletions(-) diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannel.java b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannel.java index 9a6b671265f6..05a87492f89e 100644 --- a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannel.java +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannel.java @@ -921,8 +921,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io output, internalGetUserLabels(), UserLabelsDefaultEntryHolder.defaultEntry, 8); if (verificationStatus_ != com.google.monitoring.v3.NotificationChannel.VerificationStatus - .VERIFICATION_STATUS_UNSPECIFIED - .getNumber()) { + .VERIFICATION_STATUS_UNSPECIFIED.getNumber()) { output.writeEnum(9, verificationStatus_); } if (enabled_ != null) { @@ -971,8 +970,7 @@ public int getSerializedSize() { } if (verificationStatus_ != com.google.monitoring.v3.NotificationChannel.VerificationStatus - .VERIFICATION_STATUS_UNSPECIFIED - .getNumber()) { + .VERIFICATION_STATUS_UNSPECIFIED.getNumber()) { size += com.google.protobuf.CodedOutputStream.computeEnumSize(9, verificationStatus_); } if (enabled_ != null) { diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java index 6a48c01fcb60..8fde0b16a05c 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java @@ -29,16 +29,16 @@ import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; +import com.google.protos.google.monitoring.v3.AlertPolicyName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java index f8d3578d0d06..71b09765b706 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java @@ -33,14 +33,14 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; -import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; import com.google.monitoring.v3.ListGroupsRequest; import com.google.monitoring.v3.ListGroupsResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; +import com.google.protos.google.monitoring.v3.GroupName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java index 913183e33640..2bf9ba121e29 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java @@ -41,12 +41,12 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; -import com.google.monitoring.v3.MetricDescriptorName; -import com.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; +import com.google.protos.google.monitoring.v3.MetricDescriptorName; +import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java index ec971fb6543c..bbd95d315ec0 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java @@ -38,12 +38,12 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.monitoring.v3.NotificationChannelName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; +import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.protos.google.monitoring.v3.NotificationChannelName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java index cfe1554df34f..adec7aba17f7 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java @@ -39,6 +39,7 @@ import com.google.monitoring.v3.UptimeCheckConfig; import com.google.monitoring.v3.UptimeCheckIp; import com.google.protobuf.Empty; +import com.google.protos.google.monitoring.v3.UptimeCheckConfigName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -59,8 +60,8 @@ *
  * 
  * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
+ *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+ *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
  * }
  * 
  * 
@@ -289,8 +290,34 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs( * *

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

Sample code: + * + *


+   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name.toString());
    * }
    * 
* @@ -313,9 +340,9 @@ public final UptimeCheckConfig getUptimeCheckConfig(String name) { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(request);
    * }
@@ -336,9 +363,9 @@ public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<UptimeCheckConfig> future = uptimeCheckServiceClient.getUptimeCheckConfigCallable().futureCall(request);
    *   // Do something
@@ -523,8 +550,36 @@ public final UptimeCheckConfig updateUptimeCheckConfig(UpdateUptimeCheckConfigRe
    *
    * 

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

Sample code: + * + *


+   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(name.toString());
    * }
    * 
* @@ -549,9 +604,9 @@ public final void deleteUptimeCheckConfig(String name) { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   uptimeCheckServiceClient.deleteUptimeCheckConfig(request);
    * }
@@ -574,9 +629,9 @@ public final void deleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest request
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<Void> future = uptimeCheckServiceClient.deleteUptimeCheckConfigCallable().futureCall(request);
    *   // Do something
diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
index 5c405dc40d7a..297143cd6622 100644
--- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
+++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
@@ -109,8 +109,8 @@
  * 
  * 
  * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
+ *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+ *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
  * }
  * 
  * 
diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java index 1897bfe95000..c42d13091242 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java @@ -26,17 +26,17 @@ import com.google.api.gax.rpc.InvalidArgumentException; import com.google.common.collect.Lists; import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.AlertPolicyName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java index 29d33d133a10..c3e437e127b4 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java @@ -30,13 +30,13 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; -import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.GroupName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java index 0d79d7cec208..ea7b0eeaf6d9 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java @@ -40,13 +40,13 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; -import com.google.monitoring.v3.MetricDescriptorName; -import com.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.MetricDescriptorName; +import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java index 2f61f966dd57..345a121f9374 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java @@ -18,7 +18,7 @@ import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; import com.google.common.base.Preconditions; -import com.google.monitoring.v3.ProjectName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.util.logging.Level; import java.util.logging.Logger; import org.junit.Test; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java index 4c886a9250f4..dc5e3f70c55c 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java @@ -36,13 +36,13 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.monitoring.v3.NotificationChannelName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.protos.google.monitoring.v3.NotificationChannelName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java index 1c367c49f0e0..0df214e7f900 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java @@ -30,12 +30,12 @@ import com.google.monitoring.v3.GetUptimeCheckConfigRequest; import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.ProjectName; +import com.google.protos.google.monitoring.v3.UptimeCheckConfigName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; @@ -166,16 +166,16 @@ public void getUptimeCheckConfigTest() { .build(); mockUptimeCheckService.addResponse(expectedResponse); - String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - UptimeCheckConfig actualResponse = client.getUptimeCheckConfig(formattedName); + 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(formattedName, actualRequest.getName()); + Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -189,9 +189,9 @@ public void getUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.getUptimeCheckConfig(formattedName); + client.getUptimeCheckConfig(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -302,16 +302,16 @@ public void deleteUptimeCheckConfigTest() { Empty expectedResponse = Empty.newBuilder().build(); mockUptimeCheckService.addResponse(expectedResponse); - String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.deleteUptimeCheckConfig(formattedName); + client.deleteUptimeCheckConfig(name); List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteUptimeCheckConfigRequest actualRequest = (DeleteUptimeCheckConfigRequest) actualRequests.get(0); - Assert.assertEquals(formattedName, actualRequest.getName()); + Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -325,9 +325,9 @@ public void deleteUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.deleteUptimeCheckConfig(formattedName); + client.deleteUptimeCheckConfig(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception From 78a95d59e544b0fe8570657597c9565038d225c2 Mon Sep 17 00:00:00 2001 From: Andrea Lin Date: Tue, 26 Mar 2019 11:12:25 -0700 Subject: [PATCH 2/7] regen again but with java_package --- .../google/monitoring/v3/DroppedLabels.java | 770 ++++++++++++++++++ .../monitoring/v3/DroppedLabelsOrBuilder.java | 64 ++ .../monitoring/v3/DroppedLabelsProto.java | 76 ++ .../google/monitoring/v3/dropped_labels.proto | 3 + .../v3/AlertPolicyServiceClient.java | 4 +- .../monitoring/v3/GroupServiceClient.java | 4 +- .../monitoring/v3/MetricServiceClient.java | 6 +- .../v3/NotificationChannelServiceClient.java | 6 +- .../v3/UptimeCheckServiceClient.java | 2 +- .../v3/AlertPolicyServiceClientTest.java | 4 +- .../monitoring/v3/GroupServiceClientTest.java | 4 +- .../v3/MetricServiceClientTest.java | 6 +- .../monitoring/v3/MetricServiceSmokeTest.java | 2 +- .../NotificationChannelServiceClientTest.java | 6 +- .../v3/UptimeCheckServiceClientTest.java | 4 +- 15 files changed, 937 insertions(+), 24 deletions(-) create mode 100644 google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabels.java create mode 100644 google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsOrBuilder.java create mode 100644 google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsProto.java diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabels.java b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabels.java new file mode 100644 index 000000000000..49bfe6d4affa --- /dev/null +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabels.java @@ -0,0 +1,770 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/monitoring/v3/dropped_labels.proto + +package com.google.monitoring.v3; + +/** + * + * + *
+ * A set of (label, value) pairs which were dropped during aggregation, attached
+ * to google.api.Distribution.Exemplars in google.api.Distribution values during
+ * aggregation.
+ * These values are used in combination with the label values that remain on the
+ * aggregated Distribution timeseries to construct the full label set for the
+ * exemplar values.  The resulting full label set may be used to identify the
+ * specific task/job/instance (for example) which may be contributing to a
+ * long-tail, while allowing the storage savings of only storing aggregated
+ * distribution values for a large group.
+ * Note that there are no guarantees on ordering of the labels from
+ * exemplar-to-exemplar and from distribution-to-distribution in the same
+ * stream, and there may be duplicates.  It is up to clients to resolve any
+ * ambiguities.
+ * 
+ * + * Protobuf type {@code google.monitoring.v3.DroppedLabels} + */ +public final class DroppedLabels extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.monitoring.v3.DroppedLabels) + DroppedLabelsOrBuilder { + private static final long serialVersionUID = 0L; + // Use DroppedLabels.newBuilder() to construct. + private DroppedLabels(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private DroppedLabels() {} + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private DroppedLabels( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + label_ = + com.google.protobuf.MapField.newMapField(LabelDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000001; + } + com.google.protobuf.MapEntry label__ = + input.readMessage( + LabelDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + label_.getMutableMap().put(label__.getKey(), label__.getValue()); + break; + } + default: + { + if (!parseUnknownFieldProto3(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.monitoring.v3.DroppedLabelsProto + .internal_static_google_monitoring_v3_DroppedLabels_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapField internalGetMapField(int number) { + switch (number) { + case 1: + return internalGetLabel(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.monitoring.v3.DroppedLabelsProto + .internal_static_google_monitoring_v3_DroppedLabels_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.monitoring.v3.DroppedLabels.class, + com.google.monitoring.v3.DroppedLabels.Builder.class); + } + + public static final int LABEL_FIELD_NUMBER = 1; + + private static final class LabelDefaultEntryHolder { + static final com.google.protobuf.MapEntry defaultEntry = + com.google.protobuf.MapEntry.newDefaultInstance( + com.google.monitoring.v3.DroppedLabelsProto + .internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + + private com.google.protobuf.MapField label_; + + private com.google.protobuf.MapField internalGetLabel() { + if (label_ == null) { + return com.google.protobuf.MapField.emptyMapField(LabelDefaultEntryHolder.defaultEntry); + } + return label_; + } + + public int getLabelCount() { + return internalGetLabel().getMap().size(); + } + /** + * + * + *
+   * Map from label to its value, for all labels dropped in any aggregation.
+   * 
+ * + * map<string, string> label = 1; + */ + public boolean containsLabel(java.lang.String key) { + if (key == null) { + throw new java.lang.NullPointerException(); + } + return internalGetLabel().getMap().containsKey(key); + } + /** Use {@link #getLabelMap()} instead. */ + @java.lang.Deprecated + public java.util.Map getLabel() { + return getLabelMap(); + } + /** + * + * + *
+   * Map from label to its value, for all labels dropped in any aggregation.
+   * 
+ * + * map<string, string> label = 1; + */ + public java.util.Map getLabelMap() { + return internalGetLabel().getMap(); + } + /** + * + * + *
+   * Map from label to its value, for all labels dropped in any aggregation.
+   * 
+ * + * map<string, string> label = 1; + */ + public java.lang.String getLabelOrDefault(java.lang.String key, java.lang.String defaultValue) { + if (key == null) { + throw new java.lang.NullPointerException(); + } + java.util.Map map = internalGetLabel().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * + * + *
+   * Map from label to its value, for all labels dropped in any aggregation.
+   * 
+ * + * map<string, string> label = 1; + */ + public java.lang.String getLabelOrThrow(java.lang.String key) { + if (key == null) { + throw new java.lang.NullPointerException(); + } + java.util.Map map = internalGetLabel().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( + output, internalGetLabel(), LabelDefaultEntryHolder.defaultEntry, 1); + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (java.util.Map.Entry entry : + internalGetLabel().getMap().entrySet()) { + com.google.protobuf.MapEntry label__ = + LabelDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, label__); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.monitoring.v3.DroppedLabels)) { + return super.equals(obj); + } + com.google.monitoring.v3.DroppedLabels other = (com.google.monitoring.v3.DroppedLabels) obj; + + boolean result = true; + result = result && internalGetLabel().equals(other.internalGetLabel()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (!internalGetLabel().getMap().isEmpty()) { + hash = (37 * hash) + LABEL_FIELD_NUMBER; + hash = (53 * hash) + internalGetLabel().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.monitoring.v3.DroppedLabels parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.monitoring.v3.DroppedLabels parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.monitoring.v3.DroppedLabels parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.monitoring.v3.DroppedLabels prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * A set of (label, value) pairs which were dropped during aggregation, attached
+   * to google.api.Distribution.Exemplars in google.api.Distribution values during
+   * aggregation.
+   * These values are used in combination with the label values that remain on the
+   * aggregated Distribution timeseries to construct the full label set for the
+   * exemplar values.  The resulting full label set may be used to identify the
+   * specific task/job/instance (for example) which may be contributing to a
+   * long-tail, while allowing the storage savings of only storing aggregated
+   * distribution values for a large group.
+   * Note that there are no guarantees on ordering of the labels from
+   * exemplar-to-exemplar and from distribution-to-distribution in the same
+   * stream, and there may be duplicates.  It is up to clients to resolve any
+   * ambiguities.
+   * 
+ * + * Protobuf type {@code google.monitoring.v3.DroppedLabels} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.monitoring.v3.DroppedLabels) + com.google.monitoring.v3.DroppedLabelsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.monitoring.v3.DroppedLabelsProto + .internal_static_google_monitoring_v3_DroppedLabels_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField(int number) { + switch (number) { + case 1: + return internalGetLabel(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField(int number) { + switch (number) { + case 1: + return internalGetMutableLabel(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.monitoring.v3.DroppedLabelsProto + .internal_static_google_monitoring_v3_DroppedLabels_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.monitoring.v3.DroppedLabels.class, + com.google.monitoring.v3.DroppedLabels.Builder.class); + } + + // Construct using com.google.monitoring.v3.DroppedLabels.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + internalGetMutableLabel().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.monitoring.v3.DroppedLabelsProto + .internal_static_google_monitoring_v3_DroppedLabels_descriptor; + } + + @java.lang.Override + public com.google.monitoring.v3.DroppedLabels getDefaultInstanceForType() { + return com.google.monitoring.v3.DroppedLabels.getDefaultInstance(); + } + + @java.lang.Override + public com.google.monitoring.v3.DroppedLabels build() { + com.google.monitoring.v3.DroppedLabels result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.monitoring.v3.DroppedLabels buildPartial() { + com.google.monitoring.v3.DroppedLabels result = + new com.google.monitoring.v3.DroppedLabels(this); + int from_bitField0_ = bitField0_; + result.label_ = internalGetLabel(); + result.label_.makeImmutable(); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return (Builder) super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.monitoring.v3.DroppedLabels) { + return mergeFrom((com.google.monitoring.v3.DroppedLabels) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.monitoring.v3.DroppedLabels other) { + if (other == com.google.monitoring.v3.DroppedLabels.getDefaultInstance()) return this; + internalGetMutableLabel().mergeFrom(other.internalGetLabel()); + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.monitoring.v3.DroppedLabels parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.monitoring.v3.DroppedLabels) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private com.google.protobuf.MapField label_; + + private com.google.protobuf.MapField internalGetLabel() { + if (label_ == null) { + return com.google.protobuf.MapField.emptyMapField(LabelDefaultEntryHolder.defaultEntry); + } + return label_; + } + + private com.google.protobuf.MapField + internalGetMutableLabel() { + onChanged(); + ; + if (label_ == null) { + label_ = com.google.protobuf.MapField.newMapField(LabelDefaultEntryHolder.defaultEntry); + } + if (!label_.isMutable()) { + label_ = label_.copy(); + } + return label_; + } + + public int getLabelCount() { + return internalGetLabel().getMap().size(); + } + /** + * + * + *
+     * Map from label to its value, for all labels dropped in any aggregation.
+     * 
+ * + * map<string, string> label = 1; + */ + public boolean containsLabel(java.lang.String key) { + if (key == null) { + throw new java.lang.NullPointerException(); + } + return internalGetLabel().getMap().containsKey(key); + } + /** Use {@link #getLabelMap()} instead. */ + @java.lang.Deprecated + public java.util.Map getLabel() { + return getLabelMap(); + } + /** + * + * + *
+     * Map from label to its value, for all labels dropped in any aggregation.
+     * 
+ * + * map<string, string> label = 1; + */ + public java.util.Map getLabelMap() { + return internalGetLabel().getMap(); + } + /** + * + * + *
+     * Map from label to its value, for all labels dropped in any aggregation.
+     * 
+ * + * map<string, string> label = 1; + */ + public java.lang.String getLabelOrDefault(java.lang.String key, java.lang.String defaultValue) { + if (key == null) { + throw new java.lang.NullPointerException(); + } + java.util.Map map = internalGetLabel().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * + * + *
+     * Map from label to its value, for all labels dropped in any aggregation.
+     * 
+ * + * map<string, string> label = 1; + */ + public java.lang.String getLabelOrThrow(java.lang.String key) { + if (key == null) { + throw new java.lang.NullPointerException(); + } + java.util.Map map = internalGetLabel().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearLabel() { + internalGetMutableLabel().getMutableMap().clear(); + return this; + } + /** + * + * + *
+     * Map from label to its value, for all labels dropped in any aggregation.
+     * 
+ * + * map<string, string> label = 1; + */ + public Builder removeLabel(java.lang.String key) { + if (key == null) { + throw new java.lang.NullPointerException(); + } + internalGetMutableLabel().getMutableMap().remove(key); + return this; + } + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableLabel() { + return internalGetMutableLabel().getMutableMap(); + } + /** + * + * + *
+     * Map from label to its value, for all labels dropped in any aggregation.
+     * 
+ * + * map<string, string> label = 1; + */ + public Builder putLabel(java.lang.String key, java.lang.String value) { + if (key == null) { + throw new java.lang.NullPointerException(); + } + if (value == null) { + throw new java.lang.NullPointerException(); + } + internalGetMutableLabel().getMutableMap().put(key, value); + return this; + } + /** + * + * + *
+     * Map from label to its value, for all labels dropped in any aggregation.
+     * 
+ * + * map<string, string> label = 1; + */ + public Builder putAllLabel(java.util.Map values) { + internalGetMutableLabel().getMutableMap().putAll(values); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.monitoring.v3.DroppedLabels) + } + + // @@protoc_insertion_point(class_scope:google.monitoring.v3.DroppedLabels) + private static final com.google.monitoring.v3.DroppedLabels DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.monitoring.v3.DroppedLabels(); + } + + public static com.google.monitoring.v3.DroppedLabels getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DroppedLabels parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DroppedLabels(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.monitoring.v3.DroppedLabels getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsOrBuilder.java b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsOrBuilder.java new file mode 100644 index 000000000000..daff464d3394 --- /dev/null +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsOrBuilder.java @@ -0,0 +1,64 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/monitoring/v3/dropped_labels.proto + +package com.google.monitoring.v3; + +public interface DroppedLabelsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.monitoring.v3.DroppedLabels) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Map from label to its value, for all labels dropped in any aggregation.
+   * 
+ * + * map<string, string> label = 1; + */ + int getLabelCount(); + /** + * + * + *
+   * Map from label to its value, for all labels dropped in any aggregation.
+   * 
+ * + * map<string, string> label = 1; + */ + boolean containsLabel(java.lang.String key); + /** Use {@link #getLabelMap()} instead. */ + @java.lang.Deprecated + java.util.Map getLabel(); + /** + * + * + *
+   * Map from label to its value, for all labels dropped in any aggregation.
+   * 
+ * + * map<string, string> label = 1; + */ + java.util.Map getLabelMap(); + /** + * + * + *
+   * Map from label to its value, for all labels dropped in any aggregation.
+   * 
+ * + * map<string, string> label = 1; + */ + java.lang.String getLabelOrDefault(java.lang.String key, java.lang.String defaultValue); + /** + * + * + *
+   * Map from label to its value, for all labels dropped in any aggregation.
+   * 
+ * + * map<string, string> label = 1; + */ + java.lang.String getLabelOrThrow(java.lang.String key); +} diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsProto.java b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsProto.java new file mode 100644 index 000000000000..218d33656617 --- /dev/null +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsProto.java @@ -0,0 +1,76 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/monitoring/v3/dropped_labels.proto + +package com.google.monitoring.v3; + +public final class DroppedLabelsProto { + private DroppedLabelsProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_monitoring_v3_DroppedLabels_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_monitoring_v3_DroppedLabels_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n)google/monitoring/v3/dropped_labels.pr" + + "oto\022\024google.monitoring.v3\032\034google/api/an" + + "notations.proto\"|\n\rDroppedLabels\022=\n\005labe" + + "l\030\001 \003(\0132..google.monitoring.v3.DroppedLa" + + "bels.LabelEntry\032,\n\nLabelEntry\022\013\n\003key\030\001 \001" + + "(\t\022\r\n\005value\030\002 \001(\t:\0028\001Bp\n\030com.google.moni" + + "toring.v3B\022DroppedLabelsProtoP\001Z>google." + + "golang.org/genproto/googleapis/monitorin" + + "g/v3;monitoringb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + }, + assigner); + internal_static_google_monitoring_v3_DroppedLabels_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_monitoring_v3_DroppedLabels_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_monitoring_v3_DroppedLabels_descriptor, + new java.lang.String[] { + "Label", + }); + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_descriptor = + internal_static_google_monitoring_v3_DroppedLabels_descriptor.getNestedTypes().get(0); + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + com.google.api.AnnotationsProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto index d832aa454528..acbe8cf25ad1 100644 --- a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto @@ -20,6 +20,9 @@ package google.monitoring.v3; import "google/api/annotations.proto"; option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring"; +option java_multiple_files = true; +option java_outer_classname = "DroppedLabelsProto"; +option java_package = "com.google.monitoring.v3"; // A set of (label, value) pairs which were dropped during aggregation, attached // to google.api.Distribution.Exemplars in google.api.Distribution values during diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java index 8fde0b16a05c..6a48c01fcb60 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java @@ -29,16 +29,16 @@ import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.monitoring.v3.AlertPolicy; +import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; -import com.google.protos.google.monitoring.v3.AlertPolicyName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java index 71b09765b706..f8d3578d0d06 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java @@ -33,14 +33,14 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; +import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; import com.google.monitoring.v3.ListGroupsRequest; import com.google.monitoring.v3.ListGroupsResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; -import com.google.protos.google.monitoring.v3.GroupName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java index 2bf9ba121e29..913183e33640 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java @@ -41,12 +41,12 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; +import com.google.monitoring.v3.MetricDescriptorName; +import com.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; -import com.google.protos.google.monitoring.v3.MetricDescriptorName; -import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java index bbd95d315ec0..ec971fb6543c 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java @@ -38,12 +38,12 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; +import com.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.monitoring.v3.NotificationChannelName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; -import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.protos.google.monitoring.v3.NotificationChannelName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java index adec7aba17f7..8433f26744c3 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java @@ -37,9 +37,9 @@ import com.google.monitoring.v3.ListUptimeCheckIpsResponse; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; +import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.monitoring.v3.UptimeCheckIp; import com.google.protobuf.Empty; -import com.google.protos.google.monitoring.v3.UptimeCheckConfigName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java index c42d13091242..1897bfe95000 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java @@ -26,17 +26,17 @@ import com.google.api.gax.rpc.InvalidArgumentException; import com.google.common.collect.Lists; import com.google.monitoring.v3.AlertPolicy; +import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.AlertPolicyName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java index c3e437e127b4..29d33d133a10 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java @@ -30,13 +30,13 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; +import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.GroupName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java index ea7b0eeaf6d9..0d79d7cec208 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java @@ -40,13 +40,13 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; +import com.google.monitoring.v3.MetricDescriptorName; +import com.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.MetricDescriptorName; -import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java index 345a121f9374..2f61f966dd57 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java @@ -18,7 +18,7 @@ import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; import com.google.common.base.Preconditions; -import com.google.protos.google.monitoring.v3.ProjectName; +import com.google.monitoring.v3.ProjectName; import java.util.logging.Level; import java.util.logging.Logger; import org.junit.Test; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java index dc5e3f70c55c..4c886a9250f4 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java @@ -36,13 +36,13 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; +import com.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.monitoring.v3.NotificationChannelName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.protos.google.monitoring.v3.NotificationChannelName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java index 0df214e7f900..6faa686b5e2f 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java @@ -30,12 +30,12 @@ import com.google.monitoring.v3.GetUptimeCheckConfigRequest; import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; +import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.ProjectName; -import com.google.protos.google.monitoring.v3.UptimeCheckConfigName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; From d783e25ba1c9c89fcf2e221d1d4a0079f3620efe Mon Sep 17 00:00:00 2001 From: Andrea Lin Date: Tue, 26 Mar 2019 11:53:17 -0700 Subject: [PATCH 3/7] regen again with enable_string_formatting_functions --- .../google/monitoring/v3/dropped_labels.proto | 3 - .../v3/AlertPolicyServiceClient.java | 87 +++++++++- .../monitoring/v3/GroupServiceClient.java | 38 ++++- .../monitoring/v3/MetricServiceClient.java | 87 +++++++++- .../v3/NotificationChannelServiceClient.java | 92 ++++++++++- .../v3/UptimeCheckServiceClient.java | 151 +++++++++--------- .../cloud/monitoring/v3/package-info.java | 4 +- .../v3/AlertPolicyServiceClientTest.java | 4 +- .../monitoring/v3/GroupServiceClientTest.java | 4 +- .../v3/MetricServiceClientTest.java | 6 +- .../monitoring/v3/MetricServiceSmokeTest.java | 2 +- .../NotificationChannelServiceClientTest.java | 6 +- .../v3/UptimeCheckServiceClientTest.java | 36 +++-- 13 files changed, 399 insertions(+), 121 deletions(-) diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto index acbe8cf25ad1..d832aa454528 100644 --- a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto @@ -20,9 +20,6 @@ package google.monitoring.v3; import "google/api/annotations.proto"; option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring"; -option java_multiple_files = true; -option java_outer_classname = "DroppedLabelsProto"; -option java_package = "com.google.monitoring.v3"; // A set of (label, value) pairs which were dropped during aggregation, attached // to google.api.Distribution.Exemplars in google.api.Distribution values during diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java index 6a48c01fcb60..f93b5064ce3e 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java @@ -25,20 +25,21 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStub; import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; +import com.google.protos.google.monitoring.v3.AlertPolicyName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -121,6 +122,88 @@ public class AlertPolicyServiceClient implements BackgroundResource { private final AlertPolicyServiceSettings settings; private final AlertPolicyServiceStub stub; + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("projects/{project}"); + + private static final PathTemplate ALERT_POLICY_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("projects/{project}/alertPolicies/{alert_policy}"); + + private static final PathTemplate ALERT_POLICY_CONDITION_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}"); + + /** Formats a string containing the fully-qualified path to represent a project resource. */ + public static final String formatProjectName(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } + + /** Formats a string containing the fully-qualified path to represent a alert_policy resource. */ + public static final String formatAlertPolicyName(String project, String alertPolicy) { + return ALERT_POLICY_PATH_TEMPLATE.instantiate( + "project", project, + "alert_policy", alertPolicy); + } + + /** + * Formats a string containing the fully-qualified path to represent a alert_policy_condition + * resource. + */ + public static final String formatAlertPolicyConditionName( + String project, String alertPolicy, String condition) { + return ALERT_POLICY_CONDITION_PATH_TEMPLATE.instantiate( + "project", project, + "alert_policy", alertPolicy, + "condition", condition); + } + + /** Parses the project from the given fully-qualified path which represents a project resource. */ + public static final String parseProjectFromProjectName(String projectName) { + return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); + } + + /** + * Parses the project from the given fully-qualified path which represents a alert_policy + * resource. + */ + public static final String parseProjectFromAlertPolicyName(String alertPolicyName) { + return ALERT_POLICY_PATH_TEMPLATE.parse(alertPolicyName).get("project"); + } + + /** + * Parses the alert_policy from the given fully-qualified path which represents a alert_policy + * resource. + */ + public static final String parseAlertPolicyFromAlertPolicyName(String alertPolicyName) { + return ALERT_POLICY_PATH_TEMPLATE.parse(alertPolicyName).get("alert_policy"); + } + + /** + * Parses the project from the given fully-qualified path which represents a + * alert_policy_condition resource. + */ + public static final String parseProjectFromAlertPolicyConditionName( + String alertPolicyConditionName) { + return ALERT_POLICY_CONDITION_PATH_TEMPLATE.parse(alertPolicyConditionName).get("project"); + } + + /** + * Parses the alert_policy from the given fully-qualified path which represents a + * alert_policy_condition resource. + */ + public static final String parseAlertPolicyFromAlertPolicyConditionName( + String alertPolicyConditionName) { + return ALERT_POLICY_CONDITION_PATH_TEMPLATE.parse(alertPolicyConditionName).get("alert_policy"); + } + + /** + * Parses the condition from the given fully-qualified path which represents a + * alert_policy_condition resource. + */ + public static final String parseConditionFromAlertPolicyConditionName( + String alertPolicyConditionName) { + return ALERT_POLICY_CONDITION_PATH_TEMPLATE.parse(alertPolicyConditionName).get("condition"); + } + /** Constructs an instance of AlertPolicyServiceClient with default settings. */ public static final AlertPolicyServiceClient create() throws IOException { return create(AlertPolicyServiceSettings.newBuilder().build()); diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java index f8d3578d0d06..85e5a6b3fc22 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java @@ -26,6 +26,7 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.GroupServiceStub; import com.google.cloud.monitoring.v3.stub.GroupServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; @@ -33,14 +34,14 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; -import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; import com.google.monitoring.v3.ListGroupsRequest; import com.google.monitoring.v3.ListGroupsResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; +import com.google.protos.google.monitoring.v3.GroupName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -125,6 +126,39 @@ public class GroupServiceClient implements BackgroundResource { private final GroupServiceSettings settings; private final GroupServiceStub stub; + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("projects/{project}"); + + private static final PathTemplate GROUP_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("projects/{project}/groups/{group}"); + + /** Formats a string containing the fully-qualified path to represent a project resource. */ + public static final String formatProjectName(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } + + /** Formats a string containing the fully-qualified path to represent a group resource. */ + public static final String formatGroupName(String project, String group) { + return GROUP_PATH_TEMPLATE.instantiate( + "project", project, + "group", group); + } + + /** Parses the project from the given fully-qualified path which represents a project resource. */ + public static final String parseProjectFromProjectName(String projectName) { + return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); + } + + /** Parses the project from the given fully-qualified path which represents a group resource. */ + public static final String parseProjectFromGroupName(String groupName) { + return GROUP_PATH_TEMPLATE.parse(groupName).get("project"); + } + + /** Parses the group from the given fully-qualified path which represents a group resource. */ + public static final String parseGroupFromGroupName(String groupName) { + return GROUP_PATH_TEMPLATE.parse(groupName).get("group"); + } + /** Constructs an instance of GroupServiceClient with default settings. */ public static final GroupServiceClient create() throws IOException { return create(GroupServiceSettings.newBuilder().build()); diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java index 913183e33640..2e143cfec1a3 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java @@ -27,6 +27,7 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.cloud.monitoring.v3.stub.MetricServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; @@ -41,12 +42,12 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; -import com.google.monitoring.v3.MetricDescriptorName; -import com.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; +import com.google.protos.google.monitoring.v3.MetricDescriptorName; +import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -124,6 +125,86 @@ public class MetricServiceClient implements BackgroundResource { private final MetricServiceSettings settings; private final MetricServiceStub stub; + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("projects/{project}"); + + private static final PathTemplate METRIC_DESCRIPTOR_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/metricDescriptors/{metric_descriptor=**}"); + + private static final PathTemplate MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}"); + + /** Formats a string containing the fully-qualified path to represent a project resource. */ + public static final String formatProjectName(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } + + /** + * Formats a string containing the fully-qualified path to represent a metric_descriptor resource. + */ + public static final String formatMetricDescriptorName(String project, String metricDescriptor) { + return METRIC_DESCRIPTOR_PATH_TEMPLATE.instantiate( + "project", project, + "metric_descriptor", metricDescriptor); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * monitored_resource_descriptor resource. + */ + public static final String formatMonitoredResourceDescriptorName( + String project, String monitoredResourceDescriptor) { + return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.instantiate( + "project", project, + "monitored_resource_descriptor", monitoredResourceDescriptor); + } + + /** Parses the project from the given fully-qualified path which represents a project resource. */ + public static final String parseProjectFromProjectName(String projectName) { + return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); + } + + /** + * Parses the project from the given fully-qualified path which represents a metric_descriptor + * resource. + */ + public static final String parseProjectFromMetricDescriptorName(String metricDescriptorName) { + return METRIC_DESCRIPTOR_PATH_TEMPLATE.parse(metricDescriptorName).get("project"); + } + + /** + * Parses the metric_descriptor from the given fully-qualified path which represents a + * metric_descriptor resource. + */ + public static final String parseMetricDescriptorFromMetricDescriptorName( + String metricDescriptorName) { + return METRIC_DESCRIPTOR_PATH_TEMPLATE.parse(metricDescriptorName).get("metric_descriptor"); + } + + /** + * Parses the project from the given fully-qualified path which represents a + * monitored_resource_descriptor resource. + */ + public static final String parseProjectFromMonitoredResourceDescriptorName( + String monitoredResourceDescriptorName) { + return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE + .parse(monitoredResourceDescriptorName) + .get("project"); + } + + /** + * Parses the monitored_resource_descriptor from the given fully-qualified path which represents a + * monitored_resource_descriptor resource. + */ + public static final String parseMonitoredResourceDescriptorFromMonitoredResourceDescriptorName( + String monitoredResourceDescriptorName) { + return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE + .parse(monitoredResourceDescriptorName) + .get("monitored_resource_descriptor"); + } + /** Constructs an instance of MetricServiceClient with default settings. */ public static final MetricServiceClient create() throws IOException { return create(MetricServiceSettings.newBuilder().build()); diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java index ec971fb6543c..99d9408d91e3 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java @@ -25,6 +25,7 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.NotificationChannelServiceStub; import com.google.cloud.monitoring.v3.stub.NotificationChannelServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; @@ -38,12 +39,12 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.monitoring.v3.NotificationChannelName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; +import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.protos.google.monitoring.v3.NotificationChannelName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -122,6 +123,91 @@ public class NotificationChannelServiceClient implements BackgroundResource { private final NotificationChannelServiceSettings settings; private final NotificationChannelServiceStub stub; + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("projects/{project}"); + + private static final PathTemplate NOTIFICATION_CHANNEL_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/notificationChannels/{notification_channel}"); + + private static final PathTemplate NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/notificationChannelDescriptors/{channel_descriptor}"); + + /** Formats a string containing the fully-qualified path to represent a project resource. */ + public static final String formatProjectName(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } + + /** + * Formats a string containing the fully-qualified path to represent a notification_channel + * resource. + */ + public static final String formatNotificationChannelName( + String project, String notificationChannel) { + return NOTIFICATION_CHANNEL_PATH_TEMPLATE.instantiate( + "project", project, + "notification_channel", notificationChannel); + } + + /** + * Formats a string containing the fully-qualified path to represent a + * notification_channel_descriptor resource. + */ + public static final String formatNotificationChannelDescriptorName( + String project, String channelDescriptor) { + return NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.instantiate( + "project", project, + "channel_descriptor", channelDescriptor); + } + + /** Parses the project from the given fully-qualified path which represents a project resource. */ + public static final String parseProjectFromProjectName(String projectName) { + return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); + } + + /** + * Parses the project from the given fully-qualified path which represents a notification_channel + * resource. + */ + public static final String parseProjectFromNotificationChannelName( + String notificationChannelName) { + return NOTIFICATION_CHANNEL_PATH_TEMPLATE.parse(notificationChannelName).get("project"); + } + + /** + * Parses the notification_channel from the given fully-qualified path which represents a + * notification_channel resource. + */ + public static final String parseNotificationChannelFromNotificationChannelName( + String notificationChannelName) { + return NOTIFICATION_CHANNEL_PATH_TEMPLATE + .parse(notificationChannelName) + .get("notification_channel"); + } + + /** + * Parses the project from the given fully-qualified path which represents a + * notification_channel_descriptor resource. + */ + public static final String parseProjectFromNotificationChannelDescriptorName( + String notificationChannelDescriptorName) { + return NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE + .parse(notificationChannelDescriptorName) + .get("project"); + } + + /** + * Parses the channel_descriptor from the given fully-qualified path which represents a + * notification_channel_descriptor resource. + */ + public static final String parseChannelDescriptorFromNotificationChannelDescriptorName( + String notificationChannelDescriptorName) { + return NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE + .parse(notificationChannelDescriptorName) + .get("channel_descriptor"); + } + /** Constructs an instance of NotificationChannelServiceClient with default settings. */ public static final NotificationChannelServiceClient create() throws IOException { return create(NotificationChannelServiceSettings.newBuilder().build()); diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java index 8433f26744c3..80eba48cb944 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java @@ -25,6 +25,7 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.UptimeCheckServiceStub; import com.google.cloud.monitoring.v3.stub.UptimeCheckServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; @@ -37,7 +38,6 @@ import com.google.monitoring.v3.ListUptimeCheckIpsResponse; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.monitoring.v3.UptimeCheckIp; import com.google.protobuf.Empty; import java.io.IOException; @@ -60,8 +60,8 @@ *
  * 
  * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
+ *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+ *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
  * }
  * 
  * 
@@ -122,6 +122,52 @@ public class UptimeCheckServiceClient implements BackgroundResource { private final UptimeCheckServiceSettings settings; private final UptimeCheckServiceStub stub; + private static final PathTemplate PROJECT_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("projects/{project}"); + + private static final PathTemplate UPTIME_CHECK_CONFIG_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/uptimeCheckConfigs/{uptime_check_config}"); + + /** Formats a string containing the fully-qualified path to represent a project resource. */ + public static final String formatProjectName(String project) { + return PROJECT_PATH_TEMPLATE.instantiate("project", project); + } + + /** + * Formats a string containing the fully-qualified path to represent a uptime_check_config + * resource. + */ + public static final String formatUptimeCheckConfigName(String project, String uptimeCheckConfig) { + return UPTIME_CHECK_CONFIG_PATH_TEMPLATE.instantiate( + "project", project, + "uptime_check_config", uptimeCheckConfig); + } + + /** Parses the project from the given fully-qualified path which represents a project resource. */ + public static final String parseProjectFromProjectName(String projectName) { + return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); + } + + /** + * Parses the project from the given fully-qualified path which represents a uptime_check_config + * resource. + */ + public static final String parseProjectFromUptimeCheckConfigName(String uptimeCheckConfigName) { + return UPTIME_CHECK_CONFIG_PATH_TEMPLATE.parse(uptimeCheckConfigName).get("project"); + } + + /** + * Parses the uptime_check_config from the given fully-qualified path which represents a + * uptime_check_config resource. + */ + public static final String parseUptimeCheckConfigFromUptimeCheckConfigName( + String uptimeCheckConfigName) { + return UPTIME_CHECK_CONFIG_PATH_TEMPLATE + .parse(uptimeCheckConfigName) + .get("uptime_check_config"); + } + /** Constructs an instance of UptimeCheckServiceClient with default settings. */ public static final UptimeCheckServiceClient create() throws IOException { return create(UptimeCheckServiceSettings.newBuilder().build()); @@ -179,7 +225,7 @@ public UptimeCheckServiceStub getStub() { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
+   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
    *   for (UptimeCheckConfig element : uptimeCheckServiceClient.listUptimeCheckConfigs(formattedParent).iterateAll()) {
    *     // doThingsWith(element);
    *   }
@@ -191,6 +237,7 @@ public UptimeCheckServiceStub getStub() {
    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
    */
   public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(String parent) {
+    PROJECT_PATH_TEMPLATE.validate(parent, "listUptimeCheckConfigs");
     ListUptimeCheckConfigsRequest request =
         ListUptimeCheckConfigsRequest.newBuilder().setParent(parent).build();
     return listUptimeCheckConfigs(request);
@@ -205,7 +252,7 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(String p
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
+   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
    *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
    *     .setParent(formattedParent)
    *     .build();
@@ -232,7 +279,7 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
+   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
    *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
    *     .setParent(formattedParent)
    *     .build();
@@ -258,7 +305,7 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
+   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
    *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
    *     .setParent(formattedParent)
    *     .build();
@@ -290,34 +337,8 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(
    *
    * 

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

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name.toString());
+   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
    * }
    * 
* @@ -326,7 +347,7 @@ public final UptimeCheckConfig getUptimeCheckConfig(UptimeCheckConfigName name) * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final UptimeCheckConfig getUptimeCheckConfig(String name) { - + UPTIME_CHECK_CONFIG_PATH_TEMPLATE.validate(name, "getUptimeCheckConfig"); GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder().setName(name).build(); return getUptimeCheckConfig(request); @@ -340,9 +361,9 @@ public final UptimeCheckConfig getUptimeCheckConfig(String name) { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *     .setName(formattedName)
    *     .build();
    *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(request);
    * }
@@ -363,9 +384,9 @@ public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *     .setName(formattedName)
    *     .build();
    *   ApiFuture<UptimeCheckConfig> future = uptimeCheckServiceClient.getUptimeCheckConfigCallable().futureCall(request);
    *   // Do something
@@ -386,7 +407,7 @@ public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
+   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
    *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
    *   UptimeCheckConfig response = uptimeCheckServiceClient.createUptimeCheckConfig(formattedParent, uptimeCheckConfig);
    * }
@@ -399,7 +420,7 @@ public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest
    */
   public final UptimeCheckConfig createUptimeCheckConfig(
       String parent, UptimeCheckConfig uptimeCheckConfig) {
-
+    PROJECT_PATH_TEMPLATE.validate(parent, "createUptimeCheckConfig");
     CreateUptimeCheckConfigRequest request =
         CreateUptimeCheckConfigRequest.newBuilder()
             .setParent(parent)
@@ -416,7 +437,7 @@ public final UptimeCheckConfig createUptimeCheckConfig(
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
+   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
    *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
    *   CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder()
    *     .setParent(formattedParent)
@@ -441,7 +462,7 @@ public final UptimeCheckConfig createUptimeCheckConfig(CreateUptimeCheckConfigRe
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = ProjectName.format("[PROJECT]");
+   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
    *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
    *   CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder()
    *     .setParent(formattedParent)
@@ -550,36 +571,8 @@ public final UptimeCheckConfig updateUptimeCheckConfig(UpdateUptimeCheckConfigRe
    *
    * 

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

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(name.toString());
+   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(formattedName);
    * }
    * 
* @@ -588,7 +581,7 @@ public final void deleteUptimeCheckConfig(UptimeCheckConfigName name) { * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteUptimeCheckConfig(String name) { - + UPTIME_CHECK_CONFIG_PATH_TEMPLATE.validate(name, "deleteUptimeCheckConfig"); DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder().setName(name).build(); deleteUptimeCheckConfig(request); @@ -604,9 +597,9 @@ public final void deleteUptimeCheckConfig(String name) { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *     .setName(formattedName)
    *     .build();
    *   uptimeCheckServiceClient.deleteUptimeCheckConfig(request);
    * }
@@ -629,9 +622,9 @@ public final void deleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest request
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *     .setName(formattedName)
    *     .build();
    *   ApiFuture<Void> future = uptimeCheckServiceClient.deleteUptimeCheckConfigCallable().futureCall(request);
    *   // Do something
diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
index 297143cd6622..1f76cd2eb66c 100644
--- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
+++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
@@ -109,8 +109,8 @@
  * 
  * 
  * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
+ *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+ *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
  * }
  * 
  * 
diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java index 1897bfe95000..c42d13091242 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java @@ -26,17 +26,17 @@ import com.google.api.gax.rpc.InvalidArgumentException; import com.google.common.collect.Lists; import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.AlertPolicyName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java index 29d33d133a10..c3e437e127b4 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java @@ -30,13 +30,13 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; -import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.GroupName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java index 0d79d7cec208..ea7b0eeaf6d9 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java @@ -40,13 +40,13 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; -import com.google.monitoring.v3.MetricDescriptorName; -import com.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.MetricDescriptorName; +import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java index 2f61f966dd57..345a121f9374 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java @@ -18,7 +18,7 @@ import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; import com.google.common.base.Preconditions; -import com.google.monitoring.v3.ProjectName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.util.logging.Level; import java.util.logging.Logger; import org.junit.Test; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java index 4c886a9250f4..dc5e3f70c55c 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java @@ -36,13 +36,13 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.monitoring.v3.NotificationChannelName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.protos.google.monitoring.v3.NotificationChannelName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java index 6faa686b5e2f..875cd7d891a3 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java @@ -30,10 +30,8 @@ import com.google.monitoring.v3.GetUptimeCheckConfigRequest; import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; import io.grpc.Status; @@ -115,7 +113,7 @@ public void listUptimeCheckConfigsTest() { .build(); mockUptimeCheckService.addResponse(expectedResponse); - String formattedParent = ProjectName.format("[PROJECT]"); + String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]"); ListUptimeCheckConfigsPagedResponse pagedListResponse = client.listUptimeCheckConfigs(formattedParent); @@ -143,7 +141,7 @@ public void listUptimeCheckConfigsExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - String formattedParent = ProjectName.format("[PROJECT]"); + String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]"); client.listUptimeCheckConfigs(formattedParent); Assert.fail("No exception raised"); @@ -166,16 +164,17 @@ public void getUptimeCheckConfigTest() { .build(); mockUptimeCheckService.addResponse(expectedResponse); - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + String formattedName = + UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - UptimeCheckConfig actualResponse = client.getUptimeCheckConfig(name); + UptimeCheckConfig actualResponse = client.getUptimeCheckConfig(formattedName); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetUptimeCheckConfigRequest actualRequest = (GetUptimeCheckConfigRequest) actualRequests.get(0); - Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); + Assert.assertEquals(formattedName, actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -189,9 +188,11 @@ public void getUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + String formattedName = + UptimeCheckServiceClient.formatUptimeCheckConfigName( + "[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.getUptimeCheckConfig(name); + client.getUptimeCheckConfig(formattedName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -212,7 +213,7 @@ public void createUptimeCheckConfigTest() { .build(); mockUptimeCheckService.addResponse(expectedResponse); - String formattedParent = ProjectName.format("[PROJECT]"); + String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]"); UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); UptimeCheckConfig actualResponse = @@ -239,7 +240,7 @@ public void createUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - String formattedParent = ProjectName.format("[PROJECT]"); + String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]"); UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); client.createUptimeCheckConfig(formattedParent, uptimeCheckConfig); @@ -302,16 +303,17 @@ public void deleteUptimeCheckConfigTest() { Empty expectedResponse = Empty.newBuilder().build(); mockUptimeCheckService.addResponse(expectedResponse); - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + String formattedName = + UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.deleteUptimeCheckConfig(name); + client.deleteUptimeCheckConfig(formattedName); List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteUptimeCheckConfigRequest actualRequest = (DeleteUptimeCheckConfigRequest) actualRequests.get(0); - Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); + Assert.assertEquals(formattedName, actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -325,9 +327,11 @@ public void deleteUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + String formattedName = + UptimeCheckServiceClient.formatUptimeCheckConfigName( + "[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.deleteUptimeCheckConfig(name); + client.deleteUptimeCheckConfig(formattedName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception From 148e57905d3a38c662fc0d9b8f9abec42ddeec10 Mon Sep 17 00:00:00 2001 From: Andrea Lin Date: Tue, 26 Mar 2019 11:56:35 -0700 Subject: [PATCH 4/7] regen again --- .../google/monitoring/v3/dropped_labels.proto | 3 + .../v3/AlertPolicyServiceClient.java | 4 +- .../monitoring/v3/GroupServiceClient.java | 4 +- .../monitoring/v3/MetricServiceClient.java | 6 +- .../v3/NotificationChannelServiceClient.java | 6 +- .../v3/UptimeCheckServiceClient.java | 87 +++++++++++++++---- .../cloud/monitoring/v3/package-info.java | 4 +- .../v3/AlertPolicyServiceClientTest.java | 4 +- .../monitoring/v3/GroupServiceClientTest.java | 4 +- .../v3/MetricServiceClientTest.java | 6 +- .../monitoring/v3/MetricServiceSmokeTest.java | 2 +- .../NotificationChannelServiceClientTest.java | 6 +- .../v3/UptimeCheckServiceClientTest.java | 27 +++--- 13 files changed, 108 insertions(+), 55 deletions(-) diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto index d832aa454528..acbe8cf25ad1 100644 --- a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto @@ -20,6 +20,9 @@ package google.monitoring.v3; import "google/api/annotations.proto"; option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring"; +option java_multiple_files = true; +option java_outer_classname = "DroppedLabelsProto"; +option java_package = "com.google.monitoring.v3"; // A set of (label, value) pairs which were dropped during aggregation, attached // to google.api.Distribution.Exemplars in google.api.Distribution values during diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java index f93b5064ce3e..ebb059ba46e6 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java @@ -30,16 +30,16 @@ import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.monitoring.v3.AlertPolicy; +import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; -import com.google.protos.google.monitoring.v3.AlertPolicyName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java index 85e5a6b3fc22..e431e8c2a6b7 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java @@ -34,14 +34,14 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; +import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; import com.google.monitoring.v3.ListGroupsRequest; import com.google.monitoring.v3.ListGroupsResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; -import com.google.protos.google.monitoring.v3.GroupName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java index 2e143cfec1a3..02d4db30c544 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java @@ -42,12 +42,12 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; +import com.google.monitoring.v3.MetricDescriptorName; +import com.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; -import com.google.protos.google.monitoring.v3.MetricDescriptorName; -import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java index 99d9408d91e3..d9fdc5c5739f 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java @@ -39,12 +39,12 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; +import com.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.monitoring.v3.NotificationChannelName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; -import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.protos.google.monitoring.v3.NotificationChannelName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java index 80eba48cb944..97586f2ba74a 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java @@ -38,6 +38,7 @@ import com.google.monitoring.v3.ListUptimeCheckIpsResponse; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; +import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.monitoring.v3.UptimeCheckIp; import com.google.protobuf.Empty; import java.io.IOException; @@ -60,8 +61,8 @@ *
  * 
  * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
+ *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+ *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
  * }
  * 
  * 
@@ -337,8 +338,34 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs( * *

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

Sample code: + * + *


+   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name.toString());
    * }
    * 
* @@ -347,7 +374,7 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs( * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final UptimeCheckConfig getUptimeCheckConfig(String name) { - UPTIME_CHECK_CONFIG_PATH_TEMPLATE.validate(name, "getUptimeCheckConfig"); + GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder().setName(name).build(); return getUptimeCheckConfig(request); @@ -361,9 +388,9 @@ public final UptimeCheckConfig getUptimeCheckConfig(String name) { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(request);
    * }
@@ -384,9 +411,9 @@ public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<UptimeCheckConfig> future = uptimeCheckServiceClient.getUptimeCheckConfigCallable().futureCall(request);
    *   // Do something
@@ -571,8 +598,36 @@ public final UptimeCheckConfig updateUptimeCheckConfig(UpdateUptimeCheckConfigRe
    *
    * 

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

Sample code: + * + *


+   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(name.toString());
    * }
    * 
* @@ -581,7 +636,7 @@ public final UptimeCheckConfig updateUptimeCheckConfig(UpdateUptimeCheckConfigRe * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteUptimeCheckConfig(String name) { - UPTIME_CHECK_CONFIG_PATH_TEMPLATE.validate(name, "deleteUptimeCheckConfig"); + DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder().setName(name).build(); deleteUptimeCheckConfig(request); @@ -597,9 +652,9 @@ public final void deleteUptimeCheckConfig(String name) { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   uptimeCheckServiceClient.deleteUptimeCheckConfig(request);
    * }
@@ -622,9 +677,9 @@ public final void deleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest request
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<Void> future = uptimeCheckServiceClient.deleteUptimeCheckConfigCallable().futureCall(request);
    *   // Do something
diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
index 1f76cd2eb66c..297143cd6622 100644
--- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
+++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
@@ -109,8 +109,8 @@
  * 
  * 
  * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   String formattedName = UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
+ *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+ *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
  * }
  * 
  * 
diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java index c42d13091242..1897bfe95000 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java @@ -26,17 +26,17 @@ import com.google.api.gax.rpc.InvalidArgumentException; import com.google.common.collect.Lists; import com.google.monitoring.v3.AlertPolicy; +import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.AlertPolicyName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java index c3e437e127b4..29d33d133a10 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java @@ -30,13 +30,13 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; +import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.GroupName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java index ea7b0eeaf6d9..0d79d7cec208 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java @@ -40,13 +40,13 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; +import com.google.monitoring.v3.MetricDescriptorName; +import com.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.MetricDescriptorName; -import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java index 345a121f9374..2f61f966dd57 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java @@ -18,7 +18,7 @@ import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; import com.google.common.base.Preconditions; -import com.google.protos.google.monitoring.v3.ProjectName; +import com.google.monitoring.v3.ProjectName; import java.util.logging.Level; import java.util.logging.Logger; import org.junit.Test; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java index dc5e3f70c55c..4c886a9250f4 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java @@ -36,13 +36,13 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; +import com.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.monitoring.v3.NotificationChannelName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.protos.google.monitoring.v3.NotificationChannelName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java index 875cd7d891a3..ab3f520a32c2 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java @@ -32,6 +32,7 @@ import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; +import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; import io.grpc.Status; @@ -164,17 +165,16 @@ public void getUptimeCheckConfigTest() { .build(); mockUptimeCheckService.addResponse(expectedResponse); - String formattedName = - UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - UptimeCheckConfig actualResponse = client.getUptimeCheckConfig(formattedName); + 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(formattedName, actualRequest.getName()); + Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -188,11 +188,9 @@ public void getUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - String formattedName = - UptimeCheckServiceClient.formatUptimeCheckConfigName( - "[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.getUptimeCheckConfig(formattedName); + client.getUptimeCheckConfig(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -303,17 +301,16 @@ public void deleteUptimeCheckConfigTest() { Empty expectedResponse = Empty.newBuilder().build(); mockUptimeCheckService.addResponse(expectedResponse); - String formattedName = - UptimeCheckServiceClient.formatUptimeCheckConfigName("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.deleteUptimeCheckConfig(formattedName); + client.deleteUptimeCheckConfig(name); List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteUptimeCheckConfigRequest actualRequest = (DeleteUptimeCheckConfigRequest) actualRequests.get(0); - Assert.assertEquals(formattedName, actualRequest.getName()); + Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -327,11 +324,9 @@ public void deleteUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - String formattedName = - UptimeCheckServiceClient.formatUptimeCheckConfigName( - "[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.deleteUptimeCheckConfig(formattedName); + client.deleteUptimeCheckConfig(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception From c034e4a1189caf5869d33bfc2106a9cbded91bf0 Mon Sep 17 00:00:00 2001 From: Andrea Lin Date: Tue, 26 Mar 2019 13:04:27 -0700 Subject: [PATCH 5/7] the OuterClass is generated because the proto file contains the amessage of the same name --- .../v3/DroppedLabelsOuterClass.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsOuterClass.java diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsOuterClass.java b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsOuterClass.java new file mode 100644 index 000000000000..09fb25854882 --- /dev/null +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/DroppedLabelsOuterClass.java @@ -0,0 +1,76 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/monitoring/v3/dropped_labels.proto + +package com.google.monitoring.v3; + +public final class DroppedLabelsOuterClass { + private DroppedLabelsOuterClass() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_monitoring_v3_DroppedLabels_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_monitoring_v3_DroppedLabels_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n)google/monitoring/v3/dropped_labels.pr" + + "oto\022\024google.monitoring.v3\032\034google/api/an" + + "notations.proto\"|\n\rDroppedLabels\022=\n\005labe" + + "l\030\001 \003(\0132..google.monitoring.v3.DroppedLa" + + "bels.LabelEntry\032,\n\nLabelEntry\022\013\n\003key\030\001 \001" + + "(\t\022\r\n\005value\030\002 \001(\t:\0028\001B\\\n\030com.google.moni" + + "toring.v3P\001Z>google.golang.org/genproto/" + + "googleapis/monitoring/v3;monitoringb\006pro" + + "to3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + }, + assigner); + internal_static_google_monitoring_v3_DroppedLabels_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_monitoring_v3_DroppedLabels_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_monitoring_v3_DroppedLabels_descriptor, + new java.lang.String[] { + "Label", + }); + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_descriptor = + internal_static_google_monitoring_v3_DroppedLabels_descriptor.getNestedTypes().get(0); + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_monitoring_v3_DroppedLabels_LabelEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + com.google.api.AnnotationsProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} From 68114ab00d6edd7786f8a106bd695687a32694e2 Mon Sep 17 00:00:00 2001 From: Andrea Lin Date: Tue, 26 Mar 2019 15:36:07 -0700 Subject: [PATCH 6/7] no changes in protos or gapics, just refresh --- .../monitoring/v3/NotificationChannel.java | 6 +- .../google/monitoring/v3/dropped_labels.proto | 3 - .../v3/AlertPolicyServiceClient.java | 87 +---------- .../monitoring/v3/GroupServiceClient.java | 38 +---- .../monitoring/v3/MetricServiceClient.java | 87 +---------- .../v3/NotificationChannelServiceClient.java | 92 +---------- .../v3/UptimeCheckServiceClient.java | 147 +++--------------- .../cloud/monitoring/v3/package-info.java | 4 +- .../v3/AlertPolicyServiceClientTest.java | 4 +- .../monitoring/v3/GroupServiceClientTest.java | 4 +- .../v3/MetricServiceClientTest.java | 6 +- .../monitoring/v3/MetricServiceSmokeTest.java | 2 +- .../NotificationChannelServiceClientTest.java | 6 +- .../v3/UptimeCheckServiceClientTest.java | 31 ++-- 14 files changed, 65 insertions(+), 452 deletions(-) diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannel.java b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannel.java index 05a87492f89e..9a6b671265f6 100644 --- a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannel.java +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/java/com/google/monitoring/v3/NotificationChannel.java @@ -921,7 +921,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io output, internalGetUserLabels(), UserLabelsDefaultEntryHolder.defaultEntry, 8); if (verificationStatus_ != com.google.monitoring.v3.NotificationChannel.VerificationStatus - .VERIFICATION_STATUS_UNSPECIFIED.getNumber()) { + .VERIFICATION_STATUS_UNSPECIFIED + .getNumber()) { output.writeEnum(9, verificationStatus_); } if (enabled_ != null) { @@ -970,7 +971,8 @@ public int getSerializedSize() { } if (verificationStatus_ != com.google.monitoring.v3.NotificationChannel.VerificationStatus - .VERIFICATION_STATUS_UNSPECIFIED.getNumber()) { + .VERIFICATION_STATUS_UNSPECIFIED + .getNumber()) { size += com.google.protobuf.CodedOutputStream.computeEnumSize(9, verificationStatus_); } if (enabled_ != null) { diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto index acbe8cf25ad1..d832aa454528 100644 --- a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto @@ -20,9 +20,6 @@ package google.monitoring.v3; import "google/api/annotations.proto"; option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring"; -option java_multiple_files = true; -option java_outer_classname = "DroppedLabelsProto"; -option java_package = "com.google.monitoring.v3"; // A set of (label, value) pairs which were dropped during aggregation, attached // to google.api.Distribution.Exemplars in google.api.Distribution values during diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java index ebb059ba46e6..8fde0b16a05c 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java @@ -25,21 +25,20 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStub; import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; +import com.google.protos.google.monitoring.v3.AlertPolicyName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -122,88 +121,6 @@ public class AlertPolicyServiceClient implements BackgroundResource { private final AlertPolicyServiceSettings settings; private final AlertPolicyServiceStub stub; - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}"); - - private static final PathTemplate ALERT_POLICY_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}/alertPolicies/{alert_policy}"); - - private static final PathTemplate ALERT_POLICY_CONDITION_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}"); - - /** Formats a string containing the fully-qualified path to represent a project resource. */ - public static final String formatProjectName(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** Formats a string containing the fully-qualified path to represent a alert_policy resource. */ - public static final String formatAlertPolicyName(String project, String alertPolicy) { - return ALERT_POLICY_PATH_TEMPLATE.instantiate( - "project", project, - "alert_policy", alertPolicy); - } - - /** - * Formats a string containing the fully-qualified path to represent a alert_policy_condition - * resource. - */ - public static final String formatAlertPolicyConditionName( - String project, String alertPolicy, String condition) { - return ALERT_POLICY_CONDITION_PATH_TEMPLATE.instantiate( - "project", project, - "alert_policy", alertPolicy, - "condition", condition); - } - - /** Parses the project from the given fully-qualified path which represents a project resource. */ - public static final String parseProjectFromProjectName(String projectName) { - return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); - } - - /** - * Parses the project from the given fully-qualified path which represents a alert_policy - * resource. - */ - public static final String parseProjectFromAlertPolicyName(String alertPolicyName) { - return ALERT_POLICY_PATH_TEMPLATE.parse(alertPolicyName).get("project"); - } - - /** - * Parses the alert_policy from the given fully-qualified path which represents a alert_policy - * resource. - */ - public static final String parseAlertPolicyFromAlertPolicyName(String alertPolicyName) { - return ALERT_POLICY_PATH_TEMPLATE.parse(alertPolicyName).get("alert_policy"); - } - - /** - * Parses the project from the given fully-qualified path which represents a - * alert_policy_condition resource. - */ - public static final String parseProjectFromAlertPolicyConditionName( - String alertPolicyConditionName) { - return ALERT_POLICY_CONDITION_PATH_TEMPLATE.parse(alertPolicyConditionName).get("project"); - } - - /** - * Parses the alert_policy from the given fully-qualified path which represents a - * alert_policy_condition resource. - */ - public static final String parseAlertPolicyFromAlertPolicyConditionName( - String alertPolicyConditionName) { - return ALERT_POLICY_CONDITION_PATH_TEMPLATE.parse(alertPolicyConditionName).get("alert_policy"); - } - - /** - * Parses the condition from the given fully-qualified path which represents a - * alert_policy_condition resource. - */ - public static final String parseConditionFromAlertPolicyConditionName( - String alertPolicyConditionName) { - return ALERT_POLICY_CONDITION_PATH_TEMPLATE.parse(alertPolicyConditionName).get("condition"); - } - /** Constructs an instance of AlertPolicyServiceClient with default settings. */ public static final AlertPolicyServiceClient create() throws IOException { return create(AlertPolicyServiceSettings.newBuilder().build()); diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java index e431e8c2a6b7..71b09765b706 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java @@ -26,7 +26,6 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.GroupServiceStub; import com.google.cloud.monitoring.v3.stub.GroupServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; @@ -34,14 +33,14 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; -import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; import com.google.monitoring.v3.ListGroupsRequest; import com.google.monitoring.v3.ListGroupsResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; +import com.google.protos.google.monitoring.v3.GroupName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -126,39 +125,6 @@ public class GroupServiceClient implements BackgroundResource { private final GroupServiceSettings settings; private final GroupServiceStub stub; - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}"); - - private static final PathTemplate GROUP_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}/groups/{group}"); - - /** Formats a string containing the fully-qualified path to represent a project resource. */ - public static final String formatProjectName(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** Formats a string containing the fully-qualified path to represent a group resource. */ - public static final String formatGroupName(String project, String group) { - return GROUP_PATH_TEMPLATE.instantiate( - "project", project, - "group", group); - } - - /** Parses the project from the given fully-qualified path which represents a project resource. */ - public static final String parseProjectFromProjectName(String projectName) { - return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); - } - - /** Parses the project from the given fully-qualified path which represents a group resource. */ - public static final String parseProjectFromGroupName(String groupName) { - return GROUP_PATH_TEMPLATE.parse(groupName).get("project"); - } - - /** Parses the group from the given fully-qualified path which represents a group resource. */ - public static final String parseGroupFromGroupName(String groupName) { - return GROUP_PATH_TEMPLATE.parse(groupName).get("group"); - } - /** Constructs an instance of GroupServiceClient with default settings. */ public static final GroupServiceClient create() throws IOException { return create(GroupServiceSettings.newBuilder().build()); diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java index 02d4db30c544..2bf9ba121e29 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java @@ -27,7 +27,6 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.MetricServiceStub; import com.google.cloud.monitoring.v3.stub.MetricServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; @@ -42,12 +41,12 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; -import com.google.monitoring.v3.MetricDescriptorName; -import com.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; +import com.google.protos.google.monitoring.v3.MetricDescriptorName; +import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -125,86 +124,6 @@ public class MetricServiceClient implements BackgroundResource { private final MetricServiceSettings settings; private final MetricServiceStub stub; - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}"); - - private static final PathTemplate METRIC_DESCRIPTOR_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/metricDescriptors/{metric_descriptor=**}"); - - private static final PathTemplate MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/monitoredResourceDescriptors/{monitored_resource_descriptor}"); - - /** Formats a string containing the fully-qualified path to represent a project resource. */ - public static final String formatProjectName(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** - * Formats a string containing the fully-qualified path to represent a metric_descriptor resource. - */ - public static final String formatMetricDescriptorName(String project, String metricDescriptor) { - return METRIC_DESCRIPTOR_PATH_TEMPLATE.instantiate( - "project", project, - "metric_descriptor", metricDescriptor); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * monitored_resource_descriptor resource. - */ - public static final String formatMonitoredResourceDescriptorName( - String project, String monitoredResourceDescriptor) { - return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE.instantiate( - "project", project, - "monitored_resource_descriptor", monitoredResourceDescriptor); - } - - /** Parses the project from the given fully-qualified path which represents a project resource. */ - public static final String parseProjectFromProjectName(String projectName) { - return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); - } - - /** - * Parses the project from the given fully-qualified path which represents a metric_descriptor - * resource. - */ - public static final String parseProjectFromMetricDescriptorName(String metricDescriptorName) { - return METRIC_DESCRIPTOR_PATH_TEMPLATE.parse(metricDescriptorName).get("project"); - } - - /** - * Parses the metric_descriptor from the given fully-qualified path which represents a - * metric_descriptor resource. - */ - public static final String parseMetricDescriptorFromMetricDescriptorName( - String metricDescriptorName) { - return METRIC_DESCRIPTOR_PATH_TEMPLATE.parse(metricDescriptorName).get("metric_descriptor"); - } - - /** - * Parses the project from the given fully-qualified path which represents a - * monitored_resource_descriptor resource. - */ - public static final String parseProjectFromMonitoredResourceDescriptorName( - String monitoredResourceDescriptorName) { - return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE - .parse(monitoredResourceDescriptorName) - .get("project"); - } - - /** - * Parses the monitored_resource_descriptor from the given fully-qualified path which represents a - * monitored_resource_descriptor resource. - */ - public static final String parseMonitoredResourceDescriptorFromMonitoredResourceDescriptorName( - String monitoredResourceDescriptorName) { - return MONITORED_RESOURCE_DESCRIPTOR_PATH_TEMPLATE - .parse(monitoredResourceDescriptorName) - .get("monitored_resource_descriptor"); - } - /** Constructs an instance of MetricServiceClient with default settings. */ public static final MetricServiceClient create() throws IOException { return create(MetricServiceSettings.newBuilder().build()); diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java index d9fdc5c5739f..bbd95d315ec0 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java @@ -25,7 +25,6 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.NotificationChannelServiceStub; import com.google.cloud.monitoring.v3.stub.NotificationChannelServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; @@ -39,12 +38,12 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.monitoring.v3.NotificationChannelName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; +import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.protos.google.monitoring.v3.NotificationChannelName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -123,91 +122,6 @@ public class NotificationChannelServiceClient implements BackgroundResource { private final NotificationChannelServiceSettings settings; private final NotificationChannelServiceStub stub; - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}"); - - private static final PathTemplate NOTIFICATION_CHANNEL_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/notificationChannels/{notification_channel}"); - - private static final PathTemplate NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/notificationChannelDescriptors/{channel_descriptor}"); - - /** Formats a string containing the fully-qualified path to represent a project resource. */ - public static final String formatProjectName(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** - * Formats a string containing the fully-qualified path to represent a notification_channel - * resource. - */ - public static final String formatNotificationChannelName( - String project, String notificationChannel) { - return NOTIFICATION_CHANNEL_PATH_TEMPLATE.instantiate( - "project", project, - "notification_channel", notificationChannel); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * notification_channel_descriptor resource. - */ - public static final String formatNotificationChannelDescriptorName( - String project, String channelDescriptor) { - return NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE.instantiate( - "project", project, - "channel_descriptor", channelDescriptor); - } - - /** Parses the project from the given fully-qualified path which represents a project resource. */ - public static final String parseProjectFromProjectName(String projectName) { - return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); - } - - /** - * Parses the project from the given fully-qualified path which represents a notification_channel - * resource. - */ - public static final String parseProjectFromNotificationChannelName( - String notificationChannelName) { - return NOTIFICATION_CHANNEL_PATH_TEMPLATE.parse(notificationChannelName).get("project"); - } - - /** - * Parses the notification_channel from the given fully-qualified path which represents a - * notification_channel resource. - */ - public static final String parseNotificationChannelFromNotificationChannelName( - String notificationChannelName) { - return NOTIFICATION_CHANNEL_PATH_TEMPLATE - .parse(notificationChannelName) - .get("notification_channel"); - } - - /** - * Parses the project from the given fully-qualified path which represents a - * notification_channel_descriptor resource. - */ - public static final String parseProjectFromNotificationChannelDescriptorName( - String notificationChannelDescriptorName) { - return NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE - .parse(notificationChannelDescriptorName) - .get("project"); - } - - /** - * Parses the channel_descriptor from the given fully-qualified path which represents a - * notification_channel_descriptor resource. - */ - public static final String parseChannelDescriptorFromNotificationChannelDescriptorName( - String notificationChannelDescriptorName) { - return NOTIFICATION_CHANNEL_DESCRIPTOR_PATH_TEMPLATE - .parse(notificationChannelDescriptorName) - .get("channel_descriptor"); - } - /** Constructs an instance of NotificationChannelServiceClient with default settings. */ public static final NotificationChannelServiceClient create() throws IOException { return create(NotificationChannelServiceSettings.newBuilder().build()); diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java index 97586f2ba74a..cfe1554df34f 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClient.java @@ -25,7 +25,6 @@ import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.monitoring.v3.stub.UptimeCheckServiceStub; import com.google.cloud.monitoring.v3.stub.UptimeCheckServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; @@ -38,7 +37,6 @@ import com.google.monitoring.v3.ListUptimeCheckIpsResponse; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.monitoring.v3.UptimeCheckIp; import com.google.protobuf.Empty; import java.io.IOException; @@ -61,8 +59,8 @@ *
  * 
  * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
+ *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+ *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
  * }
  * 
  * 
@@ -123,52 +121,6 @@ public class UptimeCheckServiceClient implements BackgroundResource { private final UptimeCheckServiceSettings settings; private final UptimeCheckServiceStub stub; - private static final PathTemplate PROJECT_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}"); - - private static final PathTemplate UPTIME_CHECK_CONFIG_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding( - "projects/{project}/uptimeCheckConfigs/{uptime_check_config}"); - - /** Formats a string containing the fully-qualified path to represent a project resource. */ - public static final String formatProjectName(String project) { - return PROJECT_PATH_TEMPLATE.instantiate("project", project); - } - - /** - * Formats a string containing the fully-qualified path to represent a uptime_check_config - * resource. - */ - public static final String formatUptimeCheckConfigName(String project, String uptimeCheckConfig) { - return UPTIME_CHECK_CONFIG_PATH_TEMPLATE.instantiate( - "project", project, - "uptime_check_config", uptimeCheckConfig); - } - - /** Parses the project from the given fully-qualified path which represents a project resource. */ - public static final String parseProjectFromProjectName(String projectName) { - return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); - } - - /** - * Parses the project from the given fully-qualified path which represents a uptime_check_config - * resource. - */ - public static final String parseProjectFromUptimeCheckConfigName(String uptimeCheckConfigName) { - return UPTIME_CHECK_CONFIG_PATH_TEMPLATE.parse(uptimeCheckConfigName).get("project"); - } - - /** - * Parses the uptime_check_config from the given fully-qualified path which represents a - * uptime_check_config resource. - */ - public static final String parseUptimeCheckConfigFromUptimeCheckConfigName( - String uptimeCheckConfigName) { - return UPTIME_CHECK_CONFIG_PATH_TEMPLATE - .parse(uptimeCheckConfigName) - .get("uptime_check_config"); - } - /** Constructs an instance of UptimeCheckServiceClient with default settings. */ public static final UptimeCheckServiceClient create() throws IOException { return create(UptimeCheckServiceSettings.newBuilder().build()); @@ -226,7 +178,7 @@ public UptimeCheckServiceStub getStub() { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
+   *   String formattedParent = ProjectName.format("[PROJECT]");
    *   for (UptimeCheckConfig element : uptimeCheckServiceClient.listUptimeCheckConfigs(formattedParent).iterateAll()) {
    *     // doThingsWith(element);
    *   }
@@ -238,7 +190,6 @@ public UptimeCheckServiceStub getStub() {
    * @throws com.google.api.gax.rpc.ApiException if the remote call fails
    */
   public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(String parent) {
-    PROJECT_PATH_TEMPLATE.validate(parent, "listUptimeCheckConfigs");
     ListUptimeCheckConfigsRequest request =
         ListUptimeCheckConfigsRequest.newBuilder().setParent(parent).build();
     return listUptimeCheckConfigs(request);
@@ -253,7 +204,7 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(String p
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
+   *   String formattedParent = ProjectName.format("[PROJECT]");
    *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
    *     .setParent(formattedParent)
    *     .build();
@@ -280,7 +231,7 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
+   *   String formattedParent = ProjectName.format("[PROJECT]");
    *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
    *     .setParent(formattedParent)
    *     .build();
@@ -306,7 +257,7 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
+   *   String formattedParent = ProjectName.format("[PROJECT]");
    *   ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest.newBuilder()
    *     .setParent(formattedParent)
    *     .build();
@@ -338,34 +289,8 @@ public final ListUptimeCheckConfigsPagedResponse listUptimeCheckConfigs(
    *
    * 

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

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name.toString());
+   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
    * }
    * 
* @@ -388,9 +313,9 @@ public final UptimeCheckConfig getUptimeCheckConfig(String name) { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *     .setName(formattedName)
    *     .build();
    *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(request);
    * }
@@ -411,9 +336,9 @@ public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   GetUptimeCheckConfigRequest request = GetUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *     .setName(formattedName)
    *     .build();
    *   ApiFuture<UptimeCheckConfig> future = uptimeCheckServiceClient.getUptimeCheckConfigCallable().futureCall(request);
    *   // Do something
@@ -434,7 +359,7 @@ public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
+   *   String formattedParent = ProjectName.format("[PROJECT]");
    *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
    *   UptimeCheckConfig response = uptimeCheckServiceClient.createUptimeCheckConfig(formattedParent, uptimeCheckConfig);
    * }
@@ -447,7 +372,7 @@ public final UptimeCheckConfig getUptimeCheckConfig(GetUptimeCheckConfigRequest
    */
   public final UptimeCheckConfig createUptimeCheckConfig(
       String parent, UptimeCheckConfig uptimeCheckConfig) {
-    PROJECT_PATH_TEMPLATE.validate(parent, "createUptimeCheckConfig");
+
     CreateUptimeCheckConfigRequest request =
         CreateUptimeCheckConfigRequest.newBuilder()
             .setParent(parent)
@@ -464,7 +389,7 @@ public final UptimeCheckConfig createUptimeCheckConfig(
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
+   *   String formattedParent = ProjectName.format("[PROJECT]");
    *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
    *   CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder()
    *     .setParent(formattedParent)
@@ -489,7 +414,7 @@ public final UptimeCheckConfig createUptimeCheckConfig(CreateUptimeCheckConfigRe
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]");
+   *   String formattedParent = ProjectName.format("[PROJECT]");
    *   UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build();
    *   CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest.newBuilder()
    *     .setParent(formattedParent)
@@ -598,36 +523,8 @@ public final UptimeCheckConfig updateUptimeCheckConfig(UpdateUptimeCheckConfigRe
    *
    * 

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

Sample code: - * - *


-   * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
-   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(name.toString());
+   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   uptimeCheckServiceClient.deleteUptimeCheckConfig(formattedName);
    * }
    * 
* @@ -652,9 +549,9 @@ public final void deleteUptimeCheckConfig(String name) { * *

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *     .setName(formattedName)
    *     .build();
    *   uptimeCheckServiceClient.deleteUptimeCheckConfig(request);
    * }
@@ -677,9 +574,9 @@ public final void deleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest request
    *
    * 

    * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
-   *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+   *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
    *   DeleteUptimeCheckConfigRequest request = DeleteUptimeCheckConfigRequest.newBuilder()
-   *     .setName(name.toString())
+   *     .setName(formattedName)
    *     .build();
    *   ApiFuture<Void> future = uptimeCheckServiceClient.deleteUptimeCheckConfigCallable().futureCall(request);
    *   // Do something
diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
index 297143cd6622..5c405dc40d7a 100644
--- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
+++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/package-info.java
@@ -109,8 +109,8 @@
  * 
  * 
  * try (UptimeCheckServiceClient uptimeCheckServiceClient = UptimeCheckServiceClient.create()) {
- *   UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
- *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(name);
+ *   String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]");
+ *   UptimeCheckConfig response = uptimeCheckServiceClient.getUptimeCheckConfig(formattedName);
  * }
  * 
  * 
diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java index 1897bfe95000..c42d13091242 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java @@ -26,17 +26,17 @@ import com.google.api.gax.rpc.InvalidArgumentException; import com.google.common.collect.Lists; import com.google.monitoring.v3.AlertPolicy; -import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.AlertPolicyName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java index 29d33d133a10..c3e437e127b4 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java @@ -30,13 +30,13 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; -import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.GroupName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java index 0d79d7cec208..ea7b0eeaf6d9 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java @@ -40,13 +40,13 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; -import com.google.monitoring.v3.MetricDescriptorName; -import com.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.MetricDescriptorName; +import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java index 2f61f966dd57..345a121f9374 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java @@ -18,7 +18,7 @@ import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; import com.google.common.base.Preconditions; -import com.google.monitoring.v3.ProjectName; +import com.google.protos.google.monitoring.v3.ProjectName; import java.util.logging.Level; import java.util.logging.Logger; import org.junit.Test; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java index 4c886a9250f4..dc5e3f70c55c 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java @@ -36,13 +36,13 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; -import com.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.monitoring.v3.NotificationChannelName; -import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.protos.google.monitoring.v3.NotificationChannelName; +import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java index ab3f520a32c2..99d26b56d7ba 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java @@ -32,9 +32,10 @@ import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; -import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; +import com.google.protos.google.monitoring.v3.ProjectName; +import com.google.protos.google.monitoring.v3.UptimeCheckConfigName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; @@ -114,7 +115,7 @@ public void listUptimeCheckConfigsTest() { .build(); mockUptimeCheckService.addResponse(expectedResponse); - String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]"); + String formattedParent = ProjectName.format("[PROJECT]"); ListUptimeCheckConfigsPagedResponse pagedListResponse = client.listUptimeCheckConfigs(formattedParent); @@ -142,7 +143,7 @@ public void listUptimeCheckConfigsExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]"); + String formattedParent = ProjectName.format("[PROJECT]"); client.listUptimeCheckConfigs(formattedParent); Assert.fail("No exception raised"); @@ -165,16 +166,16 @@ public void getUptimeCheckConfigTest() { .build(); mockUptimeCheckService.addResponse(expectedResponse); - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - UptimeCheckConfig actualResponse = client.getUptimeCheckConfig(name); + UptimeCheckConfig actualResponse = client.getUptimeCheckConfig(formattedName); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetUptimeCheckConfigRequest actualRequest = (GetUptimeCheckConfigRequest) actualRequests.get(0); - Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); + Assert.assertEquals(formattedName, actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -188,9 +189,9 @@ public void getUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.getUptimeCheckConfig(name); + client.getUptimeCheckConfig(formattedName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -211,7 +212,7 @@ public void createUptimeCheckConfigTest() { .build(); mockUptimeCheckService.addResponse(expectedResponse); - String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]"); + String formattedParent = ProjectName.format("[PROJECT]"); UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); UptimeCheckConfig actualResponse = @@ -238,7 +239,7 @@ public void createUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - String formattedParent = UptimeCheckServiceClient.formatProjectName("[PROJECT]"); + String formattedParent = ProjectName.format("[PROJECT]"); UptimeCheckConfig uptimeCheckConfig = UptimeCheckConfig.newBuilder().build(); client.createUptimeCheckConfig(formattedParent, uptimeCheckConfig); @@ -301,16 +302,16 @@ public void deleteUptimeCheckConfigTest() { Empty expectedResponse = Empty.newBuilder().build(); mockUptimeCheckService.addResponse(expectedResponse); - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.deleteUptimeCheckConfig(name); + client.deleteUptimeCheckConfig(formattedName); List actualRequests = mockUptimeCheckService.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteUptimeCheckConfigRequest actualRequest = (DeleteUptimeCheckConfigRequest) actualRequests.get(0); - Assert.assertEquals(name, UptimeCheckConfigName.parse(actualRequest.getName())); + Assert.assertEquals(formattedName, actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -324,9 +325,9 @@ public void deleteUptimeCheckConfigExceptionTest() throws Exception { mockUptimeCheckService.addException(exception); try { - UptimeCheckConfigName name = UptimeCheckConfigName.of("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); + String formattedName = UptimeCheckConfigName.format("[PROJECT]", "[UPTIME_CHECK_CONFIG]"); - client.deleteUptimeCheckConfig(name); + client.deleteUptimeCheckConfig(formattedName); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception From e49ab11e35e6e1328eee271d0709d6f4e5569b6a Mon Sep 17 00:00:00 2001 From: Andrea Lin Date: Tue, 26 Mar 2019 15:39:49 -0700 Subject: [PATCH 7/7] refresh but with proto changes only --- .../main/proto/google/monitoring/v3/dropped_labels.proto | 3 +++ .../cloud/monitoring/v3/AlertPolicyServiceClient.java | 4 ++-- .../com/google/cloud/monitoring/v3/GroupServiceClient.java | 4 ++-- .../com/google/cloud/monitoring/v3/MetricServiceClient.java | 6 +++--- .../monitoring/v3/NotificationChannelServiceClient.java | 6 +++--- .../cloud/monitoring/v3/AlertPolicyServiceClientTest.java | 4 ++-- .../google/cloud/monitoring/v3/GroupServiceClientTest.java | 4 ++-- .../google/cloud/monitoring/v3/MetricServiceClientTest.java | 6 +++--- .../google/cloud/monitoring/v3/MetricServiceSmokeTest.java | 2 +- .../monitoring/v3/NotificationChannelServiceClientTest.java | 6 +++--- .../cloud/monitoring/v3/UptimeCheckServiceClientTest.java | 4 ++-- 11 files changed, 26 insertions(+), 23 deletions(-) diff --git a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto index d832aa454528..acbe8cf25ad1 100644 --- a/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto +++ b/google-api-grpc/proto-google-cloud-monitoring-v3/src/main/proto/google/monitoring/v3/dropped_labels.proto @@ -20,6 +20,9 @@ package google.monitoring.v3; import "google/api/annotations.proto"; option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring"; +option java_multiple_files = true; +option java_outer_classname = "DroppedLabelsProto"; +option java_package = "com.google.monitoring.v3"; // A set of (label, value) pairs which were dropped during aggregation, attached // to google.api.Distribution.Exemplars in google.api.Distribution values during diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java index 8fde0b16a05c..6a48c01fcb60 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClient.java @@ -29,16 +29,16 @@ import com.google.cloud.monitoring.v3.stub.AlertPolicyServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.monitoring.v3.AlertPolicy; +import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; -import com.google.protos.google.monitoring.v3.AlertPolicyName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java index 71b09765b706..f8d3578d0d06 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/GroupServiceClient.java @@ -33,14 +33,14 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; +import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; import com.google.monitoring.v3.ListGroupsRequest; import com.google.monitoring.v3.ListGroupsResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; -import com.google.protos.google.monitoring.v3.GroupName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java index 2bf9ba121e29..913183e33640 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/MetricServiceClient.java @@ -41,12 +41,12 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; +import com.google.monitoring.v3.MetricDescriptorName; +import com.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; -import com.google.protos.google.monitoring.v3.MetricDescriptorName; -import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java index bbd95d315ec0..ec971fb6543c 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java +++ b/google-cloud-clients/google-cloud-monitoring/src/main/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClient.java @@ -38,12 +38,12 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; +import com.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.monitoring.v3.NotificationChannelName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; -import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.protos.google.monitoring.v3.NotificationChannelName; -import com.google.protos.google.monitoring.v3.ProjectName; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java index c42d13091242..1897bfe95000 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/AlertPolicyServiceClientTest.java @@ -26,17 +26,17 @@ import com.google.api.gax.rpc.InvalidArgumentException; import com.google.common.collect.Lists; import com.google.monitoring.v3.AlertPolicy; +import com.google.monitoring.v3.AlertPolicyName; import com.google.monitoring.v3.CreateAlertPolicyRequest; import com.google.monitoring.v3.DeleteAlertPolicyRequest; import com.google.monitoring.v3.GetAlertPolicyRequest; import com.google.monitoring.v3.ListAlertPoliciesRequest; import com.google.monitoring.v3.ListAlertPoliciesResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateAlertPolicyRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.AlertPolicyName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java index c3e437e127b4..29d33d133a10 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/GroupServiceClientTest.java @@ -30,13 +30,13 @@ import com.google.monitoring.v3.DeleteGroupRequest; import com.google.monitoring.v3.GetGroupRequest; import com.google.monitoring.v3.Group; +import com.google.monitoring.v3.GroupName; import com.google.monitoring.v3.ListGroupMembersRequest; import com.google.monitoring.v3.ListGroupMembersResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateGroupRequest; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.GroupName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java index ea7b0eeaf6d9..0d79d7cec208 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceClientTest.java @@ -40,13 +40,13 @@ import com.google.monitoring.v3.ListMonitoredResourceDescriptorsResponse; import com.google.monitoring.v3.ListTimeSeriesRequest; import com.google.monitoring.v3.ListTimeSeriesResponse; +import com.google.monitoring.v3.MetricDescriptorName; +import com.google.monitoring.v3.MonitoredResourceDescriptorName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.TimeInterval; import com.google.monitoring.v3.TimeSeries; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.MetricDescriptorName; -import com.google.protos.google.monitoring.v3.MonitoredResourceDescriptorName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java index 345a121f9374..2f61f966dd57 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/MetricServiceSmokeTest.java @@ -18,7 +18,7 @@ import static com.google.cloud.monitoring.v3.MetricServiceClient.ListMonitoredResourceDescriptorsPagedResponse; import com.google.common.base.Preconditions; -import com.google.protos.google.monitoring.v3.ProjectName; +import com.google.monitoring.v3.ProjectName; import java.util.logging.Level; import java.util.logging.Logger; import org.junit.Test; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java index dc5e3f70c55c..4c886a9250f4 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/NotificationChannelServiceClientTest.java @@ -36,13 +36,13 @@ import com.google.monitoring.v3.ListNotificationChannelsResponse; import com.google.monitoring.v3.NotificationChannel; import com.google.monitoring.v3.NotificationChannelDescriptor; +import com.google.monitoring.v3.NotificationChannelDescriptorName; +import com.google.monitoring.v3.NotificationChannelName; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateNotificationChannelRequest; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.NotificationChannelDescriptorName; -import com.google.protos.google.monitoring.v3.NotificationChannelName; -import com.google.protos.google.monitoring.v3.ProjectName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; diff --git a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java index 99d26b56d7ba..1c367c49f0e0 100644 --- a/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java +++ b/google-cloud-clients/google-cloud-monitoring/src/test/java/com/google/cloud/monitoring/v3/UptimeCheckServiceClientTest.java @@ -30,12 +30,12 @@ import com.google.monitoring.v3.GetUptimeCheckConfigRequest; import com.google.monitoring.v3.ListUptimeCheckConfigsRequest; import com.google.monitoring.v3.ListUptimeCheckConfigsResponse; +import com.google.monitoring.v3.ProjectName; import com.google.monitoring.v3.UpdateUptimeCheckConfigRequest; import com.google.monitoring.v3.UptimeCheckConfig; +import com.google.monitoring.v3.UptimeCheckConfigName; import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; -import com.google.protos.google.monitoring.v3.ProjectName; -import com.google.protos.google.monitoring.v3.UptimeCheckConfigName; import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException;