Google Cloud Developer Connect V1 Client - Class DeveloperConnectClient (0.1.1)

Reference documentation and code samples for the Google Cloud Developer Connect V1 Client class DeveloperConnectClient.

Service Description: Service describing handlers for resources

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Cloud \ DeveloperConnect \ 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.

createConnection

Creates a new Connection in a given project and location.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::createConnectionAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\CreateConnectionRequest

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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\Connection;
use Google\Cloud\DeveloperConnect\V1\CreateConnectionRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent Value for parent. Please see
 *                                {@see DeveloperConnectClient::locationName()} for help formatting this field.
 * @param string $connectionId    Id of the requesting object
 *                                If auto-generating Id server-side, remove this field and
 *                                connection_id from the method_signature of Create RPC
 */
function create_connection_sample(string $formattedParent, string $connectionId): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

    // Prepare the request message.
    $connection = new Connection();
    $request = (new CreateConnectionRequest())
        ->setParent($formattedParent)
        ->setConnectionId($connectionId)
        ->setConnection($connection);

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

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

    create_connection_sample($formattedParent, $connectionId);
}

Creates a GitRepositoryLink. Upon linking a Git Repository, Developer Connect will configure the Git Repository to send webhook events to Developer Connect. Connections that use Firebase GitHub Application will have events forwarded to the Firebase service. All other Connections will have events forwarded to Cloud Build.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::createGitRepositoryLinkAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\CreateGitRepositoryLinkRequest

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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\CreateGitRepositoryLinkRequest;
use Google\Cloud\DeveloperConnect\V1\GitRepositoryLink;
use Google\Rpc\Status;

/**
 * @param string $formattedParent           Value for parent. Please see
 *                                          {@see DeveloperConnectClient::connectionName()} for help formatting this field.
 * @param string $gitRepositoryLinkCloneUri Git Clone URI.
 * @param string $gitRepositoryLinkId       The ID to use for the repository, which will become the final
 *                                          component of the repository's resource name. This ID should be unique in
 *                                          the connection. Allows alphanumeric characters and any of
 *                                          -._~%!$&'()*+,;=@.
 */
