Class OsConfigZonalServiceClient (2.4.3)

public class OsConfigZonalServiceClient implements BackgroundResource

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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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().

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 OsConfigZonalServiceSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 OsConfigZonalServiceSettings osConfigZonalServiceSettings =
     OsConfigZonalServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create(osConfigZonalServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 OsConfigZonalServiceSettings osConfigZonalServiceSettings =
     OsConfigZonalServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create(osConfigZonalServiceSettings);
 

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

Inheritance

java.lang.Object > OsConfigZonalServiceClient

Implements

BackgroundResource

Static Methods

create()

public static final OsConfigZonalServiceClient create()

Constructs an instance of OsConfigZonalServiceClient with default settings.

Returns
TypeDescription
OsConfigZonalServiceClient
Exceptions
TypeDescription
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
NameDescription
settingsOsConfigZonalServiceSettings
Returns
TypeDescription
OsConfigZonalServiceClient
Exceptions
TypeDescription
IOException

create(OsConfigZonalServiceStub stub)

public static final OsConfigZonalServiceClient create(OsConfigZonalServiceStub stub)

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

Parameter
NameDescription
stubOsConfigZonalServiceStub
Returns
TypeDescription
OsConfigZonalServiceClient

Constructors

OsConfigZonalServiceClient(OsConfigZonalServiceSettings settings)

protected OsConfigZonalServiceClient(OsConfigZonalServiceSettings settings)

Constructs an instance of OsConfigZonalServiceClient, 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
settingsOsConfigZonalServiceSettings

OsConfigZonalServiceClient(OsConfigZonalServiceStub stub)

protected OsConfigZonalServiceClient(OsConfigZonalServiceStub stub)
Parameter
NameDescription
stubOsConfigZonalServiceStub

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

createOSPolicyAssignmentAsync(CreateOSPolicyAssignmentRequest request)

public final OperationFuture<OSPolicyAssignment,OSPolicyAssignmentOperationMetadata> createOSPolicyAssignmentAsync(CreateOSPolicyAssignmentRequest request)

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   CreateOSPolicyAssignmentRequest request =
       CreateOSPolicyAssignmentRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build())
           .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074")
           .build();
   OSPolicyAssignment response =
       osConfigZonalServiceClient.createOSPolicyAssignmentAsync(request).get();
 }
 
Parameter
NameDescription
requestCreateOSPolicyAssignmentRequest

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

Returns
TypeDescription
OperationFuture<OSPolicyAssignment,OSPolicyAssignmentOperationMetadata>

createOSPolicyAssignmentAsync(LocationName parent, OSPolicyAssignment osPolicyAssignment, String osPolicyAssignmentId)

public final OperationFuture<OSPolicyAssignment,OSPolicyAssignmentOperationMetadata> createOSPolicyAssignmentAsync(LocationName parent, OSPolicyAssignment osPolicyAssignment, String osPolicyAssignmentId)

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
   OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build();
   String osPolicyAssignmentId = "osPolicyAssignmentId-44079074";
   OSPolicyAssignment response =
       osConfigZonalServiceClient
           .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId)
           .get();
 }
 
Parameters
NameDescription
parentLocationName

Required. The parent resource name in the form: projects/{project}/locations/{location}

osPolicyAssignmentOSPolicyAssignment

Required. The OS policy assignment to be created.

osPolicyAssignmentIdString

Required. The logical name of the OS policy assignment in the project with the following restrictions:

  • Must contain only lowercase letters, numbers, and hyphens.
  • Must start with a letter.
  • Must be between 1-63 characters.
  • Must end with a number or a letter.
  • Must be unique within the project.

Returns
TypeDescription
OperationFuture<OSPolicyAssignment,OSPolicyAssignmentOperationMetadata>

createOSPolicyAssignmentAsync(String parent, OSPolicyAssignment osPolicyAssignment, String osPolicyAssignmentId)

