Google Cloud OsConfig V1 Client - Class OsConfigZonalServiceClient (2.0.1)

Reference documentation and code samples for the Google Cloud OsConfig V1 Client class OsConfigZonalServiceClient.

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.

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 parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Cloud \ OsConfig \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

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.

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::createOSPolicyAssignmentAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\CreateOSPolicyAssignmentRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\CreateOSPolicyAssignmentRequest;
use Google\Cloud\OsConfig\V1\FixedOrPercent;
use Google\Cloud\OsConfig\V1\OSPolicy;
use Google\Cloud\OsConfig\V1\OSPolicyAssignment;
use Google\Cloud\OsConfig\V1\OSPolicyAssignment\InstanceFilter;
use Google\Cloud\OsConfig\V1\OSPolicyAssignment\Rollout;
use Google\Cloud\OsConfig\V1\OSPolicy\Mode;
use Google\Cloud\OsConfig\V1\OSPolicy\Resource;
use Google\Cloud\OsConfig\V1\OSPolicy\ResourceGroup;
use Google\Protobuf\Duration;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                                       The parent resource name in the form:
 *                                                                      projects/{project}/locations/{location}
 *                                                                      Please see {@see OsConfigZonalServiceClient::locationName()} for help formatting this field.
 * @param string $osPolicyAssignmentOsPoliciesId                        The id of the OS policy 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 assignment.
 * @param int    $osPolicyAssignmentOsPoliciesMode                      Policy mode
 * @param string $osPolicyAssignmentOsPoliciesResourceGroupsResourcesId The id of the resource 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 OS policy.
 * @param string $osPolicyAssignmentId                                  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.
 */
