public class RegistrationServiceClient implements BackgroundResource
Service Description: Service Directory API for registering services. It defines the following resource model:
- The API has a collection of Namespace
resources, named projects/*/locations/*/namespaces/*
.
- Each Namespace has a collection of Service
resources, named projects/*/locations/*/namespaces/*/services/*
.
- Each Service has a collection of Endpoint
resources, named
projects/*/locations/*/namespaces/*/services/*/endpoints/*
.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Namespace namespace = Namespace.newBuilder().build();
String namespaceId = "namespaceId790852566";
Namespace response =
registrationServiceClient.createNamespace(parent, namespace, namespaceId);
}
Note: close() needs to be called on the RegistrationServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of RegistrationServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
RegistrationServiceSettings registrationServiceSettings =
RegistrationServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
RegistrationServiceClient registrationServiceClient =
RegistrationServiceClient.create(registrationServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
RegistrationServiceSettings registrationServiceSettings =
RegistrationServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
RegistrationServiceClient registrationServiceClient =
RegistrationServiceClient.create(registrationServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
RegistrationServiceSettings registrationServiceSettings =
RegistrationServiceSettings.newHttpJsonBuilder().build();
RegistrationServiceClient registrationServiceClient =
RegistrationServiceClient.create(registrationServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final RegistrationServiceClient create()
Constructs an instance of RegistrationServiceClient with default settings.
Returns | |
---|---|
Type | Description |
RegistrationServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(RegistrationServiceSettings settings)
public static final RegistrationServiceClient create(RegistrationServiceSettings settings)
Constructs an instance of RegistrationServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Parameter | |
---|---|
Name | Description |
settings | RegistrationServiceSettings |
Returns | |
---|---|
Type | Description |
RegistrationServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(RegistrationServiceStub stub)
public static final RegistrationServiceClient create(RegistrationServiceStub stub)
Constructs an instance of RegistrationServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(RegistrationServiceSettings).
Parameter | |
---|---|
Name | Description |
stub | RegistrationServiceStub |
Returns | |
---|---|
Type | Description |
RegistrationServiceClient |
Constructors
RegistrationServiceClient(RegistrationServiceSettings settings)
protected RegistrationServiceClient(RegistrationServiceSettings settings)
Constructs an instance of RegistrationServiceClient, 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.
Parameter | |
---|---|
Name | Description |
settings | RegistrationServiceSettings |
RegistrationServiceClient(RegistrationServiceStub stub)
protected RegistrationServiceClient(RegistrationServiceStub stub)
Parameter | |
---|---|
Name | Description |
stub | RegistrationServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Parameters | |
---|---|
Name | Description |
duration | long |
unit | TimeUnit |
Returns | |
---|---|
Type | Description |
boolean |
Exceptions | |
---|---|
Type | Description |
InterruptedException |
close()
public final void close()
createEndpoint(CreateEndpointRequest request)
public final Endpoint createEndpoint(CreateEndpointRequest request)
Creates an endpoint, and returns the new endpoint.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
CreateEndpointRequest request =
CreateEndpointRequest.newBuilder()
.setParent(
ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString())
.setEndpointId("endpointId-1837754992")
.setEndpoint(Endpoint.newBuilder().build())
.build();
Endpoint response = registrationServiceClient.createEndpoint(request);
}
Parameter | |
---|---|
Name | Description |
request | CreateEndpointRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Endpoint |
createEndpoint(ServiceName parent, Endpoint endpoint, String endpointId)
public final Endpoint createEndpoint(ServiceName parent, Endpoint endpoint, String endpointId)
Creates an endpoint, and returns the new endpoint.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]");
Endpoint endpoint = Endpoint.newBuilder().build();
String endpointId = "endpointId-1837754992";
Endpoint response = registrationServiceClient.createEndpoint(parent, endpoint, endpointId);
}
Parameters | |
---|---|
Name | Description |
parent | ServiceName Required. The resource name of the service that this endpoint provides. |
endpoint | Endpoint Required. A endpoint with initial fields set. |
endpointId | String Required. The Resource ID must be 1-63 characters long, and comply with <a
href="https://www.ietf.org/rfc/rfc1035.txt" target="_blank">RFC1035</a>.
Specifically, the name must be 1-63 characters long and match the regular expression
|
Returns | |
---|---|
Type | Description |
Endpoint |
createEndpoint(String parent, Endpoint endpoint, String endpointId)
public final Endpoint createEndpoint(String parent, Endpoint endpoint, String endpointId)
Creates an endpoint, and returns the new endpoint.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
String parent =
ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString();
Endpoint endpoint = Endpoint.newBuilder().build();
String endpointId = "endpointId-1837754992";
Endpoint response = registrationServiceClient.createEndpoint(parent, endpoint, endpointId);
}
Parameters | |
---|---|
Name | Description |
parent | String Required. The resource name of the service that this endpoint provides. |
endpoint | Endpoint Required. A endpoint with initial fields set. |
endpointId | String Required. The Resource ID must be 1-63 characters long, and comply with <a
href="https://www.ietf.org/rfc/rfc1035.txt" target="_blank">RFC1035</a>.
Specifically, the name must be 1-63 characters long and match the regular expression
|
Returns | |
---|---|
Type | Description |
Endpoint |
createEndpointCallable()
public final UnaryCallable<CreateEndpointRequest,Endpoint> createEndpointCallable()
Creates an endpoint, and returns the new endpoint.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
CreateEndpointRequest request =
CreateEndpointRequest.newBuilder()
.setParent(
ServiceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]").toString())
.setEndpointId("endpointId-1837754992")
.setEndpoint(Endpoint.newBuilder().build())
.build();
ApiFuture<Endpoint> future =
registrationServiceClient.createEndpointCallable().futureCall(request);
// Do something.
Endpoint response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CreateEndpointRequest,Endpoint> |
createNamespace(CreateNamespaceRequest request)
public final Namespace createNamespace(CreateNamespaceRequest request)
Creates a namespace, and returns the new namespace.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
CreateNamespaceRequest request =
CreateNamespaceRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setNamespaceId("namespaceId790852566")
.setNamespace(Namespace.newBuilder().build())
.build();
Namespace response = registrationServiceClient.createNamespace(request);
}
Parameter | |
---|---|
Name | Description |
request | CreateNamespaceRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Namespace |
createNamespace(LocationName parent, Namespace namespace, String namespaceId)
public final Namespace createNamespace(LocationName parent, Namespace namespace, String namespaceId)
Creates a namespace, and returns the new namespace.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Namespace namespace = Namespace.newBuilder().build();
String namespaceId = "namespaceId790852566";
Namespace response =
registrationServiceClient.createNamespace(parent, namespace, namespaceId);
}
Parameters | |
---|---|
Name | Description |
parent | LocationName Required. The resource name of the project and location the namespace will be created in. |
namespace | Namespace Required. A namespace with initial fields set. |
namespaceId | String Required. The Resource ID must be 1-63 characters long, and comply with
<a href="https://www.ietf.org/rfc/rfc1035.txt" target="_blank">RFC1035</a>.
Specifically, the name must be 1-63 characters long and match the regular expression
|
Returns | |
---|---|
Type | Description |
Namespace |
createNamespace(String parent, Namespace namespace, String namespaceId)
public final Namespace createNamespace(String parent, Namespace namespace, String namespaceId)
Creates a namespace, and returns the new namespace.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
Namespace namespace = Namespace.newBuilder().build();
String namespaceId = "namespaceId790852566";
Namespace response =
registrationServiceClient.createNamespace(parent, namespace, namespaceId);
}
Parameters | |
---|---|
Name | Description |
parent | String Required. The resource name of the project and location the namespace will be created in. |
namespace | Namespace Required. A namespace with initial fields set. |
namespaceId | String Required. The Resource ID must be 1-63 characters long, and comply with
<a href="https://www.ietf.org/rfc/rfc1035.txt" target="_blank">RFC1035</a>.
Specifically, the name must be 1-63 characters long and match the regular expression
|
Returns | |
---|---|
Type | Description |
Namespace |
createNamespaceCallable()
public final UnaryCallable<CreateNamespaceRequest,Namespace> createNamespaceCallable()
Creates a namespace, and returns the new namespace.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
CreateNamespaceRequest request =
CreateNamespaceRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setNamespaceId("namespaceId790852566")
.setNamespace(Namespace.newBuilder().build())
.build();
ApiFuture<Namespace> future =
registrationServiceClient.createNamespaceCallable().futureCall(request);
// Do something.
Namespace response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CreateNamespaceRequest,Namespace> |
createService(CreateServiceRequest request)
public final Service createService(CreateServiceRequest request)
Creates a service, and returns the new service.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
CreateServiceRequest request =
CreateServiceRequest.newBuilder()
.setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString())
.setServiceId("serviceId-194185552")
.setService(Service.newBuilder().build())
.build();
Service response = registrationServiceClient.createService(request);
}
Parameter | |
---|---|
Name | Description |
request | CreateServiceRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Service |
createService(NamespaceName parent, Service service, String serviceId)
public final Service createService(NamespaceName parent, Service service, String serviceId)
Creates a service, and returns the new service.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
NamespaceName parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]");
Service service = Service.newBuilder().build();
String serviceId = "serviceId-194185552";
Service response = registrationServiceClient.createService(parent, service, serviceId);
}
Parameters | |
---|---|
Name | Description |
parent | NamespaceName Required. The resource name of the namespace this service will belong to. |
service | Service Required. A service with initial fields set. |
serviceId | String Required. The Resource ID must be 1-63 characters long, and comply with <a
href="https://www.ietf.org/rfc/rfc1035.txt" target="_blank">RFC1035</a>.
Specifically, the name must be 1-63 characters long and match the regular expression
|
Returns | |
---|---|
Type | Description |
Service |
createService(String parent, Service service, String serviceId)
public final Service createService(String parent, Service service, String serviceId)
Creates a service, and returns the new service.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
String parent = NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString();
Service service = Service.newBuilder().build();
String serviceId = "serviceId-194185552";
Service response = registrationServiceClient.createService(parent, service, serviceId);
}
Parameters | |
---|---|
Name | Description |
parent | String Required. The resource name of the namespace this service will belong to. |
service | Service Required. A service with initial fields set. |
serviceId | String Required. The Resource ID must be 1-63 characters long, and comply with <a
href="https://www.ietf.org/rfc/rfc1035.txt" target="_blank">RFC1035</a>.
Specifically, the name must be 1-63 characters long and match the regular expression
|
Returns | |
---|---|
Type | Description |
Service |
createServiceCallable()
public final UnaryCallable<CreateServiceRequest,Service> createServiceCallable()
Creates a service, and returns the new service.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
CreateServiceRequest request =
CreateServiceRequest.newBuilder()
.setParent(NamespaceName.of("[PROJECT]", "[LOCATION]", "[NAMESPACE]").toString())
.setServiceId("serviceId-194185552")
.setService(Service.newBuilder().build())
.build();
ApiFuture<Service> future =
registrationServiceClient.createServiceCallable().futureCall(request);
// Do something.
Service response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CreateServiceRequest,Service> |
deleteEndpoint(DeleteEndpointRequest request)
public final void deleteEndpoint(DeleteEndpointRequest request)
Deletes an endpoint.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (RegistrationServiceClient registrationServiceClient = RegistrationServiceClient.create()) {
DeleteEndpointRequest request =
DeleteEndpointRequest.newBuilder()
.setName(
EndpointName.of(
"[PROJECT]", "[LOCATION]", "[NAMESPACE]", "[SERVICE]", "[ENDPOINT]")
.toString())
.build();
registrationServiceClient.deleteEndpoint(request);
}
Parameter | |
---|---|
Name | Description |
request |
|