PHP Class Google\Cloud\Logging\V2\MetricsServiceV2Client

EXPERIMENTAL: this client library class has not yet been declared beta. This class may change more frequently than those which have been declared beta or 1.0, including changes which break backwards compatibility. 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: try { $metricsServiceV2Client = new MetricsServiceV2Client(); $formattedParent = MetricsServiceV2Client::formatProjectName("[PROJECT]"); foreach ($metricsServiceV2Client->listLogMetrics($formattedParent) as $element) { doThingsWith(element); } } finally { if (isset($metricsServiceV2Client)) { $metricsServiceV2Client->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 parse method to extract the individual identifiers contained within names that are returned.
Datei anzeigen Open project: GoogleCloudPlatform/gcloud-php

Public Methods

Method Description
__construct ( array $options = [] ) Constructor.
close ( ) Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.
createLogMetric ( string $parent, google\logging\v2\LogMetric $metric, array $optionalArgs = [] ) : google\logging\v2\LogMetric Creates a logs-based metric.
deleteLogMetric ( string $metricName, array $optionalArgs = [] ) Deletes a logs-based metric.
formatMetricName ( $project, $metric ) Formats a string containing the fully-qualified path to represent a metric resource.
formatProjectName ( $project ) Formats a string containing the fully-qualified path to represent a project resource.
getLogMetric ( string $metricName, array $optionalArgs = [] ) : google\logging\v2\LogMetric Gets a logs-based metric.
listLogMetrics ( string $parent, array $optionalArgs = [] ) : Google\GAX\PagedListResponse Lists logs-based metrics.
parseMetricFromMetricName ( $metricName ) Parses the metric from the given fully-qualified path which represents a metric resource.
parseProjectFromMetricName ( $metricName ) Parses the project from the given fully-qualified path which represents a metric resource.
parseProjectFromProjectName ( $projectName ) Parses the project from the given fully-qualified path which represents a project resource.
updateLogMetric ( string $metricName, google\logging\v2\LogMetric $metric, array $optionalArgs = [] ) : google\logging\v2\LogMetric Creates or updates a logs-based metric.

Private Methods

Method Description
createCredentialsCallback ( )
getMetricNameTemplate ( )
getPageStreamingDescriptors ( )
getProjectNameTemplate ( )

Method Details

__construct() public method

Constructor.
public __construct ( array $options = [] )
$options array { Optional. Options for configuring the service API wrapper. @type string $serviceAddress The domain name of the API remote host. Default 'logging.googleapis.com'. @type mixed $port The port on which to connect to the remote host. Default 443. @type Grpc\ChannelCredentials $sslCreds A `ChannelCredentials` for use with an SSL-enabled channel. Default: a credentials object returned from Grpc\ChannelCredentials::createSsl() @type array $scopes A string array of scopes to use when acquiring credentials. Default the scopes for the Stackdriver Logging API. @type array $retryingOverride An associative array of string => RetryOptions, where the keys are method names (e.g. 'createFoo'), that overrides default retrying settings. A value of null indicates that the method in question should not retry. @type int $timeoutMillis The timeout in milliseconds to use for calls that don't use retries. For calls that use retries, set the timeout in RetryOptions. Default: 30000 (30 seconds) @type string $appName The codename of the calling service. Default 'gax'. @type string $appVersion The version of the calling service. Default: the current version of GAX. @type Google\Auth\CredentialsLoader $credentialsLoader A CredentialsLoader object created using the Google\Auth library. }

close() public method

Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.
public close ( )

createLogMetric() public method

Sample code: try { $metricsServiceV2Client = new MetricsServiceV2Client(); $formattedParent = MetricsServiceV2Client::formatProjectName("[PROJECT]"); $metric = new LogMetric(); $response = $metricsServiceV2Client->createLogMetric($formattedParent, $metric); } finally { if (isset($metricsServiceV2Client)) { $metricsServiceV2Client->close(); } }
public createLogMetric ( string $parent, google\logging\v2\LogMetric $metric, array $optionalArgs = [] ) : google\logging\v2\LogMetric
$parent string The resource name of the project in which to create the metric: "projects/[PROJECT_ID]" The new metric must be provided in the request.
$metric google\logging\v2\LogMetric The new logs-based metric, which must not have an identifier that already exists.
$optionalArgs array { Optional. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }
return google\logging\v2\LogMetric

deleteLogMetric() public method

Sample code: try { $metricsServiceV2Client = new MetricsServiceV2Client(); $formattedMetricName = MetricsServiceV2Client::formatMetricName("[PROJECT]", "[METRIC]"); $metricsServiceV2Client->deleteLogMetric($formattedMetricName); } finally { if (isset($metricsServiceV2Client)) { $metricsServiceV2Client->close(); } }
public deleteLogMetric ( string $metricName, array $optionalArgs = [] )
$metricName string The resource name of the metric to delete: "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
$optionalArgs array { Optional. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }

formatMetricName() public static method

Formats a string containing the fully-qualified path to represent a metric resource.
public static formatMetricName ( $project, $metric )

formatProjectName() public static method

Formats a string containing the fully-qualified path to represent a project resource.
public static formatProjectName ( $project )

getLogMetric() public method

Sample code: try { $metricsServiceV2Client = new MetricsServiceV2Client(); $formattedMetricName = MetricsServiceV2Client::formatMetricName("[PROJECT]", "[METRIC]"); $response = $metricsServiceV2Client->getLogMetric($formattedMetricName); } finally { if (isset($metricsServiceV2Client)) { $metricsServiceV2Client->close(); } }
public getLogMetric ( string $metricName, array $optionalArgs = [] ) : google\logging\v2\LogMetric
$metricName string The resource name of the desired metric: "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
$optionalArgs array { Optional. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }
return google\logging\v2\LogMetric

listLogMetrics() public method

Sample code: try { $metricsServiceV2Client = new MetricsServiceV2Client(); $formattedParent = MetricsServiceV2Client::formatProjectName("[PROJECT]"); foreach ($metricsServiceV2Client->listLogMetrics($formattedParent) as $element) { doThingsWith(element); } } finally { if (isset($metricsServiceV2Client)) { $metricsServiceV2Client->close(); } }
public listLogMetrics ( string $parent, array $optionalArgs = [] ) : Google\GAX\PagedListResponse
$parent string Required. The name of the project containing the metrics: "projects/[PROJECT_ID]"
$optionalArgs array { Optional. @type string $pageToken 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. @type int $pageSize 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. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }
return Google\GAX\PagedListResponse

parseMetricFromMetricName() public static method

Parses the metric from the given fully-qualified path which represents a metric resource.
public static parseMetricFromMetricName ( $metricName )

parseProjectFromMetricName() public static method

Parses the project from the given fully-qualified path which represents a metric resource.
public static parseProjectFromMetricName ( $metricName )

parseProjectFromProjectName() public static method

Parses the project from the given fully-qualified path which represents a project resource.
public static parseProjectFromProjectName ( $projectName )

updateLogMetric() public method

Sample code: try { $metricsServiceV2Client = new MetricsServiceV2Client(); $formattedMetricName = MetricsServiceV2Client::formatMetricName("[PROJECT]", "[METRIC]"); $metric = new LogMetric(); $response = $metricsServiceV2Client->updateLogMetric($formattedMetricName, $metric); } finally { if (isset($metricsServiceV2Client)) { $metricsServiceV2Client->close(); } }
public updateLogMetric ( string $metricName, google\logging\v2\LogMetric $metric, array $optionalArgs = [] ) : google\logging\v2\LogMetric
$metricName string The resource name of the metric to update: "projects/[PROJECT_ID]/metrics/[METRIC_ID]" The updated metric must be provided in the request and it's `name` field must be the same as `[METRIC_ID]` If the metric does not exist in `[PROJECT_ID]`, then a new metric is created.
$metric google\logging\v2\LogMetric The updated metric.
$optionalArgs array { Optional. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }
return google\logging\v2\LogMetric