Google Cloud Observability V1 Client - Class ObservabilityClient (0.1.0)

Reference documentation and code samples for the Google Cloud Observability V1 Client class ObservabilityClient.

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 \ Observability \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array|Google\ApiCore\Options\ClientOptions

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 Google\Auth\FetchAuthTokenInterface|Google\ApiCore\CredentialsWrapper

This option should only be used with a pre-constructed Google\Auth\FetchAuthTokenInterface or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Cloud\Observability\V1\ObservabilityClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new ObservabilityClient(['credentials' => $creds]); https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ 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|Google\ApiCore\Transport\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.

↳ logger false|Psr\Log\LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

↳ universeDomain string

The service domain for the client. Defaults to 'googleapis.com'.

createBucket

Create a new bucket.

The async variant is ObservabilityClient::createBucketAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\CreateBucketRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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<Google\Cloud\Observability\V1\Bucket>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Observability\V1\Bucket;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\CreateBucketRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent Name of the project and location for the bucket. The format is:
 *
 *                                projects/[PROJECT_ID]/locations/[LOCATION]
 *                                Please see {@see ObservabilityClient::locationName()} for help formatting this field.
 * @param string $bucketId        Id of the bucket to create.
 */
function create_bucket_sample(string $formattedParent, string $bucketId): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

    // Prepare the request message.
    $bucket = new Bucket();
    $request = (new CreateBucketRequest())
        ->setParent($formattedParent)
        ->setBucketId($bucketId)
        ->setBucket($bucket);

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

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

    create_bucket_sample($formattedParent, $bucketId);
}

Create a new link.

The async variant is ObservabilityClient::createLinkAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\CreateLinkRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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<Google\Cloud\Observability\V1\Link>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\CreateLinkRequest;
use Google\Cloud\Observability\V1\Link;
use Google\Rpc\Status;

/**
 * @param string $formattedParent Name of the containing dataset for this link. The format is:
 *
 *                                projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_ID]/datasets/[DATASET_ID]
 *                                Please see {@see ObservabilityClient::datasetName()} for help formatting this field.
 * @param string $linkId          Id of the link to create.
 */
