gcloudex v0.4.3 GCloudex.CloudSQL.Client

Summary

Functions

Clones the given ‘instance’ and gives the new instance the chosen ‘dest_name’ and the given ‘bin_log_file’ and ‘bin_log_pos’

Generates a short-lived X509 certificate containing the provided ‘public_key’ and signed by a private key specific to the target ‘instance’. Users may use the certificate to authenticate as themselves when connecting to the database

Deletes the backup taken by a backup run with ID ‘run_id’ and belonging to the given ‘instance’

Deletes the ‘database’ from the Cloud SQL ‘instance’

Deletes the given ‘instance’ from the project

Deletes the SSL certificate with the given ‘sha1_fingerprint’ from the specified ‘instance’

Deletes a user with the given ‘host’ and ‘name’ from the Cloud SQL ‘instance’

Failover the ‘instance’ to its failover replica instance with the specified ‘settings_version’

Retrieves a resource containing information about a backup run with the ID of ‘run_id’ and belonging to the given ‘instance’

Retrieves a resource containing information about the ‘database’ inside a Cloud SQL ‘instance’

Retrieves a resource containing information about the given Cloud SQL ‘instance’

Retrieves the instance operation with ‘operation_id’ that has been performed on an instance

Retrieves a particular SSL certificate belonging to the given ‘instance’ and with the provided ‘sh1_fingerprint’. Does not include the private key (required for usage). The private key must be saved from the response to initial creation

Creates a new database inside the specified Cloud SQL ‘instance’ with the given ‘name’

Creates a new Cloud SQL instance with the specified ‘name’, ‘settings’, ‘optional_properties’ and with the given ‘tier’ unless already passed through ‘settings’

Creates an SSL certificate for the given ‘instance’ and gives it the name specified in ‘common_name’ and returns it along with the private key and server certificate authority

Creates a new user in a Cloud SQL ‘instance’ with the given ‘name and ‘password’. The authorized host to connect can be set through ‘host’ (defaults to ‘% (any host)’)

Lists all backup runs associated with a given ‘instance’ and configuration in the reverse chronological order of the backup initiation time

Lists databases in the specified Cloud SQL ‘instance’

List all available database flags for Google the Cloud SQL ‘instance’

List instances from the project

Lists all instance operations that have been performed on the given Cloud SQL ‘instance’ in the reverse chronological order of the start time

Lists all of the current SSL certificates for the ‘instance’

Lists all available service tiers for Google Cloud SQL, for example D1, D2

Lists users in the specified Cloud SQL ‘instance’

Updates a resource containing information about a ‘database’ inside a Cloud SQL ‘instance’ using patch semantics. The ‘db_resource’ must follow the description of Database Resources in: https://cloud.google.com/sql/docs/admin-api/v1beta4/databases#resource

Promotes the read replica ‘instance’ to be a stand-alone Cloud SQL instance

Sends a HTTP request with the given ‘verb’, ‘headers’ and ‘body’ to the specified ‘endpoint’. The authorization and google project headers are added automatically

Sends a HTTP request with the given ‘verb’, ‘headers’, ‘body’ and query ‘parameters’ to the specified ‘endpoint’. The authorization and google project headers are added automatically

Deletes all client certificates and generates a new server SSL certificate for the ‘instance’

Restarts the given ‘instance’

Starts the replication in the read replica ‘instance’

Stops the replication in the read replica ‘instance’

Updates a resource containing information about a ‘database’ inside a Cloud SQL ‘instance’. The ‘update_map’ must be a Map

Updates an existing user in a Cloud SQL ‘instance’ with the given ‘host’, ‘name’ and ‘password’

Functions

clone_instance(instance, dest_name, bin_log_file, bin_log_pos)

Specs

clone_instance(instance :: binary, dest_name :: binary, bin_log_file :: binary, bin_log_pos :: binary) :: HTTPResponse.t

Clones the given ‘instance’ and gives the new instance the chosen ‘dest_name’ and the given ‘bin_log_file’ and ‘bin_log_pos’.

create_ephemeral_ssl_cert(instance, public_key)

Specs

create_ephemeral_ssl_cert(instance :: binary, public_key :: binary) :: HTTPResponse.t

