Instance(
instance_id, client, configuration_name=None, node_count=1, display_name=None
)
Representation of a Cloud Spanner Instance.
We can use a Instance
to:
reload
itselfcreate
itselfupdate
itselfdelete
itself
Parameters | |
---|---|
Name | Description |
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. |
Properties
name
Instance name used in requests.
"projects/{project}/instances/{instance_id}"
Returns | |
---|---|
Type | Description |
str | The instance name. |
Methods
copy
copy()
Make a copy of this instance.
Copies the local data stored as simple types and copies the client attached to this instance.
Returns | |
---|---|
Type | Description |
Instance | A copy of the current instance. |
create
create()
Create this instance.
Exceptions | |
---|---|
Type | Description |
Conflict | if the instance already exists |
Returns | |
---|---|
Type | Description |
| an operation instance |
database
database(database_id, ddl_statements=(), pool=None)
Factory to create a database within this instance.
Parameters | |
---|---|
Name | Description |
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. |
Returns | |
---|---|
Type | Description |
Database | a database owned by this instance. |
delete
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
exists()
Test whether this instance exists.
Returns | |
---|---|
Type | Description |
bool | True if the instance exists, else false |
from_pb
from_pb(instance_pb, client)
Creates an instance from a protobuf.
Parameters | |
---|---|
Name | Description |
instance_pb |
A instance protobuf object. |
client |
Client
The client that owns the instance. |
Exceptions | |
---|---|
Type | Description |
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. |
Returns | |
---|---|
Type | Description |
| The instance parsed from the protobuf response. |
list_databases
list_databases(page_size=None, page_token=None)
List databases for the instance.
Parameters | |
---|---|
Name | Description |
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 |
Returns | |
---|---|
Type | Description |
| Iterator of Database resources within the current instance. |
reload
reload()
Reload the metadata for this instance.
Exceptions | |
---|---|
Type | Description |
NotFound | if the instance does not exist |
update
update()
Update this instance.
Exceptions | |
---|---|
Type | Description |
NotFound | if the instance does not exist |
Returns | |
---|---|
Type | Description |
| an operation instance |