Class OsConfigZonalServiceClient (2.45.0)

GitHub RepositoryProduct Reference

Service Description: Zonal OS Config API

The OS Config service is the server-side component that allows users to manage package installations and patch jobs for Compute Engine VM 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 (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   OSPolicyAssignmentName name =
       OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]");
   OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name);
 }
 

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

CreateOSPolicyAssignment

Create an OS policy assignment.

This method also creates the first revision of the OS policy assignment.

This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO.

For more information, see Method: projects.locations.osPolicyAssignments.operations.cancel.

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

  • createOSPolicyAssignmentAsync(CreateOSPolicyAssignmentRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • createOSPolicyAssignmentAsync(LocationName parent, OSPolicyAssignment osPolicyAssignment, String osPolicyAssignmentId)

  • createOSPolicyAssignmentAsync(String parent, OSPolicyAssignment osPolicyAssignment, String osPolicyAssignmentId)

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

  • createOSPolicyAssignmentOperationCallable()

  • createOSPolicyAssignmentCallable()

UpdateOSPolicyAssignment

Update an existing OS policy assignment.

This method creates a new revision of the OS policy assignment.

This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO.

For more information, see Method: projects.locations.osPolicyAssignments.operations.cancel.

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

  • updateOSPolicyAssignmentAsync(UpdateOSPolicyAssignmentRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • updateOSPolicyAssignmentAsync(OSPolicyAssignment osPolicyAssignment, 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.

  • updateOSPolicyAssignmentOperationCallable()

  • updateOSPolicyAssignmentCallable()

GetOSPolicyAssignment

Retrieve an existing OS policy assignment.

This method always returns the latest revision. In order to retrieve a previous revision of the assignment, also provide the revision ID in the name parameter.

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

  • getOSPolicyAssignment(GetOSPolicyAssignmentRequest request)

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

  • getOSPolicyAssignment(OSPolicyAssignmentName name)

  • getOSPolicyAssignment(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.

  • getOSPolicyAssignmentCallable()

ListOSPolicyAssignments

List the OS policy assignments under the parent resource.

For each OS policy assignment, the latest revision is returned.

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

  • listOSPolicyAssignments(ListOSPolicyAssignmentsRequest request)

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

  • listOSPolicyAssignments(LocationName parent)

  • listOSPolicyAssignments(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.

  • listOSPolicyAssignmentsPagedCallable()

  • listOSPolicyAssignmentsCallable()

ListOSPolicyAssignmentRevisions

List the OS policy assignment revisions for a given OS policy assignment.

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

  • listOSPolicyAssignmentRevisions(ListOSPolicyAssignmentRevisionsRequest request)

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

  • listOSPolicyAssignmentRevisions(OSPolicyAssignmentName name)

  • listOSPolicyAssignmentRevisions(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.

  • listOSPolicyAssignmentRevisionsPagedCallable()

  • listOSPolicyAssignmentRevisionsCallable()

DeleteOSPolicyAssignment

Delete the OS policy assignment.

This method creates a new revision of the OS policy assignment.

This method returns a long running operation (LRO) that contains the rollout details. The rollout can be cancelled by cancelling the LRO.

If the LRO completes and is not cancelled, all revisions associated with the OS policy assignment are deleted.

For more information, see Method: projects.locations.osPolicyAssignments.operations.cancel.

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

  • deleteOSPolicyAssignmentAsync(DeleteOSPolicyAssignmentRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • deleteOSPolicyAssignmentAsync(OSPolicyAssignmentName name)

  • deleteOSPolicyAssignmentAsync(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.

  • deleteOSPolicyAssignmentOperationCallable()

  • deleteOSPolicyAssignmentCallable()

GetOSPolicyAssignmentReport

Get the OS policy asssignment report for the specified Compute Engine VM instance.

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

  • getOSPolicyAssignmentReport(GetOSPolicyAssignmentReportRequest request)

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

  • getOSPolicyAssignmentReport(OSPolicyAssignmentReportName name)

  • getOSPolicyAssignmentReport(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.

  • getOSPolicyAssignmentReportCallable()

ListOSPolicyAssignmentReports

List OS policy asssignment reports for all Compute Engine VM instances in the specified zone.

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

  • listOSPolicyAssignmentReports(ListOSPolicyAssignmentReportsRequest request)

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

  • listOSPolicyAssignmentReports(InstanceOSPolicyAssignmentName parent)

  • listOSPolicyAssignmentReports(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.

  • listOSPolicyAssignmentReportsPagedCallable()

  • listOSPolicyAssignmentReportsCallable()

GetInventory

Get inventory data for the specified VM instance. If the VM has no associated inventory, the message NOT_FOUND is returned.

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

  • getInventory(GetInventoryRequest request)

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

  • getInventory(InventoryName name)

  • getInventory(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.

  • getInventoryCallable()

ListInventories

List inventory data for all VM instances in the specified zone.

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

  • listInventories(ListInventoriesRequest request)

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

  • listInventories(InstanceName parent)

  • listInventories(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.

  • listInventoriesPagedCallable()

  • listInventoriesCallable()

GetVulnerabilityReport

Gets the vulnerability report for the specified VM instance. Only VMs with inventory data have vulnerability reports associated with them.

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

  • getVulnerabilityReport(GetVulnerabilityReportRequest request)

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

  • getVulnerabilityReport(VulnerabilityReportName name)

  • getVulnerabilityReport(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.

  • getVulnerabilityReportCallable()

ListVulnerabilityReports

List vulnerability reports for all VM instances in the specified zone.

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

  • listVulnerabilityReports(ListVulnerabilityReportsRequest request)

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

  • listVulnerabilityReports(InstanceName parent)

  • listVulnerabilityReports(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.

  • listVulnerabilityReportsPagedCallable()

  • listVulnerabilityReportsCallable()

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 OsConfigZonalServiceSettings 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
 OsConfigZonalServiceSettings osConfigZonalServiceSettings =
     OsConfigZonalServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create(osConfigZonalServiceSettings);
 

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
 OsConfigZonalServiceSettings osConfigZonalServiceSettings =
     OsConfigZonalServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create(osConfigZonalServiceSettings);
 

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
 OsConfigZonalServiceSettings osConfigZonalServiceSettings =
     OsConfigZonalServiceSettings.newHttpJsonBuilder().build();
 OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create(osConfigZonalServiceSettings);
 

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

Inheritance

java.lang.Object > OsConfigZonalServiceClient

Static Methods

create()

public static final OsConfigZonalServiceClient create()

Constructs an instance of OsConfigZonalServiceClient with default settings.

Returns
Type Description
OsConfigZonalServiceClient
Exceptions
Type Description
IOException

create(OsConfigZonalServiceSettings settings)

public static final OsConfigZonalServiceClient create(OsConfigZonalServiceSettings settings)

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