function create_os_policy_assignment_sample(
    string $formattedParent,
    string $osPolicyAssignmentOsPoliciesId,
    int $osPolicyAssignmentOsPoliciesMode,
    string $osPolicyAssignmentOsPoliciesResourceGroupsResourcesId,
    string $osPolicyAssignmentId
): void {
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $resource = (new Resource())
        ->setId($osPolicyAssignmentOsPoliciesResourceGroupsResourcesId);
    $osPolicyAssignmentOsPoliciesResourceGroupsResources = [$resource,];
    $resourceGroup = (new ResourceGroup())
        ->setResources($osPolicyAssignmentOsPoliciesResourceGroupsResources);
    $osPolicyAssignmentOsPoliciesResourceGroups = [$resourceGroup,];
    $oSPolicy = (new OSPolicy())
        ->setId($osPolicyAssignmentOsPoliciesId)
        ->setMode($osPolicyAssignmentOsPoliciesMode)
        ->setResourceGroups($osPolicyAssignmentOsPoliciesResourceGroups);
    $osPolicyAssignmentOsPolicies = [$oSPolicy,];
    $osPolicyAssignmentInstanceFilter = new InstanceFilter();
    $osPolicyAssignmentRolloutDisruptionBudget = new FixedOrPercent();
    $osPolicyAssignmentRolloutMinWaitDuration = new Duration();
    $osPolicyAssignmentRollout = (new Rollout())
        ->setDisruptionBudget($osPolicyAssignmentRolloutDisruptionBudget)
        ->setMinWaitDuration($osPolicyAssignmentRolloutMinWaitDuration);
    $osPolicyAssignment = (new OSPolicyAssignment())
        ->setOsPolicies($osPolicyAssignmentOsPolicies)
        ->setInstanceFilter($osPolicyAssignmentInstanceFilter)
        ->setRollout($osPolicyAssignmentRollout);
    $request = (new CreateOSPolicyAssignmentRequest())
        ->setParent($formattedParent)
        ->setOsPolicyAssignment($osPolicyAssignment)
        ->setOsPolicyAssignmentId($osPolicyAssignmentId);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $osConfigZonalServiceClient->createOSPolicyAssignment($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var OSPolicyAssignment $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = OsConfigZonalServiceClient::locationName('[PROJECT]', '[LOCATION]');
    $osPolicyAssignmentOsPoliciesId = '[ID]';
    $osPolicyAssignmentOsPoliciesMode = Mode::MODE_UNSPECIFIED;
    $osPolicyAssignmentOsPoliciesResourceGroupsResourcesId = '[ID]';
    $osPolicyAssignmentId = '[OS_POLICY_ASSIGNMENT_ID]';

    create_os_policy_assignment_sample(
        $formattedParent,
        $osPolicyAssignmentOsPoliciesId,
        $osPolicyAssignmentOsPoliciesMode,
        $osPolicyAssignmentOsPoliciesResourceGroupsResourcesId,
        $osPolicyAssignmentId
    );
}

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.

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::deleteOSPolicyAssignmentAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\DeleteOSPolicyAssignmentRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\DeleteOSPolicyAssignmentRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the OS policy assignment to be deleted
 *                              Please see {@see OsConfigZonalServiceClient::oSPolicyAssignmentName()} for help formatting this field.
 */
function delete_os_policy_assignment_sample(string $formattedName): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new DeleteOSPolicyAssignmentRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $osConfigZonalServiceClient->deleteOSPolicyAssignment($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = OsConfigZonalServiceClient::oSPolicyAssignmentName(
        '[PROJECT]',
        '[LOCATION]',
        '[OS_POLICY_ASSIGNMENT]'
    );

    delete_os_policy_assignment_sample($formattedName);
}

getInventory

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

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::getInventoryAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\GetInventoryRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\OsConfig\V1\Inventory
Example
use Google\ApiCore\ApiException;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\GetInventoryRequest;
use Google\Cloud\OsConfig\V1\Inventory;

/**
 * @param string $formattedName 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. Please see
 *                              {@see OsConfigZonalServiceClient::inventoryName()} for help formatting this field.
 */
function get_inventory_sample(string $formattedName): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new GetInventoryRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Inventory $response */
        $response = $osConfigZonalServiceClient->getInventory($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = OsConfigZonalServiceClient::inventoryName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

    get_inventory_sample($formattedName);
}

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.

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::getOSPolicyAssignmentAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\GetOSPolicyAssignmentRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\OsConfig\V1\OSPolicyAssignment
Example
use Google\ApiCore\ApiException;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\GetOSPolicyAssignmentRequest;
use Google\Cloud\OsConfig\V1\OSPolicyAssignment;

/**
 * @param string $formattedName The resource name of OS policy assignment.
 *
 *                              Format:
 *                              `projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}@{revisionId}`
 *                              Please see {@see OsConfigZonalServiceClient::oSPolicyAssignmentName()} for help formatting this field.
 */
function get_os_policy_assignment_sample(string $formattedName): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new GetOSPolicyAssignmentRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OSPolicyAssignment $response */
        $response = $osConfigZonalServiceClient->getOSPolicyAssignment($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = OsConfigZonalServiceClient::oSPolicyAssignmentName(
        '[PROJECT]',
        '[LOCATION]',
        '[OS_POLICY_ASSIGNMENT]'
    );

    get_os_policy_assignment_sample($formattedName);
}

getOSPolicyAssignmentReport

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

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::getOSPolicyAssignmentReportAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\GetOSPolicyAssignmentReportRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\OsConfig\V1\OSPolicyAssignmentReport
Example
use Google\ApiCore\ApiException;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\GetOSPolicyAssignmentReportRequest;
use Google\Cloud\OsConfig\V1\OSPolicyAssignmentReport;

/**
 * @param string $formattedName API resource name for OS policy assignment report.
 *
 *                              Format:
 *                              `/projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report`
 *
 *                              For `{project}`, either `project-number` or `project-id` can be provided.
 *                              For `{instance_id}`, either Compute Engine `instance-id` or `instance-name`
 *                              can be provided.
 *                              For `{assignment_id}`, the OSPolicyAssignment id must be provided. Please see
 *                              {@see OsConfigZonalServiceClient::oSPolicyAssignmentReportName()} for help formatting this field.
 */
function get_os_policy_assignment_report_sample(string $formattedName): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new GetOSPolicyAssignmentReportRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OSPolicyAssignmentReport $response */
        $response = $osConfigZonalServiceClient->getOSPolicyAssignmentReport($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = OsConfigZonalServiceClient::oSPolicyAssignmentReportName(
        '[PROJECT]',
        '[LOCATION]',
        '[INSTANCE]',
        '[ASSIGNMENT]'
    );

    get_os_policy_assignment_report_sample($formattedName);
}

getVulnerabilityReport

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

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::getVulnerabilityReportAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\GetVulnerabilityReportRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\OsConfig\V1\VulnerabilityReport
Example
use Google\ApiCore\ApiException;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\GetVulnerabilityReportRequest;
use Google\Cloud\OsConfig\V1\VulnerabilityReport;

/**
 * @param string $formattedName API resource name for vulnerability resource.
 *
 *                              Format:
 *                              `projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport`
 *
 *                              For `{project}`, either `project-number` or `project-id` can be provided.
 *                              For `{instance}`, either Compute Engine `instance-id` or `instance-name`
 *                              can be provided. Please see
 *                              {@see OsConfigZonalServiceClient::vulnerabilityReportName()} for help formatting this field.
 */
function get_vulnerability_report_sample(string $formattedName): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new GetVulnerabilityReportRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var VulnerabilityReport $response */
        $response = $osConfigZonalServiceClient->getVulnerabilityReport($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = OsConfigZonalServiceClient::vulnerabilityReportName(
        '[PROJECT]',
        '[LOCATION]',
        '[INSTANCE]'
    );

    get_vulnerability_report_sample($formattedName);
}

listInventories

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

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::listInventoriesAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListInventoriesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\Inventory;
use Google\Cloud\OsConfig\V1\ListInventoriesRequest;

/**
 * @param string $formattedParent The parent resource name.
 *
 *                                Format: `projects/{project}/locations/{location}/instances/-`
 *
 *                                For `{project}`, either `project-number` or `project-id` can be provided. Please see
 *                                {@see OsConfigZonalServiceClient::instanceName()} for help formatting this field.
 */
function list_inventories_sample(string $formattedParent): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new ListInventoriesRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $osConfigZonalServiceClient->listInventories($request);

        /** @var Inventory $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = OsConfigZonalServiceClient::instanceName('[PROJECT]', '[ZONE]', '[INSTANCE]');

    list_inventories_sample($formattedParent);
}

listOSPolicyAssignmentReports

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

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::listOSPolicyAssignmentReportsAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentReportsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentReportsRequest;
use Google\Cloud\OsConfig\V1\OSPolicyAssignmentReport;

/**
 * @param string $formattedParent The parent resource name.
 *
 *                                Format:
 *                                `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/reports`
 *
 *                                For `{project}`, either `project-number` or `project-id` can be provided.
 *                                For `{instance}`, either `instance-name`, `instance-id`, or `-` can be
 *                                provided. If '-' is provided, the response will include
 *                                OSPolicyAssignmentReports for all instances in the project/location.
 *                                For `{assignment}`, either `assignment-id` or `-` can be provided. If '-'
 *                                is provided, the response will include OSPolicyAssignmentReports for all
 *                                OSPolicyAssignments in the project/location.
 *                                Either {instance} or {assignment} must be `-`.
 *
 *                                For example:
 *                                `projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/-/reports`
 *                                returns all reports for the instance
 *                                `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/{assignment-id}/reports`
 *                                returns all the reports for the given assignment across all instances.
 *                                `projects/{project}/locations/{location}/instances/-/osPolicyAssignments/-/reports`
 *                                returns all the reports for all assignments across all instances. Please see
 *                                {@see OsConfigZonalServiceClient::instanceOSPolicyAssignmentName()} for help formatting this field.
 */
function list_os_policy_assignment_reports_sample(string $formattedParent): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new ListOSPolicyAssignmentReportsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $osConfigZonalServiceClient->listOSPolicyAssignmentReports($request);

        /** @var OSPolicyAssignmentReport $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = OsConfigZonalServiceClient::instanceOSPolicyAssignmentName(
        '[PROJECT]',
        '[LOCATION]',
        '[INSTANCE]',
        '[ASSIGNMENT]'
    );

    list_os_policy_assignment_reports_sample($formattedParent);
}

listOSPolicyAssignmentRevisions

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

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::listOSPolicyAssignmentRevisionsAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentRevisionsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentRevisionsRequest;
use Google\Cloud\OsConfig\V1\OSPolicyAssignment;

/**
 * @param string $formattedName The name of the OS policy assignment to list revisions for. Please see
 *                              {@see OsConfigZonalServiceClient::oSPolicyAssignmentName()} for help formatting this field.
 */
function list_os_policy_assignment_revisions_sample(string $formattedName): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new ListOSPolicyAssignmentRevisionsRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $osConfigZonalServiceClient->listOSPolicyAssignmentRevisions($request);

        /** @var OSPolicyAssignment $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = OsConfigZonalServiceClient::oSPolicyAssignmentName(
        '[PROJECT]',
        '[LOCATION]',
        '[OS_POLICY_ASSIGNMENT]'
    );

    list_os_policy_assignment_revisions_sample($formattedName);
}

listOSPolicyAssignments

List the OS policy assignments under the parent resource.

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

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::listOSPolicyAssignmentsAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentsRequest;
use Google\Cloud\OsConfig\V1\OSPolicyAssignment;

/**
 * @param string $formattedParent The parent resource name. Please see
 *                                {@see OsConfigZonalServiceClient::locationName()} for help formatting this field.
 */
function list_os_policy_assignments_sample(string $formattedParent): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new ListOSPolicyAssignmentsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $osConfigZonalServiceClient->listOSPolicyAssignments($request);

        /** @var OSPolicyAssignment $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = OsConfigZonalServiceClient::locationName('[PROJECT]', '[LOCATION]');

    list_os_policy_assignments_sample($formattedParent);
}

listVulnerabilityReports

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

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::listVulnerabilityReportsAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListVulnerabilityReportsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\ListVulnerabilityReportsRequest;
use Google\Cloud\OsConfig\V1\VulnerabilityReport;

/**
 * @param string $formattedParent The parent resource name.
 *
 *                                Format: `projects/{project}/locations/{location}/instances/-`
 *
 *                                For `{project}`, either `project-number` or `project-id` can be provided. Please see
 *                                {@see OsConfigZonalServiceClient::instanceName()} for help formatting this field.
 */
function list_vulnerability_reports_sample(string $formattedParent): void
{
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $request = (new ListVulnerabilityReportsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $osConfigZonalServiceClient->listVulnerabilityReports($request);

        /** @var VulnerabilityReport $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = OsConfigZonalServiceClient::instanceName('[PROJECT]', '[ZONE]', '[INSTANCE]');

    list_vulnerability_reports_sample($formattedParent);
}

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.

The async variant is Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient::updateOSPolicyAssignmentAsync() .

Parameters
Name Description
request Google\Cloud\OsConfig\V1\UpdateOSPolicyAssignmentRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\OsConfig\V1\Client\OsConfigZonalServiceClient;
use Google\Cloud\OsConfig\V1\FixedOrPercent;
use Google\Cloud\OsConfig\V1\OSPolicy;
use Google\Cloud\OsConfig\V1\OSPolicyAssignment;
use Google\Cloud\OsConfig\V1\OSPolicyAssignment\InstanceFilter;
use Google\Cloud\OsConfig\V1\OSPolicyAssignment\Rollout;
use Google\Cloud\OsConfig\V1\OSPolicy\Mode;
use Google\Cloud\OsConfig\V1\OSPolicy\Resource;
use Google\Cloud\OsConfig\V1\OSPolicy\ResourceGroup;
use Google\Cloud\OsConfig\V1\UpdateOSPolicyAssignmentRequest;
use Google\Protobuf\Duration;
use Google\Rpc\Status;

/**
 * @param string $osPolicyAssignmentOsPoliciesId                        The id of the OS policy 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 assignment.
 * @param int    $osPolicyAssignmentOsPoliciesMode                      Policy mode
 * @param string $osPolicyAssignmentOsPoliciesResourceGroupsResourcesId The id of the resource 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 OS policy.
 */
function update_os_policy_assignment_sample(
    string $osPolicyAssignmentOsPoliciesId,
    int $osPolicyAssignmentOsPoliciesMode,
    string $osPolicyAssignmentOsPoliciesResourceGroupsResourcesId
): void {
    // Create a client.
    $osConfigZonalServiceClient = new OsConfigZonalServiceClient();

    // Prepare the request message.
    $resource = (new Resource())
        ->setId($osPolicyAssignmentOsPoliciesResourceGroupsResourcesId);
    $osPolicyAssignmentOsPoliciesResourceGroupsResources = [$resource,];
    $resourceGroup = (new ResourceGroup())
        ->setResources($osPolicyAssignmentOsPoliciesResourceGroupsResources);
    $osPolicyAssignmentOsPoliciesResourceGroups = [$resourceGroup,];
    $oSPolicy = (new OSPolicy())
        ->setId($osPolicyAssignmentOsPoliciesId)
        ->setMode($osPolicyAssignmentOsPoliciesMode)
        ->setResourceGroups($osPolicyAssignmentOsPoliciesResourceGroups);
    $osPolicyAssignmentOsPolicies = [$oSPolicy,];
    $osPolicyAssignmentInstanceFilter = new InstanceFilter();
    $osPolicyAssignmentRolloutDisruptionBudget = new FixedOrPercent();
    $osPolicyAssignmentRolloutMinWaitDuration = new Duration();
    $osPolicyAssignmentRollout = (new Rollout())
        ->setDisruptionBudget($osPolicyAssignmentRolloutDisruptionBudget)
        ->setMinWaitDuration($osPolicyAssignmentRolloutMinWaitDuration);
    $osPolicyAssignment = (new OSPolicyAssignment())
        ->setOsPolicies($osPolicyAssignmentOsPolicies)
        ->setInstanceFilter($osPolicyAssignmentInstanceFilter)
        ->setRollout($osPolicyAssignmentRollout);
    $request = (new UpdateOSPolicyAssignmentRequest())
        ->setOsPolicyAssignment($osPolicyAssignment);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $osConfigZonalServiceClient->updateOSPolicyAssignment($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var OSPolicyAssignment $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $osPolicyAssignmentOsPoliciesId = '[ID]';
    $osPolicyAssignmentOsPoliciesMode = Mode::MODE_UNSPECIFIED;
    $osPolicyAssignmentOsPoliciesResourceGroupsResourcesId = '[ID]';

    update_os_policy_assignment_sample(
        $osPolicyAssignmentOsPoliciesId,
        $osPolicyAssignmentOsPoliciesMode,
        $osPolicyAssignmentOsPoliciesResourceGroupsResourcesId
    );
}

createOSPolicyAssignmentAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\CreateOSPolicyAssignmentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteOSPolicyAssignmentAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\DeleteOSPolicyAssignmentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getInventoryAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\GetInventoryRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\OsConfig\V1\Inventory>

getOSPolicyAssignmentAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\GetOSPolicyAssignmentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\OsConfig\V1\OSPolicyAssignment>

getOSPolicyAssignmentReportAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\GetOSPolicyAssignmentReportRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\OsConfig\V1\OSPolicyAssignmentReport>

getVulnerabilityReportAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\GetVulnerabilityReportRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\OsConfig\V1\VulnerabilityReport>

listInventoriesAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListInventoriesRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listOSPolicyAssignmentReportsAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentReportsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listOSPolicyAssignmentRevisionsAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentRevisionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listOSPolicyAssignmentsAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListOSPolicyAssignmentsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listVulnerabilityReportsAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\ListVulnerabilityReportsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

updateOSPolicyAssignmentAsync

Parameters
Name Description
request Google\Cloud\OsConfig\V1\UpdateOSPolicyAssignmentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::instanceName

Formats a string containing the fully-qualified path to represent a instance resource.

Parameters
Name Description
project string
zone string
instance string
Returns
Type Description
string The formatted instance resource.

static::instanceOSPolicyAssignmentName

Formats a string containing the fully-qualified path to represent a instance_os_policy_assignment resource.

Parameters
Name Description
project string
location string
instance string
assignment string
Returns
Type Description
string The formatted instance_os_policy_assignment resource.

static::inventoryName

Formats a string containing the fully-qualified path to represent a inventory resource.

Parameters
Name Description
project string
location string
instance string
Returns
Type Description
string The formatted inventory resource.

static::locationName

Formats a string containing the fully-qualified path to represent a location resource.

Parameters
Name Description
project string
location string
Returns
Type Description
string The formatted location resource.

static::oSPolicyAssignmentName

Formats a string containing the fully-qualified path to represent a os_policy_assignment resource.

Parameters
Name Description
project string
location string
osPolicyAssignment string
Returns
Type Description
string The formatted os_policy_assignment resource.

static::oSPolicyAssignmentReportName

Formats a string containing the fully-qualified path to represent a os_policy_assignment_report resource.

Parameters
Name Description
project string
location string
instance string
assignment string
Returns
Type Description
string The formatted os_policy_assignment_report resource.

static::projectLocationInstanceName

Formats a string containing the fully-qualified path to represent a project_location_instance resource.

Parameters
Name Description
project string
location string
instance string
Returns
Type Description
string The formatted project_location_instance resource.

static::projectZoneInstanceName

Formats a string containing the fully-qualified path to represent a project_zone_instance resource.

Parameters
Name Description
project string
zone string
instance string
Returns
Type Description
string The formatted project_zone_instance resource.

static::vulnerabilityReportName

Formats a string containing the fully-qualified path to represent a vulnerability_report resource.

Parameters
Name Description
project string
location string
instance string
Returns
Type Description
string The formatted vulnerability_report resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • instance: projects/{project}/zones/{zone}/instances/{instance}
  • instanceOSPolicyAssignment: projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}
  • inventory: projects/{project}/locations/{location}/instances/{instance}/inventory
  • location: projects/{project}/locations/{location}
  • oSPolicyAssignment: projects/{project}/locations/{location}/osPolicyAssignments/{os_policy_assignment}
  • oSPolicyAssignmentReport: projects/{project}/locations/{location}/instances/{instance}/osPolicyAssignments/{assignment}/report
  • projectLocationInstance: projects/{project}/locations/{location}/instances/{instance}
  • projectZoneInstance: projects/{project}/zones/{zone}/instances/{instance}
  • vulnerabilityReport: projects/{project}/locations/{location}/instances/{instance}/vulnerabilityReport

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.