Client Options — google-api-core documentation (original) (raw)

As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

Client options class.

Client options provide a consistent interface for user options to be defined across clients.

You can pass a client options object to a client.

from google.api_core.client_options import ClientOptions from google.cloud.vision_v1 import ImageAnnotatorClient

def get_client_cert(): # code to load client certificate and private key. return client_cert_bytes, client_private_key_bytes

options = ClientOptions(api_endpoint="foo.googleapis.com", client_cert_source=get_client_cert)

client = ImageAnnotatorClient(client_options=options)

You can also pass a mapping object.

from google.cloud.vision_v1 import ImageAnnotatorClient

client = ImageAnnotatorClient( client_options={ "api_endpoint": "foo.googleapis.com", "client_cert_source" : get_client_cert })

class google.api_core.client_options.ClientOptions(api_endpoint: Optional[str] = None, client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, client_encrypted_cert_source: Optional[Callable[[], Tuple[str, str, bytes]]] = None, quota_project_id: Optional[str] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, api_key: Optional[str] = None, api_audience: Optional[str] = None, universe_domain: Optional[str] = None)[source]

Bases: object

Client Options used to set options on clients.

Parameters

Raises

ValueError – If both client_cert_source and client_encrypted_cert_source are provided, or both credentials_file and api_key are provided.

google.api_core.client_options.from_dict(options: Mapping[str, object]) → google.api_core.client_options.ClientOptions[source]

Construct a client options object from a mapping object.

Parameters

options (collections.abc.Mapping) – A mapping object with client options. See the docstring for ClientOptions for details on valid arguments.