Google Anthos Multi Cloud V1 Client - Class AttachedClustersClient (1.1.0)

Reference documentation and code samples for the Google Anthos Multi Cloud V1 Client class AttachedClustersClient.

Service Description: The AttachedClusters API provides a single centrally managed service to register and manage Anthos attached clusters that run on customer's owned infrastructure.

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

createAttachedCluster

Creates a new AttachedCluster resource on a given Google Cloud Platform project and region.

If successful, the response contains a newly created Operation resource that can be described to track the status of the operation.

The async variant is Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient::createAttachedClusterAsync() .

Parameters
Name Description
request Google\Cloud\GkeMultiCloud\V1\CreateAttachedClusterRequest

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\GkeMultiCloud\V1\AttachedCluster;
use Google\Cloud\GkeMultiCloud\V1\AttachedOidcConfig;
use Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient;
use Google\Cloud\GkeMultiCloud\V1\CreateAttachedClusterRequest;
use Google\Cloud\GkeMultiCloud\V1\Fleet;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                The parent location where this
 *                                               [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource
 *                                               will be created.
 *
 *                                               Location names are formatted as `projects/<project-id>/locations/<region>`.
 *
 *                                               See [Resource Names](https://cloud.google.com/apis/design/resource_names)
 *                                               for more details on Google Cloud resource names. Please see
 *                                               {@see AttachedClustersClient::locationName()} for help formatting this field.
 * @param string $attachedClusterPlatformVersion The platform version for the cluster (e.g. `1.19.0-gke.1000`).
 *
 *                                               You can list all supported versions on a given Google Cloud region by
 *                                               calling
 *                                               [GetAttachedServerConfig][google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig].
 * @param string $attachedClusterDistribution    The Kubernetes distribution of the underlying attached cluster.
 *
 *                                               Supported values: ["eks", "aks", "generic"].
 * @param string $attachedClusterFleetProject    The name of the Fleet host project where this cluster will be
 *                                               registered.
 *
 *                                               Project names are formatted as
 *                                               `projects/<project-number>`.
 * @param string $attachedClusterId              A client provided ID the resource. Must be unique within the
 *                                               parent resource.
 *
 *                                               The provided ID will be part of the
 *                                               [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource
 *                                               name formatted as
 *                                               `projects/<project-id>/locations/<region>/attachedClusters/<cluster-id>`.
 *
 *                                               Valid characters are `/[a-z][0-9]-/`. Cannot be longer than 63 characters.
 */
function create_attached_cluster_sample(
    string $formattedParent,
    string $attachedClusterPlatformVersion,
    string $attachedClusterDistribution,
    string $attachedClusterFleetProject,
    string $attachedClusterId
): void {
    // Create a client.
    $attachedClustersClient = new AttachedClustersClient();

    // Prepare the request message.
    $attachedClusterOidcConfig = new AttachedOidcConfig();
    $attachedClusterFleet = (new Fleet())
        ->setProject($attachedClusterFleetProject);
    $attachedCluster = (new AttachedCluster())
        ->setOidcConfig($attachedClusterOidcConfig)
        ->setPlatformVersion($attachedClusterPlatformVersion)
        ->setDistribution($attachedClusterDistribution)
        ->setFleet($attachedClusterFleet);
    $request = (new CreateAttachedClusterRequest())
        ->setParent($formattedParent)
        ->setAttachedCluster($attachedCluster)
        ->setAttachedClusterId($attachedClusterId);

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

        if ($response->operationSucceeded()) {
            /** @var AttachedCluster $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 = AttachedClustersClient::locationName('[PROJECT]', '[LOCATION]');
    $attachedClusterPlatformVersion = '[PLATFORM_VERSION]';
    $attachedClusterDistribution = '[DISTRIBUTION]';
    $attachedClusterFleetProject = '[PROJECT]';
    $attachedClusterId = '[ATTACHED_CLUSTER_ID]';

    create_attached_cluster_sample(
        $formattedParent,
        $attachedClusterPlatformVersion,
        $attachedClusterDistribution,
        $attachedClusterFleetProject,
        $attachedClusterId
    );
}

deleteAttachedCluster

Deletes a specific AttachedCluster resource.

If successful, the response contains a newly created Operation resource that can be described to track the status of the operation.

The async variant is Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient::deleteAttachedClusterAsync() .

Parameters
Name Description
request Google\Cloud\GkeMultiCloud\V1\DeleteAttachedClusterRequest

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\GkeMultiCloud\V1\Client\AttachedClustersClient;
use Google\Cloud\GkeMultiCloud\V1\DeleteAttachedClusterRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The resource name the
 *                              [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] to delete.
 *
 *                              `AttachedCluster` names are formatted as
 *                              `projects/<project-id>/locations/<region>/attachedClusters/<cluster-id>`.
 *
 *                              See [Resource Names](https://cloud.google.com/apis/design/resource_names)
 *                              for more details on Google Cloud Platform resource names. Please see
 *                              {@see AttachedClustersClient::attachedClusterName()} for help formatting this field.
 */
function delete_attached_cluster_sample(string $formattedName): void
{
    // Create a client.
    $attachedClustersClient = new AttachedClustersClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $attachedClustersClient->deleteAttachedCluster($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 = AttachedClustersClient::attachedClusterName(
        '[PROJECT]',
        '[LOCATION]',
        '[ATTACHED_CLUSTER]'
    );

    delete_attached_cluster_sample($formattedName);
}

generateAttachedClusterAgentToken

Generates an access token for a cluster agent.

The async variant is Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient::generateAttachedClusterAgentTokenAsync() .

Parameters
Name Description
request Google\Cloud\GkeMultiCloud\V1\GenerateAttachedClusterAgentTokenRequest

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\GkeMultiCloud\V1\GenerateAttachedClusterAgentTokenResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient;
use Google\Cloud\GkeMultiCloud\V1\GenerateAttachedClusterAgentTokenRequest;
use Google\Cloud\GkeMultiCloud\V1\GenerateAttachedClusterAgentTokenResponse;

/**
 * @param string $formattedAttachedCluster Please see
 *                                         {@see AttachedClustersClient::attachedClusterName()} for help formatting this field.
 * @param string $subjectToken             Required.
 * @param string $subjectTokenType         Required.
 * @param string $version                  Required.
 */
function generate_attached_cluster_agent_token_sample(
    string $formattedAttachedCluster,
    string $subjectToken,
    string $subjectTokenType,
    string $version
): void {
    // Create a client.
    $attachedClustersClient = new AttachedClustersClient();

    // Prepare the request message.
    $request = (new GenerateAttachedClusterAgentTokenRequest())
        ->setAttachedCluster($formattedAttachedCluster)
        ->setSubjectToken($subjectToken)
        ->setSubjectTokenType($subjectTokenType)
        ->setVersion($version);

    // Call the API and handle any network failures.
    try {
        /** @var GenerateAttachedClusterAgentTokenResponse $response */
        $response = $attachedClustersClient->generateAttachedClusterAgentToken($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
{
    $formattedAttachedCluster = AttachedClustersClient::attachedClusterName(
        '[PROJECT]',
        '[LOCATION]',
        '[ATTACHED_CLUSTER]'
    );
    $subjectToken = '[SUBJECT_TOKEN]';
    $subjectTokenType = '[SUBJECT_TOKEN_TYPE]';
    $version = '[VERSION]';

    generate_attached_cluster_agent_token_sample(
        $formattedAttachedCluster,
        $subjectToken,
        $subjectTokenType,
        $version
    );
}

generateAttachedClusterInstallManifest

Generates the install manifest to be installed on the target cluster.

The async variant is Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient::generateAttachedClusterInstallManifestAsync() .

Parameters
Name Description
request Google\Cloud\GkeMultiCloud\V1\GenerateAttachedClusterInstallManifestRequest

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\GkeMultiCloud\V1\GenerateAttachedClusterInstallManifestResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient;
use Google\Cloud\GkeMultiCloud\V1\GenerateAttachedClusterInstallManifestRequest;
use Google\Cloud\GkeMultiCloud\V1\GenerateAttachedClusterInstallManifestResponse;

/**
 * @param string $formattedParent   The parent location where this
 *                                  [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource
 *                                  will be created.
 *
 *                                  Location names are formatted as `projects/<project-id>/locations/<region>`.
 *
 *                                  See [Resource Names](https://cloud.google.com/apis/design/resource_names)
 *                                  for more details on Google Cloud resource names. Please see
 *                                  {@see AttachedClustersClient::locationName()} for help formatting this field.
 * @param string $attachedClusterId A client provided ID of the resource. Must be unique within the
 *                                  parent resource.
 *
 *                                  The provided ID will be part of the
 *                                  [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource
 *                                  name formatted as
 *                                  `projects/<project-id>/locations/<region>/attachedClusters/<cluster-id>`.
 *
 *                                  Valid characters are `/[a-z][0-9]-/`. Cannot be longer than 63 characters.
 *
 *                                  When generating an install manifest for importing an existing Membership
 *                                  resource, the attached_cluster_id field must be the Membership id.
 *
 *                                  Membership names are formatted as
 *                                  `projects/<project-id>/locations/<region>/memberships/<membership-id>`.
 * @param string $platformVersion   The platform version for the cluster (e.g. `1.19.0-gke.1000`).
 *
 *                                  You can list all supported versions on a given Google Cloud region by
 *                                  calling
 *                                  [GetAttachedServerConfig][google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig].
 */
function generate_attached_cluster_install_manifest_sample(
    string $formattedParent,
    string $attachedClusterId,
    string $platformVersion
): void {
    // Create a client.
    $attachedClustersClient = new AttachedClustersClient();

    // Prepare the request message.
    $request = (new GenerateAttachedClusterInstallManifestRequest())
        ->setParent($formattedParent)
        ->setAttachedClusterId($attachedClusterId)
        ->setPlatformVersion($platformVersion);

    // Call the API and handle any network failures.
    try {
        /** @var GenerateAttachedClusterInstallManifestResponse $response */
        $response = $attachedClustersClient->generateAttachedClusterInstallManifest($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 = AttachedClustersClient::locationName('[PROJECT]', '[LOCATION]');
    $attachedClusterId = '[ATTACHED_CLUSTER_ID]';
    $platformVersion = '[PLATFORM_VERSION]';

    generate_attached_cluster_install_manifest_sample(
        $formattedParent,
        $attachedClusterId,
        $platformVersion
    );
}

getAttachedCluster

Parameters
Name Description
request Google\Cloud\GkeMultiCloud\V1\GetAttachedClusterRequest

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\GkeMultiCloud\V1\AttachedCluster
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeMultiCloud\V1\AttachedCluster;
use Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient;
use Google\Cloud\GkeMultiCloud\V1\GetAttachedClusterRequest;

/**
 * @param string $formattedName The name of the
 *                              [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource
 *                              to describe.
 *
 *                              `AttachedCluster` names are formatted as
 *                              `projects/<project-id>/locations/<region>/attachedClusters/<cluster-id>`.
 *
 *                              See [Resource Names](https://cloud.google.com/apis/design/resource_names)
 *                              for more details on Google Cloud Platform resource names. Please see
 *                              {@see AttachedClustersClient::attachedClusterName()} for help formatting this field.
 */
function get_attached_cluster_sample(string $formattedName): void
{
    // Create a client.
    $attachedClustersClient = new AttachedClustersClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var AttachedCluster $response */
        $response = $attachedClustersClient->getAttachedCluster($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 = AttachedClustersClient::attachedClusterName(
        '[PROJECT]',
        '[LOCATION]',
        '[ATTACHED_CLUSTER]'
    );

    get_attached_cluster_sample($formattedName);
}

getAttachedServerConfig

Returns information, such as supported Kubernetes versions, on a given Google Cloud location.

The async variant is Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient::getAttachedServerConfigAsync() .

Parameters
Name Description
request Google\Cloud\GkeMultiCloud\V1\GetAttachedServerConfigRequest

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\GkeMultiCloud\V1\AttachedServerConfig
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeMultiCloud\V1\AttachedServerConfig;
use Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient;
use Google\Cloud\GkeMultiCloud\V1\GetAttachedServerConfigRequest;

/**
 * @param string $formattedName The name of the
 *                              [AttachedServerConfig][google.cloud.gkemulticloud.v1.AttachedServerConfig]
 *                              resource to describe.
 *
 *                              `AttachedServerConfig` names are formatted as
 *                              `projects/<project-id>/locations/<region>/attachedServerConfig`.
 *
 *                              See [Resource Names](https://cloud.google.com/apis/design/resource_names)
 *                              for more details on Google Cloud resource names. Please see
 *                              {@see AttachedClustersClient::attachedServerConfigName()} for help formatting this field.
 */
function get_attached_server_config_sample(string $formattedName): void
{
    // Create a client.
    $attachedClustersClient = new AttachedClustersClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var AttachedServerConfig $response */
        $response = $attachedClustersClient->getAttachedServerConfig($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 = AttachedClustersClient::attachedServerConfigName('[PROJECT]', '[LOCATION]');

    get_attached_server_config_sample($formattedName);
}

importAttachedCluster

Imports creates a new AttachedCluster resource by importing an existing Fleet Membership resource.

Attached Clusters created before the introduction of the Anthos Multi-Cloud API can be imported through this method.

If successful, the response contains a newly created Operation resource that can be described to track the status of the operation.

The async variant is Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient::importAttachedClusterAsync() .

Parameters
Name Description
request Google\Cloud\GkeMultiCloud\V1\ImportAttachedClusterRequest

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\GkeMultiCloud\V1\AttachedCluster;
use Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient;
use Google\Cloud\GkeMultiCloud\V1\ImportAttachedClusterRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The parent location where this
 *                                [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resource
 *                                will be created.
 *
 *                                Location names are formatted as `projects/<project-id>/locations/<region>`.
 *
 *                                See [Resource Names](https://cloud.google.com/apis/design/resource_names)
 *                                for more details on Google Cloud resource names. Please see
 *                                {@see AttachedClustersClient::locationName()} for help formatting this field.
 * @param string $fleetMembership The name of the fleet membership resource to import.
 * @param string $platformVersion The platform version for the cluster (e.g. `1.19.0-gke.1000`).
 *
 *                                You can list all supported versions on a given Google Cloud region by
 *                                calling
 *                                [GetAttachedServerConfig][google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig].
 * @param string $distribution    The Kubernetes distribution of the underlying attached cluster.
 *
 *                                Supported values: ["eks", "aks", "generic"].
 */
function import_attached_cluster_sample(
    string $formattedParent,
    string $fleetMembership,
    string $platformVersion,
    string $distribution
): void {
    // Create a client.
    $attachedClustersClient = new AttachedClustersClient();

    // Prepare the request message.
    $request = (new ImportAttachedClusterRequest())
        ->setParent($formattedParent)
        ->setFleetMembership($fleetMembership)
        ->setPlatformVersion($platformVersion)
        ->setDistribution($distribution);

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

        if ($response->operationSucceeded()) {
            /** @var AttachedCluster $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 = AttachedClustersClient::locationName('[PROJECT]', '[LOCATION]');
    $fleetMembership = '[FLEET_MEMBERSHIP]';
    $platformVersion = '[PLATFORM_VERSION]';
    $distribution = '[DISTRIBUTION]';

    import_attached_cluster_sample($formattedParent, $fleetMembership, $platformVersion, $distribution);
}

listAttachedClusters

Lists all AttachedCluster resources on a given Google Cloud project and region.

The async variant is Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient::listAttachedClustersAsync() .

Parameters
Name Description
request Google\Cloud\GkeMultiCloud\V1\ListAttachedClustersRequest

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\GkeMultiCloud\V1\AttachedCluster;
use Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient;
use Google\Cloud\GkeMultiCloud\V1\ListAttachedClustersRequest;

/**
 * @param string $formattedParent The parent location which owns this collection of
 *                                [AttachedCluster][google.cloud.gkemulticloud.v1.AttachedCluster] resources.
 *
 *                                Location names are formatted as `projects/<project-id>/locations/<region>`.
 *
 *                                See [Resource Names](https://cloud.google.com/apis/design/resource_names)
 *                                for more details on Google Cloud Platform resource names. Please see
 *                                {@see AttachedClustersClient::locationName()} for help formatting this field.
 */
function list_attached_clusters_sample(string $formattedParent): void
{
    // Create a client.
    $attachedClustersClient = new AttachedClustersClient();

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

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

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

    list_attached_clusters_sample($formattedParent);
}

updateAttachedCluster

Parameters
Name Description
request Google\Cloud\GkeMultiCloud\V1\UpdateAttachedClusterRequest

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\GkeMultiCloud\V1\AttachedCluster;
use Google\Cloud\GkeMultiCloud\V1\AttachedOidcConfig;
use Google\Cloud\GkeMultiCloud\V1\Client\AttachedClustersClient;
use Google\Cloud\GkeMultiCloud\V1\Fleet;
use Google\Cloud\GkeMultiCloud\V1\UpdateAttachedClusterRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * @param string $attachedClusterPlatformVersion The platform version for the cluster (e.g. `1.19.0-gke.1000`).
 *
 *                                               You can list all supported versions on a given Google Cloud region by
 *                                               calling
 *                                               [GetAttachedServerConfig][google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig].
 * @param string $attachedClusterDistribution    The Kubernetes distribution of the underlying attached cluster.
 *
 *                                               Supported values: ["eks", "aks", "generic"].
 * @param string $attachedClusterFleetProject    The name of the Fleet host project where this cluster will be
 *                                               registered.
 *
 *                                               Project names are formatted as
 *                                               `projects/<project-number>`.
 */
function update_attached_cluster_sample(
    string $attachedClusterPlatformVersion,
    string $attachedClusterDistribution,
    string $attachedClusterFleetProject
): void {
    // Create a client.
    $attachedClustersClient = new AttachedClustersClient();

    // Prepare the request message.
    $attachedClusterOidcConfig = new AttachedOidcConfig();
    $attachedClusterFleet = (new Fleet())
        ->setProject($attachedClusterFleetProject);
    $attachedCluster = (new AttachedCluster())
        ->setOidcConfig($attachedClusterOidcConfig)
        ->setPlatformVersion($attachedClusterPlatformVersion)
        ->setDistribution($attachedClusterDistribution)
        ->setFleet($attachedClusterFleet);
    $updateMask = new FieldMask();
    $request = (new UpdateAttachedClusterRequest())
        ->setAttachedCluster($attachedCluster)
        ->setUpdateMask($updateMask);

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

        if ($response->operationSucceeded()) {
            /** @var AttachedCluster $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
{
    $attachedClusterPlatformVersion = '[PLATFORM_VERSION]';
    $attachedClusterDistribution = '[DISTRIBUTION]';
    $attachedClusterFleetProject = '[PROJECT]';

    update_attached_cluster_sample(
        $attachedClusterPlatformVersion,
        $attachedClusterDistribution,
        $attachedClusterFleetProject
    );
}

createAttachedClusterAsync

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

deleteAttachedClusterAsync

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

generateAttachedClusterAgentTokenAsync

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

generateAttachedClusterInstallManifestAsync

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

getAttachedClusterAsync

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

getAttachedServerConfigAsync

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

importAttachedClusterAsync

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

listAttachedClustersAsync

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

updateAttachedClusterAsync

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

getOperationsClient

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

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

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

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::attachedClusterName

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

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

static::attachedServerConfigName

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

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

  • attachedCluster: projects/{project}/locations/{location}/attachedClusters/{attached_cluster}
  • attachedServerConfig: projects/{project}/locations/{location}/attachedServerConfig
  • location: projects/{project}/locations/{location}

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.