Stackdriver Monitoring V3 Client - Class ServiceMonitoringServiceClient (1.6.0)

Reference documentation and code samples for the Stackdriver Monitoring V3 Client class ServiceMonitoringServiceClient.

Service Description: The Cloud Monitoring Service-Oriented Monitoring API has endpoints for managing and querying aspects of a workspace's services. These include the Service 's monitored resources, its Service-Level Objectives, and a taxonomy of categorized Health Metrics.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:

 $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();
try {
    $parent = 'parent';
    $service = new Service();
    $response = $serviceMonitoringServiceClient->createService($parent, $service);
} finally {
    $serviceMonitoringServiceClient->close();
} 

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

This service has a new (beta) implementation. See Google\Cloud\Monitoring\V3\Client\ServiceMonitoringServiceClient to use the new surface.

Namespace

Google \ Cloud \ Monitoring \ V3

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.

createService

Create a Service .

Parameters
Name
Description
parent
string

Required. Resource name of the parent workspace. The format is:

projects/[PROJECT_ID_OR_NUMBER]

service
Google\Cloud\Monitoring\V3\Service

Required. The Service to create.

optionalArgs
array

Optional.

↳ serviceId
string

Optional. The Service id to use for this Service. If omitted, an id will be generated instead. Must match the pattern [a-z0-9\-]+

↳ 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
Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Monitoring\V3\Service;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * @param string $parent Resource [name](https://cloud.google.com/monitoring/api/v3#project_name) of
 *                       the parent workspace. The format is:
 *
 *                       projects/[PROJECT_ID_OR_NUMBER]
 */
function create_service_sample(string $parent): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $service = new Service();

    // Call the API and handle any network failures.
    try {
        /** @var Service $response */
        $response = $serviceMonitoringServiceClient->createService($parent, $service);
        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
{
    $parent = '[PARENT]';

    create_service_sample($parent);
} 

createServiceLevelObjective

Create a ServiceLevelObjective for the given Service .

Parameters
Name
Description
parent
string

Required. Resource name of the parent Service . The format is:

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]

serviceLevelObjective
Google\Cloud\Monitoring\V3\ServiceLevelObjective

Required. The ServiceLevelObjective to create. The provided name will be respected if no ServiceLevelObjective exists with this name.

optionalArgs
array

Optional.

↳ serviceLevelObjectiveId
string

Optional. The ServiceLevelObjective id to use for this ServiceLevelObjective. If omitted, an id will be generated instead. Must match the pattern [a-z0-9\-]+

↳ retrySettings
RetrySettings|array

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

Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Monitoring\V3\ServiceLevelObjective;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * @param string $formattedParent Resource name of the parent `Service`. The format is:
 *
 *                                projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
 *                                Please see {@see ServiceMonitoringServiceClient::serviceName()} for help formatting this field.
 */
function create_service_level_objective_sample(string $formattedParent): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $serviceLevelObjective = new ServiceLevelObjective();

    // Call the API and handle any network failures.
    try {
        /** @var ServiceLevelObjective $response */
        $response = $serviceMonitoringServiceClient->createServiceLevelObjective(
            $formattedParent,
            $serviceLevelObjective
        );
        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 = ServiceMonitoringServiceClient::serviceName('[PROJECT]', '[SERVICE]');

    create_service_level_objective_sample($formattedParent);
} 

deleteService

Soft delete this Service .

Parameters
Name
Description
name
string

Required. Resource name of the Service to delete. The format is:

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]

optionalArgs
array

Optional.

↳ retrySettings
RetrySettings|array

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

Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * @param string $formattedName Resource name of the `Service` to delete. The format is:
 *
 *                              projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
 *                              Please see {@see ServiceMonitoringServiceClient::serviceName()} for help formatting this field.
 */
function delete_service_sample(string $formattedName): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

    // Call the API and handle any network failures.
    try {
        $serviceMonitoringServiceClient->deleteService($formattedName);
        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 = ServiceMonitoringServiceClient::serviceName('[PROJECT]', '[SERVICE]');

    delete_service_sample($formattedName);
} 

deleteServiceLevelObjective

Delete the given ServiceLevelObjective .

Parameters
Name
Description
name
string

Required. Resource name of the ServiceLevelObjective to delete. The format is:

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]

optionalArgs
array

Optional.

↳ retrySettings
RetrySettings|array

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

Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * @param string $formattedName Resource name of the `ServiceLevelObjective` to delete. The format is:
 *
 *                              projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
 *                              Please see {@see ServiceMonitoringServiceClient::serviceLevelObjectiveName()} for help formatting this field.
 */
