Class GatewayServiceClient (0.47.0)

GitHub RepositoryProduct Reference

Service Description: Gateway service is a public API which works as a Kubernetes resource model proxy between end users and registered Kubernetes clusters. Each RPC in this service matches with an HTTP verb. End user will initiate kubectl commands against the Gateway service, and Gateway service will forward user requests to clusters.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   HttpBody response = gatewayServiceClient.getResource(request);
 }
 

Note: close() needs to be called on the GatewayServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

GetResource

GetResource performs an HTTP GET request on the Kubernetes API Server.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getResource(HttpBody request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getResourceCallable()

PostResource

PostResource performs an HTTP POST on the Kubernetes API Server.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • postResource(HttpBody request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • postResourceCallable()

DeleteResource

DeleteResource performs an HTTP DELETE on the Kubernetes API Server.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteResource(HttpBody request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteResourceCallable()

PutResource

PutResource performs an HTTP PUT on the Kubernetes API Server.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • putResource(HttpBody request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • putResourceCallable()

PatchResource

PatchResource performs an HTTP PATCH on the Kubernetes API Server.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • patchResource(HttpBody request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • patchResourceCallable()

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 GatewayServiceSettings 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
 GatewayServiceSettings gatewayServiceSettings =
     GatewayServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create(gatewayServiceSettings);
 

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
 GatewayServiceSettings gatewayServiceSettings =
     GatewayServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create(gatewayServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > GatewayServiceClient

Static Methods

create()

public static final GatewayServiceClient create()

Constructs an instance of GatewayServiceClient with default settings.

Returns
Type Description
GatewayServiceClient
Exceptions
Type Description
IOException

create(GatewayServiceSettings settings)

public static final GatewayServiceClient create(GatewayServiceSettings settings)

Constructs an instance of GatewayServiceClient, 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 GatewayServiceSettings
Returns
Type Description
GatewayServiceClient
Exceptions
Type Description
IOException

create(GatewayServiceStub stub)

public static final GatewayServiceClient create(GatewayServiceStub stub)

Constructs an instance of GatewayServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(GatewayServiceSettings).

Parameter
Name Description
stub GatewayServiceStub
Returns
Type Description
GatewayServiceClient

Constructors

GatewayServiceClient(GatewayServiceSettings settings)

protected GatewayServiceClient(GatewayServiceSettings settings)

Constructs an instance of GatewayServiceClient, 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 GatewayServiceSettings

GatewayServiceClient(GatewayServiceStub stub)

protected GatewayServiceClient(GatewayServiceStub stub)
Parameter
Name Description
stub GatewayServiceStub

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()

deleteResource(HttpBody request)

public final HttpBody deleteResource(HttpBody request)

DeleteResource performs an HTTP DELETE on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   HttpBody response = gatewayServiceClient.deleteResource(request);
 }
 
Parameter
Name Description
request com.google.api.HttpBody

The request object containing all of the parameters for the API call.

Returns
Type Description
com.google.api.HttpBody

deleteResourceCallable()

public final UnaryCallable<HttpBody,HttpBody> deleteResourceCallable()

DeleteResource performs an HTTP DELETE on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   ApiFuture<HttpBody> future =
       gatewayServiceClient.deleteResourceCallable().futureCall(request);
   // Do something.
   HttpBody response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.api.HttpBody,com.google.api.HttpBody>

getResource(HttpBody request)

public final HttpBody getResource(HttpBody request)

GetResource performs an HTTP GET request on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   HttpBody response = gatewayServiceClient.getResource(request);
 }
 
Parameter
Name Description
request com.google.api.HttpBody

The request object containing all of the parameters for the API call.

Returns
Type Description
com.google.api.HttpBody

getResourceCallable()

public final UnaryCallable<HttpBody,HttpBody> getResourceCallable()

GetResource performs an HTTP GET request on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   ApiFuture<HttpBody> future = gatewayServiceClient.getResourceCallable().futureCall(request);
   // Do something.
   HttpBody response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.api.HttpBody,com.google.api.HttpBody>

getSettings()

public final GatewayServiceSettings getSettings()
Returns
Type Description
GatewayServiceSettings

getStub()

public GatewayServiceStub getStub()
Returns
Type Description
GatewayServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

patchResource(HttpBody request)

public final HttpBody patchResource(HttpBody request)

PatchResource performs an HTTP PATCH on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   HttpBody response = gatewayServiceClient.patchResource(request);
 }
 
Parameter
Name Description
request com.google.api.HttpBody

The request object containing all of the parameters for the API call.

Returns
Type Description
com.google.api.HttpBody

patchResourceCallable()

public final UnaryCallable<HttpBody,HttpBody> patchResourceCallable()

PatchResource performs an HTTP PATCH on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   ApiFuture<HttpBody> future = gatewayServiceClient.patchResourceCallable().futureCall(request);
   // Do something.
   HttpBody response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.api.HttpBody,com.google.api.HttpBody>

postResource(HttpBody request)

public final HttpBody postResource(HttpBody request)

PostResource performs an HTTP POST on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   HttpBody response = gatewayServiceClient.postResource(request);
 }
 
Parameter
Name Description
request com.google.api.HttpBody

The request object containing all of the parameters for the API call.

Returns
Type Description
com.google.api.HttpBody

postResourceCallable()

public final UnaryCallable<HttpBody,HttpBody> postResourceCallable()

PostResource performs an HTTP POST on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   ApiFuture<HttpBody> future = gatewayServiceClient.postResourceCallable().futureCall(request);
   // Do something.
   HttpBody response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.api.HttpBody,com.google.api.HttpBody>

putResource(HttpBody request)

public final HttpBody putResource(HttpBody request)

PutResource performs an HTTP PUT on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   HttpBody response = gatewayServiceClient.putResource(request);
 }
 
Parameter
Name Description
request com.google.api.HttpBody

The request object containing all of the parameters for the API call.

Returns
Type Description
com.google.api.HttpBody

putResourceCallable()

public final UnaryCallable<HttpBody,HttpBody> putResourceCallable()

PutResource performs an HTTP PUT on the Kubernetes API Server.

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 (GatewayServiceClient gatewayServiceClient = GatewayServiceClient.create()) {
   HttpBody request =
       HttpBody.newBuilder()
           .setContentType("contentType-389131437")
           .setData(ByteString.EMPTY)
           .addAllExtensions(new ArrayList<Any>())
           .build();
   ApiFuture<HttpBody> future = gatewayServiceClient.putResourceCallable().futureCall(request);
   // Do something.
   HttpBody response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.api.HttpBody,com.google.api.HttpBody>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()