public final OperationFuture<OSPolicyAssignment,OSPolicyAssignmentOperationMetadata> createOSPolicyAssignmentAsync(String parent, OSPolicyAssignment osPolicyAssignment, String osPolicyAssignmentId)

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
   OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build();
   String osPolicyAssignmentId = "osPolicyAssignmentId-44079074";
   OSPolicyAssignment response =
       osConfigZonalServiceClient
           .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId)
           .get();
 }
 
Parameters
NameDescription
parentString

Required. The parent resource name in the form: projects/{project}/locations/{location}

osPolicyAssignmentOSPolicyAssignment

Required. The OS policy assignment to be created.

osPolicyAssignmentIdString

Required. The logical name of the OS policy assignment in the project with the following restrictions:

  • Must contain only lowercase letters, numbers, and hyphens.
  • Must start with a letter.
  • Must be between 1-63 characters.
  • Must end with a number or a letter.
  • Must be unique within the project.

Returns
TypeDescription
OperationFuture<OSPolicyAssignment,OSPolicyAssignmentOperationMetadata>

createOSPolicyAssignmentCallable()

public final UnaryCallable<CreateOSPolicyAssignmentRequest,Operation> createOSPolicyAssignmentCallable()

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   CreateOSPolicyAssignmentRequest request =
       CreateOSPolicyAssignmentRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build())
           .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074")
           .build();
   ApiFuture<Operation> future =
       osConfigZonalServiceClient.createOSPolicyAssignmentCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<CreateOSPolicyAssignmentRequest,Operation>

createOSPolicyAssignmentOperationCallable()

public final OperationCallable<CreateOSPolicyAssignmentRequest,OSPolicyAssignment,OSPolicyAssignmentOperationMetadata> createOSPolicyAssignmentOperationCallable()

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   CreateOSPolicyAssignmentRequest request =
       CreateOSPolicyAssignmentRequest.newBuilder()
           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
           .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build())
           .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074")
           .build();
   OperationFuture<OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> future =
       osConfigZonalServiceClient
           .createOSPolicyAssignmentOperationCallable()
           .futureCall(request);
   // Do something.
   OSPolicyAssignment response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<CreateOSPolicyAssignmentRequest,OSPolicyAssignment,OSPolicyAssignmentOperationMetadata>

deleteOSPolicyAssignmentAsync(DeleteOSPolicyAssignmentRequest request)

public final OperationFuture<Empty,OSPolicyAssignmentOperationMetadata> deleteOSPolicyAssignmentAsync(DeleteOSPolicyAssignmentRequest request)

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   DeleteOSPolicyAssignmentRequest request =
       DeleteOSPolicyAssignmentRequest.newBuilder()
           .setName(
               OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]")
                   .toString())
           .build();
   osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteOSPolicyAssignmentRequest

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

Returns
TypeDescription
OperationFuture<Empty,OSPolicyAssignmentOperationMetadata>

deleteOSPolicyAssignmentAsync(OSPolicyAssignmentName name)

public final OperationFuture<Empty,OSPolicyAssignmentOperationMetadata> deleteOSPolicyAssignmentAsync(OSPolicyAssignmentName name)

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   OSPolicyAssignmentName name =
       OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]");
   osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get();
 }
 
Parameter
NameDescription
nameOSPolicyAssignmentName

Required. The name of the OS policy assignment to be deleted

Returns
TypeDescription
OperationFuture<Empty,OSPolicyAssignmentOperationMetadata>

deleteOSPolicyAssignmentAsync(String name)

public final OperationFuture<Empty,OSPolicyAssignmentOperationMetadata> deleteOSPolicyAssignmentAsync(String name)

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   String name =
       OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString();
   osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get();
 }
 
Parameter
NameDescription
nameString

Required. The name of the OS policy assignment to be deleted

Returns
TypeDescription
OperationFuture<Empty,OSPolicyAssignmentOperationMetadata>

deleteOSPolicyAssignmentCallable()

