From 099e32da75969b8a4aa116acd2740a18d114c624 Mon Sep 17 00:00:00 2001 From: katiehochberg <43226732+katiehochberg@users.noreply.github.com> Date: Wed, 10 Feb 2021 15:18:08 -0500 Subject: [PATCH] feat: update java samples to v1 (#274) As our GA date approaches, we want the samples in our docs to use the v1 version of our API rather than the v1beta1 version. Example here: https://cloud.google.com/service-directory/docs/configuring-service-directory#servicedirectory_create_namespace-java --- .../example/servicedirectory/EndpointsCreate.java | 6 +++--- .../example/servicedirectory/EndpointsDelete.java | 4 ++-- .../example/servicedirectory/NamespacesCreate.java | 6 +++--- .../example/servicedirectory/NamespacesDelete.java | 4 ++-- .../com/example/servicedirectory/Quickstart.java | 8 ++++---- .../com/example/servicedirectory/ServicesCreate.java | 12 ++++++------ .../com/example/servicedirectory/ServicesDelete.java | 4 ++-- .../example/servicedirectory/ServicesResolve.java | 10 +++++----- .../com/example/servicedirectory/EndpointsTests.java | 10 +++++----- .../example/servicedirectory/NamespacesTests.java | 10 +++++----- .../com/example/servicedirectory/ServicesTests.java | 12 ++++++------ 11 files changed, 43 insertions(+), 43 deletions(-) diff --git a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsCreate.java b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsCreate.java index 73144a631a7..ba164213554 100644 --- a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsCreate.java +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsCreate.java @@ -18,9 +18,9 @@ // [START servicedirectory_create_endpoint] -import com.google.cloud.servicedirectory.v1beta1.Endpoint; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; -import com.google.cloud.servicedirectory.v1beta1.ServiceName; +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; import java.io.IOException; public class EndpointsCreate { diff --git a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsDelete.java b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsDelete.java index 7946d632c57..378654e0f3f 100644 --- a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsDelete.java +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsDelete.java @@ -18,8 +18,8 @@ // [START servicedirectory_delete_endpoint] -import com.google.cloud.servicedirectory.v1beta1.EndpointName; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; import java.io.IOException; public class EndpointsDelete { diff --git a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesCreate.java b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesCreate.java index da7f47128e6..492fd9d9c56 100644 --- a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesCreate.java +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesCreate.java @@ -18,9 +18,9 @@ // [START servicedirectory_create_namespace] -import com.google.cloud.servicedirectory.v1beta1.LocationName; -import com.google.cloud.servicedirectory.v1beta1.Namespace; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; import java.io.IOException; public class NamespacesCreate { diff --git a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesDelete.java b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesDelete.java index 47773add27c..c3414d8013a 100644 --- a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesDelete.java +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesDelete.java @@ -18,8 +18,8 @@ // [START servicedirectory_delete_namespace] -import com.google.cloud.servicedirectory.v1beta1.NamespaceName; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; import java.io.IOException; public class NamespacesDelete { diff --git a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/Quickstart.java b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/Quickstart.java index eadf80efde1..d9d7ae393a4 100644 --- a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/Quickstart.java +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/Quickstart.java @@ -18,10 +18,10 @@ // [START servicedirectory_quickstart] -import com.google.cloud.servicedirectory.v1beta1.LocationName; -import com.google.cloud.servicedirectory.v1beta1.Namespace; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListNamespacesPagedResponse; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse; import java.io.IOException; public class Quickstart { diff --git a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesCreate.java b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesCreate.java index 7f531584f30..90a812d7d2d 100644 --- a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesCreate.java +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesCreate.java @@ -18,9 +18,9 @@ // [START servicedirectory_create_service] -import com.google.cloud.servicedirectory.v1beta1.NamespaceName; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; -import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; import java.io.IOException; public class ServicesCreate { @@ -49,15 +49,15 @@ public static void createService( NamespaceName parent = NamespaceName.of(projectId, locationId, namespaceId); // The service object to create. - // Optionally add some metadata for the service. - Service service = Service.newBuilder().putMetadata("protocol", "tcp").build(); + // Optionally add some annotations for the service. + Service service = Service.newBuilder().putAnnotations("protocol", "tcp").build(); // Send the request to create the namespace. Service createdService = client.createService(parent, service, serviceId); // Process the response. System.out.println("Created Service: " + createdService.getName()); - System.out.println("Metadata: " + createdService.getMetadata()); + System.out.println("Annotations: " + createdService.getAnnotations()); } } } diff --git a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesDelete.java b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesDelete.java index 82713e38718..3871e902a15 100644 --- a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesDelete.java +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesDelete.java @@ -18,8 +18,8 @@ // [START servicedirectory_delete_service] -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; -import com.google.cloud.servicedirectory.v1beta1.ServiceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; import java.io.IOException; public class ServicesDelete { diff --git a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesResolve.java b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesResolve.java index 99da6588c37..a170227d380 100644 --- a/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesResolve.java +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesResolve.java @@ -18,11 +18,11 @@ // [START servicedirectory_resolve_service] -import com.google.cloud.servicedirectory.v1beta1.Endpoint; -import com.google.cloud.servicedirectory.v1beta1.LookupServiceClient; -import com.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest; -import com.google.cloud.servicedirectory.v1beta1.ResolveServiceResponse; -import com.google.cloud.servicedirectory.v1beta1.ServiceName; +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.LookupServiceClient; +import com.google.cloud.servicedirectory.v1.ResolveServiceRequest; +import com.google.cloud.servicedirectory.v1.ResolveServiceResponse; +import com.google.cloud.servicedirectory.v1.ServiceName; import java.io.IOException; public class ServicesResolve { diff --git a/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/EndpointsTests.java b/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/EndpointsTests.java index e8aaf7a3236..01f960a2316 100644 --- a/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/EndpointsTests.java +++ b/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/EndpointsTests.java @@ -19,11 +19,11 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import com.google.cloud.servicedirectory.v1beta1.EndpointName; -import com.google.cloud.servicedirectory.v1beta1.LocationName; -import com.google.cloud.servicedirectory.v1beta1.Namespace; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListNamespacesPagedResponse; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.UUID; diff --git a/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/NamespacesTests.java b/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/NamespacesTests.java index b57beb14106..36f54b06d26 100644 --- a/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/NamespacesTests.java +++ b/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/NamespacesTests.java @@ -19,11 +19,11 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import com.google.cloud.servicedirectory.v1beta1.LocationName; -import com.google.cloud.servicedirectory.v1beta1.Namespace; -import com.google.cloud.servicedirectory.v1beta1.NamespaceName; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListNamespacesPagedResponse; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.UUID; diff --git a/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/ServicesTests.java b/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/ServicesTests.java index d44c1f12eb6..b9642866402 100644 --- a/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/ServicesTests.java +++ b/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/ServicesTests.java @@ -19,12 +19,12 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import com.google.cloud.servicedirectory.v1beta1.EndpointName; -import com.google.cloud.servicedirectory.v1beta1.LocationName; -import com.google.cloud.servicedirectory.v1beta1.Namespace; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; -import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListNamespacesPagedResponse; -import com.google.cloud.servicedirectory.v1beta1.ServiceName; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse; +import com.google.cloud.servicedirectory.v1.ServiceName; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.UUID;