Class GkeHubClient (1.13.0)

public class GkeHubClient implements BackgroundResource

Service Description: The GKE Hub service handles the registration of many Kubernetes clusters to Google Cloud, represented with the Membership resource.

GKE Hub is currently only available in the global region.

**Membership management may be non-trivial:** it is recommended to use one of the Google-provided client libraries or tools where possible when working with Membership resources.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   MembershipName name = MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]");
   Membership response = gkeHubClient.getMembership(name);
 }
 

Note: close() needs to be called on the GkeHubClient 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:

  1. 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.
  2. 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.
  3. 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 GkeHubSettings 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
 GkeHubSettings gkeHubSettings =
     GkeHubSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 GkeHubClient gkeHubClient = GkeHubClient.create(gkeHubSettings);
 

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
 GkeHubSettings gkeHubSettings = GkeHubSettings.newBuilder().setEndpoint(myEndpoint).build();
 GkeHubClient gkeHubClient = GkeHubClient.create(gkeHubSettings);
 

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
 GkeHubSettings gkeHubSettings = GkeHubSettings.newHttpJsonBuilder().build();
 GkeHubClient gkeHubClient = GkeHubClient.create(gkeHubSettings);
 

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

Inheritance

java.lang.Object > GkeHubClient

Implements

BackgroundResource

Static Methods

create()

public static final GkeHubClient create()

Constructs an instance of GkeHubClient with default settings.

Returns
TypeDescription
GkeHubClient
Exceptions
TypeDescription
IOException

create(GkeHubSettings settings)

public static final GkeHubClient create(GkeHubSettings settings)

Constructs an instance of GkeHubClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
NameDescription
settingsGkeHubSettings
Returns
TypeDescription
GkeHubClient
Exceptions
TypeDescription
IOException

create(GkeHubStub stub)

public static final GkeHubClient create(GkeHubStub stub)

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

Parameter
NameDescription
stubGkeHubStub
Returns
TypeDescription
GkeHubClient

Constructors

GkeHubClient(GkeHubSettings settings)

protected GkeHubClient(GkeHubSettings settings)

Constructs an instance of GkeHubClient, 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
NameDescription
settingsGkeHubSettings

GkeHubClient(GkeHubStub stub)

protected GkeHubClient(GkeHubStub stub)
Parameter
NameDescription
stubGkeHubStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

createMembershipAsync(CreateMembershipRequest request)

public final OperationFuture<Membership,OperationMetadata> createMembershipAsync(CreateMembershipRequest request)

Creates a new Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To register other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   CreateMembershipRequest request =
       CreateMembershipRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMembershipId("membershipId517665681")
           .setResource(Membership.newBuilder().build())
           .build();
   Membership response = gkeHubClient.createMembershipAsync(request).get();
 }
 
Parameter
NameDescription
requestCreateMembershipRequest

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

Returns
TypeDescription
OperationFuture<Membership,OperationMetadata>

createMembershipAsync(LocationName parent, Membership resource, String membershipId)

public final OperationFuture<Membership,OperationMetadata> createMembershipAsync(LocationName parent, Membership resource, String membershipId)

Creates a new Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To register other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   Membership resource = Membership.newBuilder().build();
   String membershipId = "membershipId517665681";
   Membership response =
       gkeHubClient.createMembershipAsync(parent, resource, membershipId).get();
 }
 
Parameters
NameDescription
parentLocationName

