diff --git a/servicedirectory/snippets/pom.xml b/servicedirectory/snippets/pom.xml new file mode 100644 index 00000000000..c983ec57b4f --- /dev/null +++ b/servicedirectory/snippets/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + com.google.cloud + google-cloud-servicedirectory-samples + 0.0.1-SNAPSHOT + pom + Google Service Directory Samples Parent + https://github.com/googleapis/java-servicedirectory + + Java idiomatic client for Google Cloud Platform services. + + + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + + + 1.8 + 1.8 + UTF-8 + + + + install-without-bom + snapshot + snippets + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + + true + + + + + diff --git a/servicedirectory/snippets/snippets/README.md b/servicedirectory/snippets/snippets/README.md new file mode 100644 index 00000000000..fe368e2a2b4 --- /dev/null +++ b/servicedirectory/snippets/snippets/README.md @@ -0,0 +1,46 @@ +# Service Directory + +[Service Directory](https://cloud.google.com/service-directory/) is a platform +for discovering, publishing, and connecting services. It offers customers a +single place to register and discover their services in a consistent and +reliable way, regardless of their environment. These sample Java applications +demonstrate how to access the Service Directory API using the Google Java API +Client Libraries. + +## Prerequisites + +### Enable the API + +You must enable the Service Directory API for your project in order to use these +samples. You can do so +[here](https://console.cloud.google.com/flows/enableapi?apiid=servicedirectory.googleapis.com&_ga=2.140387959.57242806.1585772225-360187285.1585772225). + +### Set Environment Variables + +You must set your project ID in order to run the tests + +`$ export GOOGLE_CLOUD_PROJECT=` + +### Grant Permissions + +You must ensure that the +[user account or service account](https://cloud.google.com/iam/docs/service-accounts#differences_between_a_service_account_and_a_user_account) +you used to authorize your gcloud session has the proper permissions to edit +Service Directory resources for your project. In the Cloud Console under IAM, +add the `Service Directory Admin` role to the project whose service account +you're using to test. + +More information can be found in the +[Authentication docs](https://cloud.google.com/docs/authentication/production). + +## Quickstart + +Install [Maven](https://maven.apache.org/). + +Build your project with: + + mvn clean package -DskipTests + +You can run all tests with: + + mvn clean verify diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/create/SyncCreateSetCredentialsProvider.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000000..9975dd7dded --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_LookupService_Create_SetCredentialsProvider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.servicedirectory.v1.LookupServiceClient; +import com.google.cloud.servicedirectory.v1.LookupServiceSettings; +import com.google.cloud.servicedirectory.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1_generated_LookupService_Create_SetCredentialsProvider_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/create/SyncCreateSetCredentialsProvider1.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000000..36a0b583447 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_LookupService_Create_SetCredentialsProvider1_sync] +import com.google.cloud.servicedirectory.v1.LookupServiceClient; +import com.google.cloud.servicedirectory.v1.LookupServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newHttpJsonBuilder().build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1_generated_LookupService_Create_SetCredentialsProvider1_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/create/SyncCreateSetEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000000..ad0105a25a0 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/create/SyncCreateSetEndpoint.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_LookupService_Create_SetEndpoint_sync] +import com.google.cloud.servicedirectory.v1.LookupServiceClient; +import com.google.cloud.servicedirectory.v1.LookupServiceSettings; +import com.google.cloud.servicedirectory.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1_generated_LookupService_Create_SetEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/resolveservice/AsyncResolveService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/resolveservice/AsyncResolveService.java new file mode 100644 index 00000000000..0e842b0720c --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/resolveservice/AsyncResolveService.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_LookupService_ResolveService_async] +import com.google.api.core.ApiFuture; +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; + +public class AsyncResolveService { + + public static void main(String[] args) throws Exception { + asyncResolveService(); + } + + public static void asyncResolveService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) { + ResolveServiceRequest request = + ResolveServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setMaxEndpoints(2074789987) + .setEndpointFilter("endpointFilter-1834249875") + .build(); + ApiFuture future = + lookupServiceClient.resolveServiceCallable().futureCall(request); + // Do something. + ResolveServiceResponse response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_LookupService_ResolveService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/resolveservice/SyncResolveService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/resolveservice/SyncResolveService.java new file mode 100644 index 00000000000..1d96a22bd27 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservice/resolveservice/SyncResolveService.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_LookupService_ResolveService_sync] +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; + +public class SyncResolveService { + + public static void main(String[] args) throws Exception { + syncResolveService(); + } + + public static void syncResolveService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) { + ResolveServiceRequest request = + ResolveServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setMaxEndpoints(2074789987) + .setEndpointFilter("endpointFilter-1834249875") + .build(); + ResolveServiceResponse response = lookupServiceClient.resolveService(request); + } + } +} +// [END servicedirectory_v1_generated_LookupService_ResolveService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservicesettings/resolveservice/SyncResolveService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservicesettings/resolveservice/SyncResolveService.java new file mode 100644 index 00000000000..e5eaec661cd --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservicesettings/resolveservice/SyncResolveService.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_LookupServiceSettings_ResolveService_sync] +import com.google.cloud.servicedirectory.v1.LookupServiceSettings; +import java.time.Duration; + +public class SyncResolveService { + + public static void main(String[] args) throws Exception { + syncResolveService(); + } + + public static void syncResolveService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceSettings.Builder lookupServiceSettingsBuilder = LookupServiceSettings.newBuilder(); + lookupServiceSettingsBuilder + .resolveServiceSettings() + .setRetrySettings( + lookupServiceSettingsBuilder.resolveServiceSettings().getRetrySettings().toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + LookupServiceSettings lookupServiceSettings = lookupServiceSettingsBuilder.build(); + } +} +// [END servicedirectory_v1_generated_LookupServiceSettings_ResolveService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/create/SyncCreateSetCredentialsProvider.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000000..2be6b2541f9 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_Create_SetCredentialsProvider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.RegistrationServiceSettings; +import com.google.cloud.servicedirectory.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1_generated_RegistrationService_Create_SetCredentialsProvider_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/create/SyncCreateSetCredentialsProvider1.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000000..2dce4ef17f4 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_Create_SetCredentialsProvider1_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.RegistrationServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newHttpJsonBuilder().build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1_generated_RegistrationService_Create_SetCredentialsProvider1_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/create/SyncCreateSetEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000000..a7ad089d3b6 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/create/SyncCreateSetEndpoint.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_Create_SetEndpoint_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.RegistrationServiceSettings; +import com.google.cloud.servicedirectory.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1_generated_RegistrationService_Create_SetEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/AsyncCreateEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/AsyncCreateEndpoint.java new file mode 100644 index 00000000000..0ac3494a4f8 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/AsyncCreateEndpoint.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateEndpoint_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.CreateEndpointRequest; +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class AsyncCreateEndpoint { + + public static void main(String[] args) throws Exception { + asyncCreateEndpoint(); + } + + public static void asyncCreateEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateEndpointRequest request = + CreateEndpointRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setEndpointId("endpointId-1837754992") + .setEndpoint(Endpoint.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.createEndpointCallable().futureCall(request); + // Do something. + Endpoint response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateEndpoint_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/SyncCreateEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/SyncCreateEndpoint.java new file mode 100644 index 00000000000..c22b1bfece8 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/SyncCreateEndpoint.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateEndpoint_sync] +import com.google.cloud.servicedirectory.v1.CreateEndpointRequest; +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncCreateEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateEndpoint(); + } + + public static void syncCreateEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateEndpointRequest request = + CreateEndpointRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setEndpointId("endpointId-1837754992") + .setEndpoint(Endpoint.newBuilder().build()) + .build(); + Endpoint response = registrationServiceClient.createEndpoint(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/SyncCreateEndpointServicenameEndpointString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/SyncCreateEndpointServicenameEndpointString.java new file mode 100644 index 00000000000..aadd85d2bdc --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/SyncCreateEndpointServicenameEndpointString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateEndpoint_ServicenameEndpointString_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncCreateEndpointServicenameEndpointString { + + public static void main(String[] args) throws Exception { + syncCreateEndpointServicenameEndpointString(); + } + + public static void syncCreateEndpointServicenameEndpointString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + Endpoint response = registrationServiceClient.createEndpoint(parent, endpoint, endpointId); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateEndpoint_ServicenameEndpointString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/SyncCreateEndpointStringEndpointString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/SyncCreateEndpointStringEndpointString.java new file mode 100644 index 00000000000..b8596a0b0fa --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createendpoint/SyncCreateEndpointStringEndpointString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateEndpoint_StringEndpointString_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncCreateEndpointStringEndpointString { + + public static void main(String[] args) throws Exception { + syncCreateEndpointStringEndpointString(); + } + + public static void syncCreateEndpointStringEndpointString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + Endpoint response = registrationServiceClient.createEndpoint(parent, endpoint, endpointId); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateEndpoint_StringEndpointString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/AsyncCreateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/AsyncCreateNamespace.java new file mode 100644 index 00000000000..d9fdfd6cdb3 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/AsyncCreateNamespace.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateNamespace_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.CreateNamespaceRequest; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class AsyncCreateNamespace { + + public static void main(String[] args) throws Exception { + asyncCreateNamespace(); + } + + public static void asyncCreateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateNamespaceRequest request = + CreateNamespaceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setNamespaceId("namespaceId790852566") + .setNamespace(Namespace.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.createNamespaceCallable().futureCall(request); + // Do something. + Namespace response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateNamespace_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/SyncCreateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000000..14d75dc396f --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/SyncCreateNamespace.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateNamespace_sync] +import com.google.cloud.servicedirectory.v1.CreateNamespaceRequest; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncCreateNamespace { + + public static void main(String[] args) throws Exception { + syncCreateNamespace(); + } + + public static void syncCreateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateNamespaceRequest request = + CreateNamespaceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setNamespaceId("namespaceId790852566") + .setNamespace(Namespace.newBuilder().build()) + .build(); + Namespace response = registrationServiceClient.createNamespace(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java new file mode 100644 index 00000000000..92431026f3a --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateNamespace_LocationnameNamespaceString_sync] +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncCreateNamespaceLocationnameNamespaceString { + + public static void main(String[] args) throws Exception { + syncCreateNamespaceLocationnameNamespaceString(); + } + + public static void syncCreateNamespaceLocationnameNamespaceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + Namespace response = + registrationServiceClient.createNamespace(parent, namespace, namespaceId); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateNamespace_LocationnameNamespaceString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/SyncCreateNamespaceStringNamespaceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/SyncCreateNamespaceStringNamespaceString.java new file mode 100644 index 00000000000..a02983320fb --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createnamespace/SyncCreateNamespaceStringNamespaceString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateNamespace_StringNamespaceString_sync] +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncCreateNamespaceStringNamespaceString { + + public static void main(String[] args) throws Exception { + syncCreateNamespaceStringNamespaceString(); + } + + public static void syncCreateNamespaceStringNamespaceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + Namespace response = + registrationServiceClient.createNamespace(parent, namespace, namespaceId); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateNamespace_StringNamespaceString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/AsyncCreateService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/AsyncCreateService.java new file mode 100644 index 00000000000..a38a09972ef --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/AsyncCreateService.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateService_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.CreateServiceRequest; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; + +public class AsyncCreateService { + + public static void main(String[] args) throws Exception { + asyncCreateService(); + } + + public static void asyncCreateService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateServiceRequest request = + CreateServiceRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setServiceId("serviceId-194185552") + .setService(Service.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.createServiceCallable().futureCall(request); + // Do something. + Service response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/SyncCreateService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/SyncCreateService.java new file mode 100644 index 00000000000..7b00c2b73af --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/SyncCreateService.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateService_sync] +import com.google.cloud.servicedirectory.v1.CreateServiceRequest; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; + +public class SyncCreateService { + + public static void main(String[] args) throws Exception { + syncCreateService(); + } + + public static void syncCreateService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateServiceRequest request = + CreateServiceRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setServiceId("serviceId-194185552") + .setService(Service.newBuilder().build()) + .build(); + Service response = registrationServiceClient.createService(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/SyncCreateServiceNamespacenameServiceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/SyncCreateServiceNamespacenameServiceString.java new file mode 100644 index 00000000000..98b5ad77a00 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/SyncCreateServiceNamespacenameServiceString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateService_NamespacenameServiceString_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; + +public class SyncCreateServiceNamespacenameServiceString { + + public static void main(String[] args) throws Exception { + syncCreateServiceNamespacenameServiceString(); + } + + public static void syncCreateServiceNamespacenameServiceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + Service response = registrationServiceClient.createService(parent, service, serviceId); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateService_NamespacenameServiceString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/SyncCreateServiceStringServiceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/SyncCreateServiceStringServiceString.java new file mode 100644 index 00000000000..374d7e97786 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/createservice/SyncCreateServiceStringServiceString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_CreateService_StringServiceString_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; + +public class SyncCreateServiceStringServiceString { + + public static void main(String[] args) throws Exception { + syncCreateServiceStringServiceString(); + } + + public static void syncCreateServiceStringServiceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + Service response = registrationServiceClient.createService(parent, service, serviceId); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_CreateService_StringServiceString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/AsyncDeleteEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/AsyncDeleteEndpoint.java new file mode 100644 index 00000000000..e0293cdfddb --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/AsyncDeleteEndpoint.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.DeleteEndpointRequest; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteEndpoint { + + public static void main(String[] args) throws Exception { + asyncDeleteEndpoint(); + } + + public static void asyncDeleteEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteEndpointRequest request = + DeleteEndpointRequest.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .build(); + ApiFuture future = + registrationServiceClient.deleteEndpointCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/SyncDeleteEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/SyncDeleteEndpoint.java new file mode 100644 index 00000000000..0c6ea23f3b9 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/SyncDeleteEndpoint.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_sync] +import com.google.cloud.servicedirectory.v1.DeleteEndpointRequest; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteEndpoint { + + public static void main(String[] args) throws Exception { + syncDeleteEndpoint(); + } + + public static void syncDeleteEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteEndpointRequest request = + DeleteEndpointRequest.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .build(); + registrationServiceClient.deleteEndpoint(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/SyncDeleteEndpointEndpointname.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/SyncDeleteEndpointEndpointname.java new file mode 100644 index 00000000000..b9850a06aef --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/SyncDeleteEndpointEndpointname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_Endpointname_sync] +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteEndpointEndpointname { + + public static void main(String[] args) throws Exception { + syncDeleteEndpointEndpointname(); + } + + public static void syncDeleteEndpointEndpointname() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + registrationServiceClient.deleteEndpoint(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_Endpointname_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/SyncDeleteEndpointString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/SyncDeleteEndpointString.java new file mode 100644 index 00000000000..f18d2ec2ac3 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteendpoint/SyncDeleteEndpointString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_String_sync] +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteEndpointString { + + public static void main(String[] args) throws Exception { + syncDeleteEndpointString(); + } + + public static void syncDeleteEndpointString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString(); + registrationServiceClient.deleteEndpoint(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/AsyncDeleteNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/AsyncDeleteNamespace.java new file mode 100644 index 00000000000..2cae1234189 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/AsyncDeleteNamespace.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteNamespace_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.DeleteNamespaceRequest; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteNamespace { + + public static void main(String[] args) throws Exception { + asyncDeleteNamespace(); + } + + public static void asyncDeleteNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteNamespaceRequest request = + DeleteNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + ApiFuture future = + registrationServiceClient.deleteNamespaceCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteNamespace_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/SyncDeleteNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/SyncDeleteNamespace.java new file mode 100644 index 00000000000..9808d082950 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/SyncDeleteNamespace.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteNamespace_sync] +import com.google.cloud.servicedirectory.v1.DeleteNamespaceRequest; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNamespace { + + public static void main(String[] args) throws Exception { + syncDeleteNamespace(); + } + + public static void syncDeleteNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteNamespaceRequest request = + DeleteNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + registrationServiceClient.deleteNamespace(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/SyncDeleteNamespaceNamespacename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/SyncDeleteNamespaceNamespacename.java new file mode 100644 index 00000000000..d97ba1c1361 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/SyncDeleteNamespaceNamespacename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteNamespace_Namespacename_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNamespaceNamespacename { + + public static void main(String[] args) throws Exception { + syncDeleteNamespaceNamespacename(); + } + + public static void syncDeleteNamespaceNamespacename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + registrationServiceClient.deleteNamespace(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteNamespace_Namespacename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/SyncDeleteNamespaceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/SyncDeleteNamespaceString.java new file mode 100644 index 00000000000..abb612ee162 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deletenamespace/SyncDeleteNamespaceString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteNamespace_String_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNamespaceString { + + public static void main(String[] args) throws Exception { + syncDeleteNamespaceString(); + } + + public static void syncDeleteNamespaceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + registrationServiceClient.deleteNamespace(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteNamespace_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/AsyncDeleteService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/AsyncDeleteService.java new file mode 100644 index 00000000000..356d5fde239 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/AsyncDeleteService.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteService_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.DeleteServiceRequest; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; +import com.google.protobuf.Empty; + +public class AsyncDeleteService { + + public static void main(String[] args) throws Exception { + asyncDeleteService(); + } + + public static void asyncDeleteService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteServiceRequest request = + DeleteServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .build(); + ApiFuture future = + registrationServiceClient.deleteServiceCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/SyncDeleteService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/SyncDeleteService.java new file mode 100644 index 00000000000..c76daacba93 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/SyncDeleteService.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteService_sync] +import com.google.cloud.servicedirectory.v1.DeleteServiceRequest; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; +import com.google.protobuf.Empty; + +public class SyncDeleteService { + + public static void main(String[] args) throws Exception { + syncDeleteService(); + } + + public static void syncDeleteService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteServiceRequest request = + DeleteServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .build(); + registrationServiceClient.deleteService(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/SyncDeleteServiceServicename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/SyncDeleteServiceServicename.java new file mode 100644 index 00000000000..bdeaf498ed9 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/SyncDeleteServiceServicename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteService_Servicename_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; +import com.google.protobuf.Empty; + +public class SyncDeleteServiceServicename { + + public static void main(String[] args) throws Exception { + syncDeleteServiceServicename(); + } + + public static void syncDeleteServiceServicename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + registrationServiceClient.deleteService(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteService_Servicename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/SyncDeleteServiceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/SyncDeleteServiceString.java new file mode 100644 index 00000000000..7ea80b8e446 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/deleteservice/SyncDeleteServiceString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_DeleteService_String_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; +import com.google.protobuf.Empty; + +public class SyncDeleteServiceString { + + public static void main(String[] args) throws Exception { + syncDeleteServiceString(); + } + + public static void syncDeleteServiceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + registrationServiceClient.deleteService(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_DeleteService_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/AsyncGetEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/AsyncGetEndpoint.java new file mode 100644 index 00000000000..7270fae35d8 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/AsyncGetEndpoint.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetEndpoint_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.GetEndpointRequest; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class AsyncGetEndpoint { + + public static void main(String[] args) throws Exception { + asyncGetEndpoint(); + } + + public static void asyncGetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetEndpointRequest request = + GetEndpointRequest.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .build(); + ApiFuture future = + registrationServiceClient.getEndpointCallable().futureCall(request); + // Do something. + Endpoint response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetEndpoint_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/SyncGetEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/SyncGetEndpoint.java new file mode 100644 index 00000000000..c1ef4d29e04 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/SyncGetEndpoint.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetEndpoint_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.GetEndpointRequest; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncGetEndpoint { + + public static void main(String[] args) throws Exception { + syncGetEndpoint(); + } + + public static void syncGetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetEndpointRequest request = + GetEndpointRequest.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .build(); + Endpoint response = registrationServiceClient.getEndpoint(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/SyncGetEndpointEndpointname.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/SyncGetEndpointEndpointname.java new file mode 100644 index 00000000000..9a694c9d671 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/SyncGetEndpointEndpointname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetEndpoint_Endpointname_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncGetEndpointEndpointname { + + public static void main(String[] args) throws Exception { + syncGetEndpointEndpointname(); + } + + public static void syncGetEndpointEndpointname() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + Endpoint response = registrationServiceClient.getEndpoint(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetEndpoint_Endpointname_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/SyncGetEndpointString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/SyncGetEndpointString.java new file mode 100644 index 00000000000..72d77b018f9 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getendpoint/SyncGetEndpointString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetEndpoint_String_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncGetEndpointString { + + public static void main(String[] args) throws Exception { + syncGetEndpointString(); + } + + public static void syncGetEndpointString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString(); + Endpoint response = registrationServiceClient.getEndpoint(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetEndpoint_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getiampolicy/AsyncGetIamPolicy.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 00000000000..79726c58eed --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getiampolicy/AsyncGetIamPolicy.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetIamPolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetIamPolicy_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getiampolicy/SyncGetIamPolicy.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 00000000000..21588169326 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getiampolicy/SyncGetIamPolicy.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetIamPolicy_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = registrationServiceClient.getIamPolicy(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetIamPolicy_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/AsyncGetNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/AsyncGetNamespace.java new file mode 100644 index 00000000000..0c9bb1d1812 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/AsyncGetNamespace.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetNamespace_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.GetNamespaceRequest; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class AsyncGetNamespace { + + public static void main(String[] args) throws Exception { + asyncGetNamespace(); + } + + public static void asyncGetNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetNamespaceRequest request = + GetNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + ApiFuture future = + registrationServiceClient.getNamespaceCallable().futureCall(request); + // Do something. + Namespace response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetNamespace_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/SyncGetNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/SyncGetNamespace.java new file mode 100644 index 00000000000..20bc8f896a2 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/SyncGetNamespace.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetNamespace_sync] +import com.google.cloud.servicedirectory.v1.GetNamespaceRequest; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncGetNamespace { + + public static void main(String[] args) throws Exception { + syncGetNamespace(); + } + + public static void syncGetNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetNamespaceRequest request = + GetNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + Namespace response = registrationServiceClient.getNamespace(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/SyncGetNamespaceNamespacename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/SyncGetNamespaceNamespacename.java new file mode 100644 index 00000000000..526e854c17a --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/SyncGetNamespaceNamespacename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetNamespace_Namespacename_sync] +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncGetNamespaceNamespacename { + + public static void main(String[] args) throws Exception { + syncGetNamespaceNamespacename(); + } + + public static void syncGetNamespaceNamespacename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Namespace response = registrationServiceClient.getNamespace(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetNamespace_Namespacename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/SyncGetNamespaceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/SyncGetNamespaceString.java new file mode 100644 index 00000000000..16249258cf1 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getnamespace/SyncGetNamespaceString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetNamespace_String_sync] +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncGetNamespaceString { + + public static void main(String[] args) throws Exception { + syncGetNamespaceString(); + } + + public static void syncGetNamespaceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + Namespace response = registrationServiceClient.getNamespace(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetNamespace_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/AsyncGetService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/AsyncGetService.java new file mode 100644 index 00000000000..d69439f23ea --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/AsyncGetService.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetService_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.GetServiceRequest; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class AsyncGetService { + + public static void main(String[] args) throws Exception { + asyncGetService(); + } + + public static void asyncGetService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetServiceRequest request = + GetServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .build(); + ApiFuture future = + registrationServiceClient.getServiceCallable().futureCall(request); + // Do something. + Service response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/SyncGetService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/SyncGetService.java new file mode 100644 index 00000000000..ba08e4203b4 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/SyncGetService.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetService_sync] +import com.google.cloud.servicedirectory.v1.GetServiceRequest; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncGetService { + + public static void main(String[] args) throws Exception { + syncGetService(); + } + + public static void syncGetService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetServiceRequest request = + GetServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .build(); + Service response = registrationServiceClient.getService(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/SyncGetServiceServicename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/SyncGetServiceServicename.java new file mode 100644 index 00000000000..d79dc39855f --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/SyncGetServiceServicename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetService_Servicename_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncGetServiceServicename { + + public static void main(String[] args) throws Exception { + syncGetServiceServicename(); + } + + public static void syncGetServiceServicename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Service response = registrationServiceClient.getService(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetService_Servicename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/SyncGetServiceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/SyncGetServiceString.java new file mode 100644 index 00000000000..bd25588d4b9 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/getservice/SyncGetServiceString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_GetService_String_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncGetServiceString { + + public static void main(String[] args) throws Exception { + syncGetServiceString(); + } + + public static void syncGetServiceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + Service response = registrationServiceClient.getService(name); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_GetService_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/AsyncListEndpoints.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/AsyncListEndpoints.java new file mode 100644 index 00000000000..08c12dca14f --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/AsyncListEndpoints.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListEndpoints_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.ListEndpointsRequest; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class AsyncListEndpoints { + + public static void main(String[] args) throws Exception { + asyncListEndpoints(); + } + + public static void asyncListEndpoints() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListEndpointsRequest request = + ListEndpointsRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + registrationServiceClient.listEndpointsPagedCallable().futureCall(request); + // Do something. + for (Endpoint element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListEndpoints_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/AsyncListEndpointsPaged.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/AsyncListEndpointsPaged.java new file mode 100644 index 00000000000..e7b9dc995ae --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/AsyncListEndpointsPaged.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListEndpoints_Paged_async] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.ListEndpointsRequest; +import com.google.cloud.servicedirectory.v1.ListEndpointsResponse; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; +import com.google.common.base.Strings; + +public class AsyncListEndpointsPaged { + + public static void main(String[] args) throws Exception { + asyncListEndpointsPaged(); + } + + public static void asyncListEndpointsPaged() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListEndpointsRequest request = + ListEndpointsRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListEndpointsResponse response = + registrationServiceClient.listEndpointsCallable().call(request); + for (Endpoint element : response.getEndpointsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListEndpoints_Paged_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/SyncListEndpoints.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/SyncListEndpoints.java new file mode 100644 index 00000000000..899e9aac5d8 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/SyncListEndpoints.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListEndpoints_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.ListEndpointsRequest; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncListEndpoints { + + public static void main(String[] args) throws Exception { + syncListEndpoints(); + } + + public static void syncListEndpoints() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListEndpointsRequest request = + ListEndpointsRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Endpoint element : registrationServiceClient.listEndpoints(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListEndpoints_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/SyncListEndpointsServicename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/SyncListEndpointsServicename.java new file mode 100644 index 00000000000..439156e7b27 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/SyncListEndpointsServicename.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListEndpoints_Servicename_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncListEndpointsServicename { + + public static void main(String[] args) throws Exception { + syncListEndpointsServicename(); + } + + public static void syncListEndpointsServicename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + for (Endpoint element : registrationServiceClient.listEndpoints(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListEndpoints_Servicename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/SyncListEndpointsString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/SyncListEndpointsString.java new file mode 100644 index 00000000000..a8f2d6c59b8 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listendpoints/SyncListEndpointsString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListEndpoints_String_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncListEndpointsString { + + public static void main(String[] args) throws Exception { + syncListEndpointsString(); + } + + public static void syncListEndpointsString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + for (Endpoint element : registrationServiceClient.listEndpoints(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListEndpoints_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/AsyncListNamespaces.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/AsyncListNamespaces.java new file mode 100644 index 00000000000..1d97bba0b8e --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/AsyncListNamespaces.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListNamespaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.ListNamespacesRequest; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class AsyncListNamespaces { + + public static void main(String[] args) throws Exception { + asyncListNamespaces(); + } + + public static void asyncListNamespaces() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListNamespacesRequest request = + ListNamespacesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + registrationServiceClient.listNamespacesPagedCallable().futureCall(request); + // Do something. + for (Namespace element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListNamespaces_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/AsyncListNamespacesPaged.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/AsyncListNamespacesPaged.java new file mode 100644 index 00000000000..d54c230d81e --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/AsyncListNamespacesPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListNamespaces_Paged_async] +import com.google.cloud.servicedirectory.v1.ListNamespacesRequest; +import com.google.cloud.servicedirectory.v1.ListNamespacesResponse; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.common.base.Strings; + +public class AsyncListNamespacesPaged { + + public static void main(String[] args) throws Exception { + asyncListNamespacesPaged(); + } + + public static void asyncListNamespacesPaged() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListNamespacesRequest request = + ListNamespacesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListNamespacesResponse response = + registrationServiceClient.listNamespacesCallable().call(request); + for (Namespace element : response.getNamespacesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListNamespaces_Paged_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/SyncListNamespaces.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/SyncListNamespaces.java new file mode 100644 index 00000000000..29db8d9d81a --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/SyncListNamespaces.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListNamespaces_sync] +import com.google.cloud.servicedirectory.v1.ListNamespacesRequest; +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncListNamespaces { + + public static void main(String[] args) throws Exception { + syncListNamespaces(); + } + + public static void syncListNamespaces() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListNamespacesRequest request = + ListNamespacesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Namespace element : registrationServiceClient.listNamespaces(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListNamespaces_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/SyncListNamespacesLocationname.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/SyncListNamespacesLocationname.java new file mode 100644 index 00000000000..7cb3c587914 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/SyncListNamespacesLocationname.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListNamespaces_Locationname_sync] +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncListNamespacesLocationname { + + public static void main(String[] args) throws Exception { + syncListNamespacesLocationname(); + } + + public static void syncListNamespacesLocationname() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Namespace element : registrationServiceClient.listNamespaces(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListNamespaces_Locationname_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/SyncListNamespacesString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/SyncListNamespacesString.java new file mode 100644 index 00000000000..c95e3c479ce --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listnamespaces/SyncListNamespacesString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListNamespaces_String_sync] +import com.google.cloud.servicedirectory.v1.LocationName; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncListNamespacesString { + + public static void main(String[] args) throws Exception { + syncListNamespacesString(); + } + + public static void syncListNamespacesString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Namespace element : registrationServiceClient.listNamespaces(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListNamespaces_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/AsyncListServices.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/AsyncListServices.java new file mode 100644 index 00000000000..6604c987ed6 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/AsyncListServices.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListServices_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.ListServicesRequest; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; + +public class AsyncListServices { + + public static void main(String[] args) throws Exception { + asyncListServices(); + } + + public static void asyncListServices() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + registrationServiceClient.listServicesPagedCallable().futureCall(request); + // Do something. + for (Service element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListServices_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/AsyncListServicesPaged.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/AsyncListServicesPaged.java new file mode 100644 index 00000000000..0038785f5ee --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/AsyncListServicesPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListServices_Paged_async] +import com.google.cloud.servicedirectory.v1.ListServicesRequest; +import com.google.cloud.servicedirectory.v1.ListServicesResponse; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; +import com.google.common.base.Strings; + +public class AsyncListServicesPaged { + + public static void main(String[] args) throws Exception { + asyncListServicesPaged(); + } + + public static void asyncListServicesPaged() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListServicesResponse response = + registrationServiceClient.listServicesCallable().call(request); + for (Service element : response.getServicesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListServices_Paged_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/SyncListServices.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/SyncListServices.java new file mode 100644 index 00000000000..0b3fa978827 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/SyncListServices.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListServices_sync] +import com.google.cloud.servicedirectory.v1.ListServicesRequest; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; + +public class SyncListServices { + + public static void main(String[] args) throws Exception { + syncListServices(); + } + + public static void syncListServices() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Service element : registrationServiceClient.listServices(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListServices_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/SyncListServicesNamespacename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/SyncListServicesNamespacename.java new file mode 100644 index 00000000000..3a9c9dbf897 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/SyncListServicesNamespacename.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListServices_Namespacename_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; + +public class SyncListServicesNamespacename { + + public static void main(String[] args) throws Exception { + syncListServicesNamespacename(); + } + + public static void syncListServicesNamespacename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + for (Service element : registrationServiceClient.listServices(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListServices_Namespacename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/SyncListServicesString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/SyncListServicesString.java new file mode 100644 index 00000000000..7847269f089 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/listservices/SyncListServicesString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_ListServices_String_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; + +public class SyncListServicesString { + + public static void main(String[] args) throws Exception { + syncListServicesString(); + } + + public static void syncListServicesString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + for (Service element : registrationServiceClient.listServices(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_ListServices_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/setiampolicy/AsyncSetIamPolicy.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 00000000000..c71057e0da2 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/setiampolicy/AsyncSetIamPolicy.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_SetIamPolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_SetIamPolicy_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/setiampolicy/SyncSetIamPolicy.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 00000000000..be0a5a0fb47 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/setiampolicy/SyncSetIamPolicy.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_SetIamPolicy_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = registrationServiceClient.setIamPolicy(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_SetIamPolicy_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/testiampermissions/AsyncTestIamPermissions.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 00000000000..889c23f2bb6 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/testiampermissions/AsyncTestIamPermissions.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_TestIamPermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + registrationServiceClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_TestIamPermissions_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/testiampermissions/SyncTestIamPermissions.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 00000000000..94c2d459f1e --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/testiampermissions/SyncTestIamPermissions.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_TestIamPermissions_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = registrationServiceClient.testIamPermissions(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_TestIamPermissions_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateendpoint/AsyncUpdateEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateendpoint/AsyncUpdateEndpoint.java new file mode 100644 index 00000000000..39582bce2ff --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateendpoint/AsyncUpdateEndpoint.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_UpdateEndpoint_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.UpdateEndpointRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEndpoint { + + public static void main(String[] args) throws Exception { + asyncUpdateEndpoint(); + } + + public static void asyncUpdateEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateEndpointRequest request = + UpdateEndpointRequest.newBuilder() + .setEndpoint(Endpoint.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.updateEndpointCallable().futureCall(request); + // Do something. + Endpoint response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_UpdateEndpoint_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateendpoint/SyncUpdateEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateendpoint/SyncUpdateEndpoint.java new file mode 100644 index 00000000000..b6a1494ba13 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateendpoint/SyncUpdateEndpoint.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_UpdateEndpoint_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.UpdateEndpointRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEndpoint { + + public static void main(String[] args) throws Exception { + syncUpdateEndpoint(); + } + + public static void syncUpdateEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateEndpointRequest request = + UpdateEndpointRequest.newBuilder() + .setEndpoint(Endpoint.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Endpoint response = registrationServiceClient.updateEndpoint(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_UpdateEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java new file mode 100644 index 00000000000..a8318118ebf --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_UpdateEndpoint_EndpointFieldmask_sync] +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEndpointEndpointFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateEndpointEndpointFieldmask(); + } + + public static void syncUpdateEndpointEndpointFieldmask() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + Endpoint endpoint = Endpoint.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Endpoint response = registrationServiceClient.updateEndpoint(endpoint, updateMask); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_UpdateEndpoint_EndpointFieldmask_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updatenamespace/AsyncUpdateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updatenamespace/AsyncUpdateNamespace.java new file mode 100644 index 00000000000..3e71d995e24 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updatenamespace/AsyncUpdateNamespace.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_UpdateNamespace_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.UpdateNamespaceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateNamespace { + + public static void main(String[] args) throws Exception { + asyncUpdateNamespace(); + } + + public static void asyncUpdateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateNamespaceRequest request = + UpdateNamespaceRequest.newBuilder() + .setNamespace(Namespace.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.updateNamespaceCallable().futureCall(request); + // Do something. + Namespace response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_UpdateNamespace_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updatenamespace/SyncUpdateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updatenamespace/SyncUpdateNamespace.java new file mode 100644 index 00000000000..60733bf044b --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updatenamespace/SyncUpdateNamespace.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_UpdateNamespace_sync] +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.UpdateNamespaceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateNamespace { + + public static void main(String[] args) throws Exception { + syncUpdateNamespace(); + } + + public static void syncUpdateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateNamespaceRequest request = + UpdateNamespaceRequest.newBuilder() + .setNamespace(Namespace.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Namespace response = registrationServiceClient.updateNamespace(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_UpdateNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java new file mode 100644 index 00000000000..8bb1f6d008e --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_UpdateNamespace_NamespaceFieldmask_sync] +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateNamespaceNamespaceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateNamespaceNamespaceFieldmask(); + } + + public static void syncUpdateNamespaceNamespaceFieldmask() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + Namespace namespace = Namespace.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Namespace response = registrationServiceClient.updateNamespace(namespace, updateMask); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_UpdateNamespace_NamespaceFieldmask_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateservice/AsyncUpdateService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateservice/AsyncUpdateService.java new file mode 100644 index 00000000000..7e5d1cde708 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateservice/AsyncUpdateService.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_UpdateService_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; +import com.google.cloud.servicedirectory.v1.UpdateServiceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateService { + + public static void main(String[] args) throws Exception { + asyncUpdateService(); + } + + public static void asyncUpdateService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateServiceRequest request = + UpdateServiceRequest.newBuilder() + .setService(Service.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.updateServiceCallable().futureCall(request); + // Do something. + Service response = future.get(); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_UpdateService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateservice/SyncUpdateService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateservice/SyncUpdateService.java new file mode 100644 index 00000000000..c6788b71bb0 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateservice/SyncUpdateService.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_UpdateService_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; +import com.google.cloud.servicedirectory.v1.UpdateServiceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateService { + + public static void main(String[] args) throws Exception { + syncUpdateService(); + } + + public static void syncUpdateService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateServiceRequest request = + UpdateServiceRequest.newBuilder() + .setService(Service.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Service response = registrationServiceClient.updateService(request); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_UpdateService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateservice/SyncUpdateServiceServiceFieldmask.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateservice/SyncUpdateServiceServiceFieldmask.java new file mode 100644 index 00000000000..8ecd07035f7 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservice/updateservice/SyncUpdateServiceServiceFieldmask.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationService_UpdateService_ServiceFieldmask_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.Service; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServiceServiceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateServiceServiceFieldmask(); + } + + public static void syncUpdateServiceServiceFieldmask() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + Service service = Service.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Service response = registrationServiceClient.updateService(service, updateMask); + } + } +} +// [END servicedirectory_v1_generated_RegistrationService_UpdateService_ServiceFieldmask_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservicesettings/createnamespace/SyncCreateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservicesettings/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000000..90fbf24eee0 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservicesettings/createnamespace/SyncCreateNamespace.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.samples; + +// [START servicedirectory_v1_generated_RegistrationServiceSettings_CreateNamespace_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceSettings; +import java.time.Duration; + +public class SyncCreateNamespace { + + public static void main(String[] args) throws Exception { + syncCreateNamespace(); + } + + public static void syncCreateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceSettings.Builder registrationServiceSettingsBuilder = + RegistrationServiceSettings.newBuilder(); + registrationServiceSettingsBuilder + .createNamespaceSettings() + .setRetrySettings( + registrationServiceSettingsBuilder + .createNamespaceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + RegistrationServiceSettings registrationServiceSettings = + registrationServiceSettingsBuilder.build(); + } +} +// [END servicedirectory_v1_generated_RegistrationServiceSettings_CreateNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java new file mode 100644 index 00000000000..b9c63ce98ce --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.stub.samples; + +// [START servicedirectory_v1_generated_LookupServiceStubSettings_ResolveService_sync] +import com.google.cloud.servicedirectory.v1.stub.LookupServiceStubSettings; +import java.time.Duration; + +public class SyncResolveService { + + public static void main(String[] args) throws Exception { + syncResolveService(); + } + + public static void syncResolveService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceStubSettings.Builder lookupServiceSettingsBuilder = + LookupServiceStubSettings.newBuilder(); + lookupServiceSettingsBuilder + .resolveServiceSettings() + .setRetrySettings( + lookupServiceSettingsBuilder.resolveServiceSettings().getRetrySettings().toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + LookupServiceStubSettings lookupServiceSettings = lookupServiceSettingsBuilder.build(); + } +} +// [END servicedirectory_v1_generated_LookupServiceStubSettings_ResolveService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000000..ca0a8e46469 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1.stub.samples; + +// [START servicedirectory_v1_generated_RegistrationServiceStubSettings_CreateNamespace_sync] +import com.google.cloud.servicedirectory.v1.stub.RegistrationServiceStubSettings; +import java.time.Duration; + +public class SyncCreateNamespace { + + public static void main(String[] args) throws Exception { + syncCreateNamespace(); + } + + public static void syncCreateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceStubSettings.Builder registrationServiceSettingsBuilder = + RegistrationServiceStubSettings.newBuilder(); + registrationServiceSettingsBuilder + .createNamespaceSettings() + .setRetrySettings( + registrationServiceSettingsBuilder + .createNamespaceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + RegistrationServiceStubSettings registrationServiceSettings = + registrationServiceSettingsBuilder.build(); + } +} +// [END servicedirectory_v1_generated_RegistrationServiceStubSettings_CreateNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/create/SyncCreateSetCredentialsProvider.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000000..583a3f1ecba --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_LookupService_Create_SetCredentialsProvider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.servicedirectory.v1beta1.LookupServiceClient; +import com.google.cloud.servicedirectory.v1beta1.LookupServiceSettings; +import com.google.cloud.servicedirectory.v1beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_LookupService_Create_SetCredentialsProvider_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/create/SyncCreateSetCredentialsProvider1.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000000..9e24fa95892 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_LookupService_Create_SetCredentialsProvider1_sync] +import com.google.cloud.servicedirectory.v1beta1.LookupServiceClient; +import com.google.cloud.servicedirectory.v1beta1.LookupServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newHttpJsonBuilder().build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_LookupService_Create_SetCredentialsProvider1_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/create/SyncCreateSetEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000000..c71e7184deb --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/create/SyncCreateSetEndpoint.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_LookupService_Create_SetEndpoint_sync] +import com.google.cloud.servicedirectory.v1beta1.LookupServiceClient; +import com.google.cloud.servicedirectory.v1beta1.LookupServiceSettings; +import com.google.cloud.servicedirectory.v1beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_LookupService_Create_SetEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/resolveservice/AsyncResolveService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/resolveservice/AsyncResolveService.java new file mode 100644 index 00000000000..c08247f788b --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/resolveservice/AsyncResolveService.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_LookupService_ResolveService_async] +import com.google.api.core.ApiFuture; +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; + +public class AsyncResolveService { + + public static void main(String[] args) throws Exception { + asyncResolveService(); + } + + public static void asyncResolveService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) { + ResolveServiceRequest request = + ResolveServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setMaxEndpoints(2074789987) + .setEndpointFilter("endpointFilter-1834249875") + .build(); + ApiFuture future = + lookupServiceClient.resolveServiceCallable().futureCall(request); + // Do something. + ResolveServiceResponse response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_LookupService_ResolveService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/resolveservice/SyncResolveService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/resolveservice/SyncResolveService.java new file mode 100644 index 00000000000..2dc18e621dd --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservice/resolveservice/SyncResolveService.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_LookupService_ResolveService_sync] +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; + +public class SyncResolveService { + + public static void main(String[] args) throws Exception { + syncResolveService(); + } + + public static void syncResolveService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (LookupServiceClient lookupServiceClient = LookupServiceClient.create()) { + ResolveServiceRequest request = + ResolveServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setMaxEndpoints(2074789987) + .setEndpointFilter("endpointFilter-1834249875") + .build(); + ResolveServiceResponse response = lookupServiceClient.resolveService(request); + } + } +} +// [END servicedirectory_v1beta1_generated_LookupService_ResolveService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservicesettings/resolveservice/SyncResolveService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservicesettings/resolveservice/SyncResolveService.java new file mode 100644 index 00000000000..ed6872e6fc1 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservicesettings/resolveservice/SyncResolveService.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_LookupServiceSettings_ResolveService_sync] +import com.google.cloud.servicedirectory.v1beta1.LookupServiceSettings; +import java.time.Duration; + +public class SyncResolveService { + + public static void main(String[] args) throws Exception { + syncResolveService(); + } + + public static void syncResolveService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceSettings.Builder lookupServiceSettingsBuilder = LookupServiceSettings.newBuilder(); + lookupServiceSettingsBuilder + .resolveServiceSettings() + .setRetrySettings( + lookupServiceSettingsBuilder.resolveServiceSettings().getRetrySettings().toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + LookupServiceSettings lookupServiceSettings = lookupServiceSettingsBuilder.build(); + } +} +// [END servicedirectory_v1beta1_generated_LookupServiceSettings_ResolveService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/create/SyncCreateSetCredentialsProvider.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000000..8504cc52724 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_Create_SetCredentialsProvider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceSettings; +import com.google.cloud.servicedirectory.v1beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_Create_SetCredentialsProvider_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/create/SyncCreateSetCredentialsProvider1.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000000..fb2055f465e --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_Create_SetCredentialsProvider1_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newHttpJsonBuilder().build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_Create_SetCredentialsProvider1_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/create/SyncCreateSetEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000000..bd4299a1f4f --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/create/SyncCreateSetEndpoint.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_Create_SetEndpoint_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceSettings; +import com.google.cloud.servicedirectory.v1beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_Create_SetEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/AsyncCreateEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/AsyncCreateEndpoint.java new file mode 100644 index 00000000000..39823a046c5 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/AsyncCreateEndpoint.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class AsyncCreateEndpoint { + + public static void main(String[] args) throws Exception { + asyncCreateEndpoint(); + } + + public static void asyncCreateEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateEndpointRequest request = + CreateEndpointRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setEndpointId("endpointId-1837754992") + .setEndpoint(Endpoint.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.createEndpointCallable().futureCall(request); + // Do something. + Endpoint response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/SyncCreateEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/SyncCreateEndpoint.java new file mode 100644 index 00000000000..01e305a57d9 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/SyncCreateEndpoint.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_sync] +import com.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncCreateEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateEndpoint(); + } + + public static void syncCreateEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateEndpointRequest request = + CreateEndpointRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setEndpointId("endpointId-1837754992") + .setEndpoint(Endpoint.newBuilder().build()) + .build(); + Endpoint response = registrationServiceClient.createEndpoint(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/SyncCreateEndpointServicenameEndpointString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/SyncCreateEndpointServicenameEndpointString.java new file mode 100644 index 00000000000..04d6e9867a5 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/SyncCreateEndpointServicenameEndpointString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_ServicenameEndpointString_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncCreateEndpointServicenameEndpointString { + + public static void main(String[] args) throws Exception { + syncCreateEndpointServicenameEndpointString(); + } + + public static void syncCreateEndpointServicenameEndpointString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + Endpoint response = registrationServiceClient.createEndpoint(parent, endpoint, endpointId); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_ServicenameEndpointString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/SyncCreateEndpointStringEndpointString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/SyncCreateEndpointStringEndpointString.java new file mode 100644 index 00000000000..fb29da2f265 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createendpoint/SyncCreateEndpointStringEndpointString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_StringEndpointString_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncCreateEndpointStringEndpointString { + + public static void main(String[] args) throws Exception { + syncCreateEndpointStringEndpointString(); + } + + public static void syncCreateEndpointStringEndpointString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + Endpoint response = registrationServiceClient.createEndpoint(parent, endpoint, endpointId); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_StringEndpointString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/AsyncCreateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/AsyncCreateNamespace.java new file mode 100644 index 00000000000..aff3721382a --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/AsyncCreateNamespace.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.LocationName; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class AsyncCreateNamespace { + + public static void main(String[] args) throws Exception { + asyncCreateNamespace(); + } + + public static void asyncCreateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateNamespaceRequest request = + CreateNamespaceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setNamespaceId("namespaceId790852566") + .setNamespace(Namespace.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.createNamespaceCallable().futureCall(request); + // Do something. + Namespace response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/SyncCreateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000000..e54e7692b2d --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/SyncCreateNamespace.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_sync] +import com.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.LocationName; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncCreateNamespace { + + public static void main(String[] args) throws Exception { + syncCreateNamespace(); + } + + public static void syncCreateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateNamespaceRequest request = + CreateNamespaceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setNamespaceId("namespaceId790852566") + .setNamespace(Namespace.newBuilder().build()) + .build(); + Namespace response = registrationServiceClient.createNamespace(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java new file mode 100644 index 00000000000..80043beb6bb --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_LocationnameNamespaceString_sync] +import com.google.cloud.servicedirectory.v1beta1.LocationName; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncCreateNamespaceLocationnameNamespaceString { + + public static void main(String[] args) throws Exception { + syncCreateNamespaceLocationnameNamespaceString(); + } + + public static void syncCreateNamespaceLocationnameNamespaceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + Namespace response = + registrationServiceClient.createNamespace(parent, namespace, namespaceId); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_LocationnameNamespaceString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/SyncCreateNamespaceStringNamespaceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/SyncCreateNamespaceStringNamespaceString.java new file mode 100644 index 00000000000..0fcc14188c8 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createnamespace/SyncCreateNamespaceStringNamespaceString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_StringNamespaceString_sync] +import com.google.cloud.servicedirectory.v1beta1.LocationName; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncCreateNamespaceStringNamespaceString { + + public static void main(String[] args) throws Exception { + syncCreateNamespaceStringNamespaceString(); + } + + public static void syncCreateNamespaceStringNamespaceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + Namespace response = + registrationServiceClient.createNamespace(parent, namespace, namespaceId); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_StringNamespaceString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/AsyncCreateService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/AsyncCreateService.java new file mode 100644 index 00000000000..99e62441106 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/AsyncCreateService.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateService_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.CreateServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; + +public class AsyncCreateService { + + public static void main(String[] args) throws Exception { + asyncCreateService(); + } + + public static void asyncCreateService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateServiceRequest request = + CreateServiceRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setServiceId("serviceId-194185552") + .setService(Service.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.createServiceCallable().futureCall(request); + // Do something. + Service response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/SyncCreateService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/SyncCreateService.java new file mode 100644 index 00000000000..e203981c115 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/SyncCreateService.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateService_sync] +import com.google.cloud.servicedirectory.v1beta1.CreateServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; + +public class SyncCreateService { + + public static void main(String[] args) throws Exception { + syncCreateService(); + } + + public static void syncCreateService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + CreateServiceRequest request = + CreateServiceRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setServiceId("serviceId-194185552") + .setService(Service.newBuilder().build()) + .build(); + Service response = registrationServiceClient.createService(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/SyncCreateServiceNamespacenameServiceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/SyncCreateServiceNamespacenameServiceString.java new file mode 100644 index 00000000000..fddcdf6fe93 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/SyncCreateServiceNamespacenameServiceString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateService_NamespacenameServiceString_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; + +public class SyncCreateServiceNamespacenameServiceString { + + public static void main(String[] args) throws Exception { + syncCreateServiceNamespacenameServiceString(); + } + + public static void syncCreateServiceNamespacenameServiceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + Service response = registrationServiceClient.createService(parent, service, serviceId); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateService_NamespacenameServiceString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/SyncCreateServiceStringServiceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/SyncCreateServiceStringServiceString.java new file mode 100644 index 00000000000..cad9cc7657a --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/createservice/SyncCreateServiceStringServiceString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_CreateService_StringServiceString_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; + +public class SyncCreateServiceStringServiceString { + + public static void main(String[] args) throws Exception { + syncCreateServiceStringServiceString(); + } + + public static void syncCreateServiceStringServiceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + Service response = registrationServiceClient.createService(parent, service, serviceId); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_CreateService_StringServiceString_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/AsyncDeleteEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/AsyncDeleteEndpoint.java new file mode 100644 index 00000000000..fd6d6694f1a --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/AsyncDeleteEndpoint.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteEndpoint { + + public static void main(String[] args) throws Exception { + asyncDeleteEndpoint(); + } + + public static void asyncDeleteEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteEndpointRequest request = + DeleteEndpointRequest.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .build(); + ApiFuture future = + registrationServiceClient.deleteEndpointCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/SyncDeleteEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/SyncDeleteEndpoint.java new file mode 100644 index 00000000000..91dda1d20f2 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/SyncDeleteEndpoint.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_sync] +import com.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteEndpoint { + + public static void main(String[] args) throws Exception { + syncDeleteEndpoint(); + } + + public static void syncDeleteEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteEndpointRequest request = + DeleteEndpointRequest.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .build(); + registrationServiceClient.deleteEndpoint(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/SyncDeleteEndpointEndpointname.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/SyncDeleteEndpointEndpointname.java new file mode 100644 index 00000000000..a8496a5d808 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/SyncDeleteEndpointEndpointname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_Endpointname_sync] +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteEndpointEndpointname { + + public static void main(String[] args) throws Exception { + syncDeleteEndpointEndpointname(); + } + + public static void syncDeleteEndpointEndpointname() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + registrationServiceClient.deleteEndpoint(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_Endpointname_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/SyncDeleteEndpointString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/SyncDeleteEndpointString.java new file mode 100644 index 00000000000..6ebdf6d43bb --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteendpoint/SyncDeleteEndpointString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_String_sync] +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteEndpointString { + + public static void main(String[] args) throws Exception { + syncDeleteEndpointString(); + } + + public static void syncDeleteEndpointString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString(); + registrationServiceClient.deleteEndpoint(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/AsyncDeleteNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/AsyncDeleteNamespace.java new file mode 100644 index 00000000000..9345c6456dd --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/AsyncDeleteNamespace.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteNamespace { + + public static void main(String[] args) throws Exception { + asyncDeleteNamespace(); + } + + public static void asyncDeleteNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteNamespaceRequest request = + DeleteNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + ApiFuture future = + registrationServiceClient.deleteNamespaceCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/SyncDeleteNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/SyncDeleteNamespace.java new file mode 100644 index 00000000000..abf1efa503a --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/SyncDeleteNamespace.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_sync] +import com.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNamespace { + + public static void main(String[] args) throws Exception { + syncDeleteNamespace(); + } + + public static void syncDeleteNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteNamespaceRequest request = + DeleteNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + registrationServiceClient.deleteNamespace(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/SyncDeleteNamespaceNamespacename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/SyncDeleteNamespaceNamespacename.java new file mode 100644 index 00000000000..a836c960da6 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/SyncDeleteNamespaceNamespacename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_Namespacename_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNamespaceNamespacename { + + public static void main(String[] args) throws Exception { + syncDeleteNamespaceNamespacename(); + } + + public static void syncDeleteNamespaceNamespacename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + registrationServiceClient.deleteNamespace(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_Namespacename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/SyncDeleteNamespaceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/SyncDeleteNamespaceString.java new file mode 100644 index 00000000000..f5cf68fd161 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deletenamespace/SyncDeleteNamespaceString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_String_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteNamespaceString { + + public static void main(String[] args) throws Exception { + syncDeleteNamespaceString(); + } + + public static void syncDeleteNamespaceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + registrationServiceClient.deleteNamespace(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/AsyncDeleteService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/AsyncDeleteService.java new file mode 100644 index 00000000000..d4a9a20c0c8 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/AsyncDeleteService.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteService_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; +import com.google.protobuf.Empty; + +public class AsyncDeleteService { + + public static void main(String[] args) throws Exception { + asyncDeleteService(); + } + + public static void asyncDeleteService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteServiceRequest request = + DeleteServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .build(); + ApiFuture future = + registrationServiceClient.deleteServiceCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/SyncDeleteService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/SyncDeleteService.java new file mode 100644 index 00000000000..8745974ac68 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/SyncDeleteService.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteService_sync] +import com.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; +import com.google.protobuf.Empty; + +public class SyncDeleteService { + + public static void main(String[] args) throws Exception { + syncDeleteService(); + } + + public static void syncDeleteService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteServiceRequest request = + DeleteServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .build(); + registrationServiceClient.deleteService(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/SyncDeleteServiceServicename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/SyncDeleteServiceServicename.java new file mode 100644 index 00000000000..7e5e3af4be0 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/SyncDeleteServiceServicename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteService_Servicename_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; +import com.google.protobuf.Empty; + +public class SyncDeleteServiceServicename { + + public static void main(String[] args) throws Exception { + syncDeleteServiceServicename(); + } + + public static void syncDeleteServiceServicename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + registrationServiceClient.deleteService(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteService_Servicename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/SyncDeleteServiceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/SyncDeleteServiceString.java new file mode 100644 index 00000000000..accaf2bc871 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/deleteservice/SyncDeleteServiceString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_DeleteService_String_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; +import com.google.protobuf.Empty; + +public class SyncDeleteServiceString { + + public static void main(String[] args) throws Exception { + syncDeleteServiceString(); + } + + public static void syncDeleteServiceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + registrationServiceClient.deleteService(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_DeleteService_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/AsyncGetEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/AsyncGetEndpoint.java new file mode 100644 index 00000000000..38a79a29e29 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/AsyncGetEndpoint.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.GetEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class AsyncGetEndpoint { + + public static void main(String[] args) throws Exception { + asyncGetEndpoint(); + } + + public static void asyncGetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetEndpointRequest request = + GetEndpointRequest.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .build(); + ApiFuture future = + registrationServiceClient.getEndpointCallable().futureCall(request); + // Do something. + Endpoint response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/SyncGetEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/SyncGetEndpoint.java new file mode 100644 index 00000000000..0dda0ed9045 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/SyncGetEndpoint.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.GetEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncGetEndpoint { + + public static void main(String[] args) throws Exception { + syncGetEndpoint(); + } + + public static void syncGetEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetEndpointRequest request = + GetEndpointRequest.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .build(); + Endpoint response = registrationServiceClient.getEndpoint(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/SyncGetEndpointEndpointname.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/SyncGetEndpointEndpointname.java new file mode 100644 index 00000000000..b7b31449ed3 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/SyncGetEndpointEndpointname.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_Endpointname_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncGetEndpointEndpointname { + + public static void main(String[] args) throws Exception { + syncGetEndpointEndpointname(); + } + + public static void syncGetEndpointEndpointname() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + Endpoint response = registrationServiceClient.getEndpoint(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_Endpointname_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/SyncGetEndpointString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/SyncGetEndpointString.java new file mode 100644 index 00000000000..0dc495cf933 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getendpoint/SyncGetEndpointString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_String_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncGetEndpointString { + + public static void main(String[] args) throws Exception { + syncGetEndpointString(); + } + + public static void syncGetEndpointString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString(); + Endpoint response = registrationServiceClient.getEndpoint(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getiampolicy/AsyncGetIamPolicy.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 00000000000..991ca212ab9 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getiampolicy/AsyncGetIamPolicy.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetIamPolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class AsyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncGetIamPolicy(); + } + + public static void asyncGetIamPolicy() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.getIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetIamPolicy_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getiampolicy/SyncGetIamPolicy.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 00000000000..c03f7633394 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getiampolicy/SyncGetIamPolicy.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetIamPolicy_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; + +public class SyncGetIamPolicy { + + public static void main(String[] args) throws Exception { + syncGetIamPolicy(); + } + + public static void syncGetIamPolicy() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + Policy response = registrationServiceClient.getIamPolicy(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetIamPolicy_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/AsyncGetNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/AsyncGetNamespace.java new file mode 100644 index 00000000000..e925ac54f85 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/AsyncGetNamespace.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class AsyncGetNamespace { + + public static void main(String[] args) throws Exception { + asyncGetNamespace(); + } + + public static void asyncGetNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetNamespaceRequest request = + GetNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + ApiFuture future = + registrationServiceClient.getNamespaceCallable().futureCall(request); + // Do something. + Namespace response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/SyncGetNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/SyncGetNamespace.java new file mode 100644 index 00000000000..6e479daa78f --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/SyncGetNamespace.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_sync] +import com.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncGetNamespace { + + public static void main(String[] args) throws Exception { + syncGetNamespace(); + } + + public static void syncGetNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetNamespaceRequest request = + GetNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + Namespace response = registrationServiceClient.getNamespace(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/SyncGetNamespaceNamespacename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/SyncGetNamespaceNamespacename.java new file mode 100644 index 00000000000..ec70a7b1d2b --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/SyncGetNamespaceNamespacename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_Namespacename_sync] +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncGetNamespaceNamespacename { + + public static void main(String[] args) throws Exception { + syncGetNamespaceNamespacename(); + } + + public static void syncGetNamespaceNamespacename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Namespace response = registrationServiceClient.getNamespace(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_Namespacename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/SyncGetNamespaceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/SyncGetNamespaceString.java new file mode 100644 index 00000000000..f77592b5307 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getnamespace/SyncGetNamespaceString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_String_sync] +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncGetNamespaceString { + + public static void main(String[] args) throws Exception { + syncGetNamespaceString(); + } + + public static void syncGetNamespaceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + Namespace response = registrationServiceClient.getNamespace(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/AsyncGetService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/AsyncGetService.java new file mode 100644 index 00000000000..325c70a7d93 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/AsyncGetService.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetService_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.GetServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class AsyncGetService { + + public static void main(String[] args) throws Exception { + asyncGetService(); + } + + public static void asyncGetService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetServiceRequest request = + GetServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .build(); + ApiFuture future = + registrationServiceClient.getServiceCallable().futureCall(request); + // Do something. + Service response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/SyncGetService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/SyncGetService.java new file mode 100644 index 00000000000..f59c28aad66 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/SyncGetService.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetService_sync] +import com.google.cloud.servicedirectory.v1beta1.GetServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncGetService { + + public static void main(String[] args) throws Exception { + syncGetService(); + } + + public static void syncGetService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + GetServiceRequest request = + GetServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .build(); + Service response = registrationServiceClient.getService(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/SyncGetServiceServicename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/SyncGetServiceServicename.java new file mode 100644 index 00000000000..789cf59e602 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/SyncGetServiceServicename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetService_Servicename_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncGetServiceServicename { + + public static void main(String[] args) throws Exception { + syncGetServiceServicename(); + } + + public static void syncGetServiceServicename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Service response = registrationServiceClient.getService(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetService_Servicename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/SyncGetServiceString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/SyncGetServiceString.java new file mode 100644 index 00000000000..69b0b6ea936 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/getservice/SyncGetServiceString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_GetService_String_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncGetServiceString { + + public static void main(String[] args) throws Exception { + syncGetServiceString(); + } + + public static void syncGetServiceString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + Service response = registrationServiceClient.getService(name); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_GetService_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/AsyncListEndpoints.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/AsyncListEndpoints.java new file mode 100644 index 00000000000..ca53822046e --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/AsyncListEndpoints.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class AsyncListEndpoints { + + public static void main(String[] args) throws Exception { + asyncListEndpoints(); + } + + public static void asyncListEndpoints() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListEndpointsRequest request = + ListEndpointsRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + registrationServiceClient.listEndpointsPagedCallable().futureCall(request); + // Do something. + for (Endpoint element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/AsyncListEndpointsPaged.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/AsyncListEndpointsPaged.java new file mode 100644 index 00000000000..a89790cad7d --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/AsyncListEndpointsPaged.java @@ -0,0 +1,65 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_Paged_async] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest; +import com.google.cloud.servicedirectory.v1beta1.ListEndpointsResponse; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; +import com.google.common.base.Strings; + +public class AsyncListEndpointsPaged { + + public static void main(String[] args) throws Exception { + asyncListEndpointsPaged(); + } + + public static void asyncListEndpointsPaged() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListEndpointsRequest request = + ListEndpointsRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListEndpointsResponse response = + registrationServiceClient.listEndpointsCallable().call(request); + for (Endpoint element : response.getEndpointsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_Paged_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/SyncListEndpoints.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/SyncListEndpoints.java new file mode 100644 index 00000000000..8ec198b7bc5 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/SyncListEndpoints.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncListEndpoints { + + public static void main(String[] args) throws Exception { + syncListEndpoints(); + } + + public static void syncListEndpoints() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListEndpointsRequest request = + ListEndpointsRequest.newBuilder() + .setParent( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Endpoint element : registrationServiceClient.listEndpoints(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/SyncListEndpointsServicename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/SyncListEndpointsServicename.java new file mode 100644 index 00000000000..e221cac7873 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/SyncListEndpointsServicename.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_Servicename_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncListEndpointsServicename { + + public static void main(String[] args) throws Exception { + syncListEndpointsServicename(); + } + + public static void syncListEndpointsServicename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + for (Endpoint element : registrationServiceClient.listEndpoints(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_Servicename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/SyncListEndpointsString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/SyncListEndpointsString.java new file mode 100644 index 00000000000..a137d6ce283 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listendpoints/SyncListEndpointsString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_String_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncListEndpointsString { + + public static void main(String[] args) throws Exception { + syncListEndpointsString(); + } + + public static void syncListEndpointsString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + for (Endpoint element : registrationServiceClient.listEndpoints(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/AsyncListNamespaces.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/AsyncListNamespaces.java new file mode 100644 index 00000000000..88dd78cdabc --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/AsyncListNamespaces.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest; +import com.google.cloud.servicedirectory.v1beta1.LocationName; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class AsyncListNamespaces { + + public static void main(String[] args) throws Exception { + asyncListNamespaces(); + } + + public static void asyncListNamespaces() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListNamespacesRequest request = + ListNamespacesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + registrationServiceClient.listNamespacesPagedCallable().futureCall(request); + // Do something. + for (Namespace element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/AsyncListNamespacesPaged.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/AsyncListNamespacesPaged.java new file mode 100644 index 00000000000..464f7152e06 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/AsyncListNamespacesPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_Paged_async] +import com.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest; +import com.google.cloud.servicedirectory.v1beta1.ListNamespacesResponse; +import com.google.cloud.servicedirectory.v1beta1.LocationName; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.common.base.Strings; + +public class AsyncListNamespacesPaged { + + public static void main(String[] args) throws Exception { + asyncListNamespacesPaged(); + } + + public static void asyncListNamespacesPaged() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListNamespacesRequest request = + ListNamespacesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListNamespacesResponse response = + registrationServiceClient.listNamespacesCallable().call(request); + for (Namespace element : response.getNamespacesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_Paged_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/SyncListNamespaces.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/SyncListNamespaces.java new file mode 100644 index 00000000000..65ad8150019 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/SyncListNamespaces.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_sync] +import com.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest; +import com.google.cloud.servicedirectory.v1beta1.LocationName; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncListNamespaces { + + public static void main(String[] args) throws Exception { + syncListNamespaces(); + } + + public static void syncListNamespaces() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListNamespacesRequest request = + ListNamespacesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Namespace element : registrationServiceClient.listNamespaces(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/SyncListNamespacesLocationname.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/SyncListNamespacesLocationname.java new file mode 100644 index 00000000000..79a71a3d889 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/SyncListNamespacesLocationname.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_Locationname_sync] +import com.google.cloud.servicedirectory.v1beta1.LocationName; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncListNamespacesLocationname { + + public static void main(String[] args) throws Exception { + syncListNamespacesLocationname(); + } + + public static void syncListNamespacesLocationname() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Namespace element : registrationServiceClient.listNamespaces(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_Locationname_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/SyncListNamespacesString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/SyncListNamespacesString.java new file mode 100644 index 00000000000..ce95aefb791 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listnamespaces/SyncListNamespacesString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_String_sync] +import com.google.cloud.servicedirectory.v1beta1.LocationName; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncListNamespacesString { + + public static void main(String[] args) throws Exception { + syncListNamespacesString(); + } + + public static void syncListNamespacesString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Namespace element : registrationServiceClient.listNamespaces(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/AsyncListServices.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/AsyncListServices.java new file mode 100644 index 00000000000..ad74c21a18f --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/AsyncListServices.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListServices_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.ListServicesRequest; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; + +public class AsyncListServices { + + public static void main(String[] args) throws Exception { + asyncListServices(); + } + + public static void asyncListServices() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + registrationServiceClient.listServicesPagedCallable().futureCall(request); + // Do something. + for (Service element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListServices_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/AsyncListServicesPaged.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/AsyncListServicesPaged.java new file mode 100644 index 00000000000..0f38dd220b2 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/AsyncListServicesPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListServices_Paged_async] +import com.google.cloud.servicedirectory.v1beta1.ListServicesRequest; +import com.google.cloud.servicedirectory.v1beta1.ListServicesResponse; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.common.base.Strings; + +public class AsyncListServicesPaged { + + public static void main(String[] args) throws Exception { + asyncListServicesPaged(); + } + + public static void asyncListServicesPaged() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListServicesResponse response = + registrationServiceClient.listServicesCallable().call(request); + for (Service element : response.getServicesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListServices_Paged_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/SyncListServices.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/SyncListServices.java new file mode 100644 index 00000000000..980299a5b88 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/SyncListServices.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListServices_sync] +import com.google.cloud.servicedirectory.v1beta1.ListServicesRequest; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; + +public class SyncListServices { + + public static void main(String[] args) throws Exception { + syncListServices(); + } + + public static void syncListServices() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Service element : registrationServiceClient.listServices(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListServices_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/SyncListServicesNamespacename.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/SyncListServicesNamespacename.java new file mode 100644 index 00000000000..579963265b6 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/SyncListServicesNamespacename.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListServices_Namespacename_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; + +public class SyncListServicesNamespacename { + + public static void main(String[] args) throws Exception { + syncListServicesNamespacename(); + } + + public static void syncListServicesNamespacename() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + for (Service element : registrationServiceClient.listServices(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListServices_Namespacename_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/SyncListServicesString.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/SyncListServicesString.java new file mode 100644 index 00000000000..dcd52795898 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/listservices/SyncListServicesString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_ListServices_String_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; + +public class SyncListServicesString { + + public static void main(String[] args) throws Exception { + syncListServicesString(); + } + + public static void syncListServicesString() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + for (Service element : registrationServiceClient.listServices(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_ListServices_String_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/setiampolicy/AsyncSetIamPolicy.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 00000000000..bbf72e5653d --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/setiampolicy/AsyncSetIamPolicy.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_SetIamPolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class AsyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + asyncSetIamPolicy(); + } + + public static void asyncSetIamPolicy() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.setIamPolicyCallable().futureCall(request); + // Do something. + Policy response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_SetIamPolicy_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/setiampolicy/SyncSetIamPolicy.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 00000000000..bd8ea868fd3 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/setiampolicy/SyncSetIamPolicy.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_SetIamPolicy_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.protobuf.FieldMask; + +public class SyncSetIamPolicy { + + public static void main(String[] args) throws Exception { + syncSetIamPolicy(); + } + + public static void syncSetIamPolicy() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Policy response = registrationServiceClient.setIamPolicy(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_SetIamPolicy_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/testiampermissions/AsyncTestIamPermissions.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 00000000000..e4e9889f130 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/testiampermissions/AsyncTestIamPermissions.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_TestIamPermissions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class AsyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + asyncTestIamPermissions(); + } + + public static void asyncTestIamPermissions() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + ApiFuture future = + registrationServiceClient.testIamPermissionsCallable().futureCall(request); + // Do something. + TestIamPermissionsResponse response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_TestIamPermissions_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/testiampermissions/SyncTestIamPermissions.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 00000000000..cd4c1144709 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/testiampermissions/SyncTestIamPermissions.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_TestIamPermissions_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import java.util.ArrayList; + +public class SyncTestIamPermissions { + + public static void main(String[] args) throws Exception { + syncTestIamPermissions(); + } + + public static void syncTestIamPermissions() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + TestIamPermissionsResponse response = registrationServiceClient.testIamPermissions(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_TestIamPermissions_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateendpoint/AsyncUpdateEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateendpoint/AsyncUpdateEndpoint.java new file mode 100644 index 00000000000..b169daec553 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateendpoint/AsyncUpdateEndpoint.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_UpdateEndpoint_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEndpoint { + + public static void main(String[] args) throws Exception { + asyncUpdateEndpoint(); + } + + public static void asyncUpdateEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateEndpointRequest request = + UpdateEndpointRequest.newBuilder() + .setEndpoint(Endpoint.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.updateEndpointCallable().futureCall(request); + // Do something. + Endpoint response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_UpdateEndpoint_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateendpoint/SyncUpdateEndpoint.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateendpoint/SyncUpdateEndpoint.java new file mode 100644 index 00000000000..37e2d528fdd --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateendpoint/SyncUpdateEndpoint.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_UpdateEndpoint_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEndpoint { + + public static void main(String[] args) throws Exception { + syncUpdateEndpoint(); + } + + public static void syncUpdateEndpoint() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateEndpointRequest request = + UpdateEndpointRequest.newBuilder() + .setEndpoint(Endpoint.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Endpoint response = registrationServiceClient.updateEndpoint(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_UpdateEndpoint_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java new file mode 100644 index 00000000000..e15794ceaa6 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_UpdateEndpoint_EndpointFieldmask_sync] +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEndpointEndpointFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateEndpointEndpointFieldmask(); + } + + public static void syncUpdateEndpointEndpointFieldmask() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + Endpoint endpoint = Endpoint.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Endpoint response = registrationServiceClient.updateEndpoint(endpoint, updateMask); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_UpdateEndpoint_EndpointFieldmask_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updatenamespace/AsyncUpdateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updatenamespace/AsyncUpdateNamespace.java new file mode 100644 index 00000000000..f0688f49a6a --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updatenamespace/AsyncUpdateNamespace.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_UpdateNamespace_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateNamespace { + + public static void main(String[] args) throws Exception { + asyncUpdateNamespace(); + } + + public static void asyncUpdateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateNamespaceRequest request = + UpdateNamespaceRequest.newBuilder() + .setNamespace(Namespace.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.updateNamespaceCallable().futureCall(request); + // Do something. + Namespace response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_UpdateNamespace_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updatenamespace/SyncUpdateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updatenamespace/SyncUpdateNamespace.java new file mode 100644 index 00000000000..83114fe1da2 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updatenamespace/SyncUpdateNamespace.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_UpdateNamespace_sync] +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateNamespace { + + public static void main(String[] args) throws Exception { + syncUpdateNamespace(); + } + + public static void syncUpdateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateNamespaceRequest request = + UpdateNamespaceRequest.newBuilder() + .setNamespace(Namespace.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Namespace response = registrationServiceClient.updateNamespace(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_UpdateNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java new file mode 100644 index 00000000000..cc5dc0bc467 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_UpdateNamespace_NamespaceFieldmask_sync] +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateNamespaceNamespaceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateNamespaceNamespaceFieldmask(); + } + + public static void syncUpdateNamespaceNamespaceFieldmask() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + Namespace namespace = Namespace.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Namespace response = registrationServiceClient.updateNamespace(namespace, updateMask); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_UpdateNamespace_NamespaceFieldmask_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateservice/AsyncUpdateService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateservice/AsyncUpdateService.java new file mode 100644 index 00000000000..6da4266cc7c --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateservice/AsyncUpdateService.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_UpdateService_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateService { + + public static void main(String[] args) throws Exception { + asyncUpdateService(); + } + + public static void asyncUpdateService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateServiceRequest request = + UpdateServiceRequest.newBuilder() + .setService(Service.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + registrationServiceClient.updateServiceCallable().futureCall(request); + // Do something. + Service response = future.get(); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_UpdateService_async] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateservice/SyncUpdateService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateservice/SyncUpdateService.java new file mode 100644 index 00000000000..8a54928d00a --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateservice/SyncUpdateService.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_UpdateService_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateService { + + public static void main(String[] args) throws Exception { + syncUpdateService(); + } + + public static void syncUpdateService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + UpdateServiceRequest request = + UpdateServiceRequest.newBuilder() + .setService(Service.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Service response = registrationServiceClient.updateService(request); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_UpdateService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateservice/SyncUpdateServiceServiceFieldmask.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateservice/SyncUpdateServiceServiceFieldmask.java new file mode 100644 index 00000000000..4c293689667 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservice/updateservice/SyncUpdateServiceServiceFieldmask.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationService_UpdateService_ServiceFieldmask_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.protobuf.FieldMask; + +public class SyncUpdateServiceServiceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateServiceServiceFieldmask(); + } + + public static void syncUpdateServiceServiceFieldmask() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + Service service = Service.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Service response = registrationServiceClient.updateService(service, updateMask); + } + } +} +// [END servicedirectory_v1beta1_generated_RegistrationService_UpdateService_ServiceFieldmask_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservicesettings/createnamespace/SyncCreateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservicesettings/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000000..e4d6be3a887 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservicesettings/createnamespace/SyncCreateNamespace.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationServiceSettings_CreateNamespace_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceSettings; +import java.time.Duration; + +public class SyncCreateNamespace { + + public static void main(String[] args) throws Exception { + syncCreateNamespace(); + } + + public static void syncCreateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceSettings.Builder registrationServiceSettingsBuilder = + RegistrationServiceSettings.newBuilder(); + registrationServiceSettingsBuilder + .createNamespaceSettings() + .setRetrySettings( + registrationServiceSettingsBuilder + .createNamespaceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + RegistrationServiceSettings registrationServiceSettings = + registrationServiceSettingsBuilder.build(); + } +} +// [END servicedirectory_v1beta1_generated_RegistrationServiceSettings_CreateNamespace_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java new file mode 100644 index 00000000000..1f50da6be4e --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.stub.samples; + +// [START servicedirectory_v1beta1_generated_LookupServiceStubSettings_ResolveService_sync] +import com.google.cloud.servicedirectory.v1beta1.stub.LookupServiceStubSettings; +import java.time.Duration; + +public class SyncResolveService { + + public static void main(String[] args) throws Exception { + syncResolveService(); + } + + public static void syncResolveService() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + LookupServiceStubSettings.Builder lookupServiceSettingsBuilder = + LookupServiceStubSettings.newBuilder(); + lookupServiceSettingsBuilder + .resolveServiceSettings() + .setRetrySettings( + lookupServiceSettingsBuilder.resolveServiceSettings().getRetrySettings().toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + LookupServiceStubSettings lookupServiceSettings = lookupServiceSettingsBuilder.build(); + } +} +// [END servicedirectory_v1beta1_generated_LookupServiceStubSettings_ResolveService_sync] diff --git a/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000000..998eed8f153 --- /dev/null +++ b/servicedirectory/snippets/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.servicedirectory.v1beta1.stub.samples; + +// [START servicedirectory_v1beta1_generated_RegistrationServiceStubSettings_CreateNamespace_sync] +import com.google.cloud.servicedirectory.v1beta1.stub.RegistrationServiceStubSettings; +import java.time.Duration; + +public class SyncCreateNamespace { + + public static void main(String[] args) throws Exception { + syncCreateNamespace(); + } + + public static void syncCreateNamespace() throws Exception { + // This snippet has been automatically generated and should be regarded as a code template only. + // It will require modifications to work: + // - It may require correct/in-range values for request initialization. + // - It may require specifying regional endpoints when creating the service client as shown in + // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + RegistrationServiceStubSettings.Builder registrationServiceSettingsBuilder = + RegistrationServiceStubSettings.newBuilder(); + registrationServiceSettingsBuilder + .createNamespaceSettings() + .setRetrySettings( + registrationServiceSettingsBuilder + .createNamespaceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + RegistrationServiceStubSettings registrationServiceSettings = + registrationServiceSettingsBuilder.build(); + } +} +// [END servicedirectory_v1beta1_generated_RegistrationServiceStubSettings_CreateNamespace_sync] diff --git a/servicedirectory/snippets/snippets/pom.xml b/servicedirectory/snippets/snippets/pom.xml new file mode 100644 index 00000000000..ceb602035e2 --- /dev/null +++ b/servicedirectory/snippets/snippets/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + com.google.cloud + servicedirectory-snippets + jar + Google Service Directory Snippets + https://github.com/googleapis/java-servicedirectory + + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + + + 1.8 + 1.8 + UTF-8 + + + + + + + + com.google.cloud + libraries-bom + 26.1.4 + pom + import + + + + + + + com.google.cloud + google-cloud-servicedirectory + + + + + junit + junit + 4.13.2 + test + + + com.google.truth + truth + 1.1.3 + test + + + + 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 new file mode 100644 index 00000000000..ba164213554 --- /dev/null +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsCreate.java @@ -0,0 +1,66 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +// [START servicedirectory_create_endpoint] + +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 { + + public static void createEndpoint() throws IOException { + // TODO(developer): Replace these variables before running the sample. + // These variables should refer to an existing Service Directory service. + String projectId = "your-project-id"; + String locationId = "your-region"; + String namespaceId = "your-namespace"; + String serviceId = "your-service"; + // This is user-created; must be unique within the service above. + String endpointId = "your-endpoint"; + createEndpoint(projectId, locationId, namespaceId, serviceId, endpointId); + } + + // Create a new endpoint. + public static void createEndpoint( + String projectId, String locationId, String namespaceId, String serviceId, String endpointId) + throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + + // The service to create the endpoint in. + ServiceName parent = ServiceName.of(projectId, locationId, namespaceId, serviceId); + + // The endpoint to create, with fields filled in. + // Optionally set an IP address and port for the endpoint. + Endpoint endpoint = Endpoint.newBuilder().setAddress("10.0.0.1").setPort(443).build(); + + // Send the request to create the endpoint. + Endpoint createdEndpoint = client.createEndpoint(parent, endpoint, endpointId); + + // Process the response. + System.out.println("Created Endpoint: " + createdEndpoint.getName()); + System.out.println("IP Address: " + createdEndpoint.getAddress()); + System.out.println("Port: " + createdEndpoint.getPort()); + } + } +} +// [END servicedirectory_create_endpoint] 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 new file mode 100644 index 00000000000..378654e0f3f --- /dev/null +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/EndpointsDelete.java @@ -0,0 +1,59 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +// [START servicedirectory_delete_endpoint] + +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import java.io.IOException; + +public class EndpointsDelete { + + public static void deleteEndpoint() throws IOException { + // TODO(developer): Replace these variables before running the sample. + // These variables should refer to an existing Service Directory endpoint. + String projectId = "your-project-id"; + String locationId = "your-region"; + String namespaceId = "your-namespace"; + String serviceId = "your-service"; + String endpointId = "your-endpoint"; + deleteEndpoint(projectId, locationId, namespaceId, serviceId, endpointId); + } + + // Delete an endpoint. + public static void deleteEndpoint( + String projectId, String locationId, String namespaceId, String serviceId, String endpointId) + throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + + // The endpoint to delete. + EndpointName endpointName = + EndpointName.of(projectId, locationId, namespaceId, serviceId, endpointId); + + // Send the request to delete the endpoint. + client.deleteEndpoint(endpointName); + + // Log the action. + System.out.println("Deleted Endpoint: " + endpointName.toString()); + } + } +} +// [END servicedirectory_delete_endpoint] 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 new file mode 100644 index 00000000000..492fd9d9c56 --- /dev/null +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesCreate.java @@ -0,0 +1,59 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +// [START servicedirectory_create_namespace] + +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 { + + public static void createNamespace() throws IOException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "your-project-id"; + String locationId = "your-region"; + // This is user-created; must be unique within the project/region above. + String namespaceId = "your-namespace"; + createNamespace(projectId, locationId, namespaceId); + } + + // Create a new namespace. + public static void createNamespace(String projectId, String locationId, String namespaceId) + throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + + // The project and location to create the namespace in. + LocationName parent = LocationName.of(projectId, locationId); + + // The namespace object to create. Here, we use the default instance. + Namespace namespace = Namespace.newBuilder().build(); + + // Send the request to create the namespace. + Namespace createdNamespace = client.createNamespace(parent, namespace, namespaceId); + + // Process the response. + System.out.println("Created Namespace: " + createdNamespace.getName()); + } + } +} +// [END servicedirectory_create_namespace] 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 new file mode 100644 index 00000000000..c3414d8013a --- /dev/null +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/NamespacesDelete.java @@ -0,0 +1,55 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +// [START servicedirectory_delete_namespace] + +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import java.io.IOException; + +public class NamespacesDelete { + + public static void deleteNamespace() throws IOException { + // TODO(developer): Replace these variables before running the sample. + // These variables should refer to an existing Service Directory namespace. + String projectId = "your-project-id"; + String locationId = "your-region"; + String namespaceId = "your-namespace"; + deleteNamespace(projectId, locationId, namespaceId); + } + + // Delete a namespace. + public static void deleteNamespace(String projectId, String locationId, String namespaceId) + throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + + // The namespace to delete. + NamespaceName namespaceName = NamespaceName.of(projectId, locationId, namespaceId); + + // Send the request to delete the namespace. + client.deleteNamespace(namespaceName); + + // Log the action. + System.out.println("Deleted Namespace: " + namespaceName.toString()); + } + } +} +// [END servicedirectory_delete_namespace] 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 new file mode 100644 index 00000000000..d9d7ae393a4 --- /dev/null +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/Quickstart.java @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +// [START servicedirectory_quickstart] + +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 { + + public static void quickstart() throws IOException { + // TODO(developer): Replace these variables before running the sample. + String projectId = "your-project-id"; + String locationId = "your-region"; + quickstart(projectId, locationId); + } + + public static void quickstart(String projectId, String locationId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + + // The project and location that hold the namespace to list. + LocationName parent = LocationName.of(projectId, locationId); + + // Call the API. + ListNamespacesPagedResponse response = client.listNamespaces(parent); + + // Iterate over each namespace and print its name. + System.out.println("Namespaces:"); + for (Namespace namespace : response.iterateAll()) { + System.out.println(namespace.getName()); + } + } + } +} +// [END servicedirectory_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 new file mode 100644 index 00000000000..90a812d7d2d --- /dev/null +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesCreate.java @@ -0,0 +1,64 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +// [START servicedirectory_create_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 { + + public static void createService() throws IOException { + // TODO(developer): Replace these variables before running the sample. + // These variables should refer to an existing Service Directory namespace. + String projectId = "your-project-id"; + String locationId = "your-region"; + String namespaceId = "your-namespace"; + // This is user-created; must be unique within the namespace above. + String serviceId = "your-service"; + createService(projectId, locationId, namespaceId, serviceId); + } + + // Create a new service. + public static void createService( + String projectId, String locationId, String namespaceId, String serviceId) + throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + + // The namespace to create the service in. + NamespaceName parent = NamespaceName.of(projectId, locationId, namespaceId); + + // The service object to create. + // 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("Annotations: " + createdService.getAnnotations()); + } + } +} +// [END servicedirectory_create_service] 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 new file mode 100644 index 00000000000..3871e902a15 --- /dev/null +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesDelete.java @@ -0,0 +1,57 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +// [START servicedirectory_delete_service] + +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; +import java.io.IOException; + +public class ServicesDelete { + + public static void deleteService() throws IOException { + // TODO(developer): Replace these variables before running the sample. + // These variables should refer to an existing Service Directory service. + String projectId = "your-project-id"; + String locationId = "your-region"; + String namespaceId = "your-namespace"; + String serviceId = "your-service"; + deleteService(projectId, locationId, namespaceId, serviceId); + } + + // Delete a service. + public static void deleteService( + String projectId, String locationId, String namespaceId, String serviceId) + throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + + // The service to delete. + ServiceName serviceName = ServiceName.of(projectId, locationId, namespaceId, serviceId); + + // Send the request to delete the service. + client.deleteService(serviceName); + + // Log the action. + System.out.println("Deleted Service: " + serviceName.toString()); + } + } +} +// [END servicedirectory_delete_service] 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 new file mode 100644 index 00000000000..a170227d380 --- /dev/null +++ b/servicedirectory/snippets/snippets/src/main/java/com/example/servicedirectory/ServicesResolve.java @@ -0,0 +1,69 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +// [START servicedirectory_resolve_service] + +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 { + + public static void resolveService() throws IOException { + // TODO(developer): Replace these variables before running the sample. + // These variables should refer to an existing Service Directory service. + String projectId = "your-project-id"; + String locationId = "your-region"; + String namespaceId = "your-namespace"; + String serviceId = "your-service"; + resolveService(projectId, locationId, namespaceId, serviceId); + } + + // Resolve a service. + public static void resolveService( + String projectId, String locationId, String namespaceId, String serviceId) + throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (LookupServiceClient client = LookupServiceClient.create()) { + // The service to resolve. + ServiceName name = ServiceName.of(projectId, locationId, namespaceId, serviceId); + + // Construct the resolve request to be sent to the client. + ResolveServiceRequest request = + ResolveServiceRequest.newBuilder().setName(name.toString()).build(); + + // Send the request to resolve the service. + ResolveServiceResponse resolveResponse = client.resolveService(request); + + // Process the response. + System.out.println("Resolved Service: " + resolveResponse.getService().getName()); + + System.out.println("Endpoints found:"); + for (Endpoint endpoint : resolveResponse.getService().getEndpointsList()) { + System.out.println( + endpoint.getName() + " -- " + endpoint.getAddress() + ":" + endpoint.getPort()); + } + } + } +} +// [END servicedirectory_resolve_service] 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 new file mode 100644 index 00000000000..01f960a2316 --- /dev/null +++ b/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/EndpointsTests.java @@ -0,0 +1,114 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + +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; +import org.hamcrest.CoreMatchers; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class EndpointsTests { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String LOCATION_ID = "us-central1"; + private static final String NAMESPACE_ID = "namespace-" + UUID.randomUUID().toString(); + private static final String SERVICE_ID = "service-" + UUID.randomUUID().toString(); + private static final String ENDPOINT_ID = "endpoint-" + UUID.randomUUID().toString(); + + private ByteArrayOutputStream bout; + + private static void requireEnvVar(String varName) { + assertNotNull( + String.format("Environment variable '%s' must be set to perform these tests.", varName), + System.getenv(varName)); + } + + @BeforeClass + public static void checkRequirements() { + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + } + + @Before + public void setUp() throws Exception { + bout = new ByteArrayOutputStream(); + System.setOut(new PrintStream(bout)); + + // Setup: create a namespace for the endpoints to live in. + NamespacesCreate.createNamespace(PROJECT_ID, LOCATION_ID, NAMESPACE_ID); + + // Setup: create a service for the endpoints to live in. + ServicesCreate.createService(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID); + } + + @After + public void tearDown() throws Exception { + System.setOut(null); + bout.reset(); + + // Deletes all resources created during these tests. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + // List the namespaces. + String locationPath = LocationName.format(PROJECT_ID, LOCATION_ID); + ListNamespacesPagedResponse response = client.listNamespaces(locationPath); + + // Delete each namespace. + for (Namespace namespace : response.iterateAll()) { + client.deleteNamespace(namespace.getName()); + } + } + } + + @Test + public void testCreateEndpoint() throws Exception { + EndpointsCreate.createEndpoint(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID, ENDPOINT_ID); + String endpointName = + EndpointName.format(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID, ENDPOINT_ID); + String output = bout.toString(); + assertThat( + output, CoreMatchers.containsString(String.format("Created Endpoint: %s", endpointName))); + } + + @Test + public void testDeleteService() throws Exception { + // Setup: create an endpoint. + EndpointsCreate.createEndpoint(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID, ENDPOINT_ID); + String endpointName = + EndpointName.format(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID, ENDPOINT_ID); + + // Delete the endpoint with the specified ID. + EndpointsDelete.deleteEndpoint(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID, ENDPOINT_ID); + String output = bout.toString(); + assertThat( + output, CoreMatchers.containsString(String.format("Deleted Endpoint: %s", endpointName))); + } +} 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 new file mode 100644 index 00000000000..36f54b06d26 --- /dev/null +++ b/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/NamespacesTests.java @@ -0,0 +1,104 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + +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; +import org.hamcrest.CoreMatchers; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class NamespacesTests { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String LOCATION_ID = "us-central1"; + private static final String NAMESPACE_ID = "namespace-" + UUID.randomUUID().toString(); + + private ByteArrayOutputStream bout; + + private static void requireEnvVar(String varName) { + assertNotNull( + String.format("Environment variable '%s' must be set to perform these tests.", varName), + System.getenv(varName)); + } + + @BeforeClass + public static void checkRequirements() { + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + } + + @Before + public void setUp() { + bout = new ByteArrayOutputStream(); + System.setOut(new PrintStream(bout)); + } + + @After + public void tearDown() throws Exception { + System.setOut(null); + bout.reset(); + + // Deletes any namespaces created during these tests. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + // List the namespaces. + String locationPath = LocationName.format(PROJECT_ID, LOCATION_ID); + ListNamespacesPagedResponse response = client.listNamespaces(locationPath); + + // Delete each namespace. + for (Namespace ns : response.iterateAll()) { + client.deleteNamespace(ns.getName()); + } + } + } + + @Test + public void testCreateNamespace() throws Exception { + NamespacesCreate.createNamespace(PROJECT_ID, LOCATION_ID, NAMESPACE_ID); + String namespaceName = NamespaceName.format(PROJECT_ID, LOCATION_ID, NAMESPACE_ID); + String output = bout.toString(); + assertThat( + output, CoreMatchers.containsString(String.format("Created Namespace: %s", namespaceName))); + } + + @Test + public void testDeleteNamespace() throws Exception { + // Setup: create a namespace. + NamespacesCreate.createNamespace(PROJECT_ID, LOCATION_ID, NAMESPACE_ID); + String namespaceName = NamespaceName.format(PROJECT_ID, LOCATION_ID, NAMESPACE_ID); + + // Delete the namespace with the specified ID. + NamespacesDelete.deleteNamespace(PROJECT_ID, LOCATION_ID, NAMESPACE_ID); + String output = bout.toString(); + assertThat( + output, CoreMatchers.containsString(String.format("Deleted Namespace: %s", namespaceName))); + } +} 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 new file mode 100644 index 00000000000..b9642866402 --- /dev/null +++ b/servicedirectory/snippets/snippets/src/test/java/com/example/servicedirectory/ServicesTests.java @@ -0,0 +1,129 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.servicedirectory; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + +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; +import org.hamcrest.CoreMatchers; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ServicesTests { + + private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); + private static final String LOCATION_ID = "us-central1"; + private static final String NAMESPACE_ID = "namespace-" + UUID.randomUUID().toString(); + private static final String SERVICE_ID = "service-" + UUID.randomUUID().toString(); + + private ByteArrayOutputStream bout; + + private static void requireEnvVar(String varName) { + assertNotNull( + String.format("Environment variable '%s' must be set to perform these tests.", varName), + System.getenv(varName)); + } + + @BeforeClass + public static void checkRequirements() { + requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); + requireEnvVar("GOOGLE_CLOUD_PROJECT"); + } + + @Before + public void setUp() throws Exception { + bout = new ByteArrayOutputStream(); + System.setOut(new PrintStream(bout)); + + // Setup: create a namespace for the services to live in. + NamespacesCreate.createNamespace(PROJECT_ID, LOCATION_ID, NAMESPACE_ID); + } + + @After + public void tearDown() throws Exception { + System.setOut(null); + bout.reset(); + + // Deletes all resources created during these tests. + try (RegistrationServiceClient client = RegistrationServiceClient.create()) { + // List the namespaces. + String locationPath = LocationName.format(PROJECT_ID, LOCATION_ID); + ListNamespacesPagedResponse response = client.listNamespaces(locationPath); + + // Delete each namespace. + for (Namespace namespace : response.iterateAll()) { + client.deleteNamespace(namespace.getName()); + } + } + } + + @Test + public void testCreateService() throws Exception { + ServicesCreate.createService(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID); + String serviceName = ServiceName.format(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID); + String output = bout.toString(); + assertThat( + output, CoreMatchers.containsString(String.format("Created Service: %s", serviceName))); + } + + @Test + public void testResolveService() throws Exception { + // Setup: create a service. + ServicesCreate.createService(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID); + String serviceName = ServiceName.format(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID); + // Setup: Create an endpoint in the service. + EndpointsCreate.createEndpoint( + PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID, "default-endpoint"); + String endpointName = + EndpointName.format(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID, "default-endpoint"); + + // Resolve the service with the specified ID. + ServicesResolve.resolveService(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID); + String output = bout.toString(); + assertThat( + output, CoreMatchers.containsString(String.format("Resolved Service: %s", serviceName))); + assertThat( + output, CoreMatchers.containsString(String.format("Endpoints found:\n%s", endpointName))); + } + + @Test + public void testDeleteService() throws Exception { + // Setup: create a service. + ServicesCreate.createService(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID); + String serviceName = ServiceName.format(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID); + + // Delete the service with the specified ID. + ServicesDelete.deleteService(PROJECT_ID, LOCATION_ID, NAMESPACE_ID, SERVICE_ID); + String output = bout.toString(); + assertThat( + output, CoreMatchers.containsString(String.format("Deleted Service: %s", serviceName))); + } +}