/** * Constructor. * * @param array $options [optional] { * 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 Google Cloud 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' => self::_GAX_VERSION, 'credentialsLoader' => null]; $options = array_merge($defaultOptions, $options); $headerDescriptor = new AgentHeaderDescriptor(['clientName' => $options['appName'], 'clientVersion' => $options['appVersion'], 'codeGenName' => self::_CODEGEN_NAME, 'codeGenVersion' => self::_CODEGEN_VERSION, 'gaxVersion' => self::_GAX_VERSION, '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; } // TODO load the client config in a more package-friendly way // https://github.com/googleapis/toolkit/issues/332 $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']; $generatedCreateStub = function ($hostname, $opts) { return new MetricsServiceV2Client($hostname, $opts); }; $createStubOptions = []; if (!empty($options['sslCreds'])) { $createStubOptions['sslCreds'] = $options['sslCreds']; } $grpcCredentialsHelperOptions = array_diff_key($options, $defaultOptions); $this->grpcCredentialsHelper = new GrpcCredentialsHelper($this->scopes, $grpcCredentialsHelperOptions); $this->stub = $this->grpcCredentialsHelper->createStub($generatedCreateStub, $options['serviceAddress'], $options['port'], $createStubOptions); }
/** * Constructor. * * @param array $options { * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress The domain name of the API remote host. * Default 'pubsub.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 Google Cloud Pub/Sub 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/pubsub']; $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 = ['createTopic' => $defaultDescriptors, 'publish' => $defaultDescriptors, 'getTopic' => $defaultDescriptors, 'listTopics' => $defaultDescriptors, 'listTopicSubscriptions' => $defaultDescriptors, 'deleteTopic' => $defaultDescriptors, 'setIamPolicy' => $defaultDescriptors, 'getIamPolicy' => $defaultDescriptors, 'testIamPermissions' => $defaultDescriptors]; $pageStreamingDescriptors = self::getPageStreamingDescriptors(); foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; } $clientConfigJsonString = file_get_contents(__DIR__ . '/resources/publisher_client_config.json'); $clientConfig = json_decode($clientConfigJsonString, true); $this->defaultCallSettings = CallSettings::load('google.pubsub.v1.Publisher', $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); $createIamPolicyStubFunction = function ($hostname, $opts) { return new IAMPolicyGrpcClient($hostname, $opts); }; $this->iamPolicyStub = $this->grpcCredentialsHelper->createStub($createIamPolicyStubFunction, $options['serviceAddress'], $options['port'], $createStubOptions); $createPublisherStubFunction = function ($hostname, $opts) { return new PublisherGrpcClient($hostname, $opts); }; $this->publisherStub = $this->grpcCredentialsHelper->createStub($createPublisherStubFunction, $options['serviceAddress'], $options['port'], $createStubOptions); }
/** * Constructor. * * @param array $options [optional] { * Optional. Options for configuring the service API wrapper. * * @type string $serviceAddress The domain name of the API remote host. * Default 'pubsub.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 Google Cloud Pub/Sub 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/pubsub']; $defaultOptions = ['serviceAddress' => self::SERVICE_ADDRESS, 'port' => self::DEFAULT_SERVICE_PORT, 'scopes' => $defaultScopes, 'retryingOverride' => null, 'timeoutMillis' => self::DEFAULT_TIMEOUT_MILLIS, 'appName' => 'gax', 'appVersion' => self::_GAX_VERSION, 'credentialsLoader' => null]; $options = array_merge($defaultOptions, $options); $headerDescriptor = new AgentHeaderDescriptor(['clientName' => $options['appName'], 'clientVersion' => $options['appVersion'], 'codeGenName' => self::_CODEGEN_NAME, 'codeGenVersion' => self::_CODEGEN_VERSION, 'gaxVersion' => self::_GAX_VERSION, 'phpVersion' => phpversion()]); $defaultDescriptors = ['headerDescriptor' => $headerDescriptor]; $this->descriptors = ['createSubscription' => $defaultDescriptors, 'getSubscription' => $defaultDescriptors, 'listSubscriptions' => $defaultDescriptors, 'deleteSubscription' => $defaultDescriptors, 'modifyAckDeadline' => $defaultDescriptors, 'acknowledge' => $defaultDescriptors, 'pull' => $defaultDescriptors, 'modifyPushConfig' => $defaultDescriptors, 'setIamPolicy' => $defaultDescriptors, 'getIamPolicy' => $defaultDescriptors, 'testIamPermissions' => $defaultDescriptors]; $pageStreamingDescriptors = self::getPageStreamingDescriptors(); foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; } // TODO load the client config in a more package-friendly way // https://github.com/googleapis/toolkit/issues/332 $clientConfigJsonString = file_get_contents(__DIR__ . '/resources/subscriber_client_config.json'); $clientConfig = json_decode($clientConfigJsonString, true); $this->defaultCallSettings = CallSettings::load('google.pubsub.v1.Subscriber', $clientConfig, $options['retryingOverride'], GrpcConstants::getStatusCodeNames(), $options['timeoutMillis']); $this->scopes = $options['scopes']; $createStubOptions = []; if (!empty($options['sslCreds'])) { $createStubOptions['sslCreds'] = $options['sslCreds']; } $grpcCredentialsHelperOptions = array_diff_key($options, $defaultOptions); $this->grpcCredentialsHelper = new GrpcCredentialsHelper($this->scopes, $grpcCredentialsHelperOptions); $createIAMPolicyStubFunction = function ($hostname, $opts) { return new IAMPolicyClient($hostname, $opts); }; $this->iAMPolicyStub = $this->grpcCredentialsHelper->createStub($createIAMPolicyStubFunction, $options['serviceAddress'], $options['port'], $createStubOptions); $createSubscriberStubFunction = function ($hostname, $opts) { return new SubscriberClient($hostname, $opts); }; $this->subscriberStub = $this->grpcCredentialsHelper->createStub($createSubscriberStubFunction, $options['serviceAddress'], $options['port'], $createStubOptions); }
/** * Constructor. * * @param array $options { * 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 = ['deleteLog' => $defaultDescriptors, 'writeLogEntries' => $defaultDescriptors, 'listLogEntries' => $defaultDescriptors, 'listMonitoredResourceDescriptors' => $defaultDescriptors]; $pageStreamingDescriptors = self::getPageStreamingDescriptors(); foreach ($pageStreamingDescriptors as $method => $pageStreamingDescriptor) { $this->descriptors[$method]['pageStreamingDescriptor'] = $pageStreamingDescriptor; } $clientConfigJsonString = file_get_contents(__DIR__ . '/resources/logging_service_v2_client_config.json'); $clientConfig = json_decode($clientConfigJsonString, true); $this->defaultCallSettings = CallSettings::load('google.logging.v2.LoggingServiceV2', $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); $createLoggingServiceV2StubFunction = function ($hostname, $opts) { return new LoggingServiceV2GrpcClient($hostname, $opts); }; $this->loggingServiceV2Stub = $this->grpcCredentialsHelper->createStub($createLoggingServiceV2StubFunction, $options['serviceAddress'], $options['port'], $createStubOptions); }