- 2.56.0 (latest)
- 2.55.0
- 2.54.0
- 2.53.0
- 2.51.0
- 2.50.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.26.0
- 2.25.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.6
- 2.4.3
- 2.3.2
public class OsConfigServiceClient implements BackgroundResource
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().
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 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.
Implements
BackgroundResourceStatic Methods
create()
public static final OsConfigServiceClient create()
Constructs an instance of OsConfigServiceClient with default settings.
Returns | |
---|---|
Type | Description |
OsConfigServiceClient |
Exceptions | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
settings | OsConfigServiceSettings |
Returns | |
---|---|
Type | Description |
OsConfigServiceClient |
Exceptions | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
stub | OsConfigServiceStub |
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
settings | OsConfigServiceSettings |
OsConfigServiceClient(OsConfigServiceStub stub)
protected OsConfigServiceClient(OsConfigServiceStub stub)
Parameter | |
---|---|
Name | Description |
stub | OsConfigServiceStub |
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 |
cancelPatchJob(PatchJobs.CancelPatchJobRequest request)
public final PatchJobs.PatchJob cancelPatchJob(PatchJobs.CancelPatchJobRequest request)
Cancel a patch job. The patch job must be active. Canceled patch jobs cannot be restarted.
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 (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) {
PatchJobs.CancelPatchJobRequest request =
PatchJobs.CancelPatchJobRequest.newBuilder()
.setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString())
.build();
PatchJobs.PatchJob response = osConfigServiceClient.cancelPatchJob(request);
}
Parameter | |
---|---|
Name | Description |
request | PatchJobs.CancelPatchJobRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
PatchJobs.PatchJob |
cancelPatchJobCallable()
public final UnaryCallable<PatchJobs.CancelPatchJobRequest,PatchJobs.PatchJob> cancelPatchJobCallable()
Cancel a patch job. The patch job must be active. Canceled patch jobs cannot be restarted.
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 (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) {
PatchJobs.CancelPatchJobRequest request =
PatchJobs.CancelPatchJobRequest.newBuilder()
.setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString())
.build();
ApiFuture<PatchJobs.PatchJob> future =
osConfigServiceClient.cancelPatchJobCallable().futureCall(request);
// Do something.
PatchJobs.PatchJob response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CancelPatchJobRequest,PatchJob> |
close()
public final void close()
createPatchDeployment(PatchDeployments.CreatePatchDeploymentRequest request)
public final PatchDeployments.PatchDeployment createPatchDeployment(PatchDeployments.CreatePatchDeploymentRequest request)
Create an OS Config patch deployment.
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 (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) {
PatchDeployments.CreatePatchDeploymentRequest request =
PatchDeployments.CreatePatchDeploymentRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPatchDeploymentId("patchDeploymentId-1180405976")
.setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build())
.build();
PatchDeployments.PatchDeployment response =
osConfigServiceClient.createPatchDeployment(request);
}
Parameter | |
---|---|
Name | Description |
request | PatchDeployments.CreatePatchDeploymentRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
PatchDeployments.PatchDeployment |
createPatchDeployment(ProjectName parent, PatchDeployments.PatchDeployment patchDeployment, String patchDeploymentId)
public final PatchDeployments.PatchDeployment createPatchDeployment(ProjectName parent, PatchDeployments.PatchDeployment patchDeployment, String patchDeploymentId)
Create an OS Config patch deployment.
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 (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
PatchDeployments.PatchDeployment patchDeployment =
PatchDeployments.PatchDeployment.newBuilder().build();
String patchDeploymentId = "patchDeploymentId-1180405976";
PatchDeployments.PatchDeployment response =
osConfigServiceClient.createPatchDeployment(parent, patchDeployment, patchDeploymentId);
}
Parameters | |
---|---|
Name | Description |
parent | ProjectName Required. The project to apply this patch deployment to in the form
|
patchDeployment | PatchDeployments.PatchDeployment Required. The patch deployment to create. |
patchDeploymentId | String Required. A name for the patch deployment in the project. When creating a name the following rules apply:
|
Returns | |
---|---|
Type | Description |
PatchDeployments.PatchDeployment |
createPatchDeployment(String parent, PatchDeployments.PatchDeployment patchDeployment, String patchDeploymentId)
public final PatchDeployments.PatchDeployment createPatchDeployment(String parent, PatchDeployments.PatchDeployment patchDeployment, String patchDeploymentId)
Create an OS Config patch deployment.
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 (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
PatchDeployments.PatchDeployment patchDeployment =
PatchDeployments.PatchDeployment.newBuilder().build();
String patchDeploymentId = "patchDeploymentId-1180405976";
PatchDeployments.PatchDeployment response =
osConfigServiceClient.createPatchDeployment(parent, patchDeployment, patchDeploymentId);
}
Parameters | |
---|---|
Name | Description |
parent | String Required. The project to apply this patch deployment to in the form
|
patchDeployment | PatchDeployments.PatchDeployment Required. The patch deployment to create. |
patchDeploymentId | String Required. A name for the patch deployment in the project. When creating a name the following rules apply:
|
Returns | |
---|---|
Type | Description |
PatchDeployments.PatchDeployment |
createPatchDeploymentCallable()
public final UnaryCallable<PatchDeployments.CreatePatchDeploymentRequest,PatchDeployments.PatchDeployment> createPatchDeploymentCallable()
Create an OS Config patch deployment.
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 (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) {
PatchDeployments.CreatePatchDeploymentRequest request =
PatchDeployments.CreatePatchDeploymentRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPatchDeploymentId("patchDeploymentId-1180405976")
.setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build())
.build();
ApiFuture<PatchDeployments.PatchDeployment> future =
osConfigServiceClient.createPatchDeploymentCallable().futureCall(request);
// Do something.
PatchDeployments.PatchDeployment response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CreatePatchDeploymentRequest,PatchDeployment> |
deletePatchDeployment(PatchDeploymentName name)
public final void deletePatchDeployment(PatchDeploymentName name)
Delete an OS Config patch deployment.
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 (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) {
PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]");
osConfigServiceClient.deletePatchDeployment(name);
}
Parameter | |
---|---|
Name | Description |
name | PatchDeploymentName Required. The resource name of the patch deployment in the form
|
deletePatchDeployment(PatchDeployments.DeletePatchDeploymentRequest request)
public final void deletePatchDeployment(PatchDeployments.DeletePatchDeploymentRequest request)
Delete an OS Config patch deployment.
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 (OsConfig