public final UnaryCallable<DeleteOSPolicyAssignmentRequest,Operation> deleteOSPolicyAssignmentCallable()

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   DeleteOSPolicyAssignmentRequest request =
       DeleteOSPolicyAssignmentRequest.newBuilder()
           .setName(
               OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]")
                   .toString())
           .build();
   ApiFuture<Operation> future =
       osConfigZonalServiceClient.deleteOSPolicyAssignmentCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteOSPolicyAssignmentRequest,Operation>

deleteOSPolicyAssignmentOperationCallable()

public final OperationCallable<DeleteOSPolicyAssignmentRequest,Empty,OSPolicyAssignmentOperationMetadata> deleteOSPolicyAssignmentOperationCallable()

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   DeleteOSPolicyAssignmentRequest request =
       DeleteOSPolicyAssignmentRequest.newBuilder()
           .setName(
               OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]")
                   .toString())
           .build();
   OperationFuture<Empty, OSPolicyAssignmentOperationMetadata> future =
       osConfigZonalServiceClient
           .deleteOSPolicyAssignmentOperationCallable()
           .futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
TypeDescription
OperationCallable<DeleteOSPolicyAssignmentRequest,Empty,OSPolicyAssignmentOperationMetadata>

getInstanceOSPoliciesCompliance(GetInstanceOSPoliciesComplianceRequest request) (deprecated)

public final InstanceOSPoliciesCompliance getInstanceOSPoliciesCompliance(GetInstanceOSPoliciesComplianceRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Get OS policies compliance data for the specified Compute Engine VM instance.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   GetInstanceOSPoliciesComplianceRequest request =
       GetInstanceOSPoliciesComplianceRequest.newBuilder()
           .setName(
               InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]")
                   .toString())
           .build();
   InstanceOSPoliciesCompliance response =
       osConfigZonalServiceClient.getInstanceOSPoliciesCompliance(request);
 }
 
Parameter
NameDescription
requestGetInstanceOSPoliciesComplianceRequest

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

Returns
TypeDescription
InstanceOSPoliciesCompliance

getInstanceOSPoliciesCompliance(InstanceOSPoliciesComplianceName name) (deprecated)

public final InstanceOSPoliciesCompliance getInstanceOSPoliciesCompliance(InstanceOSPoliciesComplianceName name)

Deprecated. This method is deprecated and will be removed in the next major version update.

Get OS policies compliance data for the specified Compute Engine VM instance.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   InstanceOSPoliciesComplianceName name =
       InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
   InstanceOSPoliciesCompliance response =
       osConfigZonalServiceClient.getInstanceOSPoliciesCompliance(name);
 }
 
Parameter
NameDescription
nameInstanceOSPoliciesComplianceName

Required. API resource name for instance OS policies compliance resource.

Format: projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}

For {project}, either Compute Engine project-number or project-id can be provided. For {instance}, either Compute Engine VM instance-id or instance-name can be provided.

Returns
TypeDescription
InstanceOSPoliciesCompliance

getInstanceOSPoliciesCompliance(String name) (deprecated)

public final InstanceOSPoliciesCompliance getInstanceOSPoliciesCompliance(String name)

Deprecated. This method is deprecated and will be removed in the next major version update.

Get OS policies compliance data for the specified Compute Engine VM instance.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   String name =
       InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
   InstanceOSPoliciesCompliance response =
       osConfigZonalServiceClient.getInstanceOSPoliciesCompliance(name);
 }
 
Parameter
NameDescription
nameString

Required. API resource name for instance OS policies compliance resource.

Format: projects/{project}/locations/{location}/instanceOSPoliciesCompliances/{instance}

For {project}, either Compute Engine project-number or project-id can be provided. For {instance}, either Compute Engine VM instance-id or instance-name can be provided.

Returns
TypeDescription
InstanceOSPoliciesCompliance

getInstanceOSPoliciesComplianceCallable() (deprecated)

