Google Cloud Api Hub V1 Client - Class RuntimeProjectAttachmentServiceClient (0.1.2)

Reference documentation and code samples for the Google Cloud Api Hub V1 Client class RuntimeProjectAttachmentServiceClient.

Service Description: This service is used for managing the runtime project attachments.

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 \ ApiHub \ 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. At the moment, supports only rest. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'rest' => [...], ]; See the Google\ApiCore\Transport\RestTransport::build() method for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

createRuntimeProjectAttachment

Attaches a runtime project to the host project.

The async variant is RuntimeProjectAttachmentServiceClient::createRuntimeProjectAttachmentAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateRuntimeProjectAttachmentRequest

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\ApiHub\V1\RuntimeProjectAttachment
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\RuntimeProjectAttachmentServiceClient;
use Google\Cloud\ApiHub\V1\CreateRuntimeProjectAttachmentRequest;
use Google\Cloud\ApiHub\V1\RuntimeProjectAttachment;

/**
 * @param string $formattedParent                                 The parent resource for the Runtime Project Attachment.
 *                                                                Format: `projects/{project}/locations/{location}`
 *                                                                Please see {@see RuntimeProjectAttachmentServiceClient::locationName()} for help formatting this field.
 * @param string $runtimeProjectAttachmentId                      The ID to use for the Runtime Project Attachment, which will
 *                                                                become the final component of the Runtime Project Attachment's name. The ID
 *                                                                must be the same as the project ID of the Google cloud project specified in
 *                                                                the runtime_project_attachment.runtime_project field.
 * @param string $formattedRuntimeProjectAttachmentRuntimeProject Immutable. Google cloud 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 RuntimeProjectAttachmentServiceClient::projectName()} for help formatting this field.
 */
function create_runtime_project_attachment_sample(
    string $formattedParent,
    string $runtimeProjectAttachmentId,
    string $formattedRuntimeProjectAttachmentRuntimeProject
): void {
    // Create a client.
    $runtimeProjectAttachmentServiceClient = new RuntimeProjectAttachmentServiceClient();

    // Prepare the request message.
    $runtimeProjectAttachment = (new RuntimeProjectAttachment())
        ->setRuntimeProject($formattedRuntimeProjectAttachmentRuntimeProject);
    $request = (new CreateRuntimeProjectAttachmentRequest())
        ->setParent($formattedParent)
        ->setRuntimeProjectAttachmentId($runtimeProjectAttachmentId)
        ->setRuntimeProjectAttachment($runtimeProjectAttachment);

    // Call the API and handle any network failures.
    try {
        /** @var RuntimeProjectAttachment $response */
        $response = $runtimeProjectAttachmentServiceClient->createRuntimeProjectAttachment($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 = RuntimeProjectAttachmentServiceClient::locationName('[PROJECT]', '[LOCATION]');
    $runtimeProjectAttachmentId = '[RUNTIME_PROJECT_ATTACHMENT_ID]';
    $formattedRuntimeProjectAttachmentRuntimeProject = RuntimeProjectAttachmentServiceClient::projectName(
        '[PROJECT]'
    );

    create_runtime_project_attachment_sample(
        $formattedParent,
        $runtimeProjectAttachmentId,
        $formattedRuntimeProjectAttachmentRuntimeProject
    );
}

deleteRuntimeProjectAttachment

Delete a runtime project attachment in the API Hub. This call will detach the runtime project from the host project.

The async variant is RuntimeProjectAttachmentServiceClient::deleteRuntimeProjectAttachmentAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteRuntimeProjectAttachmentRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\RuntimeProjectAttachmentServiceClient;
use Google\Cloud\ApiHub\V1\DeleteRuntimeProjectAttachmentRequest;

/**
 * @param string $formattedName The name of the Runtime Project Attachment to delete.
 *                              Format:
 *                              `projects/{project}/locations/{location}/runtimeProjectAttachments/{runtime_project_attachment}`
 *                              Please see {@see RuntimeProjectAttachmentServiceClient::runtimeProjectAttachmentName()} for help formatting this field.
 */
function delete_runtime_project_attachment_sample(string $formattedName): void
{
    // Create a client.
    $runtimeProjectAttachmentServiceClient = new RuntimeProjectAttachmentServiceClient();

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

    // Call the API and handle any network failures.
    try {
        $runtimeProjectAttachmentServiceClient->deleteRuntimeProjectAttachment($request);
        printf('Call completed successfully.' . PHP_EOL);
    } 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 = RuntimeProjectAttachmentServiceClient::runtimeProjectAttachmentName(
        '[PROJECT]',
        '[LOCATION]',
        '[RUNTIME_PROJECT_ATTACHMENT]'
    );

    delete_runtime_project_attachment_sample($formattedName);
}

getRuntimeProjectAttachment

Gets a runtime project attachment.

The async variant is RuntimeProjectAttachmentServiceClient::getRuntimeProjectAttachmentAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetRuntimeProjectAttachmentRequest

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\ApiHub\V1\RuntimeProjectAttachment
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\RuntimeProjectAttachmentServiceClient;
use Google\Cloud\ApiHub\V1\GetRuntimeProjectAttachmentRequest;
use Google\Cloud\ApiHub\V1\RuntimeProjectAttachment;

/**
 * @param string $formattedName The name of the API resource to retrieve.
 *                              Format:
 *                              `projects/{project}/locations/{location}/runtimeProjectAttachments/{runtime_project_attachment}`
 *                              Please see {@see RuntimeProjectAttachmentServiceClient::runtimeProjectAttachmentName()} for help formatting this field.
 */
function get_runtime_project_attachment_sample(string $formattedName): void
{
    // Create a client.
    $runtimeProjectAttachmentServiceClient = new RuntimeProjectAttachmentServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var RuntimeProjectAttachment $response */
        $response = $runtimeProjectAttachmentServiceClient->getRuntimeProjectAttachment($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 = RuntimeProjectAttachmentServiceClient::runtimeProjectAttachmentName(
        '[PROJECT]',
        '[LOCATION]',
        '[RUNTIME_PROJECT_ATTACHMENT]'
    );

    get_runtime_project_attachment_sample($formattedName);
}

listRuntimeProjectAttachments

List runtime projects attached to the host project.

The async variant is RuntimeProjectAttachmentServiceClient::listRuntimeProjectAttachmentsAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListRuntimeProjectAttachmentsRequest

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\ApiHub\V1\Client\RuntimeProjectAttachmentServiceClient;
use Google\Cloud\ApiHub\V1\ListRuntimeProjectAttachmentsRequest;

/**
 * @param string $formattedParent The parent, which owns this collection of runtime project
 *                                attachments. Format: `projects/{project}/locations/{location}`
 *                                Please see {@see RuntimeProjectAttachmentServiceClient::locationName()} for help formatting this field.
 */
function list_runtime_project_attachments_sample(string $formattedParent): void
{
    // Create a client.
    $runtimeProjectAttachmentServiceClient = new RuntimeProjectAttachmentServiceClient();

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

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

        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * 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 = RuntimeProjectAttachmentServiceClient::locationName('[PROJECT]', '[LOCATION]');

    list_runtime_project_attachments_sample($formattedParent);
}

lookupRuntimeProjectAttachment

Look up a runtime project attachment. This API can be called in the context of any project.

The async variant is RuntimeProjectAttachmentServiceClient::lookupRuntimeProjectAttachmentAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\LookupRuntimeProjectAttachmentRequest

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\ApiHub\V1\LookupRuntimeProjectAttachmentResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\RuntimeProjectAttachmentServiceClient;
use Google\Cloud\ApiHub\V1\LookupRuntimeProjectAttachmentRequest;
use Google\Cloud\ApiHub\V1\LookupRuntimeProjectAttachmentResponse;

/**
 * @param string $formattedName Runtime project ID to look up runtime project attachment for.
 *                              Lookup happens across all regions. Expected format:
 *                              `projects/{project}/locations/{location}`. Please see
 *                              {@see RuntimeProjectAttachmentServiceClient::locationName()} for help formatting this field.
 */
function lookup_runtime_project_attachment_sample(string $formattedName): void
{
    // Create a client.
    $runtimeProjectAttachmentServiceClient = new RuntimeProjectAttachmentServiceClient();

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

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

    lookup_runtime_project_attachment_sample($formattedName);
}

getLocation

Gets information about a location.

The async variant is RuntimeProjectAttachmentServiceClient::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\ApiHub\V1\Client\RuntimeProjectAttachmentServiceClient;
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.
    $runtimeProjectAttachmentServiceClient = new RuntimeProjectAttachmentServiceClient();

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

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

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

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

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

        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

createRuntimeProjectAttachmentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateRuntimeProjectAttachmentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\RuntimeProjectAttachment>

deleteRuntimeProjectAttachmentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteRuntimeProjectAttachmentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

getRuntimeProjectAttachmentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetRuntimeProjectAttachmentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\RuntimeProjectAttachment>

listRuntimeProjectAttachmentsAsync

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

lookupRuntimeProjectAttachmentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\LookupRuntimeProjectAttachmentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\LookupRuntimeProjectAttachmentResponse>

getLocationAsync

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

listLocationsAsync

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

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

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

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

  • location: projects/{project}/locations/{location}
  • project: projects/{project}
  • runtimeProjectAttachment: projects/{project}/locations/{location}/runtimeProjectAttachments/{runtime_project_attachment}

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.