# Google API Core Client - Class ClientOptions (1.43.0)

1.43.0 (latest) 1.42.5 1.40.0 1.38.2 1.36.1 1.35.1 Reference documentation and code samples for the Google API Core Client class ClientOptions.

The ClientOptions class adds typing to the associative array of options
passed into each API client constructor. To use this class directly, pass
the result of ClientOptions::toArray() to the
client constructor:

    use Google\ApiCore\ClientOptions;
    use Google\Cloud\SecretManager\Client\SecretManagerClient;

    $options = new ClientOptions([
        'credentials' => '/path/to/my/credentials.json'
    ]);
    $secretManager = new SecretManagerClient($options->toArray());

Note: It's possible to pass an associative array to the API clients as well,
as ClientOptions will still be used internally for validation.

## Namespace

Google \\ ApiCore \\ Options

## Methods

### __construct

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `options` | `array` { @type string $apiEndpoint The address of the API remote host, for example "example.googleapis.com. May also include the port, for example "example.googleapis.com:443" @type bool $disableRetries Determines whether or not retries defined by the client configuration should be disabled. Defaults to `false`. @type string\|array $clientConfig 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. @type FetchAuthTokenInterface\|CredentialsWrapper $credentials This option should only be used with a pre-constructed \\Google\\Auth\\FetchAuthTokenInterface object or \\Google\\ApiCore\\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $authConfig will be ignored. **Important** : If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is now recommended to create the credentials explicitly: `use Google\Auth\Credentials\ServiceAccountCredentials; use Google\ApiCore\Options\ClientOptions; $creds = new ServiceAccountCredentials($scopes, $json); $options = new ClientOptions(['credentials' => $creds]);` For more information <https://cloud.google.com/docs/authentication/external/externally-sourced-credentials> @type array $credentialsConfig 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. @type string\|TransportInterface\|null $transport The transport used for executing network requests. May be either the string `rest`, `grpc`, or 'grpc-fallback'. Defaults to `grpc` if gRPC support is detected on the system. *Advanced usage* : Additionally, it is possible to pass in an already instantiated TransportInterface object. Note that when this objects is provided, any settings in $transportConfig, and any `$apiEndpoint` setting, will be ignored. @type array $transportConfig 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' =\> \[...\], 'grpc-fallback' =\> \[...\], \]; See the GrpcTransport::build and RestTransport::build methods for the supported options. @type string $versionFile The path to a file which contains the current version of the client. @type string $descriptorsConfigPath The path to a descriptor configuration file. @type string $serviceName The name of the service. @type string $libName The name of the client application. @type string $libVersion The version of the client application. @type string $gapicVersion The code generator version of the GAPIC library. @type callable $clientCertSource A callable which returns the client cert as a string. @type string $universeDomain The default service domain for a given Cloud universe. @type string $apiKey The API key to be used for the client. @type null\|false\|LoggerInterface A PSR-3 compliant logger. } |
| `↳ apiEndpoint` | `string` The address of the API remote host, for example "example.googleapis.com. May also include the port, for example "example.googleapis.com:443" |
| `↳ 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. |
| `↳ credentials` | `https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.html|https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper` This option should only be used with a pre-constructed \\Google\\Auth\\FetchAuthTokenInterface object or \\Google\\ApiCore\\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $authConfig will be ignored. **Important** : If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is now recommended to create the credentials explicitly: `use Google\Auth\Credentials\ServiceAccountCredentials; use Google\ApiCore\Options\ClientOptions; $creds = new ServiceAccountCredentials($scopes, $json); $options = new ClientOptions(['credentials' => $creds]);` For more information <https://cloud.google.com/docs/authentication/external/externally-sourced-credentials> |
| `↳ 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. |
| `↳ transport` | `string|https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.TransportInterface|null` The transport used for executing network requests. May be either the string `rest`, `grpc`, or 'grpc-fallback'. Defaults to `grpc` if gRPC support is detected on the system. *Advanced usage* : Additionally, it is possible to pass in an already instantiated TransportInterface object. Note that when this objects 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' =\> \[...\], 'grpc-fallback' =\> \[...\], \]; See the GrpcTransport::build and RestTransport::build methods for the supported options. |
| `↳ versionFile` | `string` The path to a file which contains the current version of the client. |
| `↳ descriptorsConfigPath` | `string` The path to a descriptor configuration file. |
| `↳ serviceName` | `string` The name of the service. |
| `↳ libName` | `string` The name of the client application. |
| `↳ libVersion` | `string` The version of the client application. |
| `↳ gapicVersion` | `string` The code generator version of the GAPIC library. |
| `↳ clientCertSource` | `callable` A callable which returns the client cert as a string. |
| `↳ universeDomain` | `string` The default service domain for a given Cloud universe. |
| `↳ apiKey` | `string` The API key to be used for the client. |
| `↳ A` | `null|false|LoggerInterface ` PSR-3 compliant logger. |

### setApiEndpoint

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `apiEndpoint` | `?string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setDisableRetries

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `disableRetries` | `bool` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setClientConfig

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `clientConfig` | `string|array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setCredentials

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `credentials` | `string|array|https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.html|https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper|null` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setCredentialsConfig

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `credentialsConfig` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setTransport

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `transport` | `string|https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.TransportInterface|null` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setTransportConfig

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `transportConfig` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/Options.TransportOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setVersionFile

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `versionFile` | `?string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setServiceName

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `serviceName` | `?string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setLibName

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `libName` | `?string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setLibVersion

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `libVersion` | `?string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setGapicVersion

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `gapicVersion` | `?string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setClientCertSource

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `clientCertSource` | `?callable` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setUniverseDomain

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `universeDomain` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setApiKey

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `apiKey` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### setLogger

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `logger` | `null|false|Psr\Log\LoggerInterface` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |