Google\Cloud\Logging\V2\MetricsServiceV2Client::__construct PHP Method

__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. }
    public function __construct($options = [])
    {
        $defaultScopes = ['https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-platform.read-only', 'https://www.googleapis.com/auth/logging.admin', 'https://www.googleapis.com/auth/logging.read', 'https://www.googleapis.com/auth/logging.write'];
        $defaultOptions = ['serviceAddress' => self::SERVICE_ADDRESS, 'port' => self::DEFAULT_SERVICE_PORT, 'scopes' => $defaultScopes, 'retryingOverride' => null, 'timeoutMillis' => self::DEFAULT_TIMEOUT_MILLIS, 'appName' => 'gax', 'appVersion' => AgentHeaderDescriptor::getGaxVersion()];
        $options = array_merge($defaultOptions, $options);
        $headerDescriptor = new AgentHeaderDescriptor(['clientName' => $options['appName'], 'clientVersion' => $options['appVersion'], 'codeGenName' => self::_CODEGEN_NAME, 'codeGenVersion' => self::_CODEGEN_VERSION, 'gaxVersion' => AgentHeaderDescriptor::getGaxVersion(), 'phpVersion' => phpversion()]);
        $defaultDescriptors = ['headerDescriptor' => $headerDescriptor];
        $this->descriptors = ['listLogMetrics' => $defaultDescriptors, 'getLogMetric' => $defaultDescriptors, 'createLogMetric' => $defaultDescriptors, 'updateLogMetric' => $defaultDescriptors, 'deleteLogMetric' => $defaultDescriptors];
        $pageStreamingDescriptors = self::getPageStreamingDescriptors();
        foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) {
            $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor;
        }
        $clientConfigJsonString = file_get_contents(__DIR__ . '/resources/metrics_service_v2_client_config.json');
        $clientConfig = json_decode($clientConfigJsonString, true);
        $this->defaultCallSettings = CallSettings::load('google.logging.v2.MetricsServiceV2', $clientConfig, $options['retryingOverride'], GrpcConstants::getStatusCodeNames(), $options['timeoutMillis']);
        $this->scopes = $options['scopes'];
        $createStubOptions = [];
        if (array_key_exists('sslCreds', $options)) {
            $createStubOptions['sslCreds'] = $options['sslCreds'];
        }
        $grpcCredentialsHelperOptions = array_diff_key($options, $defaultOptions);
        $this->grpcCredentialsHelper = new GrpcCredentialsHelper($this->scopes, $grpcCredentialsHelperOptions);
        $createMetricsServiceV2StubFunction = function ($hostname, $opts) {
            return new MetricsServiceV2GrpcClient($hostname, $opts);
        };
        $this->metricsServiceV2Stub = $this->grpcCredentialsHelper->createStub($createMetricsServiceV2StubFunction, $options['serviceAddress'], $options['port'], $createStubOptions);
    }