function create_git_repository_link_sample(
    string $formattedParent,
    string $gitRepositoryLinkCloneUri,
    string $gitRepositoryLinkId
): void {
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

    // Prepare the request message.
    $gitRepositoryLink = (new GitRepositoryLink())
        ->setCloneUri($gitRepositoryLinkCloneUri);
    $request = (new CreateGitRepositoryLinkRequest())
        ->setParent($formattedParent)
        ->setGitRepositoryLink($gitRepositoryLink)
        ->setGitRepositoryLinkId($gitRepositoryLinkId);

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

        if ($response->operationSucceeded()) {
            /** @var GitRepositoryLink $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 = DeveloperConnectClient::connectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[CONNECTION]'
    );
    $gitRepositoryLinkCloneUri = '[CLONE_URI]';
    $gitRepositoryLinkId = '[GIT_REPOSITORY_LINK_ID]';

    create_git_repository_link_sample(
        $formattedParent,
        $gitRepositoryLinkCloneUri,
        $gitRepositoryLinkId
    );
}

deleteConnection

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\DeleteConnectionRequest

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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\DeleteConnectionRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the resource
 *                              Please see {@see DeveloperConnectClient::connectionName()} for help formatting this field.
 */
function delete_connection_sample(string $formattedName): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $developerConnectClient->deleteConnection($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 = DeveloperConnectClient::connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]');

    delete_connection_sample($formattedName);
}
Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\DeleteGitRepositoryLinkRequest

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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\DeleteGitRepositoryLinkRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the resource
 *                              Please see {@see DeveloperConnectClient::gitRepositoryLinkName()} for help formatting this field.
 */
function delete_git_repository_link_sample(string $formattedName): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $developerConnectClient->deleteGitRepositoryLink($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 = DeveloperConnectClient::gitRepositoryLinkName(
        '[PROJECT]',
        '[LOCATION]',
        '[CONNECTION]',
        '[GIT_REPOSITORY_LINK]'
    );

    delete_git_repository_link_sample($formattedName);
}

fetchGitHubInstallations

FetchGitHubInstallations returns the list of GitHub Installations that are available to be added to a Connection.

For github.com, only installations accessible to the authorizer token are returned. For GitHub Enterprise, all installations are returned.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::fetchGitHubInstallationsAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\FetchGitHubInstallationsRequest

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\DeveloperConnect\V1\FetchGitHubInstallationsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\FetchGitHubInstallationsRequest;
use Google\Cloud\DeveloperConnect\V1\FetchGitHubInstallationsResponse;

/**
 * @param string $formattedConnection The resource name of the connection in the format
 *                                    `projects/*/locations/*/connections/*`. Please see
 *                                    {@see DeveloperConnectClient::connectionName()} for help formatting this field.
 */
function fetch_git_hub_installations_sample(string $formattedConnection): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

    // Prepare the request message.
    $request = (new FetchGitHubInstallationsRequest())
        ->setConnection($formattedConnection);

    // Call the API and handle any network failures.
    try {
        /** @var FetchGitHubInstallationsResponse $response */
        $response = $developerConnectClient->fetchGitHubInstallations($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
{
    $formattedConnection = DeveloperConnectClient::connectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[CONNECTION]'
    );

    fetch_git_hub_installations_sample($formattedConnection);
}

fetchGitRefs

Fetch the list of branches or tags for a given repository.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::fetchGitRefsAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\FetchGitRefsRequest

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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\FetchGitRefsRequest;
use Google\Cloud\DeveloperConnect\V1\FetchGitRefsRequest\RefType;

/**
 * @param string $formattedGitRepositoryLink The resource name of GitRepositoryLink in the format
 *                                           `projects/*/locations/*/connections/*/gitRepositoryLinks/*`. Please see
 *                                           {@see DeveloperConnectClient::gitRepositoryLinkName()} for help formatting this field.
 * @param int    $refType                    Type of refs to fetch.
 */
function fetch_git_refs_sample(string $formattedGitRepositoryLink, int $refType): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

    // Prepare the request message.
    $request = (new FetchGitRefsRequest())
        ->setGitRepositoryLink($formattedGitRepositoryLink)
        ->setRefType($refType);

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

        /** @var string $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element);
        }
    } 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
{
    $formattedGitRepositoryLink = DeveloperConnectClient::gitRepositoryLinkName(
        '[PROJECT]',
        '[LOCATION]',
        '[CONNECTION]',
        '[GIT_REPOSITORY_LINK]'
    );
    $refType = RefType::REF_TYPE_UNSPECIFIED;

    fetch_git_refs_sample($formattedGitRepositoryLink, $refType);
}

fetchLinkableGitRepositories

FetchLinkableGitRepositories returns a list of git repositories from an SCM that are available to be added to a Connection.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::fetchLinkableGitRepositoriesAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\FetchLinkableGitRepositoriesRequest

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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\FetchLinkableGitRepositoriesRequest;
use Google\Cloud\DeveloperConnect\V1\LinkableGitRepository;

/**
 * @param string $formattedConnection The name of the Connection.
 *                                    Format: `projects/*/locations/*/connections/*`. Please see
 *                                    {@see DeveloperConnectClient::connectionName()} for help formatting this field.
 */
function fetch_linkable_git_repositories_sample(string $formattedConnection): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

    // Prepare the request message.
    $request = (new FetchLinkableGitRepositoriesRequest())
        ->setConnection($formattedConnection);

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

        /** @var LinkableGitRepository $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
{
    $formattedConnection = DeveloperConnectClient::connectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[CONNECTION]'
    );

    fetch_linkable_git_repositories_sample($formattedConnection);
}

fetchReadToken

Fetches read token of a given gitRepositoryLink.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::fetchReadTokenAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\FetchReadTokenRequest

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\DeveloperConnect\V1\FetchReadTokenResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\FetchReadTokenRequest;
use Google\Cloud\DeveloperConnect\V1\FetchReadTokenResponse;

/**
 * @param string $formattedGitRepositoryLink The resource name of the gitRepositoryLink in the format
 *                                           `projects/*/locations/*/connections/*/gitRepositoryLinks/*`. Please see
 *                                           {@see DeveloperConnectClient::gitRepositoryLinkName()} for help formatting this field.
 */
function fetch_read_token_sample(string $formattedGitRepositoryLink): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

    // Prepare the request message.
    $request = (new FetchReadTokenRequest())
        ->setGitRepositoryLink($formattedGitRepositoryLink);

    // Call the API and handle any network failures.
    try {
        /** @var FetchReadTokenResponse $response */
        $response = $developerConnectClient->fetchReadToken($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
{
    $formattedGitRepositoryLink = DeveloperConnectClient::gitRepositoryLinkName(
        '[PROJECT]',
        '[LOCATION]',
        '[CONNECTION]',
        '[GIT_REPOSITORY_LINK]'
    );

    fetch_read_token_sample($formattedGitRepositoryLink);
}

fetchReadWriteToken

Fetches read/write token of a given gitRepositoryLink.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::fetchReadWriteTokenAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\FetchReadWriteTokenRequest

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\DeveloperConnect\V1\FetchReadWriteTokenResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\FetchReadWriteTokenRequest;
use Google\Cloud\DeveloperConnect\V1\FetchReadWriteTokenResponse;

/**
 * @param string $formattedGitRepositoryLink The resource name of the gitRepositoryLink in the format
 *                                           `projects/*/locations/*/connections/*/gitRepositoryLinks/*`. Please see
 *                                           {@see DeveloperConnectClient::gitRepositoryLinkName()} for help formatting this field.
 */
function fetch_read_write_token_sample(string $formattedGitRepositoryLink): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

    // Prepare the request message.
    $request = (new FetchReadWriteTokenRequest())
        ->setGitRepositoryLink($formattedGitRepositoryLink);

    // Call the API and handle any network failures.
    try {
        /** @var FetchReadWriteTokenResponse $response */
        $response = $developerConnectClient->fetchReadWriteToken($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
{
    $formattedGitRepositoryLink = DeveloperConnectClient::gitRepositoryLinkName(
        '[PROJECT]',
        '[LOCATION]',
        '[CONNECTION]',
        '[GIT_REPOSITORY_LINK]'
    );

    fetch_read_write_token_sample($formattedGitRepositoryLink);
}

getConnection

Gets details of a single Connection.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::getConnectionAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\GetConnectionRequest

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\DeveloperConnect\V1\Connection
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\Connection;
use Google\Cloud\DeveloperConnect\V1\GetConnectionRequest;

/**
 * @param string $formattedName Name of the resource
 *                              Please see {@see DeveloperConnectClient::connectionName()} for help formatting this field.
 */
function get_connection_sample(string $formattedName): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Connection $response */
        $response = $developerConnectClient->getConnection($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 = DeveloperConnectClient::connectionName('[PROJECT]', '[LOCATION]', '[CONNECTION]');

    get_connection_sample($formattedName);
}

Gets details of a single GitRepositoryLink.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::getGitRepositoryLinkAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\GetGitRepositoryLinkRequest

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\DeveloperConnect\V1\GitRepositoryLink
Example
use Google\ApiCore\ApiException;
use Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\GetGitRepositoryLinkRequest;
use Google\Cloud\DeveloperConnect\V1\GitRepositoryLink;

/**
 * @param string $formattedName Name of the resource
 *                              Please see {@see DeveloperConnectClient::gitRepositoryLinkName()} for help formatting this field.
 */
function get_git_repository_link_sample(string $formattedName): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var GitRepositoryLink $response */
        $response = $developerConnectClient->getGitRepositoryLink($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 = DeveloperConnectClient::gitRepositoryLinkName(
        '[PROJECT]',
        '[LOCATION]',
        '[CONNECTION]',
        '[GIT_REPOSITORY_LINK]'
    );

    get_git_repository_link_sample($formattedName);
}

listConnections

Lists Connections in a given project and location.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::listConnectionsAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\ListConnectionsRequest

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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\Connection;
use Google\Cloud\DeveloperConnect\V1\ListConnectionsRequest;

/**
 * @param string $formattedParent Parent value for ListConnectionsRequest
 *                                Please see {@see DeveloperConnectClient::locationName()} for help formatting this field.
 */
function list_connections_sample(string $formattedParent): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

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

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

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

    list_connections_sample($formattedParent);
}

Lists GitRepositoryLinks in a given project, location, and connection.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::listGitRepositoryLinksAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\ListGitRepositoryLinksRequest

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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\GitRepositoryLink;
use Google\Cloud\DeveloperConnect\V1\ListGitRepositoryLinksRequest;

/**
 * @param string $formattedParent Parent value for ListGitRepositoryLinksRequest
 *                                Please see {@see DeveloperConnectClient::connectionName()} for help formatting this field.
 */
function list_git_repository_links_sample(string $formattedParent): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

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

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

        /** @var GitRepositoryLink $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 = DeveloperConnectClient::connectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[CONNECTION]'
    );

    list_git_repository_links_sample($formattedParent);
}

updateConnection

Updates the parameters of a single Connection.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::updateConnectionAsync() .

Parameters
Name Description
request Google\Cloud\DeveloperConnect\V1\UpdateConnectionRequest

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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\DeveloperConnect\V1\Connection;
use Google\Cloud\DeveloperConnect\V1\UpdateConnectionRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * 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 update_connection_sample(): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

    // Prepare the request message.
    $updateMask = new FieldMask();
    $connection = new Connection();
    $request = (new UpdateConnectionRequest())
        ->setUpdateMask($updateMask)
        ->setConnection($connection);

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

        if ($response->operationSucceeded()) {
            /** @var Connection $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());
    }
}

getLocation

Gets information about a location.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::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\DeveloperConnect\V1\Client\DeveloperConnectClient;
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.
    $developerConnectClient = new DeveloperConnectClient();

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

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

listLocations

Lists information about the supported locations for this service.

The async variant is Google\Cloud\DeveloperConnect\V1\Client\DeveloperConnectClient::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\DeveloperConnect\V1\Client\DeveloperConnectClient;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function list_locations_sample(): void
{
    // Create a client.
    $developerConnectClient = new DeveloperConnectClient();

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

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

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

createConnectionAsync

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

createGitRepositoryLinkAsync

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

deleteConnectionAsync

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

deleteGitRepositoryLinkAsync

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

fetchGitHubInstallationsAsync

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

fetchGitRefsAsync

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

fetchLinkableGitRepositoriesAsync

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

fetchReadTokenAsync

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

fetchReadWriteTokenAsync

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

getConnectionAsync

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

getGitRepositoryLinkAsync

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

listConnectionsAsync

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

listGitRepositoryLinksAsync

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

updateConnectionAsync

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

getLocationAsync

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

listLocationsAsync

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

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

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

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

static::gitRepositoryLinkName

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

Parameters
Name Description
project string
location string
connection string
gitRepositoryLink string
Returns
Type Description
string The formatted git_repository_link 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::secretVersionName

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

Parameters
Name Description
project string
secret string
secretVersion string
Returns
Type Description
string The formatted secret_version 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

  • connection: projects/{project}/locations/{location}/connections/{connection}
  • gitRepositoryLink: projects/{project}/locations/{location}/connections/{connection}/gitRepositoryLinks/{git_repository_link}
  • location: projects/{project}/locations/{location}
  • secretVersion: projects/{project}/secrets/{secret}/versions/{secret_version}

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.