Client¶
Parent client for calling the Google Cloud Bigtable API.
This is the base from which all interactions with the API occur.
In the hierarchy of API concepts * a client owns a cluster * a cluster owns a table * a table owns column families * a table owns data
-
gcloud_bigtable.client.ADMIN_SCOPE= 'https://www.googleapis.com/auth/cloud-bigtable.admin'¶ Scope for interacting with the Cluster Admin and Table Admin APIs.
-
class
gcloud_bigtable.client.Client(credentials=None, project_id=None, read_only=False, admin=False, user_agent='gcloud-bigtable-python', timeout_seconds=10)[source]¶ Bases:
objectClient for interacting with Google Cloud Bigtable API.
Parameters: - credentials (
oauth2client.client.OAuth2CredentialsorNoneType) – (Optional) The OAuth2 Credentials to use for this cluster. If not provided, defaulst to the Google Application Default Credentials. - project_id (string) – (Optional) The ID of the project which owns the clusters, tables and data. If not provided, will attempt to determine from the environment.
- read_only (boolean) – (Optional) Boolean indicating if the data scope should be
for reading only (or for writing as well). Defaults to
False. - admin (boolean) – (Optional) Boolean indicating if the client will be used to
interact with the Cluster Admin or Table Admin APIs. This
requires the
ADMIN_SCOPE. Defaults toFalse. - user_agent (string) – (Optional) The user agent to be used with API request.
Defaults to
DEFAULT_USER_AGENT. - timeout_seconds (integer) – Number of seconds for request time-out. If not
passed, defaults to
DEFAULT_TIMEOUT_SECONDS.
Raises: ValueErrorif bothread_onlyandadminareTrue-
cluster(zone, cluster_id, display_name=None, serve_nodes=3)[source]¶ Factory to create a cluster associated with this client.
Parameters: - zone (string) – The name of the zone where the cluster resides.
- cluster_id (string) – The ID of the cluster.
- display_name (string) – (Optional) The display name for the cluster in the Cloud Console UI. (Must be between 4 and 30 characters.) If this value is not set in the constructor, will fall back to the cluster ID.
- serve_nodes (integer) – (Optional) The number of nodes in the cluster. Defaults to 3.
Return type: ClusterReturns: The cluster owned by this client.
-
credentials¶ Getter for client’s credentials.
Return type: oauth2client.client.OAuth2CredentialsReturns: The credentials stored on the client.
-
classmethod
from_service_account_json(json_credentials_path, project_id=None, read_only=False, admin=False)[source]¶ Factory to retrieve JSON credentials while creating client object.
Parameters: - json_credentials_path (string) – The path to a private key file (this file was given to you when you created the service account). This file must contain a JSON object with a private key and other credentials information (downloaded from the Google APIs console).
- project_id (string) – The ID of the project which owns the clusters,
tables and data. Will be passed to
Clientconstructor. - read_only (boolean) – Boolean indicating if the data scope should be
for reading only (or for writing as well). Will be
passed to
Clientconstructor. - admin (boolean) – Boolean indicating if the client will be used to
interact with the Cluster Admin or Table Admin APIs. Will
be passed to
Clientconstructor.
Return type: Returns: The client created with the retrieved JSON credentials.
-
classmethod
from_service_account_p12(client_email, private_key_path, project_id=None, read_only=False, admin=False)[source]¶ Factory to retrieve P12 credentials while creating client object.
Note
Unless you have an explicit reason to use a PKCS12 key for your service account, we recommend using a JSON key.
Parameters: - client_email (string) – The e-mail attached to the service account.
- private_key_path (string) – The path to a private key file (this file was given to you when you created the service account). This file must be in P12 format.
- project_id (string) – The ID of the project which owns the clusters,
tables and data. Will be passed to
Clientconstructor. - read_only (boolean) – Boolean indicating if the data scope should be
for reading only (or for writing as well). Will be
passed to
Clientconstructor. - admin (boolean) – Boolean indicating if the client will be used to
interact with the Cluster Admin or Table Admin APIs. Will
be passed to
Clientconstructor.
Return type: Returns: The client created with the retrieved P12 credentials.
-
list_clusters(timeout_seconds=None)[source]¶ Lists clusters owned by the project.
Parameters: timeout_seconds (integer) – Number of seconds for request time-out. If not passed, defaults to value set on client. Return type: tuple Returns: A pair of results, the first is a list of Clusters returned and the second is a list of strings (the failed zones in the request).
-
list_zones(timeout_seconds=None)[source]¶ Lists zones associated with project.
Parameters: timeout_seconds (integer) – Number of seconds for request time-out. If not passed, defaults to value set on client. Return type: list of strings Returns: The names of the zones Raises: ValueErrorif one of the zones is not inOKstate.
-
project_id¶ Getter for client’s project ID.
Return type: string Returns: The project ID stored on the client.
-
project_name¶ Project name to be used with Cluster Admin API.
Note
This property will not change if
project_iddoes not, but the return value is not cached.The project name is of the form “projects/{project_id}”.
Return type: string Returns: The project name to be used with the Cloud Bigtable Admin API RPC service.
- credentials (
-
gcloud_bigtable.client.DATA_SCOPE= 'https://www.googleapis.com/auth/cloud-bigtable.data'¶ Scope for reading and writing table data.
-
gcloud_bigtable.client.PROJECT_ENV_VAR= 'GCLOUD_PROJECT'¶ Environment variable used to provide an implicit project ID.
-
gcloud_bigtable.client.READ_ONLY_SCOPE= 'https://www.googleapis.com/auth/cloud-bigtable.data.readonly'¶ Scope for reading table data.