Class OsConfigServiceClient (2.42.0)

GitHub RepositoryProduct Reference

Service Description: OS Config API

The OS Config service is a server-side component that you can use to manage package installations and patch jobs for virtual machine instances.

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 (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) {
   PatchJobs.ExecutePatchJobRequest request =
       PatchJobs.ExecutePatchJobRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setDescription("description-1724546052")
           .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build())
           .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build())
           .setDuration(Duration.newBuilder().build())
           .setDryRun(true)
           .setDisplayName("displayName1714148973")
           .setRollout(PatchJobs.PatchRollout.newBuilder().build())
           .build();
   PatchJobs.PatchJob response = osConfigServiceClient.executePatchJob(request);
 }
 

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

Methods
MethodDescriptionMethod Variants

ExecutePatchJob

Patch VM instances by creating and running a patch job.

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

  • executePatchJob(PatchJobs.ExecutePatchJobRequest request)

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

  • executePatchJobCallable()

GetPatchJob

Get the patch job. This can be used to track the progress of an ongoing patch job or review the details of completed jobs.

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

  • getPatchJob(PatchJobs.GetPatchJobRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getPatchJob(PatchJobName name)

  • getPatchJob(String name)

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

  • getPatchJobCallable()

CancelPatchJob

Cancel a patch job. The patch job must be active. Canceled patch jobs cannot be restarted.

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

  • cancelPatchJob(PatchJobs.CancelPatchJobRequest request)

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

  • cancelPatchJobCallable()

ListPatchJobs

Get a list of patch jobs.

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

  • listPatchJobs(PatchJobs.ListPatchJobsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listPatchJobs(ProjectName parent)

  • listPatchJobs(String parent)

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

  • listPatchJobsPagedCallable()

  • listPatchJobsCallable()

ListPatchJobInstanceDetails

Get a list of instance details for a given patch job.

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

  • listPatchJobInstanceDetails(PatchJobs.ListPatchJobInstanceDetailsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listPatchJobInstanceDetails(PatchJobName parent)

  • listPatchJobInstanceDetails(String parent)

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

  • listPatchJobInstanceDetailsPagedCallable()

  • listPatchJobInstanceDetailsCallable()

CreatePatchDeployment

Create an OS Config patch deployment.

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

  • createPatchDeployment(PatchDeployments.CreatePatchDeploymentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createPatchDeployment(ProjectName parent, PatchDeployments.PatchDeployment patchDeployment, String patchDeploymentId)

  • createPatchDeployment(String parent, PatchDeployments.PatchDeployment patchDeployment, String patchDeploymentId)

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

  • createPatchDeploymentCallable()

GetPatchDeployment

Get an OS Config patch deployment.

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

  • getPatchDeployment(PatchDeployments.GetPatchDeploymentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getPatchDeployment(PatchDeploymentName name)

  • getPatchDeployment(String name)

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

  • getPatchDeploymentCallable()

ListPatchDeployments

Get a page of OS Config patch deployments.

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

  • listPatchDeployments(PatchDeployments.ListPatchDeploymentsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listPatchDeployments(ProjectName parent)

  • listPatchDeployments(String parent)

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

  • listPatchDeploymentsPagedCallable()

  • listPatchDeploymentsCallable()

DeletePatchDeployment

Delete an OS Config patch deployment.

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

  • deletePatchDeployment(PatchDeployments.DeletePatchDeploymentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deletePatchDeployment(PatchDeploymentName name)

  • deletePatchDeployment(String name)

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

  • deletePatchDeploymentCallable()

UpdatePatchDeployment

Update an OS Config patch deployment.

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

  • updatePatchDeployment(PatchDeployments.UpdatePatchDeploymentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updatePatchDeployment(PatchDeployments.PatchDeployment patchDeployment, FieldMask updateMask)

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

  • updatePatchDeploymentCallable()

PausePatchDeployment

Change state of patch deployment to "PAUSED". Patch deployment in paused state doesn't generate patch jobs.

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

  • pausePatchDeployment(PatchDeployments.PausePatchDeploymentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • pausePatchDeployment(PatchDeploymentName name)

  • pausePatchDeployment(String name)

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

  • pausePatchDeploymentCallable()

ResumePatchDeployment

Change state of patch deployment back to "ACTIVE". Patch deployment in active state continues to generate patch jobs.

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

  • resumePatchDeployment(PatchDeployments.ResumePatchDeploymentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • resumePatchDeployment(PatchDeploymentName name)

  • resumePatchDeployment(String name)

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

  • resumePatchDeploymentCallable()

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 OsConfigServiceSettings 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
 OsConfigServiceSettings osConfigServiceSettings =
     OsConfigServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 OsConfigServiceClient osConfigServiceClient =
     OsConfigServiceClient.create(osConfigServiceSettings);
 

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
 OsConfigServiceSettings osConfigServiceSettings =
     OsConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 OsConfigServiceClient osConfigServiceClient =
     OsConfigServiceClient.create(osConfigServiceSettings);
 

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
 OsConfigServiceSettings osConfigServiceSettings =
     OsConfigServiceSettings.newHttpJsonBuilder().build();
 OsConfigServiceClient osConfigServiceClient =
     OsConfigServiceClient.create(osConfigServiceSettings);
 

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

Inheritance

java.lang.Object > OsConfigServiceClient

Static Methods

create()

public static final OsConfigServiceClient create()

Constructs an instance of OsConfigServiceClient with default settings.

Returns
TypeDescription
OsConfigServiceClient
Exceptions
TypeDescription
IOException

create(OsConfigServiceSettings settings)

public static final OsConfigServiceClient create(OsConfigServiceSettings settings)

Constructs an instance of OsConfigServiceClient, 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
settingsOsConfigServiceSettings
Returns
TypeDescription
OsConfigServiceClient
Exceptions
TypeDescription
IOException

create(OsConfigServiceStub stub)

public static final OsConfigServiceClient create(OsConfigServiceStub stub)

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

Parameter
NameDescription
stubOsConfigServiceStub
Returns
TypeDescription
OsConfigServiceClient

Constructors

OsConfigServiceClient(OsConfigServiceSettings settings)

protected OsConfigServiceClient(OsConfigServiceSettings settings)

Constructs an instance of OsConfigServiceClient, 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
settingsOsConfigServiceSettings

OsConfigServiceClient(OsConfigServiceStub stub)

protected OsConfigServiceClient(OsConfigServiceStub stub)
Parameter
NameDescription
stubOsConfigServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unit