Google Cloud Network Services V1 Client - Class NetworkServicesClient (0.2.1)

Reference documentation and code samples for the Google Cloud Network Services V1 Client class NetworkServicesClient.

Service Description: Service describing handlers for resources.

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 \ NetworkServices \ 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.

createEndpointPolicy

Creates a new EndpointPolicy in a given project and location.

The async variant is NetworkServicesClient::createEndpointPolicyAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\CreateEndpointPolicyRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\CreateEndpointPolicyRequest;
use Google\Cloud\NetworkServices\V1\EndpointMatcher;
use Google\Cloud\NetworkServices\V1\EndpointPolicy;
use Google\Cloud\NetworkServices\V1\EndpointPolicy\EndpointPolicyType;
use Google\Rpc\Status;

/**
 * @param string $formattedParent    The parent resource of the EndpointPolicy. Must be in the
 *                                   format `projects/*/locations/global`. Please see
 *                                   {@see NetworkServicesClient::locationName()} for help formatting this field.
 * @param string $endpointPolicyId   Short name of the EndpointPolicy resource to be created.
 *                                   E.g. "CustomECS".
 * @param string $endpointPolicyName Name of the EndpointPolicy resource. It matches pattern
 *                                   `projects/{project}/locations/global/endpointPolicies/{endpoint_policy}`.
 * @param int    $endpointPolicyType The type of endpoint policy. This is primarily used to validate
 *                                   the configuration.
 */
function create_endpoint_policy_sample(
    string $formattedParent,
    string $endpointPolicyId,
    string $endpointPolicyName,
    int $endpointPolicyType
): void {
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $endpointPolicyEndpointMatcher = new EndpointMatcher();
    $endpointPolicy = (new EndpointPolicy())
        ->setName($endpointPolicyName)
        ->setType($endpointPolicyType)
        ->setEndpointMatcher($endpointPolicyEndpointMatcher);
    $request = (new CreateEndpointPolicyRequest())
        ->setParent($formattedParent)
        ->setEndpointPolicyId($endpointPolicyId)
        ->setEndpointPolicy($endpointPolicy);

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

        if ($response->operationSucceeded()) {
            /** @var EndpointPolicy $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');
    $endpointPolicyId = '[ENDPOINT_POLICY_ID]';
    $endpointPolicyName = '[NAME]';
    $endpointPolicyType = EndpointPolicyType::ENDPOINT_POLICY_TYPE_UNSPECIFIED;

    create_endpoint_policy_sample(
        $formattedParent,
        $endpointPolicyId,
        $endpointPolicyName,
        $endpointPolicyType
    );
}

createGateway

Creates a new Gateway in a given project and location.

The async variant is NetworkServicesClient::createGatewayAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\CreateGatewayRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\CreateGatewayRequest;
use Google\Cloud\NetworkServices\V1\Gateway;
use Google\Rpc\Status;

/**
 * @param string $formattedParent     The parent resource of the Gateway. Must be in the
 *                                    format `projects/*/locations/*`. Please see
 *                                    {@see NetworkServicesClient::locationName()} for help formatting this field.
 * @param string $gatewayId           Short name of the Gateway resource to be created.
 * @param string $gatewayName         Name of the Gateway resource. It matches pattern
 *                                    `projects/&#42;/locations/&#42;/gateways/<gateway_name>`.
 * @param int    $gatewayPortsElement One or more ports that the Gateway must receive traffic on. The
 *                                    proxy binds to the ports specified. Gateway listen on 0.0.0.0 on the ports
 *                                    specified below.
 * @param string $gatewayScope        Immutable. Scope determines how configuration across multiple
 *                                    Gateway instances are merged. The configuration for multiple Gateway
 *                                    instances with the same scope will be merged as presented as a single
 *                                    coniguration to the proxy/load balancer.
 *
 *                                    Max length 64 characters.
 *                                    Scope should start with a letter and can only have letters, numbers,
 *                                    hyphens.
 */
