From ed06ee280b70e945ac72043a2416f1363317d400 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 23 Jun 2022 21:14:14 +0000 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#681) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 --- google-cloud-servicedirectory/pom.xml | 16 + .../v1/LookupServiceClient.java | 14 + .../v1/LookupServiceSettings.java | 23 +- .../v1/RegistrationServiceClient.java | 15 + .../v1/RegistrationServiceSettings.java | 23 +- .../HttpJsonLookupServiceCallableFactory.java | 105 ++ .../v1/stub/HttpJsonLookupServiceStub.java | 195 ++ ...sonRegistrationServiceCallableFactory.java | 105 ++ .../stub/HttpJsonRegistrationServiceStub.java | 1145 ++++++++++++ .../v1/stub/LookupServiceStubSettings.java | 53 +- .../stub/RegistrationServiceStubSettings.java | 53 +- .../v1beta1/LookupServiceClient.java | 14 + .../v1beta1/LookupServiceSettings.java | 23 +- .../v1beta1/RegistrationServiceClient.java | 15 + .../v1beta1/RegistrationServiceSettings.java | 23 +- .../HttpJsonLookupServiceCallableFactory.java | 105 ++ .../stub/HttpJsonLookupServiceStub.java | 196 ++ ...sonRegistrationServiceCallableFactory.java | 105 ++ .../stub/HttpJsonRegistrationServiceStub.java | 1146 ++++++++++++ .../stub/LookupServiceStubSettings.java | 53 +- .../stub/RegistrationServiceStubSettings.java | 53 +- .../v1/LookupServiceClientHttpJsonTest.java | 127 ++ ...RegistrationServiceClientHttpJsonTest.java | 1582 ++++++++++++++++ .../LookupServiceClientHttpJsonTest.java | 127 ++ ...RegistrationServiceClientHttpJsonTest.java | 1632 +++++++++++++++++ .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 40 + .../create/SyncCreateSetEndpoint.java | 38 + .../resolveservice/AsyncResolveService.java | 50 + .../resolveservice/SyncResolveService.java | 46 + .../resolveservice/SyncResolveService.java | 45 + .../SyncCreateSetCredentialsProvider.java | 43 + .../SyncCreateSetCredentialsProvider1.java | 42 + .../create/SyncCreateSetEndpoint.java | 39 + .../createendpoint/AsyncCreateEndpoint.java | 50 + .../createendpoint/SyncCreateEndpoint.java | 46 + ...eateEndpointServicenameEndpointString.java | 43 + ...yncCreateEndpointStringEndpointString.java | 44 + .../createnamespace/AsyncCreateNamespace.java | 49 + .../createnamespace/SyncCreateNamespace.java | 45 + ...eNamespaceLocationnameNamespaceString.java | 44 + ...cCreateNamespaceStringNamespaceString.java | 44 + .../createservice/AsyncCreateService.java | 49 + .../createservice/SyncCreateService.java | 45 + ...eateServiceNamespacenameServiceString.java | 43 + .../SyncCreateServiceStringServiceString.java | 43 + .../deleteendpoint/AsyncDeleteEndpoint.java | 50 + .../deleteendpoint/SyncDeleteEndpoint.java | 45 + .../SyncDeleteEndpointEndpointname.java | 39 + .../SyncDeleteEndpointString.java | 40 + .../deletenamespace/AsyncDeleteNamespace.java | 47 + .../deletenamespace/SyncDeleteNamespace.java | 42 + .../SyncDeleteNamespaceNamespacename.java | 39 + .../SyncDeleteNamespaceString.java | 38 + .../deleteservice/AsyncDeleteService.java | 48 + .../deleteservice/SyncDeleteService.java | 43 + .../SyncDeleteServiceServicename.java | 38 + .../SyncDeleteServiceString.java | 39 + .../getendpoint/AsyncGetEndpoint.java | 50 + .../getendpoint/SyncGetEndpoint.java | 46 + .../SyncGetEndpointEndpointname.java | 40 + .../getendpoint/SyncGetEndpointString.java | 41 + .../getiampolicy/AsyncGetIamPolicy.java | 49 + .../getiampolicy/SyncGetIamPolicy.java | 45 + .../getnamespace/AsyncGetNamespace.java | 47 + .../getnamespace/SyncGetNamespace.java | 43 + .../SyncGetNamespaceNamespacename.java | 39 + .../getnamespace/SyncGetNamespaceString.java | 39 + .../getservice/AsyncGetService.java | 48 + .../getservice/SyncGetService.java | 44 + .../getservice/SyncGetServiceServicename.java | 39 + .../getservice/SyncGetServiceString.java | 40 + .../listendpoints/AsyncListEndpoints.java | 54 + .../AsyncListEndpointsPaged.java | 62 + .../listendpoints/SyncListEndpoints.java | 50 + .../SyncListEndpointsServicename.java | 41 + .../SyncListEndpointsString.java | 42 + .../listnamespaces/AsyncListNamespaces.java | 53 + .../AsyncListNamespacesPaged.java | 61 + .../listnamespaces/SyncListNamespaces.java | 49 + .../SyncListNamespacesLocationname.java | 41 + .../SyncListNamespacesString.java | 41 + .../listservices/AsyncListServices.java | 53 + .../listservices/AsyncListServicesPaged.java | 61 + .../listservices/SyncListServices.java | 49 + .../SyncListServicesNamespacename.java | 41 + .../listservices/SyncListServicesString.java | 41 + .../setiampolicy/AsyncSetIamPolicy.java | 50 + .../setiampolicy/SyncSetIamPolicy.java | 46 + .../AsyncTestIamPermissions.java | 49 + .../SyncTestIamPermissions.java | 45 + .../updateendpoint/AsyncUpdateEndpoint.java | 48 + .../updateendpoint/SyncUpdateEndpoint.java | 44 + .../SyncUpdateEndpointEndpointFieldmask.java | 42 + .../updatenamespace/AsyncUpdateNamespace.java | 48 + .../updatenamespace/SyncUpdateNamespace.java | 44 + ...SyncUpdateNamespaceNamespaceFieldmask.java | 42 + .../updateservice/AsyncUpdateService.java | 48 + .../updateservice/SyncUpdateService.java | 44 + .../SyncUpdateServiceServiceFieldmask.java | 41 + .../createnamespace/SyncCreateNamespace.java | 47 + .../resolveservice/SyncResolveService.java | 46 + .../createnamespace/SyncCreateNamespace.java | 47 + .../SyncCreateSetCredentialsProvider.java | 41 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 38 + .../resolveservice/AsyncResolveService.java | 50 + .../resolveservice/SyncResolveService.java | 46 + .../resolveservice/SyncResolveService.java | 45 + .../SyncCreateSetCredentialsProvider.java | 44 + .../SyncCreateSetCredentialsProvider1.java | 43 + .../create/SyncCreateSetEndpoint.java | 39 + .../createendpoint/AsyncCreateEndpoint.java | 50 + .../createendpoint/SyncCreateEndpoint.java | 46 + ...eateEndpointServicenameEndpointString.java | 43 + ...yncCreateEndpointStringEndpointString.java | 44 + .../createnamespace/AsyncCreateNamespace.java | 49 + .../createnamespace/SyncCreateNamespace.java | 45 + ...eNamespaceLocationnameNamespaceString.java | 44 + ...cCreateNamespaceStringNamespaceString.java | 44 + .../createservice/AsyncCreateService.java | 49 + .../createservice/SyncCreateService.java | 45 + ...eateServiceNamespacenameServiceString.java | 43 + .../SyncCreateServiceStringServiceString.java | 43 + .../deleteendpoint/AsyncDeleteEndpoint.java | 50 + .../deleteendpoint/SyncDeleteEndpoint.java | 45 + .../SyncDeleteEndpointEndpointname.java | 41 + .../SyncDeleteEndpointString.java | 40 + .../deletenamespace/AsyncDeleteNamespace.java | 47 + .../deletenamespace/SyncDeleteNamespace.java | 42 + .../SyncDeleteNamespaceNamespacename.java | 40 + .../SyncDeleteNamespaceString.java | 38 + .../deleteservice/AsyncDeleteService.java | 48 + .../deleteservice/SyncDeleteService.java | 43 + .../SyncDeleteServiceServicename.java | 39 + .../SyncDeleteServiceString.java | 39 + .../getendpoint/AsyncGetEndpoint.java | 50 + .../getendpoint/SyncGetEndpoint.java | 46 + .../SyncGetEndpointEndpointname.java | 41 + .../getendpoint/SyncGetEndpointString.java | 41 + .../getiampolicy/AsyncGetIamPolicy.java | 49 + .../getiampolicy/SyncGetIamPolicy.java | 45 + .../getnamespace/AsyncGetNamespace.java | 47 + .../getnamespace/SyncGetNamespace.java | 43 + .../SyncGetNamespaceNamespacename.java | 41 + .../getnamespace/SyncGetNamespaceString.java | 39 + .../getservice/AsyncGetService.java | 48 + .../getservice/SyncGetService.java | 44 + .../getservice/SyncGetServiceServicename.java | 39 + .../getservice/SyncGetServiceString.java | 40 + .../listendpoints/AsyncListEndpoints.java | 54 + .../AsyncListEndpointsPaged.java | 62 + .../listendpoints/SyncListEndpoints.java | 50 + .../SyncListEndpointsServicename.java | 42 + .../SyncListEndpointsString.java | 42 + .../listnamespaces/AsyncListNamespaces.java | 53 + .../AsyncListNamespacesPaged.java | 61 + .../listnamespaces/SyncListNamespaces.java | 49 + .../SyncListNamespacesLocationname.java | 43 + .../SyncListNamespacesString.java | 41 + .../listservices/AsyncListServices.java | 53 + .../listservices/AsyncListServicesPaged.java | 61 + .../listservices/SyncListServices.java | 49 + .../SyncListServicesNamespacename.java | 43 + .../listservices/SyncListServicesString.java | 41 + .../setiampolicy/AsyncSetIamPolicy.java | 50 + .../setiampolicy/SyncSetIamPolicy.java | 46 + .../AsyncTestIamPermissions.java | 49 + .../SyncTestIamPermissions.java | 45 + .../updateendpoint/AsyncUpdateEndpoint.java | 48 + .../updateendpoint/SyncUpdateEndpoint.java | 44 + .../SyncUpdateEndpointEndpointFieldmask.java | 42 + .../updatenamespace/AsyncUpdateNamespace.java | 48 + .../updatenamespace/SyncUpdateNamespace.java | 44 + ...SyncUpdateNamespaceNamespaceFieldmask.java | 42 + .../updateservice/AsyncUpdateService.java | 48 + .../updateservice/SyncUpdateService.java | 44 + .../SyncUpdateServiceServiceFieldmask.java | 42 + .../createnamespace/SyncCreateNamespace.java | 47 + .../resolveservice/SyncResolveService.java | 46 + .../createnamespace/SyncCreateNamespace.java | 47 + 181 files changed, 13978 insertions(+), 20 deletions(-) create mode 100644 google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonLookupServiceCallableFactory.java create mode 100644 google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonLookupServiceStub.java create mode 100644 google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonRegistrationServiceCallableFactory.java create mode 100644 google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonRegistrationServiceStub.java create mode 100644 google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonLookupServiceCallableFactory.java create mode 100644 google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonLookupServiceStub.java create mode 100644 google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonRegistrationServiceCallableFactory.java create mode 100644 google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonRegistrationServiceStub.java create mode 100644 google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1/LookupServiceClientHttpJsonTest.java create mode 100644 google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1/RegistrationServiceClientHttpJsonTest.java create mode 100644 google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceClientHttpJsonTest.java create mode 100644 google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceClientHttpJsonTest.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/resolveservice/AsyncResolveService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/resolveservice/SyncResolveService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservicesettings/resolveservice/SyncResolveService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/AsyncCreateEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpointServicenameEndpointString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpointStringEndpointString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/AsyncCreateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespaceStringNamespaceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/AsyncCreateService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateServiceNamespacenameServiceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateServiceStringServiceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/AsyncDeleteEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointEndpointname.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/AsyncDeleteNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceNamespacename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/AsyncDeleteService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteServiceServicename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteServiceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/AsyncGetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpointEndpointname.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpointString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getiampolicy/AsyncGetIamPolicy.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getiampolicy/SyncGetIamPolicy.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/AsyncGetNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespaceNamespacename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespaceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/AsyncGetService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetServiceServicename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetServiceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/AsyncListEndpoints.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/AsyncListEndpointsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpoints.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpointsServicename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpointsString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/AsyncListNamespaces.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/AsyncListNamespacesPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespaces.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespacesLocationname.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespacesString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/AsyncListServices.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/AsyncListServicesPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServices.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServicesNamespacename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServicesString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/setiampolicy/AsyncSetIamPolicy.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/setiampolicy/SyncSetIamPolicy.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/testiampermissions/AsyncTestIamPermissions.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/testiampermissions/SyncTestIamPermissions.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/AsyncUpdateEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/SyncUpdateEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/AsyncUpdateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/SyncUpdateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/AsyncUpdateService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/SyncUpdateService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/SyncUpdateServiceServiceFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservicesettings/createnamespace/SyncCreateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/resolveservice/AsyncResolveService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/resolveservice/SyncResolveService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservicesettings/resolveservice/SyncResolveService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/AsyncCreateEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpointServicenameEndpointString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpointStringEndpointString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/AsyncCreateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespaceStringNamespaceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/AsyncCreateService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateServiceNamespacenameServiceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateServiceStringServiceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/AsyncDeleteEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointEndpointname.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/AsyncDeleteNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceNamespacename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/AsyncDeleteService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteServiceServicename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteServiceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/AsyncGetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpointEndpointname.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpointString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getiampolicy/AsyncGetIamPolicy.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getiampolicy/SyncGetIamPolicy.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/AsyncGetNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespaceNamespacename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespaceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/AsyncGetService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetServiceServicename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetServiceString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/AsyncListEndpoints.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/AsyncListEndpointsPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpoints.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpointsServicename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpointsString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/AsyncListNamespaces.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/AsyncListNamespacesPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespaces.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespacesLocationname.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespacesString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/AsyncListServices.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/AsyncListServicesPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServices.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServicesNamespacename.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServicesString.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/setiampolicy/AsyncSetIamPolicy.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/setiampolicy/SyncSetIamPolicy.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/testiampermissions/AsyncTestIamPermissions.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/testiampermissions/SyncTestIamPermissions.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/AsyncUpdateEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/SyncUpdateEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/AsyncUpdateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/SyncUpdateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/AsyncUpdateService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/SyncUpdateService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/SyncUpdateServiceServiceFieldmask.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservicesettings/createnamespace/SyncCreateNamespace.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java create mode 100644 samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java diff --git a/google-cloud-servicedirectory/pom.xml b/google-cloud-servicedirectory/pom.xml index 547aef75..6d883042 100644 --- a/google-cloud-servicedirectory/pom.xml +++ b/google-cloud-servicedirectory/pom.xml @@ -66,6 +66,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -89,12 +93,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/LookupServiceClient.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/LookupServiceClient.java index 56fd75a6..de39a0c5 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/LookupServiceClient.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/LookupServiceClient.java @@ -94,6 +94,20 @@ * LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * LookupServiceSettings lookupServiceSettings =
+ *     LookupServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             LookupServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/LookupServiceSettings.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/LookupServiceSettings.java index cd77c775..bdcfb404 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/LookupServiceSettings.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/LookupServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -98,11 +99,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return LookupServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return LookupServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return LookupServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return LookupServiceStubSettings.defaultTransportChannelProvider(); } @@ -112,11 +120,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return LookupServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -154,6 +168,11 @@ private static Builder createDefault() { return new Builder(LookupServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(LookupServiceStubSettings.newHttpJsonBuilder()); + } + public LookupServiceStubSettings.Builder getStubSettingsBuilder() { return ((LookupServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/RegistrationServiceClient.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/RegistrationServiceClient.java index 04282a21..d0aa5d6e 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/RegistrationServiceClient.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/RegistrationServiceClient.java @@ -120,6 +120,21 @@ * RegistrationServiceClient.create(registrationServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * RegistrationServiceSettings registrationServiceSettings =
+ *     RegistrationServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             RegistrationServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * RegistrationServiceClient registrationServiceClient =
+ *     RegistrationServiceClient.create(registrationServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/RegistrationServiceSettings.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/RegistrationServiceSettings.java index 55be37ef..34b68591 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/RegistrationServiceSettings.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/RegistrationServiceSettings.java @@ -25,6 +25,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -201,11 +202,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return RegistrationServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return RegistrationServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return RegistrationServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return RegistrationServiceStubSettings.defaultTransportChannelProvider(); } @@ -215,11 +223,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return RegistrationServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -257,6 +271,11 @@ private static Builder createDefault() { return new Builder(RegistrationServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(RegistrationServiceStubSettings.newHttpJsonBuilder()); + } + public RegistrationServiceStubSettings.Builder getStubSettingsBuilder() { return ((RegistrationServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonLookupServiceCallableFactory.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonLookupServiceCallableFactory.java new file mode 100644 index 00000000..c219ce1a --- /dev/null +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonLookupServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * 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; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the LookupService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonLookupServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonLookupServiceStub.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonLookupServiceStub.java new file mode 100644 index 00000000..a9ae1b60 --- /dev/null +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonLookupServiceStub.java @@ -0,0 +1,195 @@ +/* + * 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; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.servicedirectory.v1.ResolveServiceRequest; +import com.google.cloud.servicedirectory.v1.ResolveServiceResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the LookupService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonLookupServiceStub extends LookupServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + resolveServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.servicedirectory.v1.LookupService/ResolveService") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/namespaces/*/services/*}:resolve", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ResolveServiceResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable resolveServiceCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonLookupServiceStub create(LookupServiceStubSettings settings) + throws IOException { + return new HttpJsonLookupServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonLookupServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonLookupServiceStub( + LookupServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonLookupServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonLookupServiceStub( + LookupServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonLookupServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonLookupServiceStub( + LookupServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonLookupServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonLookupServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonLookupServiceStub( + LookupServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + resolveServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(resolveServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.resolveServiceCallable = + callableFactory.createUnaryCallable( + resolveServiceTransportSettings, settings.resolveServiceSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(resolveServiceMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable resolveServiceCallable() { + return resolveServiceCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonRegistrationServiceCallableFactory.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonRegistrationServiceCallableFactory.java new file mode 100644 index 00000000..45925ff1 --- /dev/null +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonRegistrationServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * 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; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the RegistrationService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonRegistrationServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonRegistrationServiceStub.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonRegistrationServiceStub.java new file mode 100644 index 00000000..439691af --- /dev/null +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/HttpJsonRegistrationServiceStub.java @@ -0,0 +1,1145 @@ +/* + * 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; + +import static com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListEndpointsPagedResponse; +import static com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse; +import static com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.servicedirectory.v1.CreateEndpointRequest; +import com.google.cloud.servicedirectory.v1.CreateNamespaceRequest; +import com.google.cloud.servicedirectory.v1.CreateServiceRequest; +import com.google.cloud.servicedirectory.v1.DeleteEndpointRequest; +import com.google.cloud.servicedirectory.v1.DeleteNamespaceRequest; +import com.google.cloud.servicedirectory.v1.DeleteServiceRequest; +import com.google.cloud.servicedirectory.v1.Endpoint; +import com.google.cloud.servicedirectory.v1.GetEndpointRequest; +import com.google.cloud.servicedirectory.v1.GetNamespaceRequest; +import com.google.cloud.servicedirectory.v1.GetServiceRequest; +import com.google.cloud.servicedirectory.v1.ListEndpointsRequest; +import com.google.cloud.servicedirectory.v1.ListEndpointsResponse; +import com.google.cloud.servicedirectory.v1.ListNamespacesRequest; +import com.google.cloud.servicedirectory.v1.ListNamespacesResponse; +import com.google.cloud.servicedirectory.v1.ListServicesRequest; +import com.google.cloud.servicedirectory.v1.ListServicesResponse; +import com.google.cloud.servicedirectory.v1.Namespace; +import com.google.cloud.servicedirectory.v1.Service; +import com.google.cloud.servicedirectory.v1.UpdateEndpointRequest; +import com.google.cloud.servicedirectory.v1.UpdateNamespaceRequest; +import com.google.cloud.servicedirectory.v1.UpdateServiceRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the RegistrationService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonRegistrationServiceStub extends RegistrationServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createNamespaceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/CreateNamespace") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/namespaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "namespaceId", request.getNamespaceId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("namespace", request.getNamespace())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Namespace.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listNamespacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/ListNamespaces") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/namespaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListNamespacesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getNamespaceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/GetNamespace") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/namespaces/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Namespace.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateNamespaceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/UpdateNamespace") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{namespace.name=projects/*/locations/*/namespaces/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "namespace.name", request.getNamespace().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("namespace", request.getNamespace())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Namespace.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteNamespaceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/DeleteNamespace") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/namespaces/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/CreateService") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/namespaces/*}/services", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "serviceId", request.getServiceId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("service", request.getService())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Service.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listServicesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/ListServices") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/namespaces/*}/services", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListServicesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.servicedirectory.v1.RegistrationService/GetService") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/namespaces/*/services/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Service.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/UpdateService") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{service.name=projects/*/locations/*/namespaces/*/services/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "service.name", request.getService().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("service", request.getService())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Service.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/DeleteService") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/namespaces/*/services/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createEndpointMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/CreateEndpoint") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/namespaces/*/services/*}/endpoints", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "endpointId", request.getEndpointId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("endpoint", request.getEndpoint())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Endpoint.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listEndpointsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/ListEndpoints") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/namespaces/*/services/*}/endpoints", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListEndpointsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getEndpointMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.servicedirectory.v1.RegistrationService/GetEndpoint") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Endpoint.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateEndpointMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/UpdateEndpoint") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{endpoint.name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "endpoint.name", request.getEndpoint().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("endpoint", request.getEndpoint())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Endpoint.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteEndpointMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/DeleteEndpoint") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/locations/*/namespaces/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/locations/*/namespaces/*/services/*}:getIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/locations/*/namespaces/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/locations/*/namespaces/*/services/*}:setIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1.RegistrationService/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/locations/*/namespaces/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/locations/*/namespaces/*/services/*}:testIamPermissions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createNamespaceCallable; + private final UnaryCallable listNamespacesCallable; + private final UnaryCallable + listNamespacesPagedCallable; + private final UnaryCallable getNamespaceCallable; + private final UnaryCallable updateNamespaceCallable; + private final UnaryCallable deleteNamespaceCallable; + private final UnaryCallable createServiceCallable; + private final UnaryCallable listServicesCallable; + private final UnaryCallable + listServicesPagedCallable; + private final UnaryCallable getServiceCallable; + private final UnaryCallable updateServiceCallable; + private final UnaryCallable deleteServiceCallable; + private final UnaryCallable createEndpointCallable; + private final UnaryCallable listEndpointsCallable; + private final UnaryCallable + listEndpointsPagedCallable; + private final UnaryCallable getEndpointCallable; + private final UnaryCallable updateEndpointCallable; + private final UnaryCallable deleteEndpointCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonRegistrationServiceStub create( + RegistrationServiceStubSettings settings) throws IOException { + return new HttpJsonRegistrationServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonRegistrationServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonRegistrationServiceStub( + RegistrationServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonRegistrationServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonRegistrationServiceStub( + RegistrationServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonRegistrationServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonRegistrationServiceStub( + RegistrationServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonRegistrationServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonRegistrationServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonRegistrationServiceStub( + RegistrationServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createNamespaceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createNamespaceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listNamespacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listNamespacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getNamespaceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getNamespaceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateNamespaceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateNamespaceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteNamespaceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteNamespaceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listServicesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listServicesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createEndpointTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createEndpointMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listEndpointsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listEndpointsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getEndpointTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEndpointMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateEndpointTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateEndpointMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteEndpointTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteEndpointMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createNamespaceCallable = + callableFactory.createUnaryCallable( + createNamespaceTransportSettings, settings.createNamespaceSettings(), clientContext); + this.listNamespacesCallable = + callableFactory.createUnaryCallable( + listNamespacesTransportSettings, settings.listNamespacesSettings(), clientContext); + this.listNamespacesPagedCallable = + callableFactory.createPagedCallable( + listNamespacesTransportSettings, settings.listNamespacesSettings(), clientContext); + this.getNamespaceCallable = + callableFactory.createUnaryCallable( + getNamespaceTransportSettings, settings.getNamespaceSettings(), clientContext); + this.updateNamespaceCallable = + callableFactory.createUnaryCallable( + updateNamespaceTransportSettings, settings.updateNamespaceSettings(), clientContext); + this.deleteNamespaceCallable = + callableFactory.createUnaryCallable( + deleteNamespaceTransportSettings, settings.deleteNamespaceSettings(), clientContext); + this.createServiceCallable = + callableFactory.createUnaryCallable( + createServiceTransportSettings, settings.createServiceSettings(), clientContext); + this.listServicesCallable = + callableFactory.createUnaryCallable( + listServicesTransportSettings, settings.listServicesSettings(), clientContext); + this.listServicesPagedCallable = + callableFactory.createPagedCallable( + listServicesTransportSettings, settings.listServicesSettings(), clientContext); + this.getServiceCallable = + callableFactory.createUnaryCallable( + getServiceTransportSettings, settings.getServiceSettings(), clientContext); + this.updateServiceCallable = + callableFactory.createUnaryCallable( + updateServiceTransportSettings, settings.updateServiceSettings(), clientContext); + this.deleteServiceCallable = + callableFactory.createUnaryCallable( + deleteServiceTransportSettings, settings.deleteServiceSettings(), clientContext); + this.createEndpointCallable = + callableFactory.createUnaryCallable( + createEndpointTransportSettings, settings.createEndpointSettings(), clientContext); + this.listEndpointsCallable = + callableFactory.createUnaryCallable( + listEndpointsTransportSettings, settings.listEndpointsSettings(), clientContext); + this.listEndpointsPagedCallable = + callableFactory.createPagedCallable( + listEndpointsTransportSettings, settings.listEndpointsSettings(), clientContext); + this.getEndpointCallable = + callableFactory.createUnaryCallable( + getEndpointTransportSettings, settings.getEndpointSettings(), clientContext); + this.updateEndpointCallable = + callableFactory.createUnaryCallable( + updateEndpointTransportSettings, settings.updateEndpointSettings(), clientContext); + this.deleteEndpointCallable = + callableFactory.createUnaryCallable( + deleteEndpointTransportSettings, settings.deleteEndpointSettings(), clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createNamespaceMethodDescriptor); + methodDescriptors.add(listNamespacesMethodDescriptor); + methodDescriptors.add(getNamespaceMethodDescriptor); + methodDescriptors.add(updateNamespaceMethodDescriptor); + methodDescriptors.add(deleteNamespaceMethodDescriptor); + methodDescriptors.add(createServiceMethodDescriptor); + methodDescriptors.add(listServicesMethodDescriptor); + methodDescriptors.add(getServiceMethodDescriptor); + methodDescriptors.add(updateServiceMethodDescriptor); + methodDescriptors.add(deleteServiceMethodDescriptor); + methodDescriptors.add(createEndpointMethodDescriptor); + methodDescriptors.add(listEndpointsMethodDescriptor); + methodDescriptors.add(getEndpointMethodDescriptor); + methodDescriptors.add(updateEndpointMethodDescriptor); + methodDescriptors.add(deleteEndpointMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createNamespaceCallable() { + return createNamespaceCallable; + } + + @Override + public UnaryCallable listNamespacesCallable() { + return listNamespacesCallable; + } + + @Override + public UnaryCallable + listNamespacesPagedCallable() { + return listNamespacesPagedCallable; + } + + @Override + public UnaryCallable getNamespaceCallable() { + return getNamespaceCallable; + } + + @Override + public UnaryCallable updateNamespaceCallable() { + return updateNamespaceCallable; + } + + @Override + public UnaryCallable deleteNamespaceCallable() { + return deleteNamespaceCallable; + } + + @Override + public UnaryCallable createServiceCallable() { + return createServiceCallable; + } + + @Override + public UnaryCallable listServicesCallable() { + return listServicesCallable; + } + + @Override + public UnaryCallable listServicesPagedCallable() { + return listServicesPagedCallable; + } + + @Override + public UnaryCallable getServiceCallable() { + return getServiceCallable; + } + + @Override + public UnaryCallable updateServiceCallable() { + return updateServiceCallable; + } + + @Override + public UnaryCallable deleteServiceCallable() { + return deleteServiceCallable; + } + + @Override + public UnaryCallable createEndpointCallable() { + return createEndpointCallable; + } + + @Override + public UnaryCallable listEndpointsCallable() { + return listEndpointsCallable; + } + + @Override + public UnaryCallable + listEndpointsPagedCallable() { + return listEndpointsPagedCallable; + } + + @Override + public UnaryCallable getEndpointCallable() { + return getEndpointCallable; + } + + @Override + public UnaryCallable updateEndpointCallable() { + return updateEndpointCallable; + } + + @Override + public UnaryCallable deleteEndpointCallable() { + return deleteEndpointCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/LookupServiceStubSettings.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/LookupServiceStubSettings.java index 46834bea..f69b02f2 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/LookupServiceStubSettings.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/LookupServiceStubSettings.java @@ -24,6 +24,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -97,6 +100,11 @@ public LookupServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcLookupServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonLookupServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -129,18 +137,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(LookupServiceStubSettings.class)) @@ -148,11 +163,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(LookupServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return LookupServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -243,6 +277,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .resolveServiceSettings() diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/RegistrationServiceStubSettings.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/RegistrationServiceStubSettings.java index 318772be..4c759d53 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/RegistrationServiceStubSettings.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1/stub/RegistrationServiceStubSettings.java @@ -29,6 +29,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -407,6 +410,11 @@ public RegistrationServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcRegistrationServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonRegistrationServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -439,18 +447,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(RegistrationServiceStubSettings.class)) @@ -458,11 +473,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(RegistrationServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return RegistrationServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -666,6 +700,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createNamespaceSettings() diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceClient.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceClient.java index 96807a27..284a6608 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceClient.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceClient.java @@ -95,6 +95,20 @@ * LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * LookupServiceSettings lookupServiceSettings =
+ *     LookupServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             LookupServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceSettings.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceSettings.java index 293dd211..6904ff10 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceSettings.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -99,11 +100,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return LookupServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return LookupServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return LookupServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return LookupServiceStubSettings.defaultTransportChannelProvider(); } @@ -113,11 +121,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return LookupServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -155,6 +169,11 @@ private static Builder createDefault() { return new Builder(LookupServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(LookupServiceStubSettings.newHttpJsonBuilder()); + } + public LookupServiceStubSettings.Builder getStubSettingsBuilder() { return ((LookupServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceClient.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceClient.java index 3ceb4663..2f6ad606 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceClient.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceClient.java @@ -121,6 +121,21 @@ * RegistrationServiceClient.create(registrationServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * RegistrationServiceSettings registrationServiceSettings =
+ *     RegistrationServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             RegistrationServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * RegistrationServiceClient registrationServiceClient =
+ *     RegistrationServiceClient.create(registrationServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceSettings.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceSettings.java index aad53239..b488f55b 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceSettings.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceSettings.java @@ -25,6 +25,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -202,11 +203,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return RegistrationServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return RegistrationServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return RegistrationServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return RegistrationServiceStubSettings.defaultTransportChannelProvider(); } @@ -216,11 +224,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return RegistrationServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -258,6 +272,11 @@ private static Builder createDefault() { return new Builder(RegistrationServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(RegistrationServiceStubSettings.newHttpJsonBuilder()); + } + public RegistrationServiceStubSettings.Builder getStubSettingsBuilder() { return ((RegistrationServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonLookupServiceCallableFactory.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonLookupServiceCallableFactory.java new file mode 100644 index 00000000..f080f317 --- /dev/null +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonLookupServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * 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; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the LookupService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonLookupServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonLookupServiceStub.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonLookupServiceStub.java new file mode 100644 index 00000000..56ed76f3 --- /dev/null +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonLookupServiceStub.java @@ -0,0 +1,196 @@ +/* + * 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; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.ResolveServiceResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the LookupService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonLookupServiceStub extends LookupServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + resolveServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.LookupService/ResolveService") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/namespaces/*/services/*}:resolve", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ResolveServiceResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable resolveServiceCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonLookupServiceStub create(LookupServiceStubSettings settings) + throws IOException { + return new HttpJsonLookupServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonLookupServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonLookupServiceStub( + LookupServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonLookupServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonLookupServiceStub( + LookupServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonLookupServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonLookupServiceStub( + LookupServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonLookupServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonLookupServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonLookupServiceStub( + LookupServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + resolveServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(resolveServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.resolveServiceCallable = + callableFactory.createUnaryCallable( + resolveServiceTransportSettings, settings.resolveServiceSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(resolveServiceMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable resolveServiceCallable() { + return resolveServiceCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonRegistrationServiceCallableFactory.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonRegistrationServiceCallableFactory.java new file mode 100644 index 00000000..0458d0ff --- /dev/null +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonRegistrationServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * 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; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the RegistrationService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonRegistrationServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonRegistrationServiceStub.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonRegistrationServiceStub.java new file mode 100644 index 00000000..27a4d15e --- /dev/null +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/HttpJsonRegistrationServiceStub.java @@ -0,0 +1,1146 @@ +/* + * 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; + +import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListEndpointsPagedResponse; +import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListNamespacesPagedResponse; +import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListServicesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.CreateServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.Endpoint; +import com.google.cloud.servicedirectory.v1beta1.GetEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.GetServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest; +import com.google.cloud.servicedirectory.v1beta1.ListEndpointsResponse; +import com.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest; +import com.google.cloud.servicedirectory.v1beta1.ListNamespacesResponse; +import com.google.cloud.servicedirectory.v1beta1.ListServicesRequest; +import com.google.cloud.servicedirectory.v1beta1.ListServicesResponse; +import com.google.cloud.servicedirectory.v1beta1.Namespace; +import com.google.cloud.servicedirectory.v1beta1.Service; +import com.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the RegistrationService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonRegistrationServiceStub extends RegistrationServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createNamespaceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/CreateNamespace") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/namespaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "namespaceId", request.getNamespaceId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("namespace", request.getNamespace())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Namespace.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listNamespacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/ListNamespaces") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/namespaces", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListNamespacesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getNamespaceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/GetNamespace") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/namespaces/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Namespace.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateNamespaceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateNamespace") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{namespace.name=projects/*/locations/*/namespaces/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "namespace.name", request.getNamespace().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("namespace", request.getNamespace())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Namespace.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteNamespaceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteNamespace") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/namespaces/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/CreateService") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/namespaces/*}/services", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "serviceId", request.getServiceId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("service", request.getService())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Service.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listServicesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/ListServices") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/namespaces/*}/services", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListServicesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.servicedirectory.v1beta1.RegistrationService/GetService") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/namespaces/*/services/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Service.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateService") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{service.name=projects/*/locations/*/namespaces/*/services/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "service.name", request.getService().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("service", request.getService())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Service.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteService") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/namespaces/*/services/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createEndpointMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/CreateEndpoint") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/namespaces/*/services/*}/endpoints", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "endpointId", request.getEndpointId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("endpoint", request.getEndpoint())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Endpoint.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listEndpointsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/ListEndpoints") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/namespaces/*/services/*}/endpoints", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListEndpointsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getEndpointMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/GetEndpoint") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Endpoint.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateEndpointMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateEndpoint") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{endpoint.name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "endpoint.name", request.getEndpoint().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("endpoint", request.getEndpoint())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Endpoint.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteEndpointMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteEndpoint") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/GetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{resource=projects/*/locations/*/namespaces/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{resource=projects/*/locations/*/namespaces/*/services/*}:getIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{resource=projects/*/locations/*/namespaces/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{resource=projects/*/locations/*/namespaces/*/services/*}:setIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.servicedirectory.v1beta1.RegistrationService/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{resource=projects/*/locations/*/namespaces/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1beta1/{resource=projects/*/locations/*/namespaces/*/services/*}:testIamPermissions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createNamespaceCallable; + private final UnaryCallable listNamespacesCallable; + private final UnaryCallable + listNamespacesPagedCallable; + private final UnaryCallable getNamespaceCallable; + private final UnaryCallable updateNamespaceCallable; + private final UnaryCallable deleteNamespaceCallable; + private final UnaryCallable createServiceCallable; + private final UnaryCallable listServicesCallable; + private final UnaryCallable + listServicesPagedCallable; + private final UnaryCallable getServiceCallable; + private final UnaryCallable updateServiceCallable; + private final UnaryCallable deleteServiceCallable; + private final UnaryCallable createEndpointCallable; + private final UnaryCallable listEndpointsCallable; + private final UnaryCallable + listEndpointsPagedCallable; + private final UnaryCallable getEndpointCallable; + private final UnaryCallable updateEndpointCallable; + private final UnaryCallable deleteEndpointCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonRegistrationServiceStub create( + RegistrationServiceStubSettings settings) throws IOException { + return new HttpJsonRegistrationServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonRegistrationServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonRegistrationServiceStub( + RegistrationServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonRegistrationServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonRegistrationServiceStub( + RegistrationServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonRegistrationServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonRegistrationServiceStub( + RegistrationServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonRegistrationServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonRegistrationServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonRegistrationServiceStub( + RegistrationServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createNamespaceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createNamespaceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listNamespacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listNamespacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getNamespaceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getNamespaceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateNamespaceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateNamespaceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteNamespaceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteNamespaceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listServicesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listServicesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createEndpointTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createEndpointMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listEndpointsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listEndpointsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getEndpointTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEndpointMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateEndpointTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateEndpointMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteEndpointTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteEndpointMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createNamespaceCallable = + callableFactory.createUnaryCallable( + createNamespaceTransportSettings, settings.createNamespaceSettings(), clientContext); + this.listNamespacesCallable = + callableFactory.createUnaryCallable( + listNamespacesTransportSettings, settings.listNamespacesSettings(), clientContext); + this.listNamespacesPagedCallable = + callableFactory.createPagedCallable( + listNamespacesTransportSettings, settings.listNamespacesSettings(), clientContext); + this.getNamespaceCallable = + callableFactory.createUnaryCallable( + getNamespaceTransportSettings, settings.getNamespaceSettings(), clientContext); + this.updateNamespaceCallable = + callableFactory.createUnaryCallable( + updateNamespaceTransportSettings, settings.updateNamespaceSettings(), clientContext); + this.deleteNamespaceCallable = + callableFactory.createUnaryCallable( + deleteNamespaceTransportSettings, settings.deleteNamespaceSettings(), clientContext); + this.createServiceCallable = + callableFactory.createUnaryCallable( + createServiceTransportSettings, settings.createServiceSettings(), clientContext); + this.listServicesCallable = + callableFactory.createUnaryCallable( + listServicesTransportSettings, settings.listServicesSettings(), clientContext); + this.listServicesPagedCallable = + callableFactory.createPagedCallable( + listServicesTransportSettings, settings.listServicesSettings(), clientContext); + this.getServiceCallable = + callableFactory.createUnaryCallable( + getServiceTransportSettings, settings.getServiceSettings(), clientContext); + this.updateServiceCallable = + callableFactory.createUnaryCallable( + updateServiceTransportSettings, settings.updateServiceSettings(), clientContext); + this.deleteServiceCallable = + callableFactory.createUnaryCallable( + deleteServiceTransportSettings, settings.deleteServiceSettings(), clientContext); + this.createEndpointCallable = + callableFactory.createUnaryCallable( + createEndpointTransportSettings, settings.createEndpointSettings(), clientContext); + this.listEndpointsCallable = + callableFactory.createUnaryCallable( + listEndpointsTransportSettings, settings.listEndpointsSettings(), clientContext); + this.listEndpointsPagedCallable = + callableFactory.createPagedCallable( + listEndpointsTransportSettings, settings.listEndpointsSettings(), clientContext); + this.getEndpointCallable = + callableFactory.createUnaryCallable( + getEndpointTransportSettings, settings.getEndpointSettings(), clientContext); + this.updateEndpointCallable = + callableFactory.createUnaryCallable( + updateEndpointTransportSettings, settings.updateEndpointSettings(), clientContext); + this.deleteEndpointCallable = + callableFactory.createUnaryCallable( + deleteEndpointTransportSettings, settings.deleteEndpointSettings(), clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createNamespaceMethodDescriptor); + methodDescriptors.add(listNamespacesMethodDescriptor); + methodDescriptors.add(getNamespaceMethodDescriptor); + methodDescriptors.add(updateNamespaceMethodDescriptor); + methodDescriptors.add(deleteNamespaceMethodDescriptor); + methodDescriptors.add(createServiceMethodDescriptor); + methodDescriptors.add(listServicesMethodDescriptor); + methodDescriptors.add(getServiceMethodDescriptor); + methodDescriptors.add(updateServiceMethodDescriptor); + methodDescriptors.add(deleteServiceMethodDescriptor); + methodDescriptors.add(createEndpointMethodDescriptor); + methodDescriptors.add(listEndpointsMethodDescriptor); + methodDescriptors.add(getEndpointMethodDescriptor); + methodDescriptors.add(updateEndpointMethodDescriptor); + methodDescriptors.add(deleteEndpointMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createNamespaceCallable() { + return createNamespaceCallable; + } + + @Override + public UnaryCallable listNamespacesCallable() { + return listNamespacesCallable; + } + + @Override + public UnaryCallable + listNamespacesPagedCallable() { + return listNamespacesPagedCallable; + } + + @Override + public UnaryCallable getNamespaceCallable() { + return getNamespaceCallable; + } + + @Override + public UnaryCallable updateNamespaceCallable() { + return updateNamespaceCallable; + } + + @Override + public UnaryCallable deleteNamespaceCallable() { + return deleteNamespaceCallable; + } + + @Override + public UnaryCallable createServiceCallable() { + return createServiceCallable; + } + + @Override + public UnaryCallable listServicesCallable() { + return listServicesCallable; + } + + @Override + public UnaryCallable listServicesPagedCallable() { + return listServicesPagedCallable; + } + + @Override + public UnaryCallable getServiceCallable() { + return getServiceCallable; + } + + @Override + public UnaryCallable updateServiceCallable() { + return updateServiceCallable; + } + + @Override + public UnaryCallable deleteServiceCallable() { + return deleteServiceCallable; + } + + @Override + public UnaryCallable createEndpointCallable() { + return createEndpointCallable; + } + + @Override + public UnaryCallable listEndpointsCallable() { + return listEndpointsCallable; + } + + @Override + public UnaryCallable + listEndpointsPagedCallable() { + return listEndpointsPagedCallable; + } + + @Override + public UnaryCallable getEndpointCallable() { + return getEndpointCallable; + } + + @Override + public UnaryCallable updateEndpointCallable() { + return updateEndpointCallable; + } + + @Override + public UnaryCallable deleteEndpointCallable() { + return deleteEndpointCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/LookupServiceStubSettings.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/LookupServiceStubSettings.java index e1807345..cfb62470 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/LookupServiceStubSettings.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/LookupServiceStubSettings.java @@ -24,6 +24,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -98,6 +101,11 @@ public LookupServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcLookupServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonLookupServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -130,18 +138,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(LookupServiceStubSettings.class)) @@ -149,11 +164,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(LookupServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return LookupServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -244,6 +278,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .resolveServiceSettings() diff --git a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/RegistrationServiceStubSettings.java b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/RegistrationServiceStubSettings.java index 70f136cf..df103ef1 100644 --- a/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/RegistrationServiceStubSettings.java +++ b/google-cloud-servicedirectory/src/main/java/com/google/cloud/servicedirectory/v1beta1/stub/RegistrationServiceStubSettings.java @@ -29,6 +29,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -408,6 +411,11 @@ public RegistrationServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcRegistrationServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonRegistrationServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -440,18 +448,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(RegistrationServiceStubSettings.class)) @@ -459,11 +474,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(RegistrationServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return RegistrationServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -667,6 +701,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createNamespaceSettings() diff --git a/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1/LookupServiceClientHttpJsonTest.java b/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1/LookupServiceClientHttpJsonTest.java new file mode 100644 index 00000000..2ccf2a2d --- /dev/null +++ b/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1/LookupServiceClientHttpJsonTest.java @@ -0,0 +1,127 @@ +/* + * 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; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.servicedirectory.v1.stub.HttpJsonLookupServiceStub; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class LookupServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static LookupServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonLookupServiceStub.getMethodDescriptors(), + LookupServiceSettings.getDefaultEndpoint()); + LookupServiceSettings settings = + LookupServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + LookupServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = LookupServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void resolveServiceTest() throws Exception { + ResolveServiceResponse expectedResponse = + ResolveServiceResponse.newBuilder().setService(Service.newBuilder().build()).build(); + mockService.addResponse(expectedResponse); + + ResolveServiceRequest request = + ResolveServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setMaxEndpoints(2074789987) + .setEndpointFilter("endpointFilter-1834249875") + .build(); + + ResolveServiceResponse actualResponse = client.resolveService(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void resolveServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResolveServiceRequest request = + ResolveServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setMaxEndpoints(2074789987) + .setEndpointFilter("endpointFilter-1834249875") + .build(); + client.resolveService(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1/RegistrationServiceClientHttpJsonTest.java b/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1/RegistrationServiceClientHttpJsonTest.java new file mode 100644 index 00000000..02465f41 --- /dev/null +++ b/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1/RegistrationServiceClientHttpJsonTest.java @@ -0,0 +1,1582 @@ +/* + * 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; + +import static com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListEndpointsPagedResponse; +import static com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListNamespacesPagedResponse; +import static com.google.cloud.servicedirectory.v1.RegistrationServiceClient.ListServicesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.servicedirectory.v1.stub.HttpJsonRegistrationServiceStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class RegistrationServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static RegistrationServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonRegistrationServiceStub.getMethodDescriptors(), + RegistrationServiceSettings.getDefaultEndpoint()); + RegistrationServiceSettings settings = + RegistrationServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + RegistrationServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = RegistrationServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createNamespaceTest() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + + Namespace actualResponse = client.createNamespace(parent, namespace, namespaceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNamespaceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + client.createNamespace(parent, namespace, namespaceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNamespaceTest2() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + + Namespace actualResponse = client.createNamespace(parent, namespace, namespaceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNamespaceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + client.createNamespace(parent, namespace, namespaceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNamespacesTest() throws Exception { + Namespace responsesElement = Namespace.newBuilder().build(); + ListNamespacesResponse expectedResponse = + ListNamespacesResponse.newBuilder() + .setNextPageToken("") + .addAllNamespaces(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListNamespacesPagedResponse pagedListResponse = client.listNamespaces(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNamespacesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listNamespacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listNamespaces(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNamespacesTest2() throws Exception { + Namespace responsesElement = Namespace.newBuilder().build(); + ListNamespacesResponse expectedResponse = + ListNamespacesResponse.newBuilder() + .setNextPageToken("") + .addAllNamespaces(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListNamespacesPagedResponse pagedListResponse = client.listNamespaces(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNamespacesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listNamespacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listNamespaces(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNamespaceTest() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + + Namespace actualResponse = client.getNamespace(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getNamespaceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + client.getNamespace(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNamespaceTest2() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9720/locations/location-9720/namespaces/namespace-9720"; + + Namespace actualResponse = client.getNamespace(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getNamespaceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9720/locations/location-9720/namespaces/namespace-9720"; + client.getNamespace(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateNamespaceTest() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + Namespace namespace = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Namespace actualResponse = client.updateNamespace(namespace, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateNamespaceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Namespace namespace = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateNamespace(namespace, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteNamespaceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + + client.deleteNamespace(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteNamespaceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + client.deleteNamespace(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteNamespaceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9720/locations/location-9720/namespaces/namespace-9720"; + + client.deleteNamespace(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteNamespaceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9720/locations/location-9720/namespaces/namespace-9720"; + client.deleteNamespace(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServiceTest() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllAnnotations(new HashMap()) + .addAllEndpoints(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + + Service actualResponse = client.createService(parent, service, serviceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + client.createService(parent, service, serviceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServiceTest2() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllAnnotations(new HashMap()) + .addAllEndpoints(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-1689/locations/location-1689/namespaces/namespace-1689"; + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + + Service actualResponse = client.createService(parent, service, serviceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createServiceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-1689/locations/location-1689/namespaces/namespace-1689"; + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + client.createService(parent, service, serviceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServicesTest() throws Exception { + Service responsesElement = Service.newBuilder().build(); + ListServicesResponse expectedResponse = + ListServicesResponse.newBuilder() + .setNextPageToken("") + .addAllServices(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + + ListServicesPagedResponse pagedListResponse = client.listServices(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listServicesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + client.listServices(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServicesTest2() throws Exception { + Service responsesElement = Service.newBuilder().build(); + ListServicesResponse expectedResponse = + ListServicesResponse.newBuilder() + .setNextPageToken("") + .addAllServices(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-1689/locations/location-1689/namespaces/namespace-1689"; + + ListServicesPagedResponse pagedListResponse = client.listServices(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listServicesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-1689/locations/location-1689/namespaces/namespace-1689"; + client.listServices(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServiceTest() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllAnnotations(new HashMap()) + .addAllEndpoints(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + + Service actualResponse = client.getService(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + client.getService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServiceTest2() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllAnnotations(new HashMap()) + .addAllEndpoints(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-160/locations/location-160/namespaces/namespace-160/services/service-160"; + + Service actualResponse = client.getService(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getServiceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-160/locations/location-160/namespaces/namespace-160/services/service-160"; + client.getService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateServiceTest() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllAnnotations(new HashMap()) + .addAllEndpoints(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + Service service = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllAnnotations(new HashMap()) + .addAllEndpoints(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Service actualResponse = client.updateService(service, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Service service = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllAnnotations(new HashMap()) + .addAllEndpoints(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateService(service, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServiceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + + client.deleteService(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + client.deleteService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServiceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-160/locations/location-160/namespaces/namespace-160/services/service-160"; + + client.deleteService(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteServiceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-160/locations/location-160/namespaces/namespace-160/services/service-160"; + client.deleteService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEndpointTest() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllAnnotations(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + + Endpoint actualResponse = client.createEndpoint(parent, endpoint, endpointId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEndpointExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + client.createEndpoint(parent, endpoint, endpointId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEndpointTest2() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllAnnotations(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4575/locations/location-4575/namespaces/namespace-4575/services/service-4575"; + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + + Endpoint actualResponse = client.createEndpoint(parent, endpoint, endpointId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEndpointExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4575/locations/location-4575/namespaces/namespace-4575/services/service-4575"; + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + client.createEndpoint(parent, endpoint, endpointId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEndpointsTest() throws Exception { + Endpoint responsesElement = Endpoint.newBuilder().build(); + ListEndpointsResponse expectedResponse = + ListEndpointsResponse.newBuilder() + .setNextPageToken("") + .addAllEndpoints(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + + ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEndpointsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + client.listEndpoints(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEndpointsTest2() throws Exception { + Endpoint responsesElement = Endpoint.newBuilder().build(); + ListEndpointsResponse expectedResponse = + ListEndpointsResponse.newBuilder() + .setNextPageToken("") + .addAllEndpoints(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4575/locations/location-4575/namespaces/namespace-4575/services/service-4575"; + + ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEndpointsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4575/locations/location-4575/namespaces/namespace-4575/services/service-4575"; + client.listEndpoints(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEndpointTest() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllAnnotations(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + + Endpoint actualResponse = client.getEndpoint(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEndpointExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + client.getEndpoint(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEndpointTest2() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllAnnotations(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9594/locations/location-9594/namespaces/namespace-9594/services/service-9594/endpoints/endpoint-9594"; + + Endpoint actualResponse = client.getEndpoint(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEndpointExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9594/locations/location-9594/namespaces/namespace-9594/services/service-9594/endpoints/endpoint-9594"; + client.getEndpoint(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEndpointTest() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllAnnotations(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + Endpoint endpoint = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllAnnotations(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Endpoint actualResponse = client.updateEndpoint(endpoint, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateEndpointExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Endpoint endpoint = + Endpoint.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllAnnotations(new HashMap()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateEndpoint(endpoint, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEndpointTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + + client.deleteEndpoint(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEndpointExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + client.deleteEndpoint(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEndpointTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9594/locations/location-9594/namespaces/namespace-9594/services/service-9594/endpoints/endpoint-9594"; + + client.deleteEndpoint(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEndpointExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9594/locations/location-9594/namespaces/namespace-9594/services/service-9594/endpoints/endpoint-9594"; + client.deleteEndpoint(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + + Policy actualResponse = client.getIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + client.getIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Policy actualResponse = client.setIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.setIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + client.testIamPermissions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceClientHttpJsonTest.java b/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceClientHttpJsonTest.java new file mode 100644 index 00000000..8fb0649a --- /dev/null +++ b/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1beta1/LookupServiceClientHttpJsonTest.java @@ -0,0 +1,127 @@ +/* + * 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; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.servicedirectory.v1beta1.stub.HttpJsonLookupServiceStub; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class LookupServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static LookupServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonLookupServiceStub.getMethodDescriptors(), + LookupServiceSettings.getDefaultEndpoint()); + LookupServiceSettings settings = + LookupServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + LookupServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = LookupServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void resolveServiceTest() throws Exception { + ResolveServiceResponse expectedResponse = + ResolveServiceResponse.newBuilder().setService(Service.newBuilder().build()).build(); + mockService.addResponse(expectedResponse); + + ResolveServiceRequest request = + ResolveServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setMaxEndpoints(2074789987) + .setEndpointFilter("endpointFilter-1834249875") + .build(); + + ResolveServiceResponse actualResponse = client.resolveService(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void resolveServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResolveServiceRequest request = + ResolveServiceRequest.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .setMaxEndpoints(2074789987) + .setEndpointFilter("endpointFilter-1834249875") + .build(); + client.resolveService(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceClientHttpJsonTest.java b/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceClientHttpJsonTest.java new file mode 100644 index 00000000..dabfbb75 --- /dev/null +++ b/google-cloud-servicedirectory/src/test/java/com/google/cloud/servicedirectory/v1beta1/RegistrationServiceClientHttpJsonTest.java @@ -0,0 +1,1632 @@ +/* + * 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; + +import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListEndpointsPagedResponse; +import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListNamespacesPagedResponse; +import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListServicesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.servicedirectory.v1beta1.stub.HttpJsonRegistrationServiceStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class RegistrationServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static RegistrationServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonRegistrationServiceStub.getMethodDescriptors(), + RegistrationServiceSettings.getDefaultEndpoint()); + RegistrationServiceSettings settings = + RegistrationServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + RegistrationServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = RegistrationServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createNamespaceTest() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + + Namespace actualResponse = client.createNamespace(parent, namespace, namespaceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNamespaceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + client.createNamespace(parent, namespace, namespaceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createNamespaceTest2() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + + Namespace actualResponse = client.createNamespace(parent, namespace, namespaceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createNamespaceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Namespace namespace = Namespace.newBuilder().build(); + String namespaceId = "namespaceId790852566"; + client.createNamespace(parent, namespace, namespaceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNamespacesTest() throws Exception { + Namespace responsesElement = Namespace.newBuilder().build(); + ListNamespacesResponse expectedResponse = + ListNamespacesResponse.newBuilder() + .setNextPageToken("") + .addAllNamespaces(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListNamespacesPagedResponse pagedListResponse = client.listNamespaces(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNamespacesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listNamespacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listNamespaces(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNamespacesTest2() throws Exception { + Namespace responsesElement = Namespace.newBuilder().build(); + ListNamespacesResponse expectedResponse = + ListNamespacesResponse.newBuilder() + .setNextPageToken("") + .addAllNamespaces(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListNamespacesPagedResponse pagedListResponse = client.listNamespaces(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNamespacesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listNamespacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listNamespaces(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNamespaceTest() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + + Namespace actualResponse = client.getNamespace(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getNamespaceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + client.getNamespace(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getNamespaceTest2() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9720/locations/location-9720/namespaces/namespace-9720"; + + Namespace actualResponse = client.getNamespace(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getNamespaceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9720/locations/location-9720/namespaces/namespace-9720"; + client.getNamespace(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateNamespaceTest() throws Exception { + Namespace expectedResponse = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Namespace namespace = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Namespace actualResponse = client.updateNamespace(namespace, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateNamespaceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Namespace namespace = + Namespace.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateNamespace(namespace, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteNamespaceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + + client.deleteNamespace(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteNamespaceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + client.deleteNamespace(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteNamespaceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9720/locations/location-9720/namespaces/namespace-9720"; + + client.deleteNamespace(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteNamespaceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9720/locations/location-9720/namespaces/namespace-9720"; + client.deleteNamespace(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServiceTest() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllMetadata(new HashMap()) + .addAllEndpoints(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + + Service actualResponse = client.createService(parent, service, serviceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + client.createService(parent, service, serviceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createServiceTest2() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllMetadata(new HashMap()) + .addAllEndpoints(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-1689/locations/location-1689/namespaces/namespace-1689"; + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + + Service actualResponse = client.createService(parent, service, serviceId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createServiceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-1689/locations/location-1689/namespaces/namespace-1689"; + Service service = Service.newBuilder().build(); + String serviceId = "serviceId-194185552"; + client.createService(parent, service, serviceId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServicesTest() throws Exception { + Service responsesElement = Service.newBuilder().build(); + ListServicesResponse expectedResponse = + ListServicesResponse.newBuilder() + .setNextPageToken("") + .addAllServices(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + + ListServicesPagedResponse pagedListResponse = client.listServices(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listServicesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + client.listServices(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listServicesTest2() throws Exception { + Service responsesElement = Service.newBuilder().build(); + ListServicesResponse expectedResponse = + ListServicesResponse.newBuilder() + .setNextPageToken("") + .addAllServices(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-1689/locations/location-1689/namespaces/namespace-1689"; + + ListServicesPagedResponse pagedListResponse = client.listServices(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listServicesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-1689/locations/location-1689/namespaces/namespace-1689"; + client.listServices(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServiceTest() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllMetadata(new HashMap()) + .addAllEndpoints(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + + Service actualResponse = client.getService(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + client.getService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServiceTest2() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllMetadata(new HashMap()) + .addAllEndpoints(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-160/locations/location-160/namespaces/namespace-160/services/service-160"; + + Service actualResponse = client.getService(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getServiceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-160/locations/location-160/namespaces/namespace-160/services/service-160"; + client.getService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateServiceTest() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllMetadata(new HashMap()) + .addAllEndpoints(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Service service = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllMetadata(new HashMap()) + .addAllEndpoints(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Service actualResponse = client.updateService(service, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Service service = + Service.newBuilder() + .setName( + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString()) + .putAllMetadata(new HashMap()) + .addAllEndpoints(new ArrayList()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateService(service, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServiceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + + client.deleteService(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + client.deleteService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteServiceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-160/locations/location-160/namespaces/namespace-160/services/service-160"; + + client.deleteService(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteServiceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-160/locations/location-160/namespaces/namespace-160/services/service-160"; + client.deleteService(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEndpointTest() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllMetadata(new HashMap()) + .setNetwork("network1843485230") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + + Endpoint actualResponse = client.createEndpoint(parent, endpoint, endpointId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEndpointExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + client.createEndpoint(parent, endpoint, endpointId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEndpointTest2() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllMetadata(new HashMap()) + .setNetwork("network1843485230") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4575/locations/location-4575/namespaces/namespace-4575/services/service-4575"; + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + + Endpoint actualResponse = client.createEndpoint(parent, endpoint, endpointId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEndpointExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4575/locations/location-4575/namespaces/namespace-4575/services/service-4575"; + Endpoint endpoint = Endpoint.newBuilder().build(); + String endpointId = "endpointId-1837754992"; + client.createEndpoint(parent, endpoint, endpointId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEndpointsTest() throws Exception { + Endpoint responsesElement = Endpoint.newBuilder().build(); + ListEndpointsResponse expectedResponse = + ListEndpointsResponse.newBuilder() + .setNextPageToken("") + .addAllEndpoints(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + + ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEndpointsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + client.listEndpoints(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEndpointsTest2() throws Exception { + Endpoint responsesElement = Endpoint.newBuilder().build(); + ListEndpointsResponse expectedResponse = + ListEndpointsResponse.newBuilder() + .setNextPageToken("") + .addAllEndpoints(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-4575/locations/location-4575/namespaces/namespace-4575/services/service-4575"; + + ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEndpointsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-4575/locations/location-4575/namespaces/namespace-4575/services/service-4575"; + client.listEndpoints(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEndpointTest() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllMetadata(new HashMap()) + .setNetwork("network1843485230") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + + Endpoint actualResponse = client.getEndpoint(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEndpointExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + client.getEndpoint(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEndpointTest2() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllMetadata(new HashMap()) + .setNetwork("network1843485230") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9594/locations/location-9594/namespaces/namespace-9594/services/service-9594/endpoints/endpoint-9594"; + + Endpoint actualResponse = client.getEndpoint(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEndpointExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9594/locations/location-9594/namespaces/namespace-9594/services/service-9594/endpoints/endpoint-9594"; + client.getEndpoint(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEndpointTest() throws Exception { + Endpoint expectedResponse = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllMetadata(new HashMap()) + .setNetwork("network1843485230") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Endpoint endpoint = + Endpoint.newBuilder() + .setName( + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllMetadata(new HashMap()) + .setNetwork("network1843485230") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Endpoint actualResponse = client.updateEndpoint(endpoint, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateEndpointExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Endpoint endpoint = + Endpoint.newBuilder() + .setName( + EndpointName.of( + "[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString()) + .setAddress("address-1147692044") + .setPort(3446913) + .putAllMetadata(new HashMap()) + .setNetwork("network1843485230") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateEndpoint(endpoint, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEndpointTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + + client.deleteEndpoint(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEndpointExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + client.deleteEndpoint(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEndpointTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-9594/locations/location-9594/namespaces/namespace-9594/services/service-9594/endpoints/endpoint-9594"; + + client.deleteEndpoint(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEndpointExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-9594/locations/location-9594/namespaces/namespace-9594/services/service-9594/endpoints/endpoint-9594"; + client.deleteEndpoint(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + + Policy actualResponse = client.getIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + client.getIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Policy actualResponse = client.setIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.setIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + client.testIamPermissions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..4380e28b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetCredentialsProvider.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_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1_generated_lookupserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..7a9cd536 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/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_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder() + .setTransportChannelProvider( + LookupServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1_generated_lookupserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..428883ce --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * 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_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1_generated_lookupserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/resolveservice/AsyncResolveService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/resolveservice/AsyncResolveService.java new file mode 100644 index 00000000..f9c0857f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/resolveservice/AsyncResolveService.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_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_lookupserviceclient_resolveservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/resolveservice/SyncResolveService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/resolveservice/SyncResolveService.java new file mode 100644 index 00000000..a3d7a946 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupserviceclient/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.samples; + +// [START servicedirectory_v1_generated_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_lookupserviceclient_resolveservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservicesettings/resolveservice/SyncResolveService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/lookupservicesettings/resolveservice/SyncResolveService.java new file mode 100644 index 00000000..14647002 --- /dev/null +++ b/samples/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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..19f829ee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetCredentialsProvider.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..c7954310 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetCredentialsProvider1.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder() + .setTransportChannelProvider( + RegistrationServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..ed7d0641 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/AsyncCreateEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/AsyncCreateEndpoint.java new file mode 100644 index 00000000..6cdf7958 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/AsyncCreateEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createendpoint_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpoint.java new file mode 100644 index 00000000..6ff94bc3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpointServicenameEndpointString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpointServicenameEndpointString.java new file mode 100644 index 00000000..112bdac2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpointServicenameEndpointString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createendpoint_servicenameendpointstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpointStringEndpointString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpointStringEndpointString.java new file mode 100644 index 00000000..19f34548 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createendpoint/SyncCreateEndpointStringEndpointString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createendpoint_stringendpointstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/AsyncCreateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/AsyncCreateNamespace.java new file mode 100644 index 00000000..d3aedbca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/AsyncCreateNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createnamespace_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000..97eeec7e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createnamespace_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java new file mode 100644 index 00000000..a09671d9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createnamespace_locationnamenamespacestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespaceStringNamespaceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespaceStringNamespaceString.java new file mode 100644 index 00000000..806fa2ca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createnamespace/SyncCreateNamespaceStringNamespaceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createnamespace_stringnamespacestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/AsyncCreateService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/AsyncCreateService.java new file mode 100644 index 00000000..b62039f1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/AsyncCreateService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateService.java new file mode 100644 index 00000000..94fcde93 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateServiceNamespacenameServiceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateServiceNamespacenameServiceString.java new file mode 100644 index 00000000..d14190bd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateServiceNamespacenameServiceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createservice_namespacenameservicestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateServiceStringServiceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateServiceStringServiceString.java new file mode 100644 index 00000000..4d663c44 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/createservice/SyncCreateServiceStringServiceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createservice_stringservicestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/AsyncDeleteEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/AsyncDeleteEndpoint.java new file mode 100644 index 00000000..c78a7796 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/AsyncDeleteEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deleteendpoint_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpoint.java new file mode 100644 index 00000000..7e6c3eb9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpoint.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_registrationserviceclient_deleteendpoint_sync] +import com.google.cloud.servicedirectory.v1.DeleteEndpointRequest; +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncDeleteEndpoint { + + public static void main(String[] args) throws Exception { + syncDeleteEndpoint(); + } + + public static void syncDeleteEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deleteendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointEndpointname.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointEndpointname.java new file mode 100644 index 00000000..7ad64ab2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointEndpointname.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_deleteendpoint_endpointname_sync] +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncDeleteEndpointEndpointname { + + public static void main(String[] args) throws Exception { + syncDeleteEndpointEndpointname(); + } + + public static void syncDeleteEndpointEndpointname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + registrationServiceClient.deleteEndpoint(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_deleteendpoint_endpointname_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointString.java new file mode 100644 index 00000000..9ffc1f54 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointString.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_registrationserviceclient_deleteendpoint_string_sync] +import com.google.cloud.servicedirectory.v1.EndpointName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncDeleteEndpointString { + + public static void main(String[] args) throws Exception { + syncDeleteEndpointString(); + } + + public static void syncDeleteEndpointString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString(); + registrationServiceClient.deleteEndpoint(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_deleteendpoint_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/AsyncDeleteNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/AsyncDeleteNamespace.java new file mode 100644 index 00000000..b26bac03 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/AsyncDeleteNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deletenamespace_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespace.java new file mode 100644 index 00000000..7a148fdd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespace.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_registrationserviceclient_deletenamespace_sync] +import com.google.cloud.servicedirectory.v1.DeleteNamespaceRequest; +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncDeleteNamespace { + + public static void main(String[] args) throws Exception { + syncDeleteNamespace(); + } + + public static void syncDeleteNamespace() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteNamespaceRequest request = + DeleteNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + registrationServiceClient.deleteNamespace(request); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_deletenamespace_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceNamespacename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceNamespacename.java new file mode 100644 index 00000000..1c349b07 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceNamespacename.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_deletenamespace_namespacename_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncDeleteNamespaceNamespacename { + + public static void main(String[] args) throws Exception { + syncDeleteNamespaceNamespacename(); + } + + public static void syncDeleteNamespaceNamespacename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + registrationServiceClient.deleteNamespace(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_deletenamespace_namespacename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceString.java new file mode 100644 index 00000000..11552613 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceString.java @@ -0,0 +1,38 @@ +/* + * 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_registrationserviceclient_deletenamespace_string_sync] +import com.google.cloud.servicedirectory.v1.NamespaceName; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; + +public class SyncDeleteNamespaceString { + + public static void main(String[] args) throws Exception { + syncDeleteNamespaceString(); + } + + public static void syncDeleteNamespaceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + registrationServiceClient.deleteNamespace(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_deletenamespace_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/AsyncDeleteService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/AsyncDeleteService.java new file mode 100644 index 00000000..0730e6be --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/AsyncDeleteService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deleteservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteService.java new file mode 100644 index 00000000..174d8fdd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteService.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_registrationserviceclient_deleteservice_sync] +import com.google.cloud.servicedirectory.v1.DeleteServiceRequest; +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncDeleteService { + + public static void main(String[] args) throws Exception { + syncDeleteService(); + } + + public static void syncDeleteService() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deleteservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteServiceServicename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteServiceServicename.java new file mode 100644 index 00000000..38324981 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteServiceServicename.java @@ -0,0 +1,38 @@ +/* + * 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_registrationserviceclient_deleteservice_servicename_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncDeleteServiceServicename { + + public static void main(String[] args) throws Exception { + syncDeleteServiceServicename(); + } + + public static void syncDeleteServiceServicename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + registrationServiceClient.deleteService(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_deleteservice_servicename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteServiceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteServiceString.java new file mode 100644 index 00000000..ea780198 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/deleteservice/SyncDeleteServiceString.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_deleteservice_string_sync] +import com.google.cloud.servicedirectory.v1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1.ServiceName; + +public class SyncDeleteServiceString { + + public static void main(String[] args) throws Exception { + syncDeleteServiceString(); + } + + public static void syncDeleteServiceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + registrationServiceClient.deleteService(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_deleteservice_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/AsyncGetEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/AsyncGetEndpoint.java new file mode 100644 index 00000000..a42070f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/AsyncGetEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getendpoint_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpoint.java new file mode 100644 index 00000000..a79d4a21 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpointEndpointname.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpointEndpointname.java new file mode 100644 index 00000000..e73c119e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpointEndpointname.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + Endpoint response = registrationServiceClient.getEndpoint(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_getendpoint_endpointname_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpointString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpointString.java new file mode 100644 index 00000000..fd00033a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getendpoint/SyncGetEndpointString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString(); + Endpoint response = registrationServiceClient.getEndpoint(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_getendpoint_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getiampolicy/AsyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 00000000..95fd3ce1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getiampolicy/AsyncGetIamPolicy.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getiampolicy/SyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 00000000..83709ee1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getiampolicy/SyncGetIamPolicy.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/AsyncGetNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/AsyncGetNamespace.java new file mode 100644 index 00000000..4992874f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/AsyncGetNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getnamespace_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespace.java new file mode 100644 index 00000000..90176243 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getnamespace_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespaceNamespacename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespaceNamespacename.java new file mode 100644 index 00000000..2dbc802b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespaceNamespacename.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Namespace response = registrationServiceClient.getNamespace(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_getnamespace_namespacename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespaceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespaceString.java new file mode 100644 index 00000000..8f8e5113 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getnamespace/SyncGetNamespaceString.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + Namespace response = registrationServiceClient.getNamespace(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_getnamespace_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/AsyncGetService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/AsyncGetService.java new file mode 100644 index 00000000..30adf262 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/AsyncGetService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetService.java new file mode 100644 index 00000000..a9bd14c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetServiceServicename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetServiceServicename.java new file mode 100644 index 00000000..97c1cc99 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetServiceServicename.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Service response = registrationServiceClient.getService(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_getservice_servicename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetServiceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetServiceString.java new file mode 100644 index 00000000..03bdcd5a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/getservice/SyncGetServiceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + Service response = registrationServiceClient.getService(name); + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_getservice_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/AsyncListEndpoints.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/AsyncListEndpoints.java new file mode 100644 index 00000000..e47208b4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/AsyncListEndpoints.java @@ -0,0 +1,54 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/AsyncListEndpointsPaged.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/AsyncListEndpointsPaged.java new file mode 100644 index 00000000..44e394e1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/AsyncListEndpointsPaged.java @@ -0,0 +1,62 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpoints.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpoints.java new file mode 100644 index 00000000..116d8ea3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpoints.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpointsServicename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpointsServicename.java new file mode 100644 index 00000000..848d925e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpointsServicename.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_servicename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpointsString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpointsString.java new file mode 100644 index 00000000..da5cc35d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listendpoints/SyncListEndpointsString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/AsyncListNamespaces.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/AsyncListNamespaces.java new file mode 100644 index 00000000..46a466f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/AsyncListNamespaces.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listnamespaces_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/AsyncListNamespacesPaged.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/AsyncListNamespacesPaged.java new file mode 100644 index 00000000..636a1b92 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/AsyncListNamespacesPaged.java @@ -0,0 +1,61 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listnamespaces_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespaces.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespaces.java new file mode 100644 index 00000000..ae9fe4ac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespaces.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listnamespaces_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespacesLocationname.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespacesLocationname.java new file mode 100644 index 00000000..79f2a211 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespacesLocationname.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Namespace element : registrationServiceClient.listNamespaces(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END servicedirectory_v1_generated_registrationserviceclient_listnamespaces_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespacesString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespacesString.java new file mode 100644 index 00000000..5ade192b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listnamespaces/SyncListNamespacesString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listnamespaces_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/AsyncListServices.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/AsyncListServices.java new file mode 100644 index 00000000..87e71a33 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/AsyncListServices.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/AsyncListServicesPaged.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/AsyncListServicesPaged.java new file mode 100644 index 00000000..0ca6dccc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/AsyncListServicesPaged.java @@ -0,0 +1,61 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServices.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServices.java new file mode 100644 index 00000000..f05a6d9f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServices.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServicesNamespacename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServicesNamespacename.java new file mode 100644 index 00000000..eeebfb77 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServicesNamespacename.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_namespacename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServicesString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServicesString.java new file mode 100644 index 00000000..10241c5e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/listservices/SyncListServicesString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/setiampolicy/AsyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 00000000..5b3d5138 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/setiampolicy/AsyncSetIamPolicy.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_setiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/setiampolicy/SyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 00000000..cfa52333 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/setiampolicy/SyncSetIamPolicy.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_setiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/testiampermissions/AsyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 00000000..5978a7f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/testiampermissions/AsyncTestIamPermissions.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_testiampermissions_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/testiampermissions/SyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 00000000..286e3a02 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/testiampermissions/SyncTestIamPermissions.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_testiampermissions_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/AsyncUpdateEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/AsyncUpdateEndpoint.java new file mode 100644 index 00000000..5a03713b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/AsyncUpdateEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateendpoint_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/SyncUpdateEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/SyncUpdateEndpoint.java new file mode 100644 index 00000000..91e38e4c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/SyncUpdateEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java new file mode 100644 index 00000000..0d51cbd9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateendpoint/SyncUpdateEndpointEndpointFieldmask.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateendpoint_endpointfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/AsyncUpdateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/AsyncUpdateNamespace.java new file mode 100644 index 00000000..948c05f4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/AsyncUpdateNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updatenamespace_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/SyncUpdateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/SyncUpdateNamespace.java new file mode 100644 index 00000000..9be1ed02 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/SyncUpdateNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updatenamespace_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java new file mode 100644 index 00000000..c770117b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updatenamespace_namespacefieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/AsyncUpdateService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/AsyncUpdateService.java new file mode 100644 index 00000000..f25fcb6d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/AsyncUpdateService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/SyncUpdateService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/SyncUpdateService.java new file mode 100644 index 00000000..9f60281a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/SyncUpdateService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/SyncUpdateServiceServiceFieldmask.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/SyncUpdateServiceServiceFieldmask.java new file mode 100644 index 00000000..805cd78b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationserviceclient/updateservice/SyncUpdateServiceServiceFieldmask.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateservice_servicefieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservicesettings/createnamespace/SyncCreateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservicesettings/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000..f0fd5e45 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/registrationservicesettings/createnamespace/SyncCreateNamespace.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_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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/samples/snippets/generated/com/google/cloud/servicedirectory/v1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java new file mode 100644 index 00000000..196e4d9c --- /dev/null +++ b/samples/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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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/samples/snippets/generated/com/google/cloud/servicedirectory/v1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000..49d7cb9a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.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.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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..84ca6e9d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetCredentialsProvider.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_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_lookupserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..4456a2b4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/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_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder() + .setTransportChannelProvider( + LookupServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_lookupserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..a7fa2ea5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * 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_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + LookupServiceSettings lookupServiceSettings = + LookupServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + LookupServiceClient lookupServiceClient = LookupServiceClient.create(lookupServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_lookupserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/resolveservice/AsyncResolveService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/resolveservice/AsyncResolveService.java new file mode 100644 index 00000000..86ceb33c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/resolveservice/AsyncResolveService.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_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_lookupserviceclient_resolveservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/resolveservice/SyncResolveService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/resolveservice/SyncResolveService.java new file mode 100644 index 00000000..a2843c0d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupserviceclient/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.samples; + +// [START servicedirectory_v1beta1_generated_lookupserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_lookupserviceclient_resolveservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservicesettings/resolveservice/SyncResolveService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/lookupservicesettings/resolveservice/SyncResolveService.java new file mode 100644 index 00000000..dfaef560 --- /dev/null +++ b/samples/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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..949fee4a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END +// servicedirectory_v1beta1_generated_registrationserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..19ecfebc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetCredentialsProvider1.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder() + .setTransportChannelProvider( + RegistrationServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END +// servicedirectory_v1beta1_generated_registrationserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..486059a5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + RegistrationServiceSettings registrationServiceSettings = + RegistrationServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + RegistrationServiceClient registrationServiceClient = + RegistrationServiceClient.create(registrationServiceSettings); + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/AsyncCreateEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/AsyncCreateEndpoint.java new file mode 100644 index 00000000..0746d2bf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/AsyncCreateEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createendpoint_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpoint.java new file mode 100644 index 00000000..a230f169 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpointServicenameEndpointString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpointServicenameEndpointString.java new file mode 100644 index 00000000..e7296674 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpointServicenameEndpointString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createendpoint_servicenameendpointstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpointStringEndpointString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpointStringEndpointString.java new file mode 100644 index 00000000..02b882f7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createendpoint/SyncCreateEndpointStringEndpointString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createendpoint_stringendpointstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/AsyncCreateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/AsyncCreateNamespace.java new file mode 100644 index 00000000..1d556f80 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/AsyncCreateNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createnamespace_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000..a71ea715 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createnamespace_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.java new file mode 100644 index 00000000..a1a8a7a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespaceLocationnameNamespaceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createnamespace_locationnamenamespacestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespaceStringNamespaceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespaceStringNamespaceString.java new file mode 100644 index 00000000..d28e0883 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createnamespace/SyncCreateNamespaceStringNamespaceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createnamespace_stringnamespacestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/AsyncCreateService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/AsyncCreateService.java new file mode 100644 index 00000000..3aaa2d53 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/AsyncCreateService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateService.java new file mode 100644 index 00000000..f2ac59a8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateServiceNamespacenameServiceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateServiceNamespacenameServiceString.java new file mode 100644 index 00000000..88273a23 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateServiceNamespacenameServiceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createservice_namespacenameservicestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateServiceStringServiceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateServiceStringServiceString.java new file mode 100644 index 00000000..62a5939a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/createservice/SyncCreateServiceStringServiceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_createservice_stringservicestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/AsyncDeleteEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/AsyncDeleteEndpoint.java new file mode 100644 index 00000000..06f0ceaa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/AsyncDeleteEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deleteendpoint_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpoint.java new file mode 100644 index 00000000..ac2aaced --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpoint.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_registrationserviceclient_deleteendpoint_sync] +import com.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest; +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncDeleteEndpoint { + + public static void main(String[] args) throws Exception { + syncDeleteEndpoint(); + } + + public static void syncDeleteEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deleteendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointEndpointname.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointEndpointname.java new file mode 100644 index 00000000..eadd1301 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointEndpointname.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_registrationserviceclient_deleteendpoint_endpointname_sync] +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncDeleteEndpointEndpointname { + + public static void main(String[] args) throws Exception { + syncDeleteEndpointEndpointname(); + } + + public static void syncDeleteEndpointEndpointname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + registrationServiceClient.deleteEndpoint(name); + } + } +} +// [END +// servicedirectory_v1beta1_generated_registrationserviceclient_deleteendpoint_endpointname_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointString.java new file mode 100644 index 00000000..48999859 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteendpoint/SyncDeleteEndpointString.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_registrationserviceclient_deleteendpoint_string_sync] +import com.google.cloud.servicedirectory.v1beta1.EndpointName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncDeleteEndpointString { + + public static void main(String[] args) throws Exception { + syncDeleteEndpointString(); + } + + public static void syncDeleteEndpointString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString(); + registrationServiceClient.deleteEndpoint(name); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_deleteendpoint_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/AsyncDeleteNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/AsyncDeleteNamespace.java new file mode 100644 index 00000000..89d486f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/AsyncDeleteNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deletenamespace_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespace.java new file mode 100644 index 00000000..a19880b2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespace.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_registrationserviceclient_deletenamespace_sync] +import com.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest; +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncDeleteNamespace { + + public static void main(String[] args) throws Exception { + syncDeleteNamespace(); + } + + public static void syncDeleteNamespace() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + DeleteNamespaceRequest request = + DeleteNamespaceRequest.newBuilder() + .setName(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString()) + .build(); + registrationServiceClient.deleteNamespace(request); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_deletenamespace_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceNamespacename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceNamespacename.java new file mode 100644 index 00000000..e461b253 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceNamespacename.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_registrationserviceclient_deletenamespace_namespacename_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncDeleteNamespaceNamespacename { + + public static void main(String[] args) throws Exception { + syncDeleteNamespaceNamespacename(); + } + + public static void syncDeleteNamespaceNamespacename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + registrationServiceClient.deleteNamespace(name); + } + } +} +// [END +// servicedirectory_v1beta1_generated_registrationserviceclient_deletenamespace_namespacename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceString.java new file mode 100644 index 00000000..20d53569 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deletenamespace/SyncDeleteNamespaceString.java @@ -0,0 +1,38 @@ +/* + * 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_registrationserviceclient_deletenamespace_string_sync] +import com.google.cloud.servicedirectory.v1beta1.NamespaceName; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; + +public class SyncDeleteNamespaceString { + + public static void main(String[] args) throws Exception { + syncDeleteNamespaceString(); + } + + public static void syncDeleteNamespaceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + registrationServiceClient.deleteNamespace(name); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_deletenamespace_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/AsyncDeleteService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/AsyncDeleteService.java new file mode 100644 index 00000000..c8460265 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/AsyncDeleteService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deleteservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteService.java new file mode 100644 index 00000000..55e506c8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteService.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_registrationserviceclient_deleteservice_sync] +import com.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest; +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncDeleteService { + + public static void main(String[] args) throws Exception { + syncDeleteService(); + } + + public static void syncDeleteService() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_deleteservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteServiceServicename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteServiceServicename.java new file mode 100644 index 00000000..a0025063 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteServiceServicename.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_deleteservice_servicename_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncDeleteServiceServicename { + + public static void main(String[] args) throws Exception { + syncDeleteServiceServicename(); + } + + public static void syncDeleteServiceServicename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + registrationServiceClient.deleteService(name); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_deleteservice_servicename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteServiceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteServiceString.java new file mode 100644 index 00000000..fc4377f3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/deleteservice/SyncDeleteServiceString.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_deleteservice_string_sync] +import com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient; +import com.google.cloud.servicedirectory.v1beta1.ServiceName; + +public class SyncDeleteServiceString { + + public static void main(String[] args) throws Exception { + syncDeleteServiceString(); + } + + public static void syncDeleteServiceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + registrationServiceClient.deleteService(name); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_deleteservice_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/AsyncGetEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/AsyncGetEndpoint.java new file mode 100644 index 00000000..2f8a439d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/AsyncGetEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getendpoint_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpoint.java new file mode 100644 index 00000000..fe61944a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpointEndpointname.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpointEndpointname.java new file mode 100644 index 00000000..ea7e6ec4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpointEndpointname.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + EndpointName name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]"); + Endpoint response = registrationServiceClient.getEndpoint(name); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_getendpoint_endpointname_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpointString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpointString.java new file mode 100644 index 00000000..4c2fba4d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getendpoint/SyncGetEndpointString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + EndpointName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]") + .toString(); + Endpoint response = registrationServiceClient.getEndpoint(name); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_getendpoint_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getiampolicy/AsyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getiampolicy/AsyncGetIamPolicy.java new file mode 100644 index 00000000..0edef8b1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getiampolicy/AsyncGetIamPolicy.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getiampolicy/SyncGetIamPolicy.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getiampolicy/SyncGetIamPolicy.java new file mode 100644 index 00000000..27e7590d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getiampolicy/SyncGetIamPolicy.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/AsyncGetNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/AsyncGetNamespace.java new file mode 100644 index 00000000..a1e1abb0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/AsyncGetNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getnamespace_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespace.java new file mode 100644 index 00000000..0e5d6281 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getnamespace_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespaceNamespacename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespaceNamespacename.java new file mode 100644 index 00000000..c2438676 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespaceNamespacename.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + NamespaceName name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]"); + Namespace response = registrationServiceClient.getNamespace(name); + } + } +} +// [END +// servicedirectory_v1beta1_generated_registrationserviceclient_getnamespace_namespacename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespaceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespaceString.java new file mode 100644 index 00000000..160f195f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getnamespace/SyncGetNamespaceString.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString(); + Namespace response = registrationServiceClient.getNamespace(name); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_getnamespace_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/AsyncGetService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/AsyncGetService.java new file mode 100644 index 00000000..211fc5dc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/AsyncGetService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetService.java new file mode 100644 index 00000000..d44a19de --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_getservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetServiceServicename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetServiceServicename.java new file mode 100644 index 00000000..4080b50d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetServiceServicename.java @@ -0,0 +1,39 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]"); + Service response = registrationServiceClient.getService(name); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_getservice_servicename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetServiceString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetServiceString.java new file mode 100644 index 00000000..d890c487 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/getservice/SyncGetServiceString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + String name = + ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString(); + Service response = registrationServiceClient.getService(name); + } + } +} +// [END servicedirectory_v1beta1_generated_registrationserviceclient_getservice_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/AsyncListEndpoints.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/AsyncListEndpoints.java new file mode 100644 index 00000000..5bd9b0c0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/AsyncListEndpoints.java @@ -0,0 +1,54 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/AsyncListEndpointsPaged.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/AsyncListEndpointsPaged.java new file mode 100644 index 00000000..013a67b3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/AsyncListEndpointsPaged.java @@ -0,0 +1,62 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpoints.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpoints.java new file mode 100644 index 00000000..976dd80e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpoints.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpointsServicename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpointsServicename.java new file mode 100644 index 00000000..4760f2b9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpointsServicename.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_servicename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpointsString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpointsString.java new file mode 100644 index 00000000..4456b1f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listendpoints/SyncListEndpointsString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listendpoints_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/AsyncListNamespaces.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/AsyncListNamespaces.java new file mode 100644 index 00000000..a49dcd00 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/AsyncListNamespaces.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listnamespaces_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/AsyncListNamespacesPaged.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/AsyncListNamespacesPaged.java new file mode 100644 index 00000000..b3b5d47d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/AsyncListNamespacesPaged.java @@ -0,0 +1,61 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listnamespaces_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespaces.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespaces.java new file mode 100644 index 00000000..e36d2223 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespaces.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listnamespaces_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespacesLocationname.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespacesLocationname.java new file mode 100644 index 00000000..40fe86e2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespacesLocationname.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Namespace element : registrationServiceClient.listNamespaces(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// servicedirectory_v1beta1_generated_registrationserviceclient_listnamespaces_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespacesString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespacesString.java new file mode 100644 index 00000000..53363cbe --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listnamespaces/SyncListNamespacesString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listnamespaces_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/AsyncListServices.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/AsyncListServices.java new file mode 100644 index 00000000..79d86c81 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/AsyncListServices.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/AsyncListServicesPaged.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/AsyncListServicesPaged.java new file mode 100644 index 00000000..f28bbc29 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/AsyncListServicesPaged.java @@ -0,0 +1,61 @@ +/* + * 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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServices.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServices.java new file mode 100644 index 00000000..553e2067 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServices.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServicesNamespacename.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServicesNamespacename.java new file mode 100644 index 00000000..d197f353 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServicesNamespacename.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_namespacename_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServicesString.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServicesString.java new file mode 100644 index 00000000..5fa17514 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/listservices/SyncListServicesString.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_listservices_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/setiampolicy/AsyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/setiampolicy/AsyncSetIamPolicy.java new file mode 100644 index 00000000..1a6ac721 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/setiampolicy/AsyncSetIamPolicy.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_setiampolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/setiampolicy/SyncSetIamPolicy.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/setiampolicy/SyncSetIamPolicy.java new file mode 100644 index 00000000..38ae2141 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/setiampolicy/SyncSetIamPolicy.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_setiampolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/testiampermissions/AsyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/testiampermissions/AsyncTestIamPermissions.java new file mode 100644 index 00000000..2b9368f4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/testiampermissions/AsyncTestIamPermissions.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_testiampermissions_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/testiampermissions/SyncTestIamPermissions.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/testiampermissions/SyncTestIamPermissions.java new file mode 100644 index 00000000..b0b358f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/testiampermissions/SyncTestIamPermissions.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_testiampermissions_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/AsyncUpdateEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/AsyncUpdateEndpoint.java new file mode 100644 index 00000000..5fcd0d73 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/AsyncUpdateEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateendpoint_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/SyncUpdateEndpoint.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/SyncUpdateEndpoint.java new file mode 100644 index 00000000..987ee05d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/SyncUpdateEndpoint.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/SyncUpdateEndpointEndpointFieldmask.java new file mode 100644 index 00000000..a4993b62 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateendpoint/SyncUpdateEndpointEndpointFieldmask.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateendpoint_endpointfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/AsyncUpdateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/AsyncUpdateNamespace.java new file mode 100644 index 00000000..e9230e51 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/AsyncUpdateNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updatenamespace_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/SyncUpdateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/SyncUpdateNamespace.java new file mode 100644 index 00000000..7814208e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/SyncUpdateNamespace.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updatenamespace_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.java new file mode 100644 index 00000000..a08ad78f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updatenamespace/SyncUpdateNamespaceNamespaceFieldmask.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updatenamespace_namespacefieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/AsyncUpdateService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/AsyncUpdateService.java new file mode 100644 index 00000000..f32493d8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/AsyncUpdateService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateservice_async] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/SyncUpdateService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/SyncUpdateService.java new file mode 100644 index 00000000..9c991066 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/SyncUpdateService.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateservice_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/SyncUpdateServiceServiceFieldmask.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/SyncUpdateServiceServiceFieldmask.java new file mode 100644 index 00000000..61519314 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationserviceclient/updateservice/SyncUpdateServiceServiceFieldmask.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_registrationserviceclient_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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_registrationserviceclient_updateservice_servicefieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservicesettings/createnamespace/SyncCreateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservicesettings/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000..ef70b136 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/registrationservicesettings/createnamespace/SyncCreateNamespace.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_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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/lookupservicestubsettings/resolveservice/SyncResolveService.java new file mode 100644 index 00000000..20f4a139 --- /dev/null +++ b/samples/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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.java new file mode 100644 index 00000000..5be54195 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/servicedirectory/v1beta1/stub/registrationservicestubsettings/createnamespace/SyncCreateNamespace.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.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 for illustrative purposes only. + // It may require modifications to work in your environment. + 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]