On January 1, 2020 this library will no longer support Python 2 on the latest released version. Previously released library versions will continue to be available. For more information please visit Python 2 support on Google Cloud.

Client Options

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 dictionary.

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=None, client_cert_source=None)[source]

Bases: object

Client Options used to set options on clients.

Parameters
  • api_endpoint (str) – The desired API endpoint, e.g., compute.googleapis.com

  • client_cert_source (Callable[[], (bytes, bytes)]) – An optional callback which returns client certificate bytes and private key bytes both in PEM format.

google.api_core.client_options.from_dict(options)[source]

Construct a client options object from a dictionary.

Parameters

options (dict) – A dictionary with client options.