Google Anthos Multi Cloud V1 Client - Class AttachedClustersClient (0.3.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. Sample code to get started:

$attachedClustersClient = new AttachedClustersClient();
try {
    $formattedParent = $attachedClustersClient->locationName('[PROJECT]', '[LOCATION]');
    $attachedCluster = new AttachedCluster();
    $attachedClusterId = 'attached_cluster_id';
    $operationResponse = $attachedClustersClient->createAttachedCluster($formattedParent, $attachedCluster, $attachedClusterId);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
    // doSomethingWith($result)
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
    // Alternatively:
    // start the operation, keep the operation name, and resume later
    $operationResponse = $attachedClustersClient->createAttachedCluster($formattedParent, $attachedCluster, $attachedClusterId);
    $operationName = $operationResponse->getName();
    // ... do other work
    $newOperationResponse = $attachedClustersClient->resumeOperation($operationName, 'createAttachedCluster');
    while (!$newOperationResponse->isDone()) {
        // ... do other work
        $newOperationResponse->reload();
    }
    if ($newOperationResponse->operationSucceeded()) {
        $result = $newOperationResponse->getResult();
    // doSomethingWith($result)
    } else {
        $error = $newOperationResponse->getError();
        // handleError($error)
    }
} finally {
    $attachedClustersClient->close();
}

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.

Methods

attachedClusterName

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

Parameters
NameDescription
project string
location string
attachedCluster string
Returns
TypeDescription
stringThe formatted attached_cluster resource.

attachedServerConfigName

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

Parameters
NameDescription
project string
location string
Returns
TypeDescription
stringThe formatted attached_server_config resource.

locationName

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

Parameters
NameDescription
project string
location string
Returns
TypeDescription
stringThe formatted location resource.

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
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

getOperationsClient

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

Returns
TypeDescription
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
NameDescription
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
TypeDescription
Google\ApiCore\OperationResponse

__construct

Constructor.

Parameters
NameDescription
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.

Parameters
NameDescription
parent string

Required. The parent location where this AttachedCluster resource will be created.

Location names are formatted as projects/<project-id>/locations/<region>.

See Resource Names for more details on Google Cloud resource names.

attachedCluster Google\Cloud\GkeMultiCloud\V1\AttachedCluster

Required. The specification of the AttachedCluster to create.

attachedClusterId string

Required. A client provided ID the resource. Must be unique within the parent resource.

The provided ID will be part of the 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.

optionalArgs array

Optional.

↳ validateOnly bool

If set, only validate the request, but do not actually create the cluster.

↳ 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
TypeDescription
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"].
 * @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());
    }
}

/**
 * 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.

Parameters
NameDescription
name string

Required. The resource name the AttachedCluster to delete.

AttachedCluster names are formatted as projects/<project-id>/locations/<region>/attachedClusters/<cluster-id>.

See Resource Names for more details on Google Cloud Platform resource names.

optionalArgs array

Optional.

↳ validateOnly bool

If set, only validate the request, but do not actually delete the resource.

↳ allowMissing bool

If set to true, and the AttachedCluster resource is not found, the request will succeed but no action will be taken on the server and a completed Operation will be returned. Useful for idempotent deletion.

↳ ignoreErrors bool

If set to true, the deletion of AttachedCluster resource will succeed even if errors occur during deleting in cluster resources. Using this parameter may result in orphaned resources in the cluster.

↳ etag string

The current etag of the AttachedCluster. Allows clients to perform deletions through optimistic concurrency control. If the provided etag does not match the current etag of the cluster, the request will fail and an ABORTED error will be returned.

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

/**
 * 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);
}

generateAttachedClusterInstallManifest

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

Parameters
NameDescription
parent string

Required. The parent location where this AttachedCluster resource will be created.

Location names are formatted as projects/<project-id>/locations/<region>.

See Resource Names for more details on Google Cloud resource names.

attachedClusterId string

Required. A client provided ID of the resource. Must be unique within the parent resource.

The provided ID will be part of the 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>.

platformVersion string

Required. 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.

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

/**
 * 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

Describes a specific AttachedCluster resource.

Parameters
NameDescription
name string

Required. The name of the AttachedCluster resource to describe.

AttachedCluster names are formatted as projects/<project-id>/locations/<region>/attachedClusters/<cluster-id>.

See Resource Names for more details on Google Cloud Platform resource names.

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

/**
 * 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.

Parameters
NameDescription
name string

Required. The name of the AttachedServerConfig resource to describe.

AttachedServerConfig names are formatted as projects/<project-id>/locations/<region>/attachedServerConfig.

See Resource Names for more details on Google Cloud resource names.

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

/**
 * 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.

Parameters
NameDescription
parent string

Required. The parent location where this AttachedCluster resource will be created.

Location names are formatted as projects/<project-id>/locations/<region>.

See Resource Names for more details on Google Cloud resource names.

fleetMembership string

Required. The name of the fleet membership resource to import.

platformVersion string

Required. 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.

distribution string

Required. The Kubernetes distribution of the underlying attached cluster.

Supported values: ["eks", "aks"].

optionalArgs array

Optional.

↳ validateOnly bool

If set, only validate the request, but do not actually import the cluster.

↳ 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
TypeDescription
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"].
 */
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());
    }
}

/**
 * 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.

Parameters
NameDescription
parent string

Required. The parent location which owns this collection of AttachedCluster resources.

Location names are formatted as projects/<project-id>/locations/<region>.

See Resource Names for more details on Google Cloud Platform resource names.

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

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

/**
 * 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

Updates an AttachedCluster.

Parameters
NameDescription
attachedCluster Google\Cloud\GkeMultiCloud\V1\AttachedCluster

Required. The AttachedCluster resource to update.

updateMask Google\Protobuf\FieldMask

Required. Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field can only include these fields from AttachedCluster:

  • description.
  • annotations.
  • platform_version.
  • authorization.admin_users.
  • logging_config.component_config.enable_components.
  • monitoring_config.managed_prometheus_config.enabled.
optionalArgs array

Optional.

↳ validateOnly bool

If set, only validate the request, but do not actually update the cluster.

↳ 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
TypeDescription
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"].
 * @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());
    }
}

/**
 * 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
    );
}

Constants

SERVICE_NAME

Value: 'google.cloud.gkemulticloud.v1.AttachedClusters'

The name of the service.

SERVICE_ADDRESS

Value: 'gkemulticloud.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

The name of the code generator, to be included in the agent header.