public final UnaryCallable<GetInstanceOSPoliciesComplianceRequest,InstanceOSPoliciesCompliance> getInstanceOSPoliciesComplianceCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Get OS policies compliance data for the specified Compute Engine VM instance.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   GetInstanceOSPoliciesComplianceRequest request =
       GetInstanceOSPoliciesComplianceRequest.newBuilder()
           .setName(
               InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]")
                   .toString())
           .build();
   ApiFuture<InstanceOSPoliciesCompliance> future =
       osConfigZonalServiceClient.getInstanceOSPoliciesComplianceCallable().futureCall(request);
   // Do something.
   InstanceOSPoliciesCompliance response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetInstanceOSPoliciesComplianceRequest,InstanceOSPoliciesCompliance>

getInventory(GetInventoryRequest request)

public final Inventory getInventory(GetInventoryRequest request)

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

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   GetInventoryRequest request =
       GetInventoryRequest.newBuilder()
           .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
           .setView(InventoryView.forNumber(0))
           .build();
   Inventory response = osConfigZonalServiceClient.getInventory(request);
 }
 
Parameter
NameDescription
requestGetInventoryRequest

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

Returns
TypeDescription
Inventory

getInventory(InventoryName name)

public final Inventory getInventory(InventoryName name)

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

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
   Inventory response = osConfigZonalServiceClient.getInventory(name);
 }
 
Parameter
NameDescription
nameInventoryName

Required. API resource name for inventory resource.

Format: projects/{project}/locations/{location}/instances/{instance}/inventory

For {project}, either project-number or project-id can be provided. For {instance}, either Compute Engine instance-id or instance-name can be provided.

Returns
TypeDescription
Inventory

getInventory(String name)

public final Inventory getInventory(String name)

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

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   String name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString();
   Inventory response = osConfigZonalServiceClient.getInventory(name);
 }
 
Parameter
NameDescription
nameString

Required. API resource name for inventory resource.

Format: projects/{project}/locations/{location}/instances/{instance}/inventory

For {project}, either project-number or project-id can be provided. For {instance}, either Compute Engine instance-id or instance-name can be provided.

Returns
TypeDescription
Inventory

getInventoryCallable()

public final UnaryCallable<GetInventoryRequest,Inventory> getInventoryCallable()

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

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   GetInventoryRequest request =
       GetInventoryRequest.newBuilder()
           .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString())
           .setView(InventoryView.forNumber(0))
           .build();
   ApiFuture<Inventory> future =
       osConfigZonalServiceClient.getInventoryCallable().futureCall(request);
   // Do something.
   Inventory response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetInventoryRequest,Inventory>

getOSPolicyAssignment(GetOSPolicyAssignmentRequest request)

public final OSPolicyAssignment getOSPolicyAssignment(GetOSPolicyAssignmentRequest request)

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   GetOSPolicyAssignmentRequest request =
       GetOSPolicyAssignmentRequest.newBuilder()
           .setName(
               OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]")
                   .toString())
           .build();
   OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(request);
 }
 
Parameter
NameDescription
requestGetOSPolicyAssignmentRequest

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

Returns
TypeDescription
OSPolicyAssignment

getOSPolicyAssignment(OSPolicyAssignmentName name)

public final OSPolicyAssignment getOSPolicyAssignment(OSPolicyAssignmentName name)

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   OSPolicyAssignmentName name =
       OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]");
   OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name);
 }
 
Parameter
NameDescription
nameOSPolicyAssignmentName

Required. The resource name of OS policy assignment.

Format: projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}

Returns
TypeDescription
OSPolicyAssignment

getOSPolicyAssignment(String name)

public final OSPolicyAssignment getOSPolicyAssignment(String name)

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZonalServiceClient.create()) {
   String name =
       OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString();
   OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name);
 }
 
Parameter
NameDescription
nameString

Required. The resource name of OS policy assignment.

Format: projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}

Returns
TypeDescription
OSPolicyAssignment

getOSPolicyAssignmentCallable()

public final UnaryCallable<GetOSPolicyAssignmentRequest,OSPolicyAssignment> getOSPolicyAssignmentCallable()

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.

Sample code:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (OsConfigZonalServiceClient osConfigZonalServiceClient =
     OsConfigZon