Required. The parent (project and location) where the Memberships will be created. Specified in the format projects/*/locations/*.

resourceMembership

Required. The membership to create.

membershipIdString

Required. Client chosen ID for the membership. membership_id must be a valid RFC 1123 compliant DNS label:

1. At most 63 characters in length 2. It must consist of lower case alphanumeric characters or - 3. It must start and end with an alphanumeric character

Which can be expressed as the regex: a-z0-9?, with a maximum length of 63 characters.

Returns
TypeDescription
OperationFuture<Membership,OperationMetadata>

createMembershipAsync(String parent, Membership resource, String membershipId)

public final OperationFuture<Membership,OperationMetadata> createMembershipAsync(String parent, Membership resource, String membershipId)

Creates a new Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To register other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   Membership resource = Membership.newBuilder().build();
   String membershipId = "membershipId517665681";
   Membership response =
       gkeHubClient.createMembershipAsync(parent, resource, membershipId).get();
 }
 
Parameters
NameDescription
parentString

Required. The parent (project and location) where the Memberships will be created. Specified in the format projects/*/locations/*.

resourceMembership

Required. The membership to create.

membershipIdString

Required. Client chosen ID for the membership. membership_id must be a valid RFC 1123 compliant DNS label:

1. At most 63 characters in length 2. It must consist of lower case alphanumeric characters or - 3. It must start and end with an alphanumeric character

Which can be expressed as the regex: a-z0-9?, with a maximum length of 63 characters.

Returns
TypeDescription
OperationFuture<Membership,OperationMetadata>

createMembershipCallable()

public final UnaryCallable<CreateMembershipRequest,Operation> createMembershipCallable()

Creates a new Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To register other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   CreateMembershipRequest request =
       CreateMembershipRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMembershipId("membershipId517665681")
           .setResource(Membership.newBuilder().build())
           .build();
   ApiFuture<Operation> future = gkeHubClient.createMembershipCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateMembershipRequest,Operation>

createMembershipOperationCallable()

public final OperationCallable<CreateMembershipRequest,Membership,OperationMetadata> createMembershipOperationCallable()

Creates a new Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To register other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   CreateMembershipRequest request =
       CreateMembershipRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setMembershipId("membershipId517665681")
           .setResource(Membership.newBuilder().build())
           .build();
   OperationFuture<Membership, OperationMetadata> future =
       gkeHubClient.createMembershipOperationCallable().futureCall(request);
   // Do something.
   Membership response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<CreateMembershipRequest,Membership,OperationMetadata>

deleteMembershipAsync(DeleteMembershipRequest request)

public final OperationFuture<Empty,OperationMetadata> deleteMembershipAsync(DeleteMembershipRequest request)

Removes a Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To unregister other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   DeleteMembershipRequest request =
       DeleteMembershipRequest.newBuilder()
           .setName(MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]").toString())
           .build();
   gkeHubClient.deleteMembershipAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteMembershipRequest

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

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteMembershipAsync(MembershipName name)

public final OperationFuture<Empty,OperationMetadata> deleteMembershipAsync(MembershipName name)

Removes a Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To unregister other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   MembershipName name = MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]");
   gkeHubClient.deleteMembershipAsync(name).get();
 }
 
Parameter
NameDescription
nameMembershipName

Required. The Membership resource name in the format projects/*/locations/*/memberships/*.

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteMembershipAsync(String name)

public final OperationFuture<Empty,OperationMetadata> deleteMembershipAsync(String name)

Removes a Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To unregister other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   String name = MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]").toString();
   gkeHubClient.deleteMembershipAsync(name).get();
 }
 
Parameter
NameDescription
nameString

Required. The Membership resource name in the format projects/*/locations/*/memberships/*.

Returns
TypeDescription
OperationFuture<Empty,OperationMetadata>

deleteMembershipCallable()

public final UnaryCallable<DeleteMembershipRequest,Operation> deleteMembershipCallable()

Removes a Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To unregister other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   DeleteMembershipRequest request =
       DeleteMembershipRequest.newBuilder()
           .setName(MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]").toString())
           .build();
   ApiFuture<Operation> future = gkeHubClient.deleteMembershipCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteMembershipRequest,Operation>

deleteMembershipOperationCallable()

public final OperationCallable<DeleteMembershipRequest,Empty,OperationMetadata> deleteMembershipOperationCallable()

Removes a Membership.

**This is currently only supported for GKE clusters on Google Cloud**. To unregister other clusters, follow the instructions at https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   DeleteMembershipRequest request =
       DeleteMembershipRequest.newBuilder()
           .setName(MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]").toString())
           .build();
   OperationFuture<Empty, OperationMetadata> future =
       gkeHubClient.deleteMembershipOperationCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
OperationCallable<DeleteMembershipRequest,Empty,OperationMetadata>

generateConnectManifest(GenerateConnectManifestRequest request)

public final GenerateConnectManifestResponse generateConnectManifest(GenerateConnectManifestRequest request)

Generates the manifest for deployment of the GKE connect agent.

**This method is used internally by Google-provided libraries.** Most clients should not need to call this method directly.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   GenerateConnectManifestRequest request =
       GenerateConnectManifestRequest.newBuilder()
           .setName("name3373707")
           .setNamespace("namespace1252218203")
           .setProxy(ByteString.EMPTY)
           .setVersion("version351608024")
           .setIsUpgrade(true)
           .setRegistry("registry-690212803")
           .setImagePullSecretContent(ByteString.EMPTY)
           .build();
   GenerateConnectManifestResponse response = gkeHubClient.generateConnectManifest(request);
 }
 
Parameter
NameDescription
requestGenerateConnectManifestRequest

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

Returns
TypeDescription
GenerateConnectManifestResponse

generateConnectManifestCallable()

public final UnaryCallable<GenerateConnectManifestRequest,GenerateConnectManifestResponse> generateConnectManifestCallable()

Generates the manifest for deployment of the GKE connect agent.

**This method is used internally by Google-provided libraries.** Most clients should not need to call this method directly.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   GenerateConnectManifestRequest request =
       GenerateConnectManifestRequest.newBuilder()
           .setName("name3373707")
           .setNamespace("namespace1252218203")
           .setProxy(ByteString.EMPTY)
           .setVersion("version351608024")
           .setIsUpgrade(true)
           .setRegistry("registry-690212803")
           .setImagePullSecretContent(ByteString.EMPTY)
           .build();
   ApiFuture<GenerateConnectManifestResponse> future =
       gkeHubClient.generateConnectManifestCallable().futureCall(request);
   // Do something.
   GenerateConnectManifestResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GenerateConnectManifestRequest,GenerateConnectManifestResponse>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getMembership(GetMembershipRequest request)

public final Membership getMembership(GetMembershipRequest request)

Gets the details of a Membership.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   GetMembershipRequest request =
       GetMembershipRequest.newBuilder()
           .setName(MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]").toString())
           .build();
   Membership response = gkeHubClient.getMembership(request);
 }
 
Parameter
NameDescription
requestGetMembershipRequest

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

Returns
TypeDescription
Membership

getMembership(MembershipName name)

public final Membership getMembership(MembershipName name)

Gets the details of a Membership.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   MembershipName name = MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]");
   Membership response = gkeHubClient.getMembership(name);
 }
 
Parameter
NameDescription
nameMembershipName

Required. The Membership resource name in the format projects/*/locations/*/memberships/*.

Returns
TypeDescription
Membership

getMembership(String name)

public final Membership getMembership(String name)

Gets the details of a Membership.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   String name = MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]").toString();
   Membership response = gkeHubClient.getMembership(name);
 }
 
Parameter
NameDescription
nameString

Required. The Membership resource name in the format projects/*/locations/*/memberships/*.

Returns
TypeDescription
Membership

getMembershipCallable()

public final UnaryCallable<GetMembershipRequest,Membership> getMembershipCallable()

Gets the details of a Membership.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   GetMembershipRequest request =
       GetMembershipRequest.newBuilder()
           .setName(MembershipName.of("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]").toString())
           .build();
   ApiFuture<Membership> future = gkeHubClient.getMembershipCallable().futureCall(request);
   // Do something.
   Membership response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetMembershipRequest,Membership>

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getSettings()

public final GkeHubSettings getSettings()
Returns
TypeDescription
GkeHubSettings

getStub()

public GkeHubStub getStub()
Returns
TypeDescription
GkeHubStub

initializeHub(InitializeHubRequest request)

public final InitializeHubResponse initializeHub(InitializeHubRequest request)

Initializes the Hub in this project, which includes creating the default Hub Service Account and the Hub Workload Identity Pool. Initialization is optional, and happens automatically when the first Membership is created.

InitializeHub should be called when the first Membership cannot be registered without these resources. A common example is granting the Hub Service Account access to another project, which requires the account to exist first.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   InitializeHubRequest request =
       InitializeHubRequest.newBuilder().setProject("project-309310695").build();
   InitializeHubResponse response = gkeHubClient.initializeHub(request);
 }
 
Parameter
NameDescription
requestInitializeHubRequest

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

Returns
TypeDescription
InitializeHubResponse

initializeHubCallable()

public final UnaryCallable<InitializeHubRequest,InitializeHubResponse> initializeHubCallable()

Initializes the Hub in this project, which includes creating the default Hub Service Account and the Hub Workload Identity Pool. Initialization is optional, and happens automatically when the first Membership is created.

InitializeHub should be called when the first Membership cannot be registered without these resources. A common example is granting the Hub Service Account access to another project, which requires the account to exist first.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   InitializeHubRequest request =
       InitializeHubRequest.newBuilder().setProject("project-309310695").build();
   ApiFuture<InitializeHubResponse> future =
       gkeHubClient.initializeHubCallable().futureCall(request);
   // Do something.
   InitializeHubResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<InitializeHubRequest,InitializeHubResponse>

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

listMemberships(ListMembershipsRequest request)

public final GkeHubClient.ListMembershipsPagedResponse listMemberships(ListMembershipsRequest request)

Lists Memberships in a given project and location.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   ListMembershipsRequest request =
       ListMembershipsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .build();
   for (Membership element : gkeHubClient.listMemberships(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListMembershipsRequest

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

Returns
TypeDescription
GkeHubClient.ListMembershipsPagedResponse

listMemberships(LocationName parent)

public final GkeHubClient.ListMembershipsPagedResponse listMemberships(LocationName parent)

Lists Memberships in a given project and location.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   for (Membership element : gkeHubClient.listMemberships(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentLocationName

Required. The parent (project and location) where the Memberships will be listed. Specified in the format projects/*/locations/*.

Returns
TypeDescription
GkeHubClient.ListMembershipsPagedResponse

listMemberships(String parent)

public final GkeHubClient.ListMembershipsPagedResponse listMemberships(String parent)

Lists Memberships in a given project and location.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   for (Membership element : gkeHubClient.listMemberships(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
parentString

Required. The parent (project and location) where the Memberships will be listed. Specified in the format projects/*/locations/*.

Returns
TypeDescription
GkeHubClient.ListMembershipsPagedResponse

listMembershipsCallable()

public final UnaryCallable<ListMembershipsRequest,ListMembershipsResponse> listMembershipsCallable()

Lists Memberships in a given project and location.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   ListMembershipsRequest request =
       ListMembershipsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .build();
   while (true) {
     ListMembershipsResponse response = gkeHubClient.listMembershipsCallable().call(request);
     for (Membership element : response.getResourcesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListMembershipsRequest,ListMembershipsResponse>

listMembershipsPagedCallable()

public final UnaryCallable<ListMembershipsRequest,GkeHubClient.ListMembershipsPagedResponse> listMembershipsPagedCallable()

Lists Memberships in a given project and location.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   ListMembershipsRequest request =
       ListMembershipsRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .build();
   ApiFuture<Membership> future =
       gkeHubClient.listMembershipsPagedCallable().futureCall(request);
   // Do something.
   for (Membership element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListMembershipsRequest,ListMembershipsPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateMembershipAsync(UpdateMembershipRequest request)

public final OperationFuture<Membership,OperationMetadata> updateMembershipAsync(UpdateMembershipRequest request)

Updates an existing Membership.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   UpdateMembershipRequest request =
       UpdateMembershipRequest.newBuilder()
           .setName("name3373707")
           .setUpdateMask(FieldMask.newBuilder().build())
           .setResource(Membership.newBuilder().build())
           .build();
   Membership response = gkeHubClient.updateMembershipAsync(request).get();
 }
 
Parameter
NameDescription
requestUpdateMembershipRequest

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

Returns
TypeDescription
OperationFuture<Membership,OperationMetadata>

updateMembershipAsync(String name, Membership resource, FieldMask updateMask)

public final OperationFuture<Membership,OperationMetadata> updateMembershipAsync(String name, Membership resource, FieldMask updateMask)

Updates an existing Membership.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   String name = "name3373707";
   Membership resource = Membership.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Membership response = gkeHubClient.updateMembershipAsync(name, resource, updateMask).get();
 }
 
Parameters
NameDescription
nameString

Required. The Membership resource name in the format projects/*/locations/*/memberships/*.

resourceMembership

Required. Only fields specified in update_mask are updated. If you specify a field in the update_mask but don't specify its value here that field will be deleted. If you are updating a map field, set the value of a key to null or empty string to delete the key from the map. It's not possible to update a key's value to the empty string. If you specify the update_mask to be a special path "*", fully replaces all user-modifiable fields to match resource.

updateMaskFieldMask

Required. Mask of fields to update.

Returns
TypeDescription
OperationFuture<Membership,OperationMetadata>

updateMembershipCallable()

public final UnaryCallable<UpdateMembershipRequest,Operation> updateMembershipCallable()

Updates an existing Membership.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   UpdateMembershipRequest request =
       UpdateMembershipRequest.newBuilder()
           .setName("name3373707")
           .setUpdateMask(FieldMask.newBuilder().build())
           .setResource(Membership.newBuilder().build())
           .build();
   ApiFuture<Operation> future = gkeHubClient.updateMembershipCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<UpdateMembershipRequest,Operation>

updateMembershipOperationCallable()

public final OperationCallable<UpdateMembershipRequest,Membership,OperationMetadata> updateMembershipOperationCallable()

Updates an existing Membership.

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 (GkeHubClient gkeHubClient = GkeHubClient.create()) {
   UpdateMembershipRequest request =
       UpdateMembershipRequest.newBuilder()
           .setName("name3373707")
           .setUpdateMask(FieldMask.newBuilder().build())
           .setResource(Membership.newBuilder().build())
           .build();
   OperationFuture<Membership, OperationMetadata> future =
       gkeHubClient.updateMembershipOperationCallable().futureCall(request);
   // Do something.
   Membership response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<UpdateMembershipRequest,Membership,OperationMetadata>