function delete_service_level_objective_sample(string $formattedName): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

    // Call the API and handle any network failures.
    try {
        $serviceMonitoringServiceClient->deleteServiceLevelObjective($formattedName);
        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 = ServiceMonitoringServiceClient::serviceLevelObjectiveName(
        '[PROJECT]',
        '[SERVICE]',
        '[SERVICE_LEVEL_OBJECTIVE]'
    );

    delete_service_level_objective_sample($formattedName);
} 

getService

Get the named Service .

Parameters
Name
Description
name
string

Required. Resource name of the Service . The format is:

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]

optionalArgs
array

Optional.

↳ retrySettings
RetrySettings|array

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

Returns
Type
Description
Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Monitoring\V3\Service;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * @param string $formattedName Resource name of the `Service`. The format is:
 *
 *                              projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
 *                              Please see {@see ServiceMonitoringServiceClient::serviceName()} for help formatting this field.
 */
function get_service_sample(string $formattedName): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var Service $response */
        $response = $serviceMonitoringServiceClient->getService($formattedName);
        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 = ServiceMonitoringServiceClient::serviceName('[PROJECT]', '[SERVICE]');

    get_service_sample($formattedName);
} 

getServiceLevelObjective

Get a ServiceLevelObjective by name.

Parameters
Name
Description
name
string

Required. Resource name of the ServiceLevelObjective to get. The format is:

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]

optionalArgs
array

Optional.

↳ view
int

View of the ServiceLevelObjective to return. If DEFAULT , return the ServiceLevelObjective as originally defined. If EXPLICIT and the ServiceLevelObjective is defined in terms of a BasicSli , replace the BasicSli with a RequestBasedSli spelling out how the SLI is computed. For allowed values, use constants defined on Google\Cloud\Monitoring\V3\ServiceLevelObjective\View

↳ retrySettings
RetrySettings|array

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

Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Monitoring\V3\ServiceLevelObjective;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * @param string $formattedName Resource name of the `ServiceLevelObjective` to get. The format is:
 *
 *                              projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]/serviceLevelObjectives/[SLO_NAME]
 *                              Please see {@see ServiceMonitoringServiceClient::serviceLevelObjectiveName()} for help formatting this field.
 */
function get_service_level_objective_sample(string $formattedName): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var ServiceLevelObjective $response */
        $response = $serviceMonitoringServiceClient->getServiceLevelObjective($formattedName);
        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 = ServiceMonitoringServiceClient::serviceLevelObjectiveName(
        '[PROJECT]',
        '[SERVICE]',
        '[SERVICE_LEVEL_OBJECTIVE]'
    );

    get_service_level_objective_sample($formattedName);
} 

listServiceLevelObjectives

List the ServiceLevelObjective s for the given Service .

Parameters
Name
Description
parent
string

Required. Resource name of the parent containing the listed SLOs, either a project or a Monitoring Workspace. The formats are:

projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID] workspaces/[HOST_PROJECT_ID_OR_NUMBER]/services/-

optionalArgs
array

Optional.

↳ filter
string

A filter specifying what ServiceLevelObjective s to return.

↳ pageSize
int

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

↳ pageToken
string

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

↳ view
int

View of the ServiceLevelObjective s to return. If DEFAULT , return each ServiceLevelObjective as originally defined. If EXPLICIT and the ServiceLevelObjective is defined in terms of a BasicSli , replace the BasicSli with a RequestBasedSli spelling out how the SLI is computed. For allowed values, use constants defined on Google\Cloud\Monitoring\V3\ServiceLevelObjective\View

↳ 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
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Monitoring\V3\ServiceLevelObjective;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * @param string $formattedParent Resource name of the parent containing the listed SLOs, either a
 *                                project or a Monitoring Workspace. The formats are:
 *
 *                                projects/[PROJECT_ID_OR_NUMBER]/services/[SERVICE_ID]
 *                                workspaces/[HOST_PROJECT_ID_OR_NUMBER]/services/-
 *                                Please see {@see ServiceMonitoringServiceClient::serviceName()} for help formatting this field.
 */