function create_gateway_sample(
    string $formattedParent,
    string $gatewayId,
    string $gatewayName,
    int $gatewayPortsElement,
    string $gatewayScope
): void {
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $gatewayPorts = [$gatewayPortsElement,];
    $gateway = (new Gateway())
        ->setName($gatewayName)
        ->setPorts($gatewayPorts)
        ->setScope($gatewayScope);
    $request = (new CreateGatewayRequest())
        ->setParent($formattedParent)
        ->setGatewayId($gatewayId)
        ->setGateway($gateway);

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

        if ($response->operationSucceeded()) {
            /** @var Gateway $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');
    $gatewayId = '[GATEWAY_ID]';
    $gatewayName = '[NAME]';
    $gatewayPortsElement = 0;
    $gatewayScope = '[SCOPE]';

    create_gateway_sample(
        $formattedParent,
        $gatewayId,
        $gatewayName,
        $gatewayPortsElement,
        $gatewayScope
    );
}

createGrpcRoute

Creates a new GrpcRoute in a given project and location.

The async variant is NetworkServicesClient::createGrpcRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\CreateGrpcRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\CreateGrpcRouteRequest;
use Google\Cloud\NetworkServices\V1\GrpcRoute;
use Google\Cloud\NetworkServices\V1\GrpcRoute\RouteAction;
use Google\Cloud\NetworkServices\V1\GrpcRoute\RouteRule;
use Google\Rpc\Status;

/**
 * @param string $formattedParent           The parent resource of the GrpcRoute. Must be in the
 *                                          format `projects/&#42;/locations/global`. Please see
 *                                          {@see NetworkServicesClient::locationName()} for help formatting this field.
 * @param string $grpcRouteId               Short name of the GrpcRoute resource to be created.
 * @param string $grpcRouteName             Name of the GrpcRoute resource. It matches pattern
 *                                          `projects/&#42;/locations/global/grpcRoutes/<grpc_route_name>`
 * @param string $grpcRouteHostnamesElement Service hostnames with an optional port for which this route
 *                                          describes traffic.
 *
 *                                          Format: <hostname>[:<port>]
 *
 *                                          Hostname is the fully qualified domain name of a network host. This matches
 *                                          the RFC 1123 definition of a hostname with 2 notable exceptions:
 *                                          - IPs are not allowed.
 *                                          - A hostname may be prefixed with a wildcard label (`*.`). The wildcard
 *                                          label must appear by itself as the first label.
 *
 *                                          Hostname can be "precise" which is a domain name without the terminating
 *                                          dot of a network host (e.g. `foo.example.com`) or "wildcard", which is a
 *                                          domain name prefixed with a single wildcard label (e.g. `*.example.com`).
 *
 *                                          Note that as per RFC1035 and RFC1123, a label must consist of lower case
 *                                          alphanumeric characters or '-', and must start and end with an alphanumeric
 *                                          character. No other punctuation is allowed.
 *
 *                                          The routes associated with a Mesh or Gateway must have unique hostnames. If
 *                                          you attempt to attach multiple routes with conflicting hostnames, the
 *                                          configuration will be rejected.
 *
 *                                          For example, while it is acceptable for routes for the hostnames
 *                                          `*.foo.bar.com` and `*.bar.com` to be associated with the same route, it is
 *                                          not possible to associate two routes both with `*.bar.com` or both with
 *                                          `bar.com`.
 *
 *                                          If a port is specified, then gRPC clients must use the channel URI with the
 *                                          port to match this rule (i.e. "xds:///service:123"), otherwise they must
 *                                          supply the URI without a port (i.e. "xds:///service").
 */
function create_grpc_route_sample(
    string $formattedParent,
    string $grpcRouteId,
    string $grpcRouteName,
    string $grpcRouteHostnamesElement
): void {
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $grpcRouteHostnames = [$grpcRouteHostnamesElement,];
    $grpcRouteRulesAction = new RouteAction();
    $routeRule = (new RouteRule())
        ->setAction($grpcRouteRulesAction);
    $grpcRouteRules = [$routeRule,];
    $grpcRoute = (new GrpcRoute())
        ->setName($grpcRouteName)
        ->setHostnames($grpcRouteHostnames)
        ->setRules($grpcRouteRules);
    $request = (new CreateGrpcRouteRequest())
        ->setParent($formattedParent)
        ->setGrpcRouteId($grpcRouteId)
        ->setGrpcRoute($grpcRoute);

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

        if ($response->operationSucceeded()) {
            /** @var GrpcRoute $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');
    $grpcRouteId = '[GRPC_ROUTE_ID]';
    $grpcRouteName = '[NAME]';
    $grpcRouteHostnamesElement = '[HOSTNAMES]';

    create_grpc_route_sample(
        $formattedParent,
        $grpcRouteId,
        $grpcRouteName,
        $grpcRouteHostnamesElement
    );
}

createHttpRoute

Creates a new HttpRoute in a given project and location.

The async variant is NetworkServicesClient::createHttpRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\CreateHttpRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\CreateHttpRouteRequest;
use Google\Cloud\NetworkServices\V1\HttpRoute;
use Google\Cloud\NetworkServices\V1\HttpRoute\RouteRule;
use Google\Rpc\Status;

/**
 * @param string $formattedParent           The parent resource of the HttpRoute. Must be in the
 *                                          format `projects/&#42;/locations/global`. Please see
 *                                          {@see NetworkServicesClient::locationName()} for help formatting this field.
 * @param string $httpRouteId               Short name of the HttpRoute resource to be created.
 * @param string $httpRouteName             Name of the HttpRoute resource. It matches pattern
 *                                          `projects/&#42;/locations/global/httpRoutes/http_route_name>`.
 * @param string $httpRouteHostnamesElement Hostnames define a set of hosts that should match against the
 *                                          HTTP host header to select a HttpRoute to process the request. Hostname is
 *                                          the fully qualified domain name of a network host, as defined by RFC 1123
 *                                          with the exception that:
 *                                          - IPs are not allowed.
 *                                          - A hostname may be prefixed with a wildcard label (`*.`). The wildcard
 *                                          label must appear by itself as the first label.
 *
 *                                          Hostname can be "precise" which is a domain name without the terminating
 *                                          dot of a network host (e.g. `foo.example.com`) or "wildcard", which is a
 *                                          domain name prefixed with a single wildcard label (e.g. `*.example.com`).
 *
 *                                          Note that as per RFC1035 and RFC1123, a label must consist of lower case
 *                                          alphanumeric characters or '-', and must start and end with an alphanumeric
 *                                          character. No other punctuation is allowed.
 *
 *                                          The routes associated with a Mesh or Gateways  must have unique hostnames.
 *                                          If you attempt to attach multiple routes with conflicting hostnames,
 *                                          the configuration will be rejected.
 *
 *                                          For example, while it is acceptable for routes for the hostnames
 *                                          `*.foo.bar.com` and `*.bar.com` to be associated with the same Mesh (or
 *                                          Gateways under the same scope), it is not possible to associate two routes
 *                                          both with `*.bar.com` or both with `bar.com`.
 */
function create_http_route_sample(
    string $formattedParent,
    string $httpRouteId,
    string $httpRouteName,
    string $httpRouteHostnamesElement
): void {
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $httpRouteHostnames = [$httpRouteHostnamesElement,];
    $httpRouteRules = [new RouteRule()];
    $httpRoute = (new HttpRoute())
        ->setName($httpRouteName)
        ->setHostnames($httpRouteHostnames)
        ->setRules($httpRouteRules);
    $request = (new CreateHttpRouteRequest())
        ->setParent($formattedParent)
        ->setHttpRouteId($httpRouteId)
        ->setHttpRoute($httpRoute);

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

        if ($response->operationSucceeded()) {
            /** @var HttpRoute $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');
    $httpRouteId = '[HTTP_ROUTE_ID]';
    $httpRouteName = '[NAME]';
    $httpRouteHostnamesElement = '[HOSTNAMES]';

    create_http_route_sample(
        $formattedParent,
        $httpRouteId,
        $httpRouteName,
        $httpRouteHostnamesElement
    );
}

createMesh

Creates a new Mesh in a given project and location.

The async variant is NetworkServicesClient::createMeshAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\CreateMeshRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\CreateMeshRequest;
use Google\Cloud\NetworkServices\V1\Mesh;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The parent resource of the Mesh. Must be in the
 *                                format `projects/&#42;/locations/global`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 * @param string $meshId          Short name of the Mesh resource to be created.
 * @param string $meshName        Name of the Mesh resource. It matches pattern
 *                                `projects/&#42;/locations/global/meshes/<mesh_name>`.
 */
function create_mesh_sample(string $formattedParent, string $meshId, string $meshName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $mesh = (new Mesh())
        ->setName($meshName);
    $request = (new CreateMeshRequest())
        ->setParent($formattedParent)
        ->setMeshId($meshId)
        ->setMesh($mesh);

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

        if ($response->operationSucceeded()) {
            /** @var Mesh $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');
    $meshId = '[MESH_ID]';
    $meshName = '[NAME]';

    create_mesh_sample($formattedParent, $meshId, $meshName);
}

createServiceBinding

Creates a new ServiceBinding in a given project and location.

The async variant is NetworkServicesClient::createServiceBindingAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\CreateServiceBindingRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\CreateServiceBindingRequest;
use Google\Cloud\NetworkServices\V1\ServiceBinding;
use Google\Rpc\Status;

/**
 * @param string $formattedParent       The parent resource of the ServiceBinding. Must be in the
 *                                      format `projects/&#42;/locations/global`. Please see
 *                                      {@see NetworkServicesClient::locationName()} for help formatting this field.
 * @param string $serviceBindingId      Short name of the ServiceBinding resource to be created.
 * @param string $serviceBindingName    Name of the ServiceBinding resource. It matches pattern
 *                                      `projects/&#42;/locations/global/serviceBindings/service_binding_name`.
 * @param string $serviceBindingService The full service directory service name of the format
 *                                      /projects/&#42;/locations/&#42;/namespaces/&#42;/services/*
 */
function create_service_binding_sample(
    string $formattedParent,
    string $serviceBindingId,
    string $serviceBindingName,
    string $serviceBindingService
): void {
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $serviceBinding = (new ServiceBinding())
        ->setName($serviceBindingName)
        ->setService($serviceBindingService);
    $request = (new CreateServiceBindingRequest())
        ->setParent($formattedParent)
        ->setServiceBindingId($serviceBindingId)
        ->setServiceBinding($serviceBinding);

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

        if ($response->operationSucceeded()) {
            /** @var ServiceBinding $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');
    $serviceBindingId = '[SERVICE_BINDING_ID]';
    $serviceBindingName = '[NAME]';
    $serviceBindingService = '[SERVICE]';

    create_service_binding_sample(
        $formattedParent,
        $serviceBindingId,
        $serviceBindingName,
        $serviceBindingService
    );
}

createTcpRoute

Creates a new TcpRoute in a given project and location.

The async variant is NetworkServicesClient::createTcpRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\CreateTcpRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\CreateTcpRouteRequest;
use Google\Cloud\NetworkServices\V1\TcpRoute;
use Google\Cloud\NetworkServices\V1\TcpRoute\RouteAction;
use Google\Cloud\NetworkServices\V1\TcpRoute\RouteRule;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The parent resource of the TcpRoute. Must be in the
 *                                format `projects/&#42;/locations/global`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 * @param string $tcpRouteId      Short name of the TcpRoute resource to be created.
 * @param string $tcpRouteName    Name of the TcpRoute resource. It matches pattern
 *                                `projects/&#42;/locations/global/tcpRoutes/tcp_route_name>`.
 */
function create_tcp_route_sample(
    string $formattedParent,
    string $tcpRouteId,
    string $tcpRouteName
): void {
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $tcpRouteRulesAction = new RouteAction();
    $routeRule = (new RouteRule())
        ->setAction($tcpRouteRulesAction);
    $tcpRouteRules = [$routeRule,];
    $tcpRoute = (new TcpRoute())
        ->setName($tcpRouteName)
        ->setRules($tcpRouteRules);
    $request = (new CreateTcpRouteRequest())
        ->setParent($formattedParent)
        ->setTcpRouteId($tcpRouteId)
        ->setTcpRoute($tcpRoute);

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

        if ($response->operationSucceeded()) {
            /** @var TcpRoute $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');
    $tcpRouteId = '[TCP_ROUTE_ID]';
    $tcpRouteName = '[NAME]';

    create_tcp_route_sample($formattedParent, $tcpRouteId, $tcpRouteName);
}

createTlsRoute

Creates a new TlsRoute in a given project and location.

The async variant is NetworkServicesClient::createTlsRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\CreateTlsRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\CreateTlsRouteRequest;
use Google\Cloud\NetworkServices\V1\TlsRoute;
use Google\Cloud\NetworkServices\V1\TlsRoute\RouteAction;
use Google\Cloud\NetworkServices\V1\TlsRoute\RouteDestination;
use Google\Cloud\NetworkServices\V1\TlsRoute\RouteMatch;
use Google\Cloud\NetworkServices\V1\TlsRoute\RouteRule;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                                     The parent resource of the TlsRoute. Must be in the
 *                                                                    format `projects/&#42;/locations/global`. Please see
 *                                                                    {@see NetworkServicesClient::locationName()} for help formatting this field.
 * @param string $tlsRouteId                                          Short name of the TlsRoute resource to be created.
 * @param string $tlsRouteName                                        Name of the TlsRoute resource. It matches pattern
 *                                                                    `projects/&#42;/locations/global/tlsRoutes/tls_route_name>`.
 * @param string $formattedTlsRouteRulesActionDestinationsServiceName The URL of a BackendService to route traffic to. Please see
 *                                                                    {@see NetworkServicesClient::backendServiceName()} for help formatting this field.
 */
function create_tls_route_sample(
    string $formattedParent,
    string $tlsRouteId,
    string $tlsRouteName,
    string $formattedTlsRouteRulesActionDestinationsServiceName
): void {
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $tlsRouteRulesMatches = [new RouteMatch()];
    $routeDestination = (new RouteDestination())
        ->setServiceName($formattedTlsRouteRulesActionDestinationsServiceName);
    $tlsRouteRulesActionDestinations = [$routeDestination,];
    $tlsRouteRulesAction = (new RouteAction())
        ->setDestinations($tlsRouteRulesActionDestinations);
    $routeRule = (new RouteRule())
        ->setMatches($tlsRouteRulesMatches)
        ->setAction($tlsRouteRulesAction);
    $tlsRouteRules = [$routeRule,];
    $tlsRoute = (new TlsRoute())
        ->setName($tlsRouteName)
        ->setRules($tlsRouteRules);
    $request = (new CreateTlsRouteRequest())
        ->setParent($formattedParent)
        ->setTlsRouteId($tlsRouteId)
        ->setTlsRoute($tlsRoute);

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

        if ($response->operationSucceeded()) {
            /** @var TlsRoute $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');
    $tlsRouteId = '[TLS_ROUTE_ID]';
    $tlsRouteName = '[NAME]';
    $formattedTlsRouteRulesActionDestinationsServiceName = NetworkServicesClient::backendServiceName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKEND_SERVICE]'
    );

    create_tls_route_sample(
        $formattedParent,
        $tlsRouteId,
        $tlsRouteName,
        $formattedTlsRouteRulesActionDestinationsServiceName
    );
}

deleteEndpointPolicy

Deletes a single EndpointPolicy.

The async variant is NetworkServicesClient::deleteEndpointPolicyAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\DeleteEndpointPolicyRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\DeleteEndpointPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName A name of the EndpointPolicy to delete. Must be in the format
 *                              `projects/&#42;/locations/global/endpointPolicies/*`. Please see
 *                              {@see NetworkServicesClient::endpointPolicyName()} for help formatting this field.
 */
function delete_endpoint_policy_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $networkServicesClient->deleteEndpointPolicy($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 = NetworkServicesClient::endpointPolicyName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENDPOINT_POLICY]'
    );

    delete_endpoint_policy_sample($formattedName);
}

deleteGateway

Deletes a single Gateway.

The async variant is NetworkServicesClient::deleteGatewayAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\DeleteGatewayRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\DeleteGatewayRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName A name of the Gateway to delete. Must be in the format
 *                              `projects/&#42;/locations/&#42;/gateways/*`. Please see
 *                              {@see NetworkServicesClient::gatewayName()} for help formatting this field.
 */
function delete_gateway_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $networkServicesClient->deleteGateway($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 = NetworkServicesClient::gatewayName('[PROJECT]', '[LOCATION]', '[GATEWAY]');

    delete_gateway_sample($formattedName);
}

deleteGrpcRoute

Deletes a single GrpcRoute.

The async variant is NetworkServicesClient::deleteGrpcRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\DeleteGrpcRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\DeleteGrpcRouteRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName A name of the GrpcRoute to delete. Must be in the format
 *                              `projects/&#42;/locations/global/grpcRoutes/*`. Please see
 *                              {@see NetworkServicesClient::grpcRouteName()} for help formatting this field.
 */
function delete_grpc_route_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $networkServicesClient->deleteGrpcRoute($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 = NetworkServicesClient::grpcRouteName('[PROJECT]', '[LOCATION]', '[GRPC_ROUTE]');

    delete_grpc_route_sample($formattedName);
}

deleteHttpRoute

Deletes a single HttpRoute.

The async variant is NetworkServicesClient::deleteHttpRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\DeleteHttpRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\DeleteHttpRouteRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName A name of the HttpRoute to delete. Must be in the format
 *                              `projects/&#42;/locations/global/httpRoutes/*`. Please see
 *                              {@see NetworkServicesClient::httpRouteName()} for help formatting this field.
 */
function delete_http_route_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $networkServicesClient->deleteHttpRoute($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 = NetworkServicesClient::httpRouteName('[PROJECT]', '[LOCATION]', '[HTTP_ROUTE]');

    delete_http_route_sample($formattedName);
}

deleteMesh

Deletes a single Mesh.

The async variant is NetworkServicesClient::deleteMeshAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\DeleteMeshRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\DeleteMeshRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName A name of the Mesh to delete. Must be in the format
 *                              `projects/&#42;/locations/global/meshes/*`. Please see
 *                              {@see NetworkServicesClient::meshName()} for help formatting this field.
 */
function delete_mesh_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $networkServicesClient->deleteMesh($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 = NetworkServicesClient::meshName('[PROJECT]', '[LOCATION]', '[MESH]');

    delete_mesh_sample($formattedName);
}

deleteServiceBinding

Deletes a single ServiceBinding.

The async variant is NetworkServicesClient::deleteServiceBindingAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\DeleteServiceBindingRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\DeleteServiceBindingRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName A name of the ServiceBinding to delete. Must be in the format
 *                              `projects/&#42;/locations/global/serviceBindings/*`. Please see
 *                              {@see NetworkServicesClient::serviceBindingName()} for help formatting this field.
 */
function delete_service_binding_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $networkServicesClient->deleteServiceBinding($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 = NetworkServicesClient::serviceBindingName(
        '[PROJECT]',
        '[LOCATION]',
        '[SERVICE_BINDING]'
    );

    delete_service_binding_sample($formattedName);
}

deleteTcpRoute

Deletes a single TcpRoute.

The async variant is NetworkServicesClient::deleteTcpRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\DeleteTcpRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\DeleteTcpRouteRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName A name of the TcpRoute to delete. Must be in the format
 *                              `projects/&#42;/locations/global/tcpRoutes/*`. Please see
 *                              {@see NetworkServicesClient::tcpRouteName()} for help formatting this field.
 */
function delete_tcp_route_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $networkServicesClient->deleteTcpRoute($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 = NetworkServicesClient::tcpRouteName('[PROJECT]', '[LOCATION]', '[TCP_ROUTE]');

    delete_tcp_route_sample($formattedName);
}

deleteTlsRoute

Deletes a single TlsRoute.

The async variant is NetworkServicesClient::deleteTlsRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\DeleteTlsRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\DeleteTlsRouteRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName A name of the TlsRoute to delete. Must be in the format
 *                              `projects/&#42;/locations/global/tlsRoutes/*`. Please see
 *                              {@see NetworkServicesClient::tlsRouteName()} for help formatting this field.
 */
function delete_tls_route_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $networkServicesClient->deleteTlsRoute($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 = NetworkServicesClient::tlsRouteName('[PROJECT]', '[LOCATION]', '[TLS_ROUTE]');

    delete_tls_route_sample($formattedName);
}

getEndpointPolicy

Gets details of a single EndpointPolicy.

The async variant is NetworkServicesClient::getEndpointPolicyAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetEndpointPolicyRequest

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\NetworkServices\V1\EndpointPolicy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\EndpointPolicy;
use Google\Cloud\NetworkServices\V1\GetEndpointPolicyRequest;

/**
 * @param string $formattedName A name of the EndpointPolicy to get. Must be in the format
 *                              `projects/&#42;/locations/global/endpointPolicies/*`. Please see
 *                              {@see NetworkServicesClient::endpointPolicyName()} for help formatting this field.
 */
function get_endpoint_policy_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var EndpointPolicy $response */
        $response = $networkServicesClient->getEndpointPolicy($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 = NetworkServicesClient::endpointPolicyName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENDPOINT_POLICY]'
    );

    get_endpoint_policy_sample($formattedName);
}

getGateway

Gets details of a single Gateway.

The async variant is NetworkServicesClient::getGatewayAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetGatewayRequest

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\NetworkServices\V1\Gateway
Example
use Google\ApiCore\ApiException;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\Gateway;
use Google\Cloud\NetworkServices\V1\GetGatewayRequest;

/**
 * @param string $formattedName A name of the Gateway to get. Must be in the format
 *                              `projects/&#42;/locations/&#42;/gateways/*`. Please see
 *                              {@see NetworkServicesClient::gatewayName()} for help formatting this field.
 */
function get_gateway_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Gateway $response */
        $response = $networkServicesClient->getGateway($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 = NetworkServicesClient::gatewayName('[PROJECT]', '[LOCATION]', '[GATEWAY]');

    get_gateway_sample($formattedName);
}

getGrpcRoute

Gets details of a single GrpcRoute.

The async variant is NetworkServicesClient::getGrpcRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetGrpcRouteRequest

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\NetworkServices\V1\GrpcRoute
Example
use Google\ApiCore\ApiException;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\GetGrpcRouteRequest;
use Google\Cloud\NetworkServices\V1\GrpcRoute;

/**
 * @param string $formattedName A name of the GrpcRoute to get. Must be in the format
 *                              `projects/&#42;/locations/global/grpcRoutes/*`. Please see
 *                              {@see NetworkServicesClient::grpcRouteName()} for help formatting this field.
 */
function get_grpc_route_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var GrpcRoute $response */
        $response = $networkServicesClient->getGrpcRoute($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 = NetworkServicesClient::grpcRouteName('[PROJECT]', '[LOCATION]', '[GRPC_ROUTE]');

    get_grpc_route_sample($formattedName);
}

getHttpRoute

Gets details of a single HttpRoute.

The async variant is NetworkServicesClient::getHttpRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetHttpRouteRequest

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\NetworkServices\V1\HttpRoute
Example
use Google\ApiCore\ApiException;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\GetHttpRouteRequest;
use Google\Cloud\NetworkServices\V1\HttpRoute;

/**
 * @param string $formattedName A name of the HttpRoute to get. Must be in the format
 *                              `projects/&#42;/locations/global/httpRoutes/*`. Please see
 *                              {@see NetworkServicesClient::httpRouteName()} for help formatting this field.
 */
function get_http_route_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var HttpRoute $response */
        $response = $networkServicesClient->getHttpRoute($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 = NetworkServicesClient::httpRouteName('[PROJECT]', '[LOCATION]', '[HTTP_ROUTE]');

    get_http_route_sample($formattedName);
}

getMesh

Gets details of a single Mesh.

The async variant is NetworkServicesClient::getMeshAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetMeshRequest

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\NetworkServices\V1\Mesh
Example
use Google\ApiCore\ApiException;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\GetMeshRequest;
use Google\Cloud\NetworkServices\V1\Mesh;

/**
 * @param string $formattedName A name of the Mesh to get. Must be in the format
 *                              `projects/&#42;/locations/global/meshes/*`. Please see
 *                              {@see NetworkServicesClient::meshName()} for help formatting this field.
 */
function get_mesh_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Mesh $response */
        $response = $networkServicesClient->getMesh($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 = NetworkServicesClient::meshName('[PROJECT]', '[LOCATION]', '[MESH]');

    get_mesh_sample($formattedName);
}

getServiceBinding

Gets details of a single ServiceBinding.

The async variant is NetworkServicesClient::getServiceBindingAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetServiceBindingRequest

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\NetworkServices\V1\ServiceBinding
Example
use Google\ApiCore\ApiException;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\GetServiceBindingRequest;
use Google\Cloud\NetworkServices\V1\ServiceBinding;

/**
 * @param string $formattedName A name of the ServiceBinding to get. Must be in the format
 *                              `projects/&#42;/locations/global/serviceBindings/*`. Please see
 *                              {@see NetworkServicesClient::serviceBindingName()} for help formatting this field.
 */
function get_service_binding_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var ServiceBinding $response */
        $response = $networkServicesClient->getServiceBinding($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 = NetworkServicesClient::serviceBindingName(
        '[PROJECT]',
        '[LOCATION]',
        '[SERVICE_BINDING]'
    );

    get_service_binding_sample($formattedName);
}

getTcpRoute

Gets details of a single TcpRoute.

The async variant is NetworkServicesClient::getTcpRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetTcpRouteRequest

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\NetworkServices\V1\TcpRoute
Example
use Google\ApiCore\ApiException;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\GetTcpRouteRequest;
use Google\Cloud\NetworkServices\V1\TcpRoute;

/**
 * @param string $formattedName A name of the TcpRoute to get. Must be in the format
 *                              `projects/&#42;/locations/global/tcpRoutes/*`. Please see
 *                              {@see NetworkServicesClient::tcpRouteName()} for help formatting this field.
 */
function get_tcp_route_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var TcpRoute $response */
        $response = $networkServicesClient->getTcpRoute($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 = NetworkServicesClient::tcpRouteName('[PROJECT]', '[LOCATION]', '[TCP_ROUTE]');

    get_tcp_route_sample($formattedName);
}

getTlsRoute

Gets details of a single TlsRoute.

The async variant is NetworkServicesClient::getTlsRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetTlsRouteRequest

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\NetworkServices\V1\TlsRoute
Example
use Google\ApiCore\ApiException;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\GetTlsRouteRequest;
use Google\Cloud\NetworkServices\V1\TlsRoute;

/**
 * @param string $formattedName A name of the TlsRoute to get. Must be in the format
 *                              `projects/&#42;/locations/global/tlsRoutes/*`. Please see
 *                              {@see NetworkServicesClient::tlsRouteName()} for help formatting this field.
 */
function get_tls_route_sample(string $formattedName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var TlsRoute $response */
        $response = $networkServicesClient->getTlsRoute($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 = NetworkServicesClient::tlsRouteName('[PROJECT]', '[LOCATION]', '[TLS_ROUTE]');

    get_tls_route_sample($formattedName);
}

listEndpointPolicies

Lists EndpointPolicies in a given project and location.

The async variant is NetworkServicesClient::listEndpointPoliciesAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\ListEndpointPoliciesRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\EndpointPolicy;
use Google\Cloud\NetworkServices\V1\ListEndpointPoliciesRequest;

/**
 * @param string $formattedParent The project and location from which the EndpointPolicies should
 *                                be listed, specified in the format `projects/&#42;/locations/global`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 */
function list_endpoint_policies_sample(string $formattedParent): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

        /** @var EndpointPolicy $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');

    list_endpoint_policies_sample($formattedParent);
}

listGateways

Lists Gateways in a given project and location.

The async variant is NetworkServicesClient::listGatewaysAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\ListGatewaysRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\Gateway;
use Google\Cloud\NetworkServices\V1\ListGatewaysRequest;

/**
 * @param string $formattedParent The project and location from which the Gateways should be
 *                                listed, specified in the format `projects/&#42;/locations/*`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 */
function list_gateways_sample(string $formattedParent): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

        /** @var Gateway $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');

    list_gateways_sample($formattedParent);
}

listGrpcRoutes

Lists GrpcRoutes in a given project and location.

The async variant is NetworkServicesClient::listGrpcRoutesAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\ListGrpcRoutesRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\GrpcRoute;
use Google\Cloud\NetworkServices\V1\ListGrpcRoutesRequest;

/**
 * @param string $formattedParent The project and location from which the GrpcRoutes should be
 *                                listed, specified in the format `projects/&#42;/locations/global`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 */
function list_grpc_routes_sample(string $formattedParent): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

        /** @var GrpcRoute $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');

    list_grpc_routes_sample($formattedParent);
}

listHttpRoutes

Lists HttpRoute in a given project and location.

The async variant is NetworkServicesClient::listHttpRoutesAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\ListHttpRoutesRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\HttpRoute;
use Google\Cloud\NetworkServices\V1\ListHttpRoutesRequest;

/**
 * @param string $formattedParent The project and location from which the HttpRoutes should be
 *                                listed, specified in the format `projects/&#42;/locations/global`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 */
function list_http_routes_sample(string $formattedParent): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

        /** @var HttpRoute $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');

    list_http_routes_sample($formattedParent);
}

listMeshes

Lists Meshes in a given project and location.

The async variant is NetworkServicesClient::listMeshesAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\ListMeshesRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\ListMeshesRequest;
use Google\Cloud\NetworkServices\V1\Mesh;

/**
 * @param string $formattedParent The project and location from which the Meshes should be
 *                                listed, specified in the format `projects/&#42;/locations/global`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 */
function list_meshes_sample(string $formattedParent): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

        /** @var Mesh $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');

    list_meshes_sample($formattedParent);
}

listServiceBindings

Lists ServiceBinding in a given project and location.

The async variant is NetworkServicesClient::listServiceBindingsAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\ListServiceBindingsRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\ListServiceBindingsRequest;
use Google\Cloud\NetworkServices\V1\ServiceBinding;

/**
 * @param string $formattedParent The project and location from which the ServiceBindings should be
 *                                listed, specified in the format `projects/&#42;/locations/global`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 */
function list_service_bindings_sample(string $formattedParent): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

        /** @var ServiceBinding $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');

    list_service_bindings_sample($formattedParent);
}

listTcpRoutes

Lists TcpRoute in a given project and location.

The async variant is NetworkServicesClient::listTcpRoutesAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\ListTcpRoutesRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\ListTcpRoutesRequest;
use Google\Cloud\NetworkServices\V1\TcpRoute;

/**
 * @param string $formattedParent The project and location from which the TcpRoutes should be
 *                                listed, specified in the format `projects/&#42;/locations/global`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 */
function list_tcp_routes_sample(string $formattedParent): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

        /** @var TcpRoute $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');

    list_tcp_routes_sample($formattedParent);
}

listTlsRoutes

Lists TlsRoute in a given project and location.

The async variant is NetworkServicesClient::listTlsRoutesAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\ListTlsRoutesRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\ListTlsRoutesRequest;
use Google\Cloud\NetworkServices\V1\TlsRoute;

/**
 * @param string $formattedParent The project and location from which the TlsRoutes should be
 *                                listed, specified in the format `projects/&#42;/locations/global`. Please see
 *                                {@see NetworkServicesClient::locationName()} for help formatting this field.
 */
function list_tls_routes_sample(string $formattedParent): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

        /** @var TlsRoute $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 = NetworkServicesClient::locationName('[PROJECT]', '[LOCATION]');

    list_tls_routes_sample($formattedParent);
}

updateEndpointPolicy

Updates the parameters of a single EndpointPolicy.

The async variant is NetworkServicesClient::updateEndpointPolicyAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\UpdateEndpointPolicyRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\EndpointMatcher;
use Google\Cloud\NetworkServices\V1\EndpointPolicy;
use Google\Cloud\NetworkServices\V1\EndpointPolicy\EndpointPolicyType;
use Google\Cloud\NetworkServices\V1\UpdateEndpointPolicyRequest;
use Google\Rpc\Status;

/**
 * @param string $endpointPolicyName Name of the EndpointPolicy resource. It matches pattern
 *                                   `projects/{project}/locations/global/endpointPolicies/{endpoint_policy}`.
 * @param int    $endpointPolicyType The type of endpoint policy. This is primarily used to validate
 *                                   the configuration.
 */
function update_endpoint_policy_sample(string $endpointPolicyName, int $endpointPolicyType): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $endpointPolicyEndpointMatcher = new EndpointMatcher();
    $endpointPolicy = (new EndpointPolicy())
        ->setName($endpointPolicyName)
        ->setType($endpointPolicyType)
        ->setEndpointMatcher($endpointPolicyEndpointMatcher);
    $request = (new UpdateEndpointPolicyRequest())
        ->setEndpointPolicy($endpointPolicy);

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

        if ($response->operationSucceeded()) {
            /** @var EndpointPolicy $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
{
    $endpointPolicyName = '[NAME]';
    $endpointPolicyType = EndpointPolicyType::ENDPOINT_POLICY_TYPE_UNSPECIFIED;

    update_endpoint_policy_sample($endpointPolicyName, $endpointPolicyType);
}

updateGateway

Updates the parameters of a single Gateway.

The async variant is NetworkServicesClient::updateGatewayAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\UpdateGatewayRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\Gateway;
use Google\Cloud\NetworkServices\V1\UpdateGatewayRequest;
use Google\Rpc\Status;

/**
 * @param string $gatewayName         Name of the Gateway resource. It matches pattern
 *                                    `projects/&#42;/locations/&#42;/gateways/<gateway_name>`.
 * @param int    $gatewayPortsElement One or more ports that the Gateway must receive traffic on. The
 *                                    proxy binds to the ports specified. Gateway listen on 0.0.0.0 on the ports
 *                                    specified below.
 * @param string $gatewayScope        Immutable. Scope determines how configuration across multiple
 *                                    Gateway instances are merged. The configuration for multiple Gateway
 *                                    instances with the same scope will be merged as presented as a single
 *                                    coniguration to the proxy/load balancer.
 *
 *                                    Max length 64 characters.
 *                                    Scope should start with a letter and can only have letters, numbers,
 *                                    hyphens.
 */
function update_gateway_sample(
    string $gatewayName,
    int $gatewayPortsElement,
    string $gatewayScope
): void {
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $gatewayPorts = [$gatewayPortsElement,];
    $gateway = (new Gateway())
        ->setName($gatewayName)
        ->setPorts($gatewayPorts)
        ->setScope($gatewayScope);
    $request = (new UpdateGatewayRequest())
        ->setGateway($gateway);

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

        if ($response->operationSucceeded()) {
            /** @var Gateway $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
{
    $gatewayName = '[NAME]';
    $gatewayPortsElement = 0;
    $gatewayScope = '[SCOPE]';

    update_gateway_sample($gatewayName, $gatewayPortsElement, $gatewayScope);
}

updateGrpcRoute

Updates the parameters of a single GrpcRoute.

The async variant is NetworkServicesClient::updateGrpcRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\UpdateGrpcRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\GrpcRoute;
use Google\Cloud\NetworkServices\V1\GrpcRoute\RouteAction;
use Google\Cloud\NetworkServices\V1\GrpcRoute\RouteRule;
use Google\Cloud\NetworkServices\V1\UpdateGrpcRouteRequest;
use Google\Rpc\Status;

/**
 * @param string $grpcRouteName             Name of the GrpcRoute resource. It matches pattern
 *                                          `projects/&#42;/locations/global/grpcRoutes/<grpc_route_name>`
 * @param string $grpcRouteHostnamesElement Service hostnames with an optional port for which this route
 *                                          describes traffic.
 *
 *                                          Format: <hostname>[:<port>]
 *
 *                                          Hostname is the fully qualified domain name of a network host. This matches
 *                                          the RFC 1123 definition of a hostname with 2 notable exceptions:
 *                                          - IPs are not allowed.
 *                                          - A hostname may be prefixed with a wildcard label (`*.`). The wildcard
 *                                          label must appear by itself as the first label.
 *
 *                                          Hostname can be "precise" which is a domain name without the terminating
 *                                          dot of a network host (e.g. `foo.example.com`) or "wildcard", which is a
 *                                          domain name prefixed with a single wildcard label (e.g. `*.example.com`).
 *
 *                                          Note that as per RFC1035 and RFC1123, a label must consist of lower case
 *                                          alphanumeric characters or '-', and must start and end with an alphanumeric
 *                                          character. No other punctuation is allowed.
 *
 *                                          The routes associated with a Mesh or Gateway must have unique hostnames. If
 *                                          you attempt to attach multiple routes with conflicting hostnames, the
 *                                          configuration will be rejected.
 *
 *                                          For example, while it is acceptable for routes for the hostnames
 *                                          `*.foo.bar.com` and `*.bar.com` to be associated with the same route, it is
 *                                          not possible to associate two routes both with `*.bar.com` or both with
 *                                          `bar.com`.
 *
 *                                          If a port is specified, then gRPC clients must use the channel URI with the
 *                                          port to match this rule (i.e. "xds:///service:123"), otherwise they must
 *                                          supply the URI without a port (i.e. "xds:///service").
 */
function update_grpc_route_sample(string $grpcRouteName, string $grpcRouteHostnamesElement): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $grpcRouteHostnames = [$grpcRouteHostnamesElement,];
    $grpcRouteRulesAction = new RouteAction();
    $routeRule = (new RouteRule())
        ->setAction($grpcRouteRulesAction);
    $grpcRouteRules = [$routeRule,];
    $grpcRoute = (new GrpcRoute())
        ->setName($grpcRouteName)
        ->setHostnames($grpcRouteHostnames)
        ->setRules($grpcRouteRules);
    $request = (new UpdateGrpcRouteRequest())
        ->setGrpcRoute($grpcRoute);

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

        if ($response->operationSucceeded()) {
            /** @var GrpcRoute $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
{
    $grpcRouteName = '[NAME]';
    $grpcRouteHostnamesElement = '[HOSTNAMES]';

    update_grpc_route_sample($grpcRouteName, $grpcRouteHostnamesElement);
}

updateHttpRoute

Updates the parameters of a single HttpRoute.

The async variant is NetworkServicesClient::updateHttpRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\UpdateHttpRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\HttpRoute;
use Google\Cloud\NetworkServices\V1\HttpRoute\RouteRule;
use Google\Cloud\NetworkServices\V1\UpdateHttpRouteRequest;
use Google\Rpc\Status;

/**
 * @param string $httpRouteName             Name of the HttpRoute resource. It matches pattern
 *                                          `projects/&#42;/locations/global/httpRoutes/http_route_name>`.
 * @param string $httpRouteHostnamesElement Hostnames define a set of hosts that should match against the
 *                                          HTTP host header to select a HttpRoute to process the request. Hostname is
 *                                          the fully qualified domain name of a network host, as defined by RFC 1123
 *                                          with the exception that:
 *                                          - IPs are not allowed.
 *                                          - A hostname may be prefixed with a wildcard label (`*.`). The wildcard
 *                                          label must appear by itself as the first label.
 *
 *                                          Hostname can be "precise" which is a domain name without the terminating
 *                                          dot of a network host (e.g. `foo.example.com`) or "wildcard", which is a
 *                                          domain name prefixed with a single wildcard label (e.g. `*.example.com`).
 *
 *                                          Note that as per RFC1035 and RFC1123, a label must consist of lower case
 *                                          alphanumeric characters or '-', and must start and end with an alphanumeric
 *                                          character. No other punctuation is allowed.
 *
 *                                          The routes associated with a Mesh or Gateways  must have unique hostnames.
 *                                          If you attempt to attach multiple routes with conflicting hostnames,
 *                                          the configuration will be rejected.
 *
 *                                          For example, while it is acceptable for routes for the hostnames
 *                                          `*.foo.bar.com` and `*.bar.com` to be associated with the same Mesh (or
 *                                          Gateways under the same scope), it is not possible to associate two routes
 *                                          both with `*.bar.com` or both with `bar.com`.
 */
function update_http_route_sample(string $httpRouteName, string $httpRouteHostnamesElement): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $httpRouteHostnames = [$httpRouteHostnamesElement,];
    $httpRouteRules = [new RouteRule()];
    $httpRoute = (new HttpRoute())
        ->setName($httpRouteName)
        ->setHostnames($httpRouteHostnames)
        ->setRules($httpRouteRules);
    $request = (new UpdateHttpRouteRequest())
        ->setHttpRoute($httpRoute);

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

        if ($response->operationSucceeded()) {
            /** @var HttpRoute $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
{
    $httpRouteName = '[NAME]';
    $httpRouteHostnamesElement = '[HOSTNAMES]';

    update_http_route_sample($httpRouteName, $httpRouteHostnamesElement);
}

updateMesh

Updates the parameters of a single Mesh.

The async variant is NetworkServicesClient::updateMeshAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\UpdateMeshRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\Mesh;
use Google\Cloud\NetworkServices\V1\UpdateMeshRequest;
use Google\Rpc\Status;

/**
 * @param string $meshName Name of the Mesh resource. It matches pattern
 *                         `projects/&#42;/locations/global/meshes/<mesh_name>`.
 */
function update_mesh_sample(string $meshName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $mesh = (new Mesh())
        ->setName($meshName);
    $request = (new UpdateMeshRequest())
        ->setMesh($mesh);

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

        if ($response->operationSucceeded()) {
            /** @var Mesh $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
{
    $meshName = '[NAME]';

    update_mesh_sample($meshName);
}

updateTcpRoute

Updates the parameters of a single TcpRoute.

The async variant is NetworkServicesClient::updateTcpRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\UpdateTcpRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\TcpRoute;
use Google\Cloud\NetworkServices\V1\TcpRoute\RouteAction;
use Google\Cloud\NetworkServices\V1\TcpRoute\RouteRule;
use Google\Cloud\NetworkServices\V1\UpdateTcpRouteRequest;
use Google\Rpc\Status;

/**
 * @param string $tcpRouteName Name of the TcpRoute resource. It matches pattern
 *                             `projects/&#42;/locations/global/tcpRoutes/tcp_route_name>`.
 */
function update_tcp_route_sample(string $tcpRouteName): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $tcpRouteRulesAction = new RouteAction();
    $routeRule = (new RouteRule())
        ->setAction($tcpRouteRulesAction);
    $tcpRouteRules = [$routeRule,];
    $tcpRoute = (new TcpRoute())
        ->setName($tcpRouteName)
        ->setRules($tcpRouteRules);
    $request = (new UpdateTcpRouteRequest())
        ->setTcpRoute($tcpRoute);

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

        if ($response->operationSucceeded()) {
            /** @var TcpRoute $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
{
    $tcpRouteName = '[NAME]';

    update_tcp_route_sample($tcpRouteName);
}

updateTlsRoute

Updates the parameters of a single TlsRoute.

The async variant is NetworkServicesClient::updateTlsRouteAsync() .

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\UpdateTlsRouteRequest

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\NetworkServices\V1\Client\NetworkServicesClient;
use Google\Cloud\NetworkServices\V1\TlsRoute;
use Google\Cloud\NetworkServices\V1\TlsRoute\RouteAction;
use Google\Cloud\NetworkServices\V1\TlsRoute\RouteDestination;
use Google\Cloud\NetworkServices\V1\TlsRoute\RouteMatch;
use Google\Cloud\NetworkServices\V1\TlsRoute\RouteRule;
use Google\Cloud\NetworkServices\V1\UpdateTlsRouteRequest;
use Google\Rpc\Status;

/**
 * @param string $tlsRouteName                                        Name of the TlsRoute resource. It matches pattern
 *                                                                    `projects/&#42;/locations/global/tlsRoutes/tls_route_name>`.
 * @param string $formattedTlsRouteRulesActionDestinationsServiceName The URL of a BackendService to route traffic to. Please see
 *                                                                    {@see NetworkServicesClient::backendServiceName()} for help formatting this field.
 */
function update_tls_route_sample(
    string $tlsRouteName,
    string $formattedTlsRouteRulesActionDestinationsServiceName
): void {
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $tlsRouteRulesMatches = [new RouteMatch()];
    $routeDestination = (new RouteDestination())
        ->setServiceName($formattedTlsRouteRulesActionDestinationsServiceName);
    $tlsRouteRulesActionDestinations = [$routeDestination,];
    $tlsRouteRulesAction = (new RouteAction())
        ->setDestinations($tlsRouteRulesActionDestinations);
    $routeRule = (new RouteRule())
        ->setMatches($tlsRouteRulesMatches)
        ->setAction($tlsRouteRulesAction);
    $tlsRouteRules = [$routeRule,];
    $tlsRoute = (new TlsRoute())
        ->setName($tlsRouteName)
        ->setRules($tlsRouteRules);
    $request = (new UpdateTlsRouteRequest())
        ->setTlsRoute($tlsRoute);

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

        if ($response->operationSucceeded()) {
            /** @var TlsRoute $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
{
    $tlsRouteName = '[NAME]';
    $formattedTlsRouteRulesActionDestinationsServiceName = NetworkServicesClient::backendServiceName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKEND_SERVICE]'
    );

    update_tls_route_sample($tlsRouteName, $formattedTlsRouteRulesActionDestinationsServiceName);
}

getLocation

Gets information about a location.

The async variant is NetworkServicesClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

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\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;

/**
 * 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 get_location_sample(): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

listLocations

Lists information about the supported locations for this service.

The async variant is NetworkServicesClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

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\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;

/**
 * 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_locations_sample(): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

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

        /** @var Location $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());
    }
}

getIamPolicy

Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.

The async variant is NetworkServicesClient::getIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest

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\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;

/**
 * @param string $resource REQUIRED: The resource for which the policy is being requested.
 *                         See the operation documentation for the appropriate value for this field.
 */
function get_iam_policy_sample(string $resource): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $networkServicesClient->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);
}

setIamPolicy

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

Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.

The async variant is NetworkServicesClient::setIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest

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\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;

/**
 * @param string $resource REQUIRED: The resource for which the policy is being specified.
 *                         See the operation documentation for the appropriate value for this field.
 */
function set_iam_policy_sample(string $resource): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $policy = new Policy();
    $request = (new SetIamPolicyRequest())
        ->setResource($resource)
        ->setPolicy($policy);

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $networkServicesClient->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. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

The async variant is NetworkServicesClient::testIamPermissionsAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest

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\Iam\V1\TestIamPermissionsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Iam\V1\TestIamPermissionsRequest;
use Google\Cloud\Iam\V1\TestIamPermissionsResponse;
use Google\Cloud\NetworkServices\V1\Client\NetworkServicesClient;

/**
 * @param string $resource           REQUIRED: The resource for which the policy detail is being requested.
 *                                   See the operation documentation for the appropriate value for this field.
 * @param string $permissionsElement The set of permissions to check for the `resource`. Permissions with
 *                                   wildcards (such as '*' or 'storage.*') are not allowed. For more
 *                                   information see
 *                                   [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
 */
function test_iam_permissions_sample(string $resource, string $permissionsElement): void
{
    // Create a client.
    $networkServicesClient = new NetworkServicesClient();

    // Prepare the request message.
    $permissions = [$permissionsElement,];
    $request = (new TestIamPermissionsRequest())
        ->setResource($resource)
        ->setPermissions($permissions);

    // Call the API and handle any network failures.
    try {
        /** @var TestIamPermissionsResponse $response */
        $response = $networkServicesClient->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]';
    $permissionsElement = '[PERMISSIONS]';

    test_iam_permissions_sample($resource, $permissionsElement);
}

createEndpointPolicyAsync

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

createGatewayAsync

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

createGrpcRouteAsync

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

createHttpRouteAsync

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

createMeshAsync

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

createServiceBindingAsync

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

createTcpRouteAsync

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

createTlsRouteAsync

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

deleteEndpointPolicyAsync

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

deleteGatewayAsync

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

deleteGrpcRouteAsync

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

deleteHttpRouteAsync

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

deleteMeshAsync

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

deleteServiceBindingAsync

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

deleteTcpRouteAsync

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

deleteTlsRouteAsync

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

getEndpointPolicyAsync

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetEndpointPolicyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\NetworkServices\V1\EndpointPolicy>

getGatewayAsync

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetGatewayRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\NetworkServices\V1\Gateway>

getGrpcRouteAsync

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetGrpcRouteRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\NetworkServices\V1\GrpcRoute>

getHttpRouteAsync

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetHttpRouteRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\NetworkServices\V1\HttpRoute>

getMeshAsync

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetMeshRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\NetworkServices\V1\Mesh>

getServiceBindingAsync

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetServiceBindingRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\NetworkServices\V1\ServiceBinding>

getTcpRouteAsync

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetTcpRouteRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\NetworkServices\V1\TcpRoute>

getTlsRouteAsync

Parameters
Name Description
request Google\Cloud\NetworkServices\V1\GetTlsRouteRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\NetworkServices\V1\TlsRoute>

listEndpointPoliciesAsync

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

listGatewaysAsync

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

listGrpcRoutesAsync

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

listHttpRoutesAsync

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

listMeshesAsync

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

listServiceBindingsAsync

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

listTcpRoutesAsync

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

listTlsRoutesAsync

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

updateEndpointPolicyAsync

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

updateGatewayAsync

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

updateGrpcRouteAsync

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

updateHttpRouteAsync

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

updateMeshAsync

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

updateTcpRouteAsync

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

updateTlsRouteAsync

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

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Location\Location>

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

getIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\Policy>

setIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\Policy>

testIamPermissionsAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\TestIamPermissionsResponse>

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::authorizationPolicyName

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

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

static::backendServiceName

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

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

static::clientTlsPolicyName

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

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

static::endpointPolicyName

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

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

static::gatewayName

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

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

static::grpcRouteName

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

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

static::httpRouteName

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

Parameters
Name Description
project string
location string
httpRoute string
Returns
Type Description
string The formatted http_route 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::meshName

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

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

static::serverTlsPolicyName

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

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

static::serviceBindingName

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

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

static::tcpRouteName

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

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

static::tlsRouteName

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

Parameters
Name Description
project string
location string
tlsRoute string
Returns
Type Description
string The formatted tls_route 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

  • authorizationPolicy: projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}
  • backendService: projects/{project}/locations/{location}/backendServices/{backend_service}
  • clientTlsPolicy: projects/{project}/locations/{location}/clientTlsPolicies/{client_tls_policy}
  • endpointPolicy: projects/{project}/locations/{location}/endpointPolicies/{endpoint_policy}
  • gateway: projects/{project}/locations/{location}/gateways/{gateway}
  • grpcRoute: projects/{project}/locations/{location}/grpcRoutes/{grpc_route}
  • httpRoute: projects/{project}/locations/{location}/httpRoutes/{http_route}
  • location: projects/{project}/locations/{location}
  • mesh: projects/{project}/locations/{location}/meshes/{mesh}
  • serverTlsPolicy: projects/{project}/locations/{location}/serverTlsPolicies/{server_tls_policy}
  • serviceBinding: projects/{project}/locations/{location}/serviceBindings/{service_binding}
  • tcpRoute: projects/{project}/locations/{location}/tcpRoutes/{tcp_route}
  • tlsRoute: projects/{project}/locations/{location}/tlsRoutes/{tls_route}

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.