GrapheneDB
Simple Ruby Wrapper for the GrapheneDB API
Requirements
- Ruby >= 2.0.0
- GrapheneDB account
- GrapheneDB API Key
Install
Use 'gem install' command or add graphenedb to Gemfile
gem install graphenedbConfigure
If you don't have a GrapheneDB account, sign up here, then get your api key here.
Graphenedb.configure do |config|
config.api_key = 'your-api-key'
# configuration defaults, uncomment to change
# config.version = 'v314'
# config.region = 'us-east-1'
# config.plan = 'sandbox'
endUsage
To list available database versions:
Graphenedb.versionsTo get the status of an async operation:
Graphenedb.operation('operation-id')To list all databases:
Graphenedb.databasesTo get a single database:
Graphenedb.database('database-id')To empty a database:
Graphenedb.empty_database('database-id')To restart a database:
Graphenedb.restart_database('database-id')To create a database:
Graphenedb.create_database('database-name')
# you can also use a hash to specify config:
Graphenedb.create_database(name: 'name', region: 'us-west-2')
# config defaults: {version: 'v314', region: 'us-east-1', plan: 'sandbox'}
- version: must be a valid version identifier from Graphenedb.versions
- region: aws region [us-east-1, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-west-2, eu-central-1, ap-northeast-1, ap-southeast-1, ap-southeast-2]
- plan: [sandbox, developer0, s1, s2, p1, p2, p3, p4]
To clone a database:
Graphenedb.clone_database('database-id', 'new-database-name')
# you can also use a hash to specify config:
Graphenedb.clone_database(id: 'id', name: 'name', region: 'us-west-2')
# config defaults: {version: 'v314', region: 'us-east-1', plan: 'sandbox'}
- version: must be a valid version identifier from Graphenedb.versions
- region: aws region [us-east-1, us-west-1, us-west-2, ca-central-1, eu-west-1, eu-west-2, eu-central-1, ap-northeast-1, ap-southeast-1, ap-southeast-2]
- plan: [sandbox, developer0, s1, s2, p1, p2, p3, p4]
To delete a database:
Graphenedb.delete_database('id')To get all database users:
Graphenedb.users('database-id')To get a single database user:
Graphenedb.user('database-id', 'user-id')To create a database user:
# pass in a name for the new database
Graphenedb.create_user('database-id', 'description')
# note: based on graphenedb's api, "description" is set as the "username" as well, so it might be a bit confusing, but set this value to what you want the username to be.
# you can also use a hash to specify config:
Graphenedb.create_user(id: 'database-id', description: 'description', expire_at: "yyyy-MM-dd'T'HH:mm:ss'Z'")
# config defaults: {expire_at: 'never'}To delete a database user:
Graphenedb.delete_user('database-id', 'user-id')Note: For backups support, the DB plan must be S1 or better.
To list all database backups:
Graphenedb.backups('database-id')To get a single database backup:
Graphenedb.backup('database-id', 'backup-id')To get database backup URL:
Graphenedb.backup('database-id', 'backup-id')To get database backup URL:
Graphenedb.backup('database-id', 'backup-id')To list all database backup schedules:
Graphenedb.all_backup_schedules('database-id')To list database backup schedules within timeframe:
Graphenedb.backup_schedules(id: 'database-id', time: '04:20:00', timezone: 'UTC', frequency: 'daily')The body params must follow the correct format:
- time: String-formatted time in HH:MM:SS, eg. 04:20:00
- timezone: only [UTC].
- frequency: only [daily] backups.
To create manual backup (snapshot) of database:
Graphenedb.snapshot('database-id')Restore backup to database:
Graphenedb.restore_backup('database-id', 'backup-id')Import backup to database:
Graphenedb.import('database-id', 'url-of-backup')
Graphenedb.import(id: 'database-id', url: 'url-of-backup')
- url: Link to S3 graphdb.zip
TODO
- Automated tests (important)
Questions or Problems?
Create a new issue on Github and/or submit a pull request :)