- 3.46.0 (latest)
- 3.45.0
- 3.44.0
- 3.43.0
- 3.42.0
- 3.41.0
- 3.40.1
- 3.39.0
- 3.38.0
- 3.37.0
- 3.36.0
- 3.35.1
- 3.34.0
- 3.33.0
- 3.32.0
- 3.31.0
- 3.30.0
- 3.29.0
- 3.28.0
- 3.27.1
- 3.26.0
- 3.25.0
- 3.24.0
- 3.23.0
- 3.22.2
- 3.21.0
- 3.20.0
- 3.19.0
- 3.18.0
- 3.17.0
- 3.16.0
- 3.15.1
- 3.14.1
- 3.13.0
- 3.12.1
- 3.11.1
- 3.10.0
- 3.9.0
- 3.8.0
- 3.7.0
- 3.6.0
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.1.1
- 2.0.0
- 1.19.3
- 1.18.0
- 1.17.1
- 1.16.0
- 1.15.1
- 1.14.0
- 1.13.0
- 1.12.0
- 1.11.0
- 1.10.0
Instance API
User friendly container for Cloud Spanner Instance.
class google.cloud.spanner_v1.instance.Instance(instance_id, client, configuration_name=None, node_count=1, display_name=None)
Bases: object
Representation of a Cloud Spanner Instance.
We can use a Instance
to:
reload()
itselfcreate()
itselfupdate()
itselfdelete()
itselfParameters
instance_id (str) – The ID of the instance.
client (
Client
) – The client that owns the instance. Provides authorization and a project ID.configuration_name (str) – Name of the instance configuration defining how the instance will be created. Required for instances which do not yet exist.
node_count (int) – (Optional) Number of nodes allocated to the instance.
display_name (str) – (Optional) The display name for the instance 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 instance ID.
copy()
Make a copy of this instance.
Copies the local data stored as simple types and copies the client attached to this instance.
Return type
Instance
Returns
A copy of the current instance.
create()
Create this instance.
NOTE: Uses the project
and instance_id
on the current
Instance
in addition to the display_name
.
To change them before creating, reset the values via
instance.display_name = 'New display name'
instance.instance_id = 'i-changed-my-mind'
before calling create()
.
Return type
google.api_core.operation.Operation
Returns
an operation instance
Raises
Conflict – if the instance already exists
database(database_id, ddl_statements=(), pool=None)
Factory to create a database within this instance.
Parameters
database_id (str) – The ID of the instance.
ddl_statements (list of string) – (Optional) DDL statements, excluding the ‘CREATE DATABSE’ statement.
pool (concrete subclass of
AbstractSessionPool
.) – (Optional) session pool to be used by database.
Return type
Returns
a database owned by this instance.
delete()
Mark an instance and all of its databases for permanent deletion.
Immediately upon completion of the request:
- Billing will cease for all of the instance’s reserved resources.
Soon afterward:
- The instance and all databases within the instance will be deleteed. All data in the databases will be permanently deleted.
exists()
Test whether this instance exists.
Return type
Returns
True if the instance exists, else false
classmethod from_pb(instance_pb, client)
Creates an instance from a protobuf.
Parameters
instance_pb (
google.spanner.v2.spanner_instance_admin_pb2.Instance
) – A instance protobuf object.client (
Client
) – The client that owns the instance.
Return type
Instance
Returns
The instance parsed from the protobuf response.
Raises
ValueError – if the instance name does not match
projects/{project}/instances/{instance_id}
or if the parsed project ID does not match the project ID on the client.
list_databases(page_size=None, page_token=None)
List databases for the instance.
Parameters
page_size (int) – Optional. The maximum number of databases in each page of results from this request. Non-positive values are ignored. Defaults to a sensible value set by the API.
page_token (str) – Optional. If present, return the next batch of databases, using the value, which must correspond to the
nextPageToken
value returned in the previous response. Deprecated: use thepages
property of the returned iterator instead of manually passing the token.
Return type
Iterator
Returns
Iterator of
Database
resources within the current instance.
property name()
Instance name used in requests.
NOTE: This property will not change if instance_id
does not,
but the return value is not cached.
The instance name is of the form
"projects/{project}/instances/{instance_id}"
Return type
Returns
The instance name.
reload()
Reload the metadata for this instance.
Raises
NotFound – if the instance does not exist
update()
Update this instance.
NOTE: Updates the display_name
and node_count
. To change those
values before updating, set them via
instance.display_name = 'New display name'
instance.node_count = 5
before calling :meth:`update`.
Return type
google.api_core.operation.Operation
Returns
an operation instance
Raises
NotFound – if the instance does not exist