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);
}