function list_service_level_objectives_sample(string $formattedParent): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

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

        /** @var ServiceLevelObjective $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 = ServiceMonitoringServiceClient::serviceName('[PROJECT]', '[SERVICE]');

    list_service_level_objectives_sample($formattedParent);
} 

listServices

List Service s for this workspace.

Parameters
Name
Description
parent
string

Required. Resource name of the parent containing the listed services, either a project or a Monitoring Workspace. The formats are:

projects/[PROJECT_ID_OR_NUMBER] workspaces/[HOST_PROJECT_ID_OR_NUMBER]

optionalArgs
array

Optional.

↳ filter
string

A filter specifying what Service s to return. The filter currently supports the following fields: - identifier_case - app_engine.module_id - cloud_endpoints.service (reserved for future use) - mesh_istio.mesh_uid - mesh_istio.service_namespace - mesh_istio.service_name - cluster_istio.location (deprecated) - cluster_istio.cluster_name (deprecated) - cluster_istio.service_namespace (deprecated) - cluster_istio.service_name (deprecated) identifier_case refers to which option in the identifier oneof is populated. For example, the filter identifier_case = "CUSTOM" would match all services with a value for the custom field. Valid options are "CUSTOM", "APP_ENGINE", "MESH_ISTIO", plus "CLUSTER_ISTIO" (deprecated) and "CLOUD_ENDPOINTS" (reserved for future use).

↳ pageSize
int

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

↳ pageToken
string

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

↳ retrySettings
RetrySettings|array

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

Returns
Type
Description
Example
 use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Monitoring\V3\Service;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * @param string $parent Resource name of the parent containing the listed services, either a
 *                       [project](https://cloud.google.com/monitoring/api/v3#project_name) or a
 *                       Monitoring Workspace. The formats are:
 *
 *                       projects/[PROJECT_ID_OR_NUMBER]
 *                       workspaces/[HOST_PROJECT_ID_OR_NUMBER]
 */
function list_services_sample(string $parent): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

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

        /** @var Service $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
{
    $parent = '[PARENT]';

    list_services_sample($parent);
} 

updateService

Update this Service .

Parameters
Name
Description
service
Google\Cloud\Monitoring\V3\Service

Required. The Service to draw updates from. The given name specifies the resource to update.

optionalArgs
array

Optional.

↳ updateMask
FieldMask

A set of field paths defining which fields to use for the update.

↳ 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
Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Monitoring\V3\Service;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * 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_service_sample(): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $service = new Service();

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

updateServiceLevelObjective

Update the given ServiceLevelObjective .

Parameters
Name
Description
serviceLevelObjective
Google\Cloud\Monitoring\V3\ServiceLevelObjective

Required. The ServiceLevelObjective to draw updates from. The given name specifies the resource to update.

optionalArgs
array

Optional.

↳ updateMask
FieldMask

A set of field paths defining which fields to use for the update.

↳ retrySettings
RetrySettings|array

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

Example
 use Google\ApiCore\ApiException;
use Google\Cloud\Monitoring\V3\ServiceLevelObjective;
use Google\Cloud\Monitoring\V3\ServiceMonitoringServiceClient;

/**
 * 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_service_level_objective_sample(): void
{
    // Create a client.
    $serviceMonitoringServiceClient = new ServiceMonitoringServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $serviceLevelObjective = new ServiceLevelObjective();

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

static::projectName

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

Parameter
Name
Description
project
string
Returns
Type
Description
string
The formatted project resource.

static::folderServiceName

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

Parameters
Name
Description
folder
string
service
string
Returns
Type
Description
string
The formatted folder_service resource.

static::folderServiceServiceLevelObjectiveName

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

Parameters
Name
Description
folder
string
service
string
serviceLevelObjective
string
Returns
Type
Description
string
The formatted folder_service_service_level_objective resource.

static::organizationServiceName

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

Parameters
Name
Description
organization
string
service
string
Returns
Type
Description
string
The formatted organization_service resource.

static::organizationServiceServiceLevelObjectiveName

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

Parameters
Name
Description
organization
string
service
string
serviceLevelObjective
string
Returns
Type
Description
string
The formatted organization_service_service_level_objective resource.

static::projectServiceName

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

Parameters
Name
Description
project
string
service
string
Returns
Type
Description
string
The formatted project_service resource.

static::projectServiceServiceLevelObjectiveName

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

Parameters
Name
Description
project
string
service
string
serviceLevelObjective
string
Returns
Type
Description
string
The formatted project_service_service_level_objective resource.

static::serviceName

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

Parameters
Name
Description
project
string
service
string
Returns
Type
Description
string
The formatted service resource.

static::serviceLevelObjectiveName

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

Parameters
Name
Description
project
string
service
string
serviceLevelObjective
string
Returns
Type
Description
string
The formatted service_level_objective 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

  • folderService: folders/{folder}/services/{service}
  • folderServiceServiceLevelObjective: folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}
  • organizationService: organizations/{organization}/services/{service}
  • organizationServiceServiceLevelObjective: organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}
  • projectService: projects/{project}/services/{service}
  • projectServiceServiceLevelObjective: projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}
  • service: projects/{project}/services/{service}
  • serviceLevelObjective: projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}

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.

Constants

SERVICE_NAME

  Value: 'google.monitoring.v3.ServiceMonitoringService' 
 

The name of the service.

SERVICE_ADDRESS

  Value: 'monitoring.googleapis.com' 
 

The default address of the service.

DEFAULT_SERVICE_PORT

  Value: 443 
 

The default port of the service.

CODEGEN_NAME

  Value: 'gapic' 
 

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

Create a Mobile Website
View Site in Mobile | Classic
Share by: