Compute V1 Client - Class FirewallPoliciesClient (1.34.0)

Reference documentation and code samples for the Compute V1 Client class FirewallPoliciesClient.

Service Description: The FirewallPolicies API.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Namespace

Google \ Cloud \ Compute \ 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. Important : If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ 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. At the moment, supports only rest . 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 = [ 'rest' => [...], ]; See the Google\ApiCore\Transport\RestTransport::build() method 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.

↳ logger
false|LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

addAssociation

Inserts an association for the specified firewall policy.

The async variant is FirewallPoliciesClient::addAssociationAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\AddAssociationFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\AddAssociationFirewallPolicyRequest;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\FirewallPolicyAssociation;
use Google\Rpc\Status;

/**
 * @param string $firewallPolicy Name of the firewall policy to update.
 */
function add_association_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $firewallPolicyAssociationResource = new FirewallPolicyAssociation();
    $request = (new AddAssociationFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy)
        ->setFirewallPolicyAssociationResource($firewallPolicyAssociationResource);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->addAssociation($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    add_association_sample($firewallPolicy);
} 

addRule

Inserts a rule into a firewall policy.

The async variant is FirewallPoliciesClient::addRuleAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\AddRuleFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\AddRuleFirewallPolicyRequest;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\FirewallPolicyRule;
use Google\Rpc\Status;

/**
 * @param string $firewallPolicy Name of the firewall policy to update.
 */
function add_rule_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $firewallPolicyRuleResource = new FirewallPolicyRule();
    $request = (new AddRuleFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy)
        ->setFirewallPolicyRuleResource($firewallPolicyRuleResource);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->addRule($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    add_rule_sample($firewallPolicy);
} 

cloneRules

Copies rules to the specified firewall policy.

The async variant is FirewallPoliciesClient::cloneRulesAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\CloneRulesFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\CloneRulesFirewallPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $firewallPolicy Name of the firewall policy to update.
 */
function clone_rules_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = (new CloneRulesFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->cloneRules($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    clone_rules_sample($firewallPolicy);
} 

delete

Deletes the specified policy.

The async variant is FirewallPoliciesClient::deleteAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\DeleteFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\DeleteFirewallPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $firewallPolicy Name of the firewall policy to delete.
 */
function delete_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = (new DeleteFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->delete($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    delete_sample($firewallPolicy);
} 

get

Returns the specified firewall policy.

The async variant is FirewallPoliciesClient::getAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\GetFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\FirewallPolicy;
use Google\Cloud\Compute\V1\GetFirewallPolicyRequest;

/**
 * @param string $firewallPolicy Name of the firewall policy to get.
 */
function get_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = (new GetFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy);

    // Call the API and handle any network failures.
    try {
        /** @var FirewallPolicy $response */
        $response = $firewallPoliciesClient->get($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    get_sample($firewallPolicy);
} 

getAssociation

Gets an association with the specified name.

The async variant is FirewallPoliciesClient::getAssociationAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\GetAssociationFirewallPolicyRequest

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.

Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\FirewallPolicyAssociation;
use Google\Cloud\Compute\V1\GetAssociationFirewallPolicyRequest;

/**
 * @param string $firewallPolicy Name of the firewall policy to which the queried rule belongs.
 */
function get_association_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = (new GetAssociationFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy);

    // Call the API and handle any network failures.
    try {
        /** @var FirewallPolicyAssociation $response */
        $response = $firewallPoliciesClient->getAssociation($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    get_association_sample($firewallPolicy);
} 

getIamPolicy

Gets the access control policy for a resource. May be empty if no such policy or resource exists.

The async variant is FirewallPoliciesClient::getIamPolicyAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\GetIamPolicyFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\GetIamPolicyFirewallPolicyRequest;
use Google\Cloud\Compute\V1\Policy;

/**
 * @param string $resource Name or id of the resource for this request.
 */
function get_iam_policy_sample(string $resource): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = (new GetIamPolicyFirewallPolicyRequest())
        ->setResource($resource);

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $firewallPoliciesClient->getIamPolicy($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
{
    $resource = '[RESOURCE]';

    get_iam_policy_sample($resource);
} 

getRule

Gets a rule of the specified priority.

The async variant is FirewallPoliciesClient::getRuleAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\GetRuleFirewallPolicyRequest

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.

Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\FirewallPolicyRule;
use Google\Cloud\Compute\V1\GetRuleFirewallPolicyRequest;

/**
 * @param string $firewallPolicy Name of the firewall policy to which the queried rule belongs.
 */
function get_rule_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = (new GetRuleFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy);

    // Call the API and handle any network failures.
    try {
        /** @var FirewallPolicyRule $response */
        $response = $firewallPoliciesClient->getRule($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    get_rule_sample($firewallPolicy);
} 

insert

Creates a new policy in the specified project using the data included in the request.

The async variant is FirewallPoliciesClient::insertAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\InsertFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\FirewallPolicy;
use Google\Cloud\Compute\V1\InsertFirewallPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $parentId Parent ID for this request. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization.
 */
function insert_sample(string $parentId): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $firewallPolicyResource = new FirewallPolicy();
    $request = (new InsertFirewallPolicyRequest())
        ->setFirewallPolicyResource($firewallPolicyResource)
        ->setParentId($parentId);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->insert($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
{
    $parentId = '[PARENT_ID]';

    insert_sample($parentId);
} 

list

Lists all the policies that have been configured for the specified folder or organization.

The async variant is FirewallPoliciesClient::listAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\ListFirewallPoliciesRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\ListFirewallPoliciesRequest;

/**
 * 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 list_sample(): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = new ListFirewallPoliciesRequest();

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

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

listAssociations

Lists associations of a specified target, i.e., organization or folder.

The async variant is FirewallPoliciesClient::listAssociationsAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\ListAssociationsFirewallPolicyRequest

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.

Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\FirewallPoliciesListAssociationsResponse;
use Google\Cloud\Compute\V1\ListAssociationsFirewallPolicyRequest;

/**
 * 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 list_associations_sample(): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = new ListAssociationsFirewallPolicyRequest();

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

move

Moves the specified firewall policy.

The async variant is FirewallPoliciesClient::moveAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\MoveFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\MoveFirewallPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $firewallPolicy Name of the firewall policy to update.
 * @param string $parentId       The new parent of the firewall policy. The ID can be either be "folders/[FOLDER_ID]" if the parent is a folder or "organizations/[ORGANIZATION_ID]" if the parent is an organization.
 */
function move_sample(string $firewallPolicy, string $parentId): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = (new MoveFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy)
        ->setParentId($parentId);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->move($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';
    $parentId = '[PARENT_ID]';

    move_sample($firewallPolicy, $parentId);
} 

patch

Patches the specified policy with the data included in the request.

The async variant is FirewallPoliciesClient::patchAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\PatchFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\FirewallPolicy;
use Google\Cloud\Compute\V1\PatchFirewallPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $firewallPolicy Name of the firewall policy to update.
 */
function patch_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $firewallPolicyResource = new FirewallPolicy();
    $request = (new PatchFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy)
        ->setFirewallPolicyResource($firewallPolicyResource);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->patch($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    patch_sample($firewallPolicy);
} 

patchRule

Patches a rule of the specified priority.

The async variant is FirewallPoliciesClient::patchRuleAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\PatchRuleFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\FirewallPolicyRule;
use Google\Cloud\Compute\V1\PatchRuleFirewallPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $firewallPolicy Name of the firewall policy to update.
 */
function patch_rule_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $firewallPolicyRuleResource = new FirewallPolicyRule();
    $request = (new PatchRuleFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy)
        ->setFirewallPolicyRuleResource($firewallPolicyRuleResource);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->patchRule($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    patch_rule_sample($firewallPolicy);
} 

removeAssociation

Removes an association for the specified firewall policy.

The async variant is FirewallPoliciesClient::removeAssociationAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\RemoveAssociationFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\RemoveAssociationFirewallPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $firewallPolicy Name of the firewall policy to update.
 */
function remove_association_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = (new RemoveAssociationFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->removeAssociation($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    remove_association_sample($firewallPolicy);
} 

removeRule

Deletes a rule of the specified priority.

The async variant is FirewallPoliciesClient::removeRuleAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\RemoveRuleFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\RemoveRuleFirewallPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $firewallPolicy Name of the firewall policy to update.
 */
function remove_rule_sample(string $firewallPolicy): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $request = (new RemoveRuleFirewallPolicyRequest())
        ->setFirewallPolicy($firewallPolicy);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $firewallPoliciesClient->removeRule($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
{
    $firewallPolicy = '[FIREWALL_POLICY]';

    remove_rule_sample($firewallPolicy);
} 

setIamPolicy

Sets the access control policy on the specified resource. Replaces any existing policy.

The async variant is FirewallPoliciesClient::setIamPolicyAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\SetIamPolicyFirewallPolicyRequest

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
Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\GlobalOrganizationSetPolicyRequest;
use Google\Cloud\Compute\V1\Policy;
use Google\Cloud\Compute\V1\SetIamPolicyFirewallPolicyRequest;

/**
 * @param string $resource Name or id of the resource for this request.
 */
function set_iam_policy_sample(string $resource): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $globalOrganizationSetPolicyRequestResource = new GlobalOrganizationSetPolicyRequest();
    $request = (new SetIamPolicyFirewallPolicyRequest())
        ->setGlobalOrganizationSetPolicyRequestResource($globalOrganizationSetPolicyRequestResource)
        ->setResource($resource);

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $firewallPoliciesClient->setIamPolicy($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
{
    $resource = '[RESOURCE]';

    set_iam_policy_sample($resource);
} 

testIamPermissions

Returns permissions that a caller has on the specified resource.

The async variant is FirewallPoliciesClient::testIamPermissionsAsync() .

Parameters
Name
Description
request
Google\Cloud\Compute\V1\TestIamPermissionsFirewallPolicyRequest

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.

Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Compute\V1\Client\FirewallPoliciesClient;
use Google\Cloud\Compute\V1\TestIamPermissionsFirewallPolicyRequest;
use Google\Cloud\Compute\V1\TestPermissionsRequest;
use Google\Cloud\Compute\V1\TestPermissionsResponse;

/**
 * @param string $resource Name or id of the resource for this request.
 */
function test_iam_permissions_sample(string $resource): void
{
    // Create a client.
    $firewallPoliciesClient = new FirewallPoliciesClient();

    // Prepare the request message.
    $testPermissionsRequestResource = new TestPermissionsRequest();
    $request = (new TestIamPermissionsFirewallPolicyRequest())
        ->setResource($resource)
        ->setTestPermissionsRequestResource($testPermissionsRequestResource);

    // Call the API and handle any network failures.
    try {
        /** @var TestPermissionsResponse $response */
        $response = $firewallPoliciesClient->testIamPermissions($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
{
    $resource = '[RESOURCE]';

    test_iam_permissions_sample($resource);
} 

addAssociationAsync

Parameters
Name
Description
optionalArgs
array

addRuleAsync

Parameters
Name
Description
optionalArgs
array

cloneRulesAsync

Parameters
Name
Description
optionalArgs
array

deleteAsync

Parameters
Name
Description
optionalArgs
array

getAsync

Parameters
Name
Description
optionalArgs
array

getAssociationAsync

Parameters
Name
Description
optionalArgs
array

getIamPolicyAsync

Parameters
Name
Description
optionalArgs
array

getRuleAsync

Parameters
Name
Description
optionalArgs
array

insertAsync

Parameters
Name
Description
optionalArgs
array

listAsync

Parameters
Name
Description
optionalArgs
array

listAssociationsAsync

Parameters
Name
Description
optionalArgs
array

moveAsync

Parameters
Name
Description
optionalArgs
array

patchAsync

Parameters
Name
Description
optionalArgs
array

patchRuleAsync

Parameters
Name
Description
optionalArgs
array

removeAssociationAsync

Parameters
Name
Description
optionalArgs
array

removeRuleAsync

Parameters
Name
Description
optionalArgs
array

setIamPolicyAsync

Parameters
Name
Description
optionalArgs
array

testIamPermissionsAsync

Parameters
Name
Description
optionalArgs
array

getOperationsClient

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

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
Design a Mobile Site
View Site in Mobile | Classic
Share by: