Database RDS API

For details on how to use database, see /sdk/guides/rds (NEEDS TO BE DONE)

The Database Class

The database high-level interface is available through the rds member of a Connection object. The rds member will only be added if the otcextensions.sdk.register_otc_extensions(conn) method is called.

Datastore Operations

class otcextensions.sdk.rds.v3._proxy.Proxy(session, *args, **kwargs)
datastore_types()

List supported datastore types

Returns:

A generator of supported datastore type objects with name attribute.

datastores(database_name)

List datastores

Parameters:

database_name – database store name (MySQL, PostgreSQL, or SQLServer and is case-sensitive.)

Returns:

A generator of supported datastore versions.

Return type:

Datastore

Flavor Operations

class otcextensions.sdk.rds.v3._proxy.Proxy(session, *args, **kwargs)
flavors(datastore_name, **params)

List flavors of given datastore_name and other optional parameters

Parameters:
  • datastore_name – datastore_name

  • version_name – version_name

  • spec_code – spec_code

Returns:

A generator of flavor objects.

Instance Operations

class otcextensions.sdk.rds.v3._proxy.Proxy(session, *args, **kwargs)
create_instance(**attrs)

Create a new instance from attributes

Parameters:

attrs (dict) – Keyword arguments which will be used to create a Instance, comprised of the properties on the Instance class.

Returns:

The result of an instance creation.

Return type:

Instance

delete_instance(instance, ignore_missing=True)

Delete an instance

Parameters:
  • instance – The value can be either the ID of an instance or a Instance instance.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the instance does not exist. When set to True, no exception will be set when attempting to delete a nonexistent instance.

Returns:

None

get_instance(instance)

Get a single instance

Parameters:

instance – The value can be either the ID of an instance or a Instance instance.

Returns:

One Instance

find_instance(name_or_id, ignore_missing=True)

Find a single instance

Parameters:
  • name_or_id – The name or ID of a instance.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the resource does not exist. When set to True, None will be returned when attempting to find a nonexistent resource.

Returns:

One Instance or None.

instances(**params)

Return a generator of instances

Parameters:

params (dict) – Optional query parameters to be sent to limit the instances being returned.

Returns:

A generator of instance objects.

restore_instance(instance, backup=None, restore_time=None)
Restore instance from backup or Restore using Point in

Time Recovery

Parameters:
  • instance – Either the id of a source target instance or a Instance instance.

  • backup – Either the id of a backup or a Backup instance.

Returns:

Job ID

get_instance_restore_time(instance)

Obtaining a restore time of an instance.

Parameters:

instance – This parameter can be either the ID of an instance or a Instance

Returns:

Instance restore time

Return type:

list

restart_instance(instance)

Restart the database instance

Parameters:

instance – This parameter can be either the ID of an instance or a Instance

enlarge_instance_volume(instance, size)

Enlarge the instance volume

Parameters:
  • instance – This parameter can be either the ID of an instance or a Instance

  • size

change_instance_flavor(instance, spec_code)

Change the instance’s flavor.

Parameters:
  • instance – This parameter can be either the ID of an instance or a Instance

  • spec_code

get_instance_logs(instance, log_type, start_date=None, end_date=None, offset=1, limit=10, level='ALL')
Get instance logs. If no dates are specified logs are gathered

from the last 24 hours.

Parameters:
  • instance – This parameter can be either the ID of an instance or a Instance

  • log_type (str) – The type of logs to query: ‘errorlog’ or ‘slowlog’.

  • start_date (str) – Start date of the of the log query. Format: %Y-%m-%dT%H:%M:%S%z where z is the tzinfo in HHMM format.

  • end_date (str) – End date of the of the log query. Format: %Y-%m-%dT%H:%M:%S%z where z is the tzinfo in HHMM format.

  • offset (int) – Specifies the page offset such as 1, 2, 3 or 4.

  • limit (int) – Specifies the number of records on a page. Its value range is from 1 to 100.

  • level (str) – Specifies the log level. Values: ALL, INFO, LOG, WARNING, ERROR, FATAL, PANIC, NOTE.

add_tag(instance, key, value)

Add tag to instance.

Parameters:
  • instance – This parameter can be either the ID of an instance or a Instance

  • key (str) – Name of the tag to be added.

  • value (str) – Value of the tag to be added.

remove_tag(instance, key)

Remove tag from instance.

Parameters:
  • instance – This parameter can be either the ID of an instance or a Instance

  • key (str) – Name of the tag to be removed.

Backup Operations

class otcextensions.sdk.rds.v3._proxy.Proxy(session, *args, **kwargs)
get_instance_backup_policy(instance)

Obtaining a backup policy of the instance

Parameters:

instance – This parameter can be either the ID of an instance or a Instance

Returns:

Instance Backup policy.

Return type:

BackupPolicy

set_instance_backup_policy(instance, keep_days, start_time=None, period=None)

Sets the backup policy of the instance

Parameters:
  • instance – This parameter can be either the ID of an instance or a Instance

  • keep_days

  • start_time

  • period

Returns:

None

backups(instance, **params)

List Backups.

Parameters:
  • instance – This parameter can be either the ID of an instance or a Instance

  • params (dict) – Optional query parameters to be sent to limit the instance backups being returned.

Returns:

A generator of backup objects.

create_backup(instance, **attrs)

Create a backups of instance

Parameters:

instance – This parameter can be either the ID of an instance or a Instance

Returns:

A new backup object.

Return type:

Backup

delete_backup(backup, ignore_missing=True)

Deletes given backup

Parameters:
  • instance – The value can be either the ID of an instance or a Instance instance.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the instance does not exist. When set to True, no exception will be set when attempting to delete a nonexistent instance.

Returns:

None

find_backup(name_or_id, instance, ignore_missing=True)

Find a single backup

Parameters:
  • name_or_id – The name or ID of a instance.

  • instance – The value can be either the ID of an instance or a Instance instance.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the resource does not exist. When set to True, None will be returned when attempting to find a nonexistent resource.

Returns:

One Backup or None

backup_download_links(backup_id)

Obtaining a backup file download links.

Parameters:

backup_id

Returns:

backup files download link

Return type:

BackupFile

Configuration Operations

class otcextensions.sdk.rds.v3._proxy.Proxy(session, *args, **kwargs)
configurations(**params)

Obtaining a list of DB Configuration.

Parameters:

params (dict) – Optional query parameters to be sent to limit the configurations being returned.

Returns:

A generator of Configuration objects.

get_configuration(cg)

Obtaining a Configuration.

Parameters:

parameter_group – The value can be the ID of a Configuration or a Configuration instance.

Returns:

One Configuration

find_configuration(name_or_id, ignore_missing=True)

Find Configuration by name or id.

Parameters:
  • name_or_id – The name or ID of configuration.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the resource does not exist. When set to True, None will be returned when attempting to find a nonexistent resource.

Returns:

A configuration object.

Return type:

Configuration

create_configuration(**attrs)

Create DB Configuration.

Parameters:

attrs (dict) – Dict to overwrite Configuration object

Returns:

A Configuration object.

Return type:

Configuration

delete_configuration(cg, ignore_missing=True)

Delete DB Configuration.

Parameters:
  • cg – The value can be the ID of a Configuration or a object of Configuration.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the Configration does not exist. When set to True, no exception will be set when attempting to delete a nonexistent Configuration.

Returns:

None

update_configuration(config, **attrs)

Sets the configuration properties

Parameters:
  • config – This parameter can be either the ID of a configuration or a Configuration

  • attrs (dict) – The attributes to update on the configuration.

Returns:

None

apply_configuration(configuration, instances)

Apply configuration to instances.

Parameters:
  • configuration – The value can be the ID of a Configuration or a object of Configuration.

  • instances – List of instance ids the configuration should be applied to

Returns:

Updated Configuration object.

Return type:

Configuration.