function create_link_sample(string $formattedParent, string $linkId): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

    // Prepare the request message.
    $link = new Link();
    $request = (new CreateLinkRequest())
        ->setParent($formattedParent)
        ->setLinkId($linkId)
        ->setLink($link);

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

        if ($response->operationSucceeded()) {
            /** @var Link $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 = ObservabilityClient::datasetName(
        '[PROJECT]',
        '[LOCATION]',
        '[BUCKET]',
        '[DATASET]'
    );
    $linkId = '[LINK_ID]';

    create_link_sample($formattedParent, $linkId);
}

createTraceScope

Create a new TraceScope.

The async variant is ObservabilityClient::createTraceScopeAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\CreateTraceScopeRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\TraceScope
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\CreateTraceScopeRequest;
use Google\Cloud\Observability\V1\TraceScope;

/**
 * @param string $formattedParent                The full resource name of the location where the trace scope
 *                                               should be created
 *
 *                                               projects/[PROJECT_ID]/locations/[LOCATION_ID]
 *
 *                                               For example:
 *
 *                                               projects/my-project/locations/global
 *                                               Please see {@see ObservabilityClient::locationName()} for help formatting this field.
 * @param string $traceScopeId                   A client-assigned identifier for the trace scope.
 * @param string $traceScopeResourceNamesElement Names of the projects that are included in this trace scope.
 *
 *                                               *  `projects/[PROJECT_ID]`
 *
 *                                               A trace scope can include a maximum of 20 projects.
 */
function create_trace_scope_sample(
    string $formattedParent,
    string $traceScopeId,
    string $traceScopeResourceNamesElement
): void {
    // Create a client.
    $observabilityClient = new ObservabilityClient();

    // Prepare the request message.
    $traceScopeResourceNames = [$traceScopeResourceNamesElement];
    $traceScope = (new TraceScope())
        ->setResourceNames($traceScopeResourceNames);
    $request = (new CreateTraceScopeRequest())
        ->setParent($formattedParent)
        ->setTraceScopeId($traceScopeId)
        ->setTraceScope($traceScope);

    // Call the API and handle any network failures.
    try {
        /** @var TraceScope $response */
        $response = $observabilityClient->createTraceScope($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 = ObservabilityClient::locationName('[PROJECT]', '[LOCATION]');
    $traceScopeId = '[TRACE_SCOPE_ID]';
    $traceScopeResourceNamesElement = '[RESOURCE_NAMES]';

    create_trace_scope_sample($formattedParent, $traceScopeId, $traceScopeResourceNamesElement);
}

Delete a link.

The async variant is ObservabilityClient::deleteLinkAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\DeleteLinkRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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<null>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\DeleteLinkRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the link to delete. The format is:
 *
 *                              projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_ID]/datasets/[DATASET_ID]/links/[LINK_ID]
 *                              Please see {@see ObservabilityClient::linkName()} for help formatting this field.
 */
function delete_link_sample(string $formattedName): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $observabilityClient->deleteLink($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 = ObservabilityClient::linkName(
        '[PROJECT]',
        '[LOCATION]',
        '[BUCKET]',
        '[DATASET]',
        '[LINK]'
    );

    delete_link_sample($formattedName);
}

deleteTraceScope

Delete a TraceScope.

The async variant is ObservabilityClient::deleteTraceScopeAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\DeleteTraceScopeRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\DeleteTraceScopeRequest;

/**
 * @param string $formattedName The full resource name of the trace scope to delete:
 *
 *                              projects/[PROJECT_ID]/locations/[LOCATION_ID]/traceScopes/[TRACE_SCOPE_ID]
 *
 *                              For example:
 *
 *                              projects/my-project/locations/global/traceScopes/my-trace-scope
 *                              Please see {@see ObservabilityClient::traceScopeName()} for help formatting this field.
 */
function delete_trace_scope_sample(string $formattedName): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

    // Call the API and handle any network failures.
    try {
        $observabilityClient->deleteTraceScope($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 = ObservabilityClient::traceScopeName('[PROJECT]', '[LOCATION]', '[TRACE_SCOPE]');

    delete_trace_scope_sample($formattedName);
}

getBucket

Get bucket resource.

The async variant is ObservabilityClient::getBucketAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\GetBucketRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Bucket
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Bucket;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\GetBucketRequest;

/**
 * @param string $formattedName Name of the bucket to retrieve. The format is:
 *
 *                              projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_ID]
 *                              Please see {@see ObservabilityClient::bucketName()} for help formatting this field.
 */
function get_bucket_sample(string $formattedName): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Bucket $response */
        $response = $observabilityClient->getBucket($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 = ObservabilityClient::bucketName('[PROJECT]', '[LOCATION]', '[BUCKET]');

    get_bucket_sample($formattedName);
}

getDataset

Get a dataset.

The async variant is ObservabilityClient::getDatasetAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\GetDatasetRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Dataset
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\Dataset;
use Google\Cloud\Observability\V1\GetDatasetRequest;

/**
 * @param string $formattedName Name of the dataset to retrieve. The format is:
 *
 *                              projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_ID]/datasets/[DATASET_ID]
 *                              Please see {@see ObservabilityClient::datasetName()} for help formatting this field.
 */
function get_dataset_sample(string $formattedName): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Dataset $response */
        $response = $observabilityClient->getDataset($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 = ObservabilityClient::datasetName(
        '[PROJECT]',
        '[LOCATION]',
        '[BUCKET]',
        '[DATASET]'
    );

    get_dataset_sample($formattedName);
}

Get a link.

The async variant is ObservabilityClient::getLinkAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\GetLinkRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Link
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\GetLinkRequest;
use Google\Cloud\Observability\V1\Link;

/**
 * @param string $formattedName Name of the link to retrieve. The format is:
 *
 *                              projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_ID]/datasets/[DATASET_ID]/links/[LINK_ID]
 *                              Please see {@see ObservabilityClient::linkName()} for help formatting this field.
 */
function get_link_sample(string $formattedName): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Link $response */
        $response = $observabilityClient->getLink($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 = ObservabilityClient::linkName(
        '[PROJECT]',
        '[LOCATION]',
        '[BUCKET]',
        '[DATASET]',
        '[LINK]'
    );

    get_link_sample($formattedName);
}

getScope

Gets details of a single Scope.

The async variant is ObservabilityClient::getScopeAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\GetScopeRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Scope
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\GetScopeRequest;
use Google\Cloud\Observability\V1\Scope;

/**
 * @param string $formattedName Name of the resource. The format is:
 *
 *                              projects/{project}/locations/{location}/scopes/{scope}
 *
 *                              The `{location}` field must be set to `global`. The `{scope}` field must
 *                              be set to `_Default`. Please see
 *                              {@see ObservabilityClient::scopeName()} for help formatting this field.
 */
function get_scope_sample(string $formattedName): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Scope $response */
        $response = $observabilityClient->getScope($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 = ObservabilityClient::scopeName('[PROJECT]', '[LOCATION]', '[SCOPE]');

    get_scope_sample($formattedName);
}

getSettings

Get Settings

The async variant is ObservabilityClient::getSettingsAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\GetSettingsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Settings
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\GetSettingsRequest;
use Google\Cloud\Observability\V1\Settings;

/**
 * @param string $formattedName Name of the settings to retrieve.
 *
 *                              Name format:
 *
 *                              "projects/[PROJECT_ID]/locations/[LOCATION]/settings"
 *                              "folders/[FOLDER_ID]/locations/[LOCATION]/settings"
 *                              "organizations/[ORGANIZATION_ID]/locations/[LOCATION]/settings"
 *                              Please see {@see ObservabilityClient::settingsName()} for help formatting this field.
 */
function get_settings_sample(string $formattedName): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Settings $response */
        $response = $observabilityClient->getSettings($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 = ObservabilityClient::settingsName('[PROJECT]', '[LOCATION]');

    get_settings_sample($formattedName);
}

getTraceScope

Get TraceScope resource.

The async variant is ObservabilityClient::getTraceScopeAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\GetTraceScopeRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\TraceScope
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\GetTraceScopeRequest;
use Google\Cloud\Observability\V1\TraceScope;

/**
 * @param string $formattedName The resource name of the trace scope:
 *
 *                              projects/[PROJECT_ID]/locations/[LOCATION_ID]/traceScopes/[TRACE_SCOPE_ID]
 *
 *                              For example:
 *
 *                              projects/my-project/locations/global/traceScopes/my-trace-scope
 *                              Please see {@see ObservabilityClient::traceScopeName()} for help formatting this field.
 */
function get_trace_scope_sample(string $formattedName): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var TraceScope $response */
        $response = $observabilityClient->getTraceScope($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 = ObservabilityClient::traceScopeName('[PROJECT]', '[LOCATION]', '[TRACE_SCOPE]');

    get_trace_scope_sample($formattedName);
}

getView

Get a view.

The async variant is ObservabilityClient::getViewAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\GetViewRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\View
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\GetViewRequest;
use Google\Cloud\Observability\V1\View;

/**
 * @param string $formattedName Name of the view to retrieve. The format is:
 *
 *                              projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_ID]/datasets/[DATASET_ID]/views/[VIEW_ID]
 *                              Please see {@see ObservabilityClient::viewName()} for help formatting this field.
 */
function get_view_sample(string $formattedName): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var View $response */
        $response = $observabilityClient->getView($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 = ObservabilityClient::viewName(
        '[PROJECT]',
        '[LOCATION]',
        '[BUCKET]',
        '[DATASET]',
        '[VIEW]'
    );

    get_view_sample($formattedName);
}

listBuckets

List buckets of a project in a particular location.

The async variant is ObservabilityClient::listBucketsAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\ListBucketsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Bucket;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\ListBucketsRequest;

/**
 * @param string $formattedParent The parent, which owns this collection of buckets. The format is:
 *
 *                                projects/[PROJECT_ID]/locations/[LOCATION]
 *                                Please see {@see ObservabilityClient::locationName()} for help formatting this field.
 */
function list_buckets_sample(string $formattedParent): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

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

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

    list_buckets_sample($formattedParent);
}

listDatasets

List datasets of a bucket.

The async variant is ObservabilityClient::listDatasetsAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\ListDatasetsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\Dataset;
use Google\Cloud\Observability\V1\ListDatasetsRequest;

/**
 * @param string $formattedParent The parent bucket that owns this collection of datasets. The
 *                                format is:
 *
 *                                projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_ID]
 *                                Please see {@see ObservabilityClient::bucketName()} for help formatting this field.
 */
function list_datasets_sample(string $formattedParent): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

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

        /** @var Dataset $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 = ObservabilityClient::bucketName('[PROJECT]', '[LOCATION]', '[BUCKET]');

    list_datasets_sample($formattedParent);
}

List links of a dataset.

The async variant is ObservabilityClient::listLinksAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\ListLinksRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\Link;
use Google\Cloud\Observability\V1\ListLinksRequest;

/**
 * @param string $formattedParent The parent dataset that owns this collection of links. The format
 *                                is:
 *
 *                                projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_ID]/datasets/[DATASET_ID]
 *                                Please see {@see ObservabilityClient::datasetName()} for help formatting this field.
 */
function list_links_sample(string $formattedParent): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

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

        /** @var Link $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 = ObservabilityClient::datasetName(
        '[PROJECT]',
        '[LOCATION]',
        '[BUCKET]',
        '[DATASET]'
    );

    list_links_sample($formattedParent);
}

listTraceScopes

List TraceScopes of a project in a particular location.

The async variant is ObservabilityClient::listTraceScopesAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\ListTraceScopesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\ListTraceScopesRequest;
use Google\Cloud\Observability\V1\TraceScope;

/**
 * @param string $formattedParent The full resource name of the location to look for trace scopes:
 *
 *                                projects/[PROJECT_ID]/locations/[LOCATION_ID]
 *
 *                                For example:
 *
 *                                projects/my-project/locations/global
 *                                Please see {@see ObservabilityClient::locationName()} for help formatting this field.
 */
function list_trace_scopes_sample(string $formattedParent): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

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

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

    list_trace_scopes_sample($formattedParent);
}

listViews

List views of a dataset.

The async variant is ObservabilityClient::listViewsAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\ListViewsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\ListViewsRequest;
use Google\Cloud\Observability\V1\View;

/**
 * @param string $formattedParent Dataset whose views are to be listed. The format is:
 *
 *                                projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_ID]/datasets/[DATASET_ID]
 *                                Please see {@see ObservabilityClient::datasetName()} for help formatting this field.
 */
function list_views_sample(string $formattedParent): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

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

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

        /** @var View $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 = ObservabilityClient::datasetName(
        '[PROJECT]',
        '[LOCATION]',
        '[BUCKET]',
        '[DATASET]'
    );

    list_views_sample($formattedParent);
}

updateBucket

Update a bucket.

The async variant is ObservabilityClient::updateBucketAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateBucketRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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<Google\Cloud\Observability\V1\Bucket>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Observability\V1\Bucket;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\UpdateBucketRequest;
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_bucket_sample(): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

    // Prepare the request message.
    $bucket = new Bucket();
    $request = (new UpdateBucketRequest())
        ->setBucket($bucket);

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

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

Update a link.

The async variant is ObservabilityClient::updateLinkAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateLinkRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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<Google\Cloud\Observability\V1\Link>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\Link;
use Google\Cloud\Observability\V1\UpdateLinkRequest;
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_link_sample(): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

    // Prepare the request message.
    $link = new Link();
    $request = (new UpdateLinkRequest())
        ->setLink($link);

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

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

updateScope

Updates the parameters of a single Scope.

The async variant is ObservabilityClient::updateScopeAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateScopeRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\Scope
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\Scope;
use Google\Cloud\Observability\V1\UpdateScopeRequest;

/**
 * @param string $scopeLogScope   The full resource name of the `logging.googleapis.com/LogScope`.
 *                                For example:
 *
 *                                //logging.googleapis.com/projects/myproject/locations/global/logScopes/my-log-scope
 * @param string $scopeTraceScope The unqualified resource name of the
 *                                `cloudtrace.googleapis.com/TraceScope`. For example:
 *
 *                                projects/myproject/locations/global/traceScopes/my-trace-scope
 */
function update_scope_sample(string $scopeLogScope, string $scopeTraceScope): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

    // Prepare the request message.
    $scope = (new Scope())
        ->setLogScope($scopeLogScope)
        ->setTraceScope($scopeTraceScope);
    $request = (new UpdateScopeRequest())
        ->setScope($scope);

    // Call the API and handle any network failures.
    try {
        /** @var Scope $response */
        $response = $observabilityClient->updateScope($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
{
    $scopeLogScope = '[LOG_SCOPE]';
    $scopeTraceScope = '[TRACE_SCOPE]';

    update_scope_sample($scopeLogScope, $scopeTraceScope);
}

updateSettings

Update Settings

The async variant is ObservabilityClient::updateSettingsAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateSettingsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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<Google\Cloud\Observability\V1\Settings>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\Settings;
use Google\Cloud\Observability\V1\UpdateSettingsRequest;
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_settings_sample(): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

    // Prepare the request message.
    $settings = new Settings();
    $request = (new UpdateSettingsRequest())
        ->setSettings($settings);

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

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

updateTraceScope

Update a TraceScope.

The async variant is ObservabilityClient::updateTraceScopeAsync() .

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateTraceScopeRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Observability\V1\TraceScope
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;
use Google\Cloud\Observability\V1\TraceScope;
use Google\Cloud\Observability\V1\UpdateTraceScopeRequest;

/**
 * @param string $traceScopeResourceNamesElement Names of the projects that are included in this trace scope.
 *
 *                                               *  `projects/[PROJECT_ID]`
 *
 *                                               A trace scope can include a maximum of 20 projects.
 */
function update_trace_scope_sample(string $traceScopeResourceNamesElement): void
{
    // Create a client.
    $observabilityClient = new ObservabilityClient();

    // Prepare the request message.
    $traceScopeResourceNames = [$traceScopeResourceNamesElement];
    $traceScope = (new TraceScope())
        ->setResourceNames($traceScopeResourceNames);
    $request = (new UpdateTraceScopeRequest())
        ->setTraceScope($traceScope);

    // Call the API and handle any network failures.
    try {
        /** @var TraceScope $response */
        $response = $observabilityClient->updateTraceScope($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
{
    $traceScopeResourceNamesElement = '[RESOURCE_NAMES]';

    update_trace_scope_sample($traceScopeResourceNamesElement);
}

getLocation

Gets information about a location.

The async variant is ObservabilityClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Location\GetLocationRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;

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

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

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $observabilityClient->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.

This method lists locations based on the resource scope provided in the ListLocationsRequest.name field: * Global locations: If name is empty, the method lists the public locations available to all projects. * Project-specific locations: If name follows the format projects/{project}, the method lists locations visible to that specific project. This includes public, private, or other project-specific locations enabled for the project.

For gRPC and client library implementations, the resource name is passed as the name field. For direct service calls, the resource name is incorporated into the request path based on the specific service implementation and version.

The async variant is ObservabilityClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\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\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\Observability\V1\Client\ObservabilityClient;

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

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $observabilityClient->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());
    }
}

createBucketAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\CreateBucketRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

createLinkAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\CreateLinkRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

createTraceScopeAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\CreateTraceScopeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\TraceScope>

deleteLinkAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\DeleteLinkRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteTraceScopeAsync

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

getBucketAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\GetBucketRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\Bucket>

getDatasetAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\GetDatasetRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\Dataset>

getLinkAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\GetLinkRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\Link>

getScopeAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\GetScopeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\Scope>

getSettingsAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\GetSettingsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\Settings>

getTraceScopeAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\GetTraceScopeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\TraceScope>

getViewAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\GetViewRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\View>

listBucketsAsync

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

listDatasetsAsync

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

listLinksAsync

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

listTraceScopesAsync

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

listViewsAsync

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

updateBucketAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateBucketRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

updateLinkAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateLinkRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

updateScopeAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateScopeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\Scope>

updateSettingsAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateSettingsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

updateTraceScopeAsync

Parameters
Name Description
request Google\Cloud\Observability\V1\UpdateTraceScopeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Observability\V1\TraceScope>

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>

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

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

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

static::datasetName

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

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

static::folderLocationSettingsName

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

Parameters
Name Description
folder string
location string
Returns
Type Description
string The formatted folder_location_settings resource.

static::linkName

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

Parameters
Name Description
project string
location string
bucket string
dataset string
link string
Returns
Type Description
string The formatted 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::organizationLocationSettingsName

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

Parameters
Name Description
organization string
location string
Returns
Type Description
string The formatted organization_location_settings resource.

static::projectLocationSettingsName

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

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

static::scopeName

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

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

static::settingsName

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

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

static::traceScopeName

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

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

static::viewName

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

Parameters
Name Description
project string
location string
bucket string
dataset string
view string
Returns
Type Description
string The formatted view 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

  • bucket: projects/{project}/locations/{location}/buckets/{bucket}
  • dataset: projects/{project}/locations/{location}/buckets/{bucket}/datasets/{dataset}
  • folderLocationSettings: folders/{folder}/locations/{location}/settings
  • link: projects/{project}/locations/{location}/buckets/{bucket}/datasets/{dataset}/links/{link}
  • location: projects/{project}/locations/{location}
  • organizationLocationSettings: organizations/{organization}/locations/{location}/settings
  • projectLocationSettings: projects/{project}/locations/{location}/settings
  • scope: projects/{project}/locations/{location}/scopes/{scope}
  • settings: projects/{project}/locations/{location}/settings
  • traceScope: projects/{project}/locations/{location}/traceScopes/{trace_scope}
  • view: projects/{project}/locations/{location}/buckets/{bucket}/datasets/{dataset}/views/{view}

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.