Google Cloud App Hub V1 Client - Class AppHubClient (0.1.2)

Reference documentation and code samples for the Google Cloud App Hub V1 Client class AppHubClient.

Service Description: The App Hub API allows you to manage App Hub 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 \ AppHub \ 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.

createApplication

Creates an Application in a host project and location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::createApplicationAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\CreateApplicationRequest

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\AppHub\V1\Application;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\CreateApplicationRequest;
use Google\Cloud\AppHub\V1\Scope;
use Google\Cloud\AppHub\V1\Scope\Type;
use Google\Rpc\Status;

/**
 * @param string $formattedParent      Project and location to create Application in.
 *                                     Expected format: `projects/{project}/locations/{location}`. Please see
 *                                     {@see AppHubClient::locationName()} for help formatting this field.
 * @param string $applicationId        The Application identifier.
 *                                     Must contain only lowercase letters, numbers
 *                                     or hyphens, with the first character a letter, the last a letter or a
 *                                     number, and a 63 character maximum.
 * @param int    $applicationScopeType Scope Type.
 */
function create_application_sample(
    string $formattedParent,
    string $applicationId,
    int $applicationScopeType
): void {
    // Create a client.
    $appHubClient = new AppHubClient();

    // Prepare the request message.
    $applicationScope = (new Scope())
        ->setType($applicationScopeType);
    $application = (new Application())
        ->setScope($applicationScope);
    $request = (new CreateApplicationRequest())
        ->setParent($formattedParent)
        ->setApplicationId($applicationId)
        ->setApplication($application);

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

        if ($response->operationSucceeded()) {
            /** @var Application $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 = AppHubClient::locationName('[PROJECT]', '[LOCATION]');
    $applicationId = '[APPLICATION_ID]';
    $applicationScopeType = Type::TYPE_UNSPECIFIED;

    create_application_sample($formattedParent, $applicationId, $applicationScopeType);
}

createService

Creates a Service in an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::createServiceAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\CreateServiceRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\CreateServiceRequest;
use Google\Cloud\AppHub\V1\Service;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                   Fully qualified name of the parent Application to create the
 *                                                  Service in. Expected format:
 *                                                  `projects/{project}/locations/{location}/applications/{application}`. Please see
 *                                                  {@see AppHubClient::applicationName()} for help formatting this field.
 * @param string $serviceId                         The Service identifier.
 *                                                  Must contain only lowercase letters, numbers
 *                                                  or hyphens, with the first character a letter, the last a letter or a
 *                                                  number, and a 63 character maximum.
 * @param string $formattedServiceDiscoveredService Immutable. The resource name of the original discovered service. Please see
 *                                                  {@see AppHubClient::locationName()} for help formatting this field.
 */
function create_service_sample(
    string $formattedParent,
    string $serviceId,
    string $formattedServiceDiscoveredService
): void {
    // Create a client.
    $appHubClient = new AppHubClient();

    // Prepare the request message.
    $service = (new Service())
        ->setDiscoveredService($formattedServiceDiscoveredService);
    $request = (new CreateServiceRequest())
        ->setParent($formattedParent)
        ->setServiceId($serviceId)
        ->setService($service);

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

        if ($response->operationSucceeded()) {
            /** @var Service $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 = AppHubClient::applicationName('[PROJECT]', '[LOCATION]', '[APPLICATION]');
    $serviceId = '[SERVICE_ID]';
    $formattedServiceDiscoveredService = AppHubClient::locationName('[PROJECT]', '[LOCATION]');

    create_service_sample($formattedParent, $serviceId, $formattedServiceDiscoveredService);
}

createServiceProjectAttachment

Attaches a service project to the host project.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::createServiceProjectAttachmentAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\CreateServiceProjectAttachmentRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\CreateServiceProjectAttachmentRequest;
use Google\Cloud\AppHub\V1\ServiceProjectAttachment;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                                 Host project ID and location to which service project is being
 *                                                                attached. Only global location is supported. Expected format:
 *                                                                `projects/{project}/locations/{location}`. Please see
 *                                                                {@see AppHubClient::locationName()} for help formatting this field.
 * @param string $serviceProjectAttachmentId                      The service project attachment identifier must contain the
 *                                                                project id of the service project specified in the
 *                                                                service_project_attachment.service_project field.
 * @param string $formattedServiceProjectAttachmentServiceProject Immutable. Service project name in the format: "projects/abc" or
 *                                                                "projects/123". As input, project name with either project id or number are
 *                                                                accepted. As output, this field will contain project number. Please see
 *                                                                {@see AppHubClient::projectName()} for help formatting this field.
 */
function create_service_project_attachment_sample(
    string $formattedParent,
    string $serviceProjectAttachmentId,
    string $formattedServiceProjectAttachmentServiceProject
): void {
    // Create a client.
    $appHubClient = new AppHubClient();

    // Prepare the request message.
    $serviceProjectAttachment = (new ServiceProjectAttachment())
        ->setServiceProject($formattedServiceProjectAttachmentServiceProject);
    $request = (new CreateServiceProjectAttachmentRequest())
        ->setParent($formattedParent)
        ->setServiceProjectAttachmentId($serviceProjectAttachmentId)
        ->setServiceProjectAttachment($serviceProjectAttachment);

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

        if ($response->operationSucceeded()) {
            /** @var ServiceProjectAttachment $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 = AppHubClient::locationName('[PROJECT]', '[LOCATION]');
    $serviceProjectAttachmentId = '[SERVICE_PROJECT_ATTACHMENT_ID]';
    $formattedServiceProjectAttachmentServiceProject = AppHubClient::projectName('[PROJECT]');

    create_service_project_attachment_sample(
        $formattedParent,
        $serviceProjectAttachmentId,
        $formattedServiceProjectAttachmentServiceProject
    );
}

createWorkload

Creates a Workload in an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::createWorkloadAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\CreateWorkloadRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\CreateWorkloadRequest;
use Google\Cloud\AppHub\V1\Workload;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                     Fully qualified name of the Application to create Workload in.
 *                                                    Expected format:
 *                                                    `projects/{project}/locations/{location}/applications/{application}`. Please see
 *                                                    {@see AppHubClient::applicationName()} for help formatting this field.
 * @param string $workloadId                          The Workload identifier.
 *                                                    Must contain only lowercase letters, numbers
 *                                                    or hyphens, with the first character a letter, the last a letter or a
 *                                                    number, and a 63 character maximum.
 * @param string $formattedWorkloadDiscoveredWorkload Immutable. The resource name of the original discovered workload. Please see
 *                                                    {@see AppHubClient::locationName()} for help formatting this field.
 */
function create_workload_sample(
    string $formattedParent,
    string $workloadId,
    string $formattedWorkloadDiscoveredWorkload
): void {
    // Create a client.
    $appHubClient = new AppHubClient();

    // Prepare the request message.
    $workload = (new Workload())
        ->setDiscoveredWorkload($formattedWorkloadDiscoveredWorkload);
    $request = (new CreateWorkloadRequest())
        ->setParent($formattedParent)
        ->setWorkloadId($workloadId)
        ->setWorkload($workload);

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

        if ($response->operationSucceeded()) {
            /** @var Workload $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 = AppHubClient::applicationName('[PROJECT]', '[LOCATION]', '[APPLICATION]');
    $workloadId = '[WORKLOAD_ID]';
    $formattedWorkloadDiscoveredWorkload = AppHubClient::locationName('[PROJECT]', '[LOCATION]');

    create_workload_sample($formattedParent, $workloadId, $formattedWorkloadDiscoveredWorkload);
}

deleteApplication

Deletes an Application in a host project and location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::deleteApplicationAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\DeleteApplicationRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\DeleteApplicationRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Fully qualified name of the Application to delete.
 *                              Expected format:
 *                              `projects/{project}/locations/{location}/applications/{application}`. Please see
 *                              {@see AppHubClient::applicationName()} for help formatting this field.
 */
function delete_application_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $appHubClient->deleteApplication($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 = AppHubClient::applicationName('[PROJECT]', '[LOCATION]', '[APPLICATION]');

    delete_application_sample($formattedName);
}

deleteService

Deletes a Service from an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::deleteServiceAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\DeleteServiceRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\DeleteServiceRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Fully qualified name of the Service to delete from an
 *                              Application. Expected format:
 *                              `projects/{project}/locations/{location}/applications/{application}/services/{service}`. Please see
 *                              {@see AppHubClient::serviceName()} for help formatting this field.
 */
function delete_service_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $appHubClient->deleteService($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 = AppHubClient::serviceName('[PROJECT]', '[LOCATION]', '[APPLICATION]', '[SERVICE]');

    delete_service_sample($formattedName);
}

deleteServiceProjectAttachment

Deletes a service project attachment.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::deleteServiceProjectAttachmentAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\DeleteServiceProjectAttachmentRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\DeleteServiceProjectAttachmentRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Fully qualified name of the service project attachment to delete.
 *                              Expected format:
 *                              `projects/{project}/locations/{location}/serviceProjectAttachments/{serviceProjectAttachment}`. Please see
 *                              {@see AppHubClient::serviceProjectAttachmentName()} for help formatting this field.
 */
function delete_service_project_attachment_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $appHubClient->deleteServiceProjectAttachment($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 = AppHubClient::serviceProjectAttachmentName(
        '[PROJECT]',
        '[LOCATION]',
        '[SERVICE_PROJECT_ATTACHMENT]'
    );

    delete_service_project_attachment_sample($formattedName);
}

deleteWorkload

Deletes a Workload from an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::deleteWorkloadAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\DeleteWorkloadRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\DeleteWorkloadRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Fully qualified name of the Workload to delete from an
 *                              Application. Expected format:
 *                              `projects/{project}/locations/{location}/applications/{application}/workloads/{workload}`. Please see
 *                              {@see AppHubClient::workloadName()} for help formatting this field.
 */
function delete_workload_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $appHubClient->deleteWorkload($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 = AppHubClient::workloadName(
        '[PROJECT]',
        '[LOCATION]',
        '[APPLICATION]',
        '[WORKLOAD]'
    );

    delete_workload_sample($formattedName);
}

detachServiceProjectAttachment

Detaches a service project from a host project.

You can call this API from any service project without needing access to the host project that it is attached to.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::detachServiceProjectAttachmentAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\DetachServiceProjectAttachmentRequest

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\AppHub\V1\DetachServiceProjectAttachmentResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\DetachServiceProjectAttachmentRequest;
use Google\Cloud\AppHub\V1\DetachServiceProjectAttachmentResponse;

/**
 * @param string $formattedName Service project id and location to detach from a host project.
 *                              Only global location is supported. Expected format:
 *                              `projects/{project}/locations/{location}`. Please see
 *                              {@see AppHubClient::locationName()} for help formatting this field.
 */
function detach_service_project_attachment_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var DetachServiceProjectAttachmentResponse $response */
        $response = $appHubClient->detachServiceProjectAttachment($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 = AppHubClient::locationName('[PROJECT]', '[LOCATION]');

    detach_service_project_attachment_sample($formattedName);
}

getApplication

Gets an Application in a host project and location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::getApplicationAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetApplicationRequest

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\AppHub\V1\Application
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Application;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\GetApplicationRequest;

/**
 * @param string $formattedName Fully qualified name of the Application to fetch.
 *                              Expected format:
 *                              `projects/{project}/locations/{location}/applications/{application}`. Please see
 *                              {@see AppHubClient::applicationName()} for help formatting this field.
 */
function get_application_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Application $response */
        $response = $appHubClient->getApplication($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 = AppHubClient::applicationName('[PROJECT]', '[LOCATION]', '[APPLICATION]');

    get_application_sample($formattedName);
}

getDiscoveredService

Gets a Discovered Service in a host project and location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::getDiscoveredServiceAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetDiscoveredServiceRequest

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\AppHub\V1\DiscoveredService
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\DiscoveredService;
use Google\Cloud\AppHub\V1\GetDiscoveredServiceRequest;

/**
 * @param string $formattedName Fully qualified name of the Discovered Service to fetch.
 *                              Expected format:
 *                              `projects/{project}/locations/{location}/discoveredServices/{discoveredService}`. Please see
 *                              {@see AppHubClient::discoveredServiceName()} for help formatting this field.
 */
function get_discovered_service_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var DiscoveredService $response */
        $response = $appHubClient->getDiscoveredService($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 = AppHubClient::discoveredServiceName(
        '[PROJECT]',
        '[LOCATION]',
        '[DISCOVERED_SERVICE]'
    );

    get_discovered_service_sample($formattedName);
}

getDiscoveredWorkload

Gets a Discovered Workload in a host project and location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::getDiscoveredWorkloadAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetDiscoveredWorkloadRequest

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\AppHub\V1\DiscoveredWorkload
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\DiscoveredWorkload;
use Google\Cloud\AppHub\V1\GetDiscoveredWorkloadRequest;

/**
 * @param string $formattedName Fully qualified name of the Discovered Workload to fetch.
 *                              Expected format:
 *                              `projects/{project}/locations/{location}/discoveredWorkloads/{discoveredWorkload}`. Please see
 *                              {@see AppHubClient::discoveredWorkloadName()} for help formatting this field.
 */
function get_discovered_workload_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var DiscoveredWorkload $response */
        $response = $appHubClient->getDiscoveredWorkload($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 = AppHubClient::discoveredWorkloadName(
        '[PROJECT]',
        '[LOCATION]',
        '[DISCOVERED_WORKLOAD]'
    );

    get_discovered_workload_sample($formattedName);
}

getService

Gets a Service in an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::getServiceAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetServiceRequest

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\AppHub\V1\Service
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\GetServiceRequest;
use Google\Cloud\AppHub\V1\Service;

/**
 * @param string $formattedName Fully qualified name of the Service to fetch.
 *                              Expected format:
 *                              `projects/{project}/locations/{location}/applications/{application}/services/{service}`. Please see
 *                              {@see AppHubClient::serviceName()} for help formatting this field.
 */
function get_service_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Service $response */
        $response = $appHubClient->getService($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 = AppHubClient::serviceName('[PROJECT]', '[LOCATION]', '[APPLICATION]', '[SERVICE]');

    get_service_sample($formattedName);
}

getServiceProjectAttachment

Gets a service project attachment.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::getServiceProjectAttachmentAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetServiceProjectAttachmentRequest

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\AppHub\V1\ServiceProjectAttachment
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\GetServiceProjectAttachmentRequest;
use Google\Cloud\AppHub\V1\ServiceProjectAttachment;

/**
 * @param string $formattedName Fully qualified name of the service project attachment to
 *                              retrieve. Expected format:
 *                              `projects/{project}/locations/{location}/serviceProjectAttachments/{serviceProjectAttachment}`. Please see
 *                              {@see AppHubClient::serviceProjectAttachmentName()} for help formatting this field.
 */
function get_service_project_attachment_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var ServiceProjectAttachment $response */
        $response = $appHubClient->getServiceProjectAttachment($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 = AppHubClient::serviceProjectAttachmentName(
        '[PROJECT]',
        '[LOCATION]',
        '[SERVICE_PROJECT_ATTACHMENT]'
    );

    get_service_project_attachment_sample($formattedName);
}

getWorkload

Gets a Workload in an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::getWorkloadAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetWorkloadRequest

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\AppHub\V1\Workload
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\GetWorkloadRequest;
use Google\Cloud\AppHub\V1\Workload;

/**
 * @param string $formattedName Fully qualified name of the Workload to fetch.
 *                              Expected format:
 *                              `projects/{project}/locations/{location}/applications/{application}/workloads/{workload}`. Please see
 *                              {@see AppHubClient::workloadName()} for help formatting this field.
 */
function get_workload_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Workload $response */
        $response = $appHubClient->getWorkload($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 = AppHubClient::workloadName(
        '[PROJECT]',
        '[LOCATION]',
        '[APPLICATION]',
        '[WORKLOAD]'
    );

    get_workload_sample($formattedName);
}

listApplications

Lists Applications in a host project and location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::listApplicationsAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListApplicationsRequest

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\AppHub\V1\Application;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\ListApplicationsRequest;

/**
 * @param string $formattedParent Project and location to list Applications on.
 *                                Expected format: `projects/{project}/locations/{location}`. Please see
 *                                {@see AppHubClient::locationName()} for help formatting this field.
 */
function list_applications_sample(string $formattedParent): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

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

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

    list_applications_sample($formattedParent);
}

listDiscoveredServices

Lists Discovered Services that can be added to an Application in a host project and location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::listDiscoveredServicesAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListDiscoveredServicesRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\DiscoveredService;
use Google\Cloud\AppHub\V1\ListDiscoveredServicesRequest;

/**
 * @param string $formattedParent Project and location to list Discovered Services on.
 *                                Expected format: `projects/{project}/locations/{location}`. Please see
 *                                {@see AppHubClient::locationName()} for help formatting this field.
 */
function list_discovered_services_sample(string $formattedParent): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

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

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

    list_discovered_services_sample($formattedParent);
}

listDiscoveredWorkloads

Lists Discovered Workloads that can be added to an Application in a host project and location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::listDiscoveredWorkloadsAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListDiscoveredWorkloadsRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\DiscoveredWorkload;
use Google\Cloud\AppHub\V1\ListDiscoveredWorkloadsRequest;

/**
 * @param string $formattedParent Project and location to list Discovered Workloads on.
 *                                Expected format: `projects/{project}/locations/{location}`. Please see
 *                                {@see AppHubClient::locationName()} for help formatting this field.
 */
function list_discovered_workloads_sample(string $formattedParent): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

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

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

    list_discovered_workloads_sample($formattedParent);
}

listServiceProjectAttachments

Lists service projects attached to the host project.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::listServiceProjectAttachmentsAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListServiceProjectAttachmentsRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\ListServiceProjectAttachmentsRequest;
use Google\Cloud\AppHub\V1\ServiceProjectAttachment;

/**
 * @param string $formattedParent Host project ID and location to list service project attachments.
 *                                Only global location is supported. Expected format:
 *                                `projects/{project}/locations/{location}`. Please see
 *                                {@see AppHubClient::locationName()} for help formatting this field.
 */
function list_service_project_attachments_sample(string $formattedParent): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

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

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

    list_service_project_attachments_sample($formattedParent);
}

listServices

Lists Services in an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::listServicesAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListServicesRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\ListServicesRequest;
use Google\Cloud\AppHub\V1\Service;

/**
 * @param string $formattedParent Fully qualified name of the parent Application to list Services
 *                                for. Expected format:
 *                                `projects/{project}/locations/{location}/applications/{application}`. Please see
 *                                {@see AppHubClient::applicationName()} for help formatting this field.
 */
function list_services_sample(string $formattedParent): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

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

        /** @var Service $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 = AppHubClient::applicationName('[PROJECT]', '[LOCATION]', '[APPLICATION]');

    list_services_sample($formattedParent);
}

listWorkloads

Lists Workloads in an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::listWorkloadsAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListWorkloadsRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\ListWorkloadsRequest;
use Google\Cloud\AppHub\V1\Workload;

/**
 * @param string $formattedParent Fully qualified name of the parent Application to list Workloads
 *                                for. Expected format:
 *                                `projects/{project}/locations/{location}/applications/{application}`. Please see
 *                                {@see AppHubClient::applicationName()} for help formatting this field.
 */
function list_workloads_sample(string $formattedParent): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

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

        /** @var Workload $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 = AppHubClient::applicationName('[PROJECT]', '[LOCATION]', '[APPLICATION]');

    list_workloads_sample($formattedParent);
}

lookupDiscoveredService

Lists a Discovered Service in a host project and location, with a given resource URI.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::lookupDiscoveredServiceAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\LookupDiscoveredServiceRequest

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\AppHub\V1\LookupDiscoveredServiceResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\LookupDiscoveredServiceRequest;
use Google\Cloud\AppHub\V1\LookupDiscoveredServiceResponse;

/**
 * @param string $formattedParent Host project ID and location to lookup Discovered Service in.
 *                                Expected format: `projects/{project}/locations/{location}`. Please see
 *                                {@see AppHubClient::locationName()} for help formatting this field.
 * @param string $uri             Resource URI to find DiscoveredService for.
 *                                Accepts both project number and project ID and does translation when
 *                                needed.
 */
function lookup_discovered_service_sample(string $formattedParent, string $uri): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var LookupDiscoveredServiceResponse $response */
        $response = $appHubClient->lookupDiscoveredService($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
{
    $formattedParent = AppHubClient::locationName('[PROJECT]', '[LOCATION]');
    $uri = '[URI]';

    lookup_discovered_service_sample($formattedParent, $uri);
}

lookupDiscoveredWorkload

Lists a Discovered Workload in a host project and location, with a given resource URI.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::lookupDiscoveredWorkloadAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\LookupDiscoveredWorkloadRequest

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\AppHub\V1\LookupDiscoveredWorkloadResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\LookupDiscoveredWorkloadRequest;
use Google\Cloud\AppHub\V1\LookupDiscoveredWorkloadResponse;

/**
 * @param string $formattedParent Host project ID and location to lookup Discovered Workload in.
 *                                Expected format: `projects/{project}/locations/{location}`. Please see
 *                                {@see AppHubClient::locationName()} for help formatting this field.
 * @param string $uri             Resource URI to find Discovered Workload for.
 *                                Accepts both project number and project ID and does translation when
 *                                needed.
 */
function lookup_discovered_workload_sample(string $formattedParent, string $uri): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var LookupDiscoveredWorkloadResponse $response */
        $response = $appHubClient->lookupDiscoveredWorkload($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
{
    $formattedParent = AppHubClient::locationName('[PROJECT]', '[LOCATION]');
    $uri = '[URI]';

    lookup_discovered_workload_sample($formattedParent, $uri);
}

lookupServiceProjectAttachment

Lists a service project attachment for a given service project. You can call this API from any project to find if it is attached to a host project.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::lookupServiceProjectAttachmentAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\LookupServiceProjectAttachmentRequest

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\AppHub\V1\LookupServiceProjectAttachmentResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\LookupServiceProjectAttachmentRequest;
use Google\Cloud\AppHub\V1\LookupServiceProjectAttachmentResponse;

/**
 * @param string $formattedName Service project ID and location to lookup service project
 *                              attachment for. Only global location is supported. Expected format:
 *                              `projects/{project}/locations/{location}`. Please see
 *                              {@see AppHubClient::locationName()} for help formatting this field.
 */
function lookup_service_project_attachment_sample(string $formattedName): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var LookupServiceProjectAttachmentResponse $response */
        $response = $appHubClient->lookupServiceProjectAttachment($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 = AppHubClient::locationName('[PROJECT]', '[LOCATION]');

    lookup_service_project_attachment_sample($formattedName);
}

updateApplication

Updates an Application in a host project and location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::updateApplicationAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\UpdateApplicationRequest

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\AppHub\V1\Application;
use Google\Cloud\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\Scope;
use Google\Cloud\AppHub\V1\Scope\Type;
use Google\Cloud\AppHub\V1\UpdateApplicationRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * @param int $applicationScopeType Scope Type.
 */
function update_application_sample(int $applicationScopeType): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

    // Prepare the request message.
    $updateMask = new FieldMask();
    $applicationScope = (new Scope())
        ->setType($applicationScopeType);
    $application = (new Application())
        ->setScope($applicationScope);
    $request = (new UpdateApplicationRequest())
        ->setUpdateMask($updateMask)
        ->setApplication($application);

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

        if ($response->operationSucceeded()) {
            /** @var Application $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
{
    $applicationScopeType = Type::TYPE_UNSPECIFIED;

    update_application_sample($applicationScopeType);
}

updateService

Updates a Service in an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::updateServiceAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\UpdateServiceRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\Service;
use Google\Cloud\AppHub\V1\UpdateServiceRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * @param string $formattedServiceDiscoveredService Immutable. The resource name of the original discovered service. Please see
 *                                                  {@see AppHubClient::locationName()} for help formatting this field.
 */
function update_service_sample(string $formattedServiceDiscoveredService): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

    // Prepare the request message.
    $updateMask = new FieldMask();
    $service = (new Service())
        ->setDiscoveredService($formattedServiceDiscoveredService);
    $request = (new UpdateServiceRequest())
        ->setUpdateMask($updateMask)
        ->setService($service);

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

        if ($response->operationSucceeded()) {
            /** @var Service $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
{
    $formattedServiceDiscoveredService = AppHubClient::locationName('[PROJECT]', '[LOCATION]');

    update_service_sample($formattedServiceDiscoveredService);
}

updateWorkload

Updates a Workload in an Application.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::updateWorkloadAsync() .

Parameters
Name Description
request Google\Cloud\AppHub\V1\UpdateWorkloadRequest

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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\AppHub\V1\UpdateWorkloadRequest;
use Google\Cloud\AppHub\V1\Workload;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * @param string $formattedWorkloadDiscoveredWorkload Immutable. The resource name of the original discovered workload. Please see
 *                                                    {@see AppHubClient::locationName()} for help formatting this field.
 */
function update_workload_sample(string $formattedWorkloadDiscoveredWorkload): void
{
    // Create a client.
    $appHubClient = new AppHubClient();

    // Prepare the request message.
    $updateMask = new FieldMask();
    $workload = (new Workload())
        ->setDiscoveredWorkload($formattedWorkloadDiscoveredWorkload);
    $request = (new UpdateWorkloadRequest())
        ->setUpdateMask($updateMask)
        ->setWorkload($workload);

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

        if ($response->operationSucceeded()) {
            /** @var Workload $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
{
    $formattedWorkloadDiscoveredWorkload = AppHubClient::locationName('[PROJECT]', '[LOCATION]');

    update_workload_sample($formattedWorkloadDiscoveredWorkload);
}

getLocation

Gets information about a location.

The async variant is Google\Cloud\AppHub\V1\Client\AppHubClient::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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;

/**
 * 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.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $appHubClient->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 Google\Cloud\AppHub\V1\Client\AppHubClient::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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;

/**
 * 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.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $appHubClient->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 Google\Cloud\AppHub\V1\Client\AppHubClient::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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;

/**
 * @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.
    $appHubClient = new AppHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $appHubClient->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 Google\Cloud\AppHub\V1\Client\AppHubClient::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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;

/**
 * @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.
    $appHubClient = new AppHubClient();

    // 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 = $appHubClient->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 Google\Cloud\AppHub\V1\Client\AppHubClient::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\AppHub\V1\Client\AppHubClient;
use Google\Cloud\Iam\V1\TestIamPermissionsRequest;
use Google\Cloud\Iam\V1\TestIamPermissionsResponse;

/**
 * @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.
    $appHubClient = new AppHubClient();

    // 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 = $appHubClient->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);
}

createApplicationAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\CreateApplicationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createServiceAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\CreateServiceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createServiceProjectAttachmentAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\CreateServiceProjectAttachmentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createWorkloadAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\CreateWorkloadRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteApplicationAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\DeleteApplicationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteServiceAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\DeleteServiceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteServiceProjectAttachmentAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\DeleteServiceProjectAttachmentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteWorkloadAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\DeleteWorkloadRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

detachServiceProjectAttachmentAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\DetachServiceProjectAttachmentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getApplicationAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetApplicationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getDiscoveredServiceAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetDiscoveredServiceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getDiscoveredWorkloadAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetDiscoveredWorkloadRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getServiceAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetServiceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getServiceProjectAttachmentAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetServiceProjectAttachmentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getWorkloadAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\GetWorkloadRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listApplicationsAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListApplicationsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listDiscoveredServicesAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListDiscoveredServicesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listDiscoveredWorkloadsAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListDiscoveredWorkloadsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listServiceProjectAttachmentsAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListServiceProjectAttachmentsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listServicesAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListServicesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listWorkloadsAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\ListWorkloadsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

lookupDiscoveredServiceAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\LookupDiscoveredServiceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

lookupDiscoveredWorkloadAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\LookupDiscoveredWorkloadRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

lookupServiceProjectAttachmentAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\LookupServiceProjectAttachmentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateApplicationAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\UpdateApplicationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateServiceAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\UpdateServiceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateWorkloadAsync

Parameters
Name Description
request Google\Cloud\AppHub\V1\UpdateWorkloadRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

setIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

testIamPermissionsAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

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

Returns
Type Description
Google\ApiCore\LongRunning\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::applicationName

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

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

static::discoveredServiceName

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

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

static::discoveredWorkloadName

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

Parameters
Name Description
project string
location string
discoveredWorkload string
Returns
Type Description
string The formatted discovered_workload 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::projectName

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

Parameter
Name Description
project string
Returns
Type Description
string The formatted project resource.

static::serviceName

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

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

static::serviceProjectAttachmentName

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

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

static::workloadName

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

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

  • application: projects/{project}/locations/{location}/applications/{application}
  • discoveredService: projects/{project}/locations/{location}/discoveredServices/{discovered_service}
  • discoveredWorkload: projects/{project}/locations/{location}/discoveredWorkloads/{discovered_workload}
  • location: projects/{project}/locations/{location}
  • project: projects/{project}
  • service: projects/{project}/locations/{location}/applications/{application}/services/{service}
  • serviceProjectAttachment: projects/{project}/locations/{location}/serviceProjectAttachments/{service_project_attachment}
  • workload: projects/{project}/locations/{location}/applications/{application}/workloads/{workload}

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.