Generates a short-lived X509 certificate containing the provided ‘public_key’ and signed by a private key specific to the target ‘instance’. Users may use the certificate to authenticate as themselves when connecting to the database.

delete_backup_run(instance, run_id)

Specs

delete_backup_run(instance :: binary, run_id :: binary | number) :: HTTPResponse.t

Deletes the backup taken by a backup run with ID ‘run_id’ and belonging to the given ‘instance’.

delete_database(instance, database)

Specs

delete_database(instance :: binary, database :: binary) :: HTTPResponse.t

Deletes the ‘database’ from the Cloud SQL ‘instance’.

delete_instance(instance)

Specs

delete_instance(instance :: binary) :: HTTPResponse.t

Deletes the given ‘instance’ from the project.

delete_ssl_cert(instance, sha1_fingerprint)

Specs

delete_ssl_cert(instance :: binary, sha1_fingerprint :: binary) :: HTTPResponse.t

Deletes the SSL certificate with the given ‘sha1_fingerprint’ from the specified ‘instance’.

delete_user(instance, host, name)

Specs

delete_user(instance :: binary, host :: binary, name :: binary) :: HTTPResponse.t

Deletes a user with the given ‘host’ and ‘name’ from the Cloud SQL ‘instance’.

failover_instance(instance, settings_version)

Specs

failover_instance(instance :: binary, settings_version :: number) :: HTTPResponse.t

Failover the ‘instance’ to its failover replica instance with the specified ‘settings_version’.

get_backup_run(instance, run_id)

Specs

get_backup_run(instance :: binary, run_id :: binary | number) :: HTTPResponse.t

Retrieves a resource containing information about a backup run with the ID of ‘run_id’ and belonging to the given ‘instance’.

get_database(instance, database)

Specs

get_database(instance :: binary, database :: binary) :: HTTPResponse.t

Retrieves a resource containing information about the ‘database’ inside a Cloud SQL ‘instance’.

get_instance(instance)

Specs

get_instance(instance :: binary) :: HTTPResponse.t

Retrieves a resource containing information about the given Cloud SQL ‘instance’.

get_operation(operation_id)

Specs

get_operation(operation_id :: binary) :: HTTPResponse.t

Retrieves the instance operation with ‘operation_id’ that has been performed on an instance.

get_ssl_cert(instance, sha1_fingerprint)

Specs

get_ssl_cert(instance :: binary, sh1_fingerprint :: binary) :: HTTPResponse.t

Retrieves a particular SSL certificate belonging to the given ‘instance’ and with the provided ‘sh1_fingerprint’. Does not include the private key (required for usage). The private key must be saved from the response to initial creation.

insert_database(instance, name)

Specs

insert_database(instance :: binary, name :: binary) :: HTTPResponse.t

Creates a new database inside the specified Cloud SQL ‘instance’ with the given ‘name’.

insert_instance(name, optional_properties, settings, tier)

Specs

insert_instance(name :: binary, optional_properties :: map, settings :: map, tier :: binary) :: HTTPResponse.t

Creates a new Cloud SQL instance with the specified ‘name’, ‘settings’, ‘optional_properties’ and with the given ‘tier’ unless already passed through ‘settings’.

The ‘settings’ parameter is meant to have the settings JSON nested object while ‘optional_properties’ is meant to have other non-required request fields like the ‘replicaConfiguration’ JSON nested object field. The ‘settings’ map will be nested into ‘optional_properties’ to match the API’s request structure like in the following example:

optional_properties = %{

name: 'name',
region: someRegion,
settings: %{
  tier: 'tier',
  other_key_1: someValue,
  other_key_2: someValue
},
optional_prop_1: someValue,
optional_prop_2: someValue

}

TODO: Re-evaluate how the optional fields should be passed.

insert_ssl_cert(instance, common_name)

Specs

insert_ssl_cert(instance :: binary, common_name :: binary) :: HTTPResponse.t

Creates an SSL certificate for the given ‘instance’ and gives it the name specified in ‘common_name’ and returns it along with the private key and server certificate authority.

For First Generation instances, the new certificate does not take effect until the instance is restarted.

insert_user(instance, name, password, host \\ "%")

Specs

insert_user(instance :: binary, name :: binary, password :: binary, host :: binary) :: HTTPResponse.t

Creates a new user in a Cloud SQL ‘instance’ with the given ‘name and ‘password’. The authorized host to connect can be set through ‘host’ (defaults to ‘% (any host)’).

list_backup_runs(instance)

Specs

list_backup_runs(instance :: binary) :: HTTPResponse.t

Lists all backup runs associated with a given ‘instance’ and configuration in the reverse chronological order of the backup initiation time.

list_databases(instance)

Specs

list_databases(instance :: binary) :: HTTPResponse.t

Lists databases in the specified Cloud SQL ‘instance’.

list_flags()

Specs

list_flags :: HTTPResponse.t

List all available database flags for Google the Cloud SQL ‘instance’.

list_instances()

Specs

list_instances :: HTTPResponse.t

List instances from the project.

list_operations(instance)

Specs

list_operations(instance :: binary) :: HTTPResponse.t

Lists all instance operations that have been performed on the given Cloud SQL ‘instance’ in the reverse chronological order of the start time.

list_ssl_certs(instance)

Specs

list_ssl_certs(instance :: binary) :: HTTPResponse.t

Lists all of the current SSL certificates for the ‘instance’.

list_tiers()

Specs

list_tiers :: HTTPResponse.t

Lists all available service tiers for Google Cloud SQL, for example D1, D2.

list_users(instance)

Specs

list_users(instance :: binary) :: HTTPResponse.t

Lists users in the specified Cloud SQL ‘instance’.

patch_database(instance, database, db_resource)

Specs

patch_database(instance :: binary, database :: binary, db_resource :: Map.t) :: HTTPResponse.t

Updates a resource containing information about a ‘database’ inside a Cloud SQL ‘instance’ using patch semantics. The ‘db_resource’ must follow the description of Database Resources in: https://cloud.google.com/sql/docs/admin-api/v1beta4/databases#resource

promote_replica(instance)

Specs

promote_replica(instance :: binary) :: HTTPResponse.t

Promotes the read replica ‘instance’ to be a stand-alone Cloud SQL instance.

request(verb, endpoint, headers \\ [], body \\ "")

Specs

request(verb :: atom, endpoint :: binary, headers :: [{key :: binary, value :: binary}], body :: binary) :: HTTPoison.HTTPResponse.t

Sends a HTTP request with the given ‘verb’, ‘headers’ and ‘body’ to the specified ‘endpoint’. The authorization and google project headers are added automatically.

request_query(verb, endpoint, headers \\ [], body \\ "", parameters)

Specs

request_query(verb :: atom, endpoint :: binary, headers :: [{key :: binary, value :: binary}], body :: binary, parameters :: binary) :: HTTPoison.HTTPResponse.t

Sends a HTTP request with the given ‘verb’, ‘headers’, ‘body’ and query ‘parameters’ to the specified ‘endpoint’. The authorization and google project headers are added automatically.

reset_ssl_config(instance)

Specs

reset_ssl_config(instance :: binary) :: HTTPResponse.t

Deletes all client certificates and generates a new server SSL certificate for the ‘instance’.

For First Generation instances, the changes do not take effect until the instance is restarted. For Second Generation instances, the changes are immediate; all existing connections to the instance are broken.

restart_instance(instance)

Specs

restart_instance(instance :: binary) :: HTTPResponse.t

Restarts the given ‘instance’.

start_replica(instance)

Specs

start_replica(instance :: binary) :: HTTPResponse.t

Starts the replication in the read replica ‘instance’.

stop_replica(instance)

Specs

stop_replica(instance :: binary) :: HTTPResponse.t

Stops the replication in the read replica ‘instance’.

update_database(instance, database, db_resource)

Specs

update_database(instance :: binary, database :: binary, db_resource :: Map.t) :: HTTPResponse.t

Updates a resource containing information about a ‘database’ inside a Cloud SQL ‘instance’. The ‘update_map’ must be a Map.

update_user(instance, host, name, password)

Specs

update_user(instance :: binary, host :: binary, name :: binary, password :: binary) :: HTTPResponse.t

Updates an existing user in a Cloud SQL ‘instance’ with the given ‘host’, ‘name’ and ‘password’.