droplet_kit 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +70 -0
- data/Rakefile +2 -0
- data/droplet_kit.gemspec +33 -0
- data/lib/droplet_kit.rb +63 -0
- data/lib/droplet_kit/client.rb +58 -0
- data/lib/droplet_kit/mappings/action_mapping.rb +19 -0
- data/lib/droplet_kit/mappings/backup_mapping.rb +19 -0
- data/lib/droplet_kit/mappings/domain_mapping.rb +15 -0
- data/lib/droplet_kit/mappings/domain_record_mapping.rb +18 -0
- data/lib/droplet_kit/mappings/droplet_mapping.rb +38 -0
- data/lib/droplet_kit/mappings/error_mapping.rb +19 -0
- data/lib/droplet_kit/mappings/image_action_mapping.rb +19 -0
- data/lib/droplet_kit/mappings/image_mapping.rb +17 -0
- data/lib/droplet_kit/mappings/kernel_mapping.rb +14 -0
- data/lib/droplet_kit/mappings/network_detail_mapping.rb +15 -0
- data/lib/droplet_kit/mappings/network_mapping.rb +12 -0
- data/lib/droplet_kit/mappings/region_mapping.rb +16 -0
- data/lib/droplet_kit/mappings/size_mapping.rb +15 -0
- data/lib/droplet_kit/mappings/snapshot_mapping.rb +19 -0
- data/lib/droplet_kit/mappings/ssh_key_mapping.rb +17 -0
- data/lib/droplet_kit/models/action.rb +12 -0
- data/lib/droplet_kit/models/backup.rb +12 -0
- data/lib/droplet_kit/models/base_model.rb +13 -0
- data/lib/droplet_kit/models/domain.rb +10 -0
- data/lib/droplet_kit/models/domain_record.rb +11 -0
- data/lib/droplet_kit/models/droplet.rb +15 -0
- data/lib/droplet_kit/models/image.rb +10 -0
- data/lib/droplet_kit/models/image_action.rb +12 -0
- data/lib/droplet_kit/models/kernel.rb +7 -0
- data/lib/droplet_kit/models/meta_information.rb +14 -0
- data/lib/droplet_kit/models/network.rb +4 -0
- data/lib/droplet_kit/models/network_hash.rb +4 -0
- data/lib/droplet_kit/models/pagination_information.rb +17 -0
- data/lib/droplet_kit/models/region.rb +9 -0
- data/lib/droplet_kit/models/size.rb +8 -0
- data/lib/droplet_kit/models/snapshot.rb +12 -0
- data/lib/droplet_kit/models/ssh_key.rb +8 -0
- data/lib/droplet_kit/paginated_resource.rb +71 -0
- data/lib/droplet_kit/resources/action_resource.rb +17 -0
- data/lib/droplet_kit/resources/domain_record_resource.rb +31 -0
- data/lib/droplet_kit/resources/domain_resource.rb +26 -0
- data/lib/droplet_kit/resources/droplet_action_resource.rb +49 -0
- data/lib/droplet_kit/resources/droplet_resource.rb +44 -0
- data/lib/droplet_kit/resources/image_action_resource.rb +14 -0
- data/lib/droplet_kit/resources/image_resource.rb +26 -0
- data/lib/droplet_kit/resources/region_resource.rb +13 -0
- data/lib/droplet_kit/resources/size_resource.rb +13 -0
- data/lib/droplet_kit/resources/ssh_key_resource.rb +26 -0
- data/lib/droplet_kit/version.rb +3 -0
- data/spec/fixtures/actions/all.json +17 -0
- data/spec/fixtures/actions/find.json +12 -0
- data/spec/fixtures/domain_records/all.json +52 -0
- data/spec/fixtures/domain_records/create.json +11 -0
- data/spec/fixtures/domain_records/find.json +11 -0
- data/spec/fixtures/domain_records/update.json +11 -0
- data/spec/fixtures/domains/all.json +12 -0
- data/spec/fixtures/domains/create.json +7 -0
- data/spec/fixtures/domains/find.json +7 -0
- data/spec/fixtures/droplets/all.json +84 -0
- data/spec/fixtures/droplets/create.json +79 -0
- data/spec/fixtures/droplets/find.json +79 -0
- data/spec/fixtures/droplets/list_actions.json +17 -0
- data/spec/fixtures/droplets/list_backups.json +18 -0
- data/spec/fixtures/droplets/list_kernels.json +17 -0
- data/spec/fixtures/droplets/list_snapshots.json +18 -0
- data/spec/fixtures/image_actions/create.json +12 -0
- data/spec/fixtures/image_actions/find.json +12 -0
- data/spec/fixtures/images/all.json +29 -0
- data/spec/fixtures/images/find.json +13 -0
- data/spec/fixtures/regions/all.json +47 -0
- data/spec/fixtures/sizes/all.json +35 -0
- data/spec/fixtures/ssh_keys/all.json +13 -0
- data/spec/fixtures/ssh_keys/create.json +8 -0
- data/spec/fixtures/ssh_keys/find.json +8 -0
- data/spec/fixtures/ssh_keys/update.json +8 -0
- data/spec/lib/droplet_kit/client_spec.rb +22 -0
- data/spec/lib/droplet_kit/paginated_resource_spec.rb +69 -0
- data/spec/lib/droplet_kit/resources/action_resource_spec.rb +26 -0
- data/spec/lib/droplet_kit/resources/domain_record_resource_spec.rb +83 -0
- data/spec/lib/droplet_kit/resources/domain_resource_spec.rb +53 -0
- data/spec/lib/droplet_kit/resources/droplet_action_resource_spec.rb +150 -0
- data/spec/lib/droplet_kit/resources/droplet_resource_spec.rb +194 -0
- data/spec/lib/droplet_kit/resources/image_action_resource_spec.rb +45 -0
- data/spec/lib/droplet_kit/resources/image_resource_spec.rb +56 -0
- data/spec/lib/droplet_kit/resources/region_resource_spec.rb +16 -0
- data/spec/lib/droplet_kit/resources/size_resource_spec.rb +16 -0
- data/spec/lib/droplet_kit/resources/ssh_key_resource_spec.rb +80 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/fake_server.rb +4 -0
- data/spec/support/null_hash_load.rb +9 -0
- data/spec/support/request_stub_helpers.rb +9 -0
- data/spec/support/resource_context.rb +4 -0
- metadata +309 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e43efb48656febf1baf2550b520d7c0c2a7b39d2
|
4
|
+
data.tar.gz: 1e5a17558dd524315f33b1ce62f525d5d6bd7564
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ea1044a5bfdb6c3a778a23f5c16410a13b51772ea0071de14e786a3661d684d8115934f71ccfbdd1b59f479e01e10cf0acf94f0eead04b5d0397d7b11508267
|
7
|
+
data.tar.gz: 460b7344ce21709ea9e6af3353d529b7620e61c0f1dda18ca04d10a2bcb3de69fb2804b0baf122d1700bc0e64337fec7e3abc0e3d4cb972c6bf75a0627848529
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Robert Ross
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# DropletKit
|
2
|
+
|
3
|
+
DropletKit is the official [DigitalOcean V2 API](https://developers.digitalocean.com/v2/) client. It supports everything the API can do with a simple interface written in Ruby.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'droplet_kit'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install droplet_kit
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You'll need to generate an access token in Digital Oceans control panel at https://cloud.digitalocean.com/settings/applications
|
22
|
+
|
23
|
+
With your access token, retrieve a client instance with it.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
client = DropletKit::Client.new(access_token: 'YOUR_TOKEN')
|
27
|
+
```
|
28
|
+
|
29
|
+
## Design
|
30
|
+
|
31
|
+
DropletKit follows a strict design of resoures as methods on your client. For examples, for droplets, you will call your client like this:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
client = DropletKit::Client.new(access_token: 'YOUR_TOKEN')
|
35
|
+
client.droplets #=> DropletsResource
|
36
|
+
```
|
37
|
+
|
38
|
+
DropletKit will return Plain Old Ruby objects(tm) that contain the information provided by the API. For example:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
client = DropletKit::Client.new(access_token: 'YOUR_TOKEN')
|
42
|
+
client.droplets.all
|
43
|
+
# => [ DropletKit::Dropet(id: 123, name: 'something.com', ...), DropletKit::Dropet(id: 1066, name: 'bunk.com', ...) ]
|
44
|
+
```
|
45
|
+
|
46
|
+
When you'd like to save objects, it's your responsibility to instantiate the objects and persist them using the resource objects. Lets use creating a Droplet as an example:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
client = DropletKit::Client.new(access_token: 'YOUR_TOKEN')
|
50
|
+
droplet = DropletKit::Droplet.new(name: 'mysite.com', region: 'nyc2', image: 'ubuntu-14-04-x64', size: '512mb')
|
51
|
+
created = client.droplets.create(droplet)
|
52
|
+
# => DropletKit::Droplet(id: 1231, name: 'something.com', ...)
|
53
|
+
```
|
54
|
+
|
55
|
+
To retrieve objects, you can perform this type of action on the resource (if the API supports it):
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
client = DropletKit::Client.new(access_token: 'YOUR_TOKEN')
|
59
|
+
droplet = client.droplets.find(id: 123)
|
60
|
+
# => DropletKit::Droplet(id: 1231, name: 'something.com', ...)
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
1. Fork it ( https://github.com/digitaloceancloud/droplet_kit/fork )
|
67
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
68
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
70
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/droplet_kit.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'droplet_kit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "droplet_kit"
|
8
|
+
spec.version = DropletKit::VERSION
|
9
|
+
spec.authors = ["Robert Ross"]
|
10
|
+
spec.email = ["rross@digitalocean.com"]
|
11
|
+
spec.summary = %q{Droplet Kit is the official Ruby library for Digital Ocean's API}
|
12
|
+
spec.description = %q{Droplet Kit is the official Ruby library for Digital Ocean's API}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'virtus', '~> 1.0.3'
|
22
|
+
spec.add_dependency "resource_kit", '~> 0.0.5'
|
23
|
+
spec.add_dependency "kartograph", '~> 0.0.5'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0.0"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
|
30
|
+
# FakeServe
|
31
|
+
spec.add_development_dependency 'sinatra', '~> 1.4'
|
32
|
+
spec.add_development_dependency 'webmock', '~> 1.18'
|
33
|
+
end
|
data/lib/droplet_kit.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require "droplet_kit/version"
|
2
|
+
require 'resource_kit'
|
3
|
+
require 'kartograph'
|
4
|
+
|
5
|
+
module DropletKit
|
6
|
+
autoload :Client, 'droplet_kit/client'
|
7
|
+
|
8
|
+
# Models
|
9
|
+
autoload :BaseModel, 'droplet_kit/models/base_model'
|
10
|
+
autoload :Droplet, 'droplet_kit/models/droplet'
|
11
|
+
autoload :Region, 'droplet_kit/models/region'
|
12
|
+
autoload :Image, 'droplet_kit/models/image'
|
13
|
+
autoload :ImageAction, 'droplet_kit/models/image_action'
|
14
|
+
autoload :Size, 'droplet_kit/models/size'
|
15
|
+
autoload :NetworkHash, 'droplet_kit/models/network_hash'
|
16
|
+
autoload :Network, 'droplet_kit/models/network'
|
17
|
+
autoload :Kernel, 'droplet_kit/models/kernel'
|
18
|
+
autoload :Snapshot, 'droplet_kit/models/snapshot'
|
19
|
+
autoload :Backup, 'droplet_kit/models/backup'
|
20
|
+
autoload :Action, 'droplet_kit/models/action'
|
21
|
+
autoload :Domain, 'droplet_kit/models/domain'
|
22
|
+
autoload :DomainRecord, 'droplet_kit/models/domain_record'
|
23
|
+
autoload :SSHKey, 'droplet_kit/models/ssh_key'
|
24
|
+
autoload :MetaInformation, 'droplet_kit/models/meta_information'
|
25
|
+
|
26
|
+
# Resources
|
27
|
+
autoload :DropletResource, 'droplet_kit/resources/droplet_resource'
|
28
|
+
autoload :ActionResource, 'droplet_kit/resources/action_resource'
|
29
|
+
autoload :DomainResource, 'droplet_kit/resources/domain_resource'
|
30
|
+
autoload :DomainRecordResource, 'droplet_kit/resources/domain_record_resource'
|
31
|
+
autoload :DropletActionResource, 'droplet_kit/resources/droplet_action_resource'
|
32
|
+
autoload :ImageResource, 'droplet_kit/resources/image_resource'
|
33
|
+
autoload :ImageActionResource, 'droplet_kit/resources/image_action_resource'
|
34
|
+
autoload :SSHKeyResource, 'droplet_kit/resources/ssh_key_resource'
|
35
|
+
autoload :RegionResource, 'droplet_kit/resources/region_resource'
|
36
|
+
autoload :SizeResource, 'droplet_kit/resources/size_resource'
|
37
|
+
|
38
|
+
# JSON Maps
|
39
|
+
autoload :DropletMapping, 'droplet_kit/mappings/droplet_mapping'
|
40
|
+
autoload :ImageMapping, 'droplet_kit/mappings/image_mapping'
|
41
|
+
autoload :RegionMapping, 'droplet_kit/mappings/region_mapping'
|
42
|
+
autoload :SizeMapping, 'droplet_kit/mappings/size_mapping'
|
43
|
+
autoload :NetworkMapping, 'droplet_kit/mappings/network_mapping'
|
44
|
+
autoload :NetworkDetailMapping, 'droplet_kit/mappings/network_detail_mapping'
|
45
|
+
autoload :KernelMapping, 'droplet_kit/mappings/kernel_mapping'
|
46
|
+
autoload :SnapshotMapping, 'droplet_kit/mappings/snapshot_mapping'
|
47
|
+
autoload :BackupMapping, 'droplet_kit/mappings/backup_mapping'
|
48
|
+
autoload :ActionMapping, 'droplet_kit/mappings/action_mapping'
|
49
|
+
autoload :DomainMapping, 'droplet_kit/mappings/domain_mapping'
|
50
|
+
autoload :DomainRecordMapping, 'droplet_kit/mappings/domain_record_mapping'
|
51
|
+
autoload :DropletActionMapping, 'droplet_kit/mappings/droplet_action_mapping'
|
52
|
+
autoload :ImageActionMapping, 'droplet_kit/mappings/image_action_mapping'
|
53
|
+
autoload :SSHKeyMapping, 'droplet_kit/mappings/ssh_key_mapping'
|
54
|
+
|
55
|
+
|
56
|
+
# Utils
|
57
|
+
autoload :PaginatedResource, 'droplet_kit/paginated_resource'
|
58
|
+
|
59
|
+
# Errors
|
60
|
+
autoload :ErrorMapping, 'droplet_kit/mappings/error_mapping'
|
61
|
+
FailedCreate = Class.new(StandardError)
|
62
|
+
FailedUpdate = Class.new(StandardError)
|
63
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module DropletKit
|
4
|
+
class Client
|
5
|
+
DIGITALOCEAN_API = 'https://api.digitalocean.com'
|
6
|
+
|
7
|
+
attr_reader :access_token
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@access_token = options[:access_token]
|
11
|
+
end
|
12
|
+
|
13
|
+
def connection
|
14
|
+
Faraday.new(connection_options) do |req|
|
15
|
+
req.adapter :net_http
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.resources
|
20
|
+
{
|
21
|
+
droplets: DropletResource,
|
22
|
+
domains: DomainResource,
|
23
|
+
domain_records: DomainRecordResource,
|
24
|
+
droplet_actions: DropletActionResource,
|
25
|
+
images: ImageResource,
|
26
|
+
image_actions: ImageActionResource,
|
27
|
+
regions: RegionResource,
|
28
|
+
sizes: SizeResource,
|
29
|
+
ssh_keys: SSHKeyResource,
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_missing(name, *args, &block)
|
34
|
+
if self.class.resources.keys.include?(name)
|
35
|
+
resources[name] ||= self.class.resources[name].new(connection)
|
36
|
+
resources[name]
|
37
|
+
else
|
38
|
+
super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def resources
|
43
|
+
@resources ||= {}
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def connection_options
|
49
|
+
{
|
50
|
+
url: DIGITALOCEAN_API,
|
51
|
+
headers: {
|
52
|
+
content_type: 'application/json',
|
53
|
+
authorization: "Bearer #{access_token}"
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class ActionMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping Action
|
7
|
+
root_key plural: 'actions', singular: 'action', scopes: [:read]
|
8
|
+
|
9
|
+
property :id, scopes: [:read]
|
10
|
+
property :status, scopes: [:read]
|
11
|
+
property :type, scopes: [:read]
|
12
|
+
property :started_at, scopes: [:read]
|
13
|
+
property :completed_at, scopes: [:read]
|
14
|
+
property :resource_id, scopes: [:read]
|
15
|
+
property :resource_type, scopes: [:read]
|
16
|
+
property :region, scopes: [:read]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class BackupMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
root_key plural: 'backups', singular: 'backup', scopes: [:read]
|
7
|
+
mapping Backup
|
8
|
+
|
9
|
+
property :id, scopes: [:read]
|
10
|
+
property :name, scopes: [:read]
|
11
|
+
property :distribution, scopes: [:read]
|
12
|
+
property :slug, scopes: [:read]
|
13
|
+
property :public, scopes: [:read]
|
14
|
+
property :regions, scopes: [:read]
|
15
|
+
property :action_ids, scopes: [:read]
|
16
|
+
property :created_at, scopes: [:read]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DomainMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping Domain
|
7
|
+
root_key plural: 'domains', singular: 'domain', scopes: [:read]
|
8
|
+
|
9
|
+
property :name, scopes: [:read, :create]
|
10
|
+
property :ttl, scopes: [:read]
|
11
|
+
property :zone_file, scopes: [:read]
|
12
|
+
property :ip_address, scopes: [:create]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DomainRecordMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping DomainRecord
|
7
|
+
root_key plural: 'domain_records', singular: 'domain_record', scopes: [:read]
|
8
|
+
|
9
|
+
property :id, scopes: [:read]
|
10
|
+
property :type, scopes: [:read, :create]
|
11
|
+
property :name, scopes: [:read, :create, :update]
|
12
|
+
property :data, scopes: [:read, :create]
|
13
|
+
property :priority, scopes: [:read, :create]
|
14
|
+
property :port, scopes: [:read, :create]
|
15
|
+
property :weight, scopes: [:read, :create]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class DropletMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping Droplet
|
7
|
+
root_key plural: 'droplets', singular: 'droplet', scopes: [:read]
|
8
|
+
|
9
|
+
property :id, scopes: [:read]
|
10
|
+
property :name, scopes: [:read]
|
11
|
+
property :memory, scopes: [:read]
|
12
|
+
property :vcpus, scopes: [:read]
|
13
|
+
property :disk, scopes: [:read]
|
14
|
+
property :locked, scopes: [:read]
|
15
|
+
property :created_at, scopes: [:read]
|
16
|
+
property :status, scopes: [:read]
|
17
|
+
property :backup_ids, scopes: [:read]
|
18
|
+
property :snapshot_ids, scopes: [:read]
|
19
|
+
property :action_ids, scopes: [:read]
|
20
|
+
property :features, scopes: [:read]
|
21
|
+
|
22
|
+
property :region, scopes: [:read], include: RegionMapping
|
23
|
+
property :image, scopes: [:read], include: ImageMapping
|
24
|
+
property :size, scopes: [:read], include: SizeMapping
|
25
|
+
property :networks, scopes: [:read], include: NetworkMapping
|
26
|
+
property :kernel, scopes: [:read], include: KernelMapping
|
27
|
+
|
28
|
+
# Create properties arent quite the same
|
29
|
+
property :name, scopes: [:create]
|
30
|
+
property :region, scopes: [:create]
|
31
|
+
property :size, scopes: [:create]
|
32
|
+
property :image, scopes: [:create]
|
33
|
+
property :ssh_keys, scopes: [:create]
|
34
|
+
property :backups, scopes: [:create]
|
35
|
+
property :ipv6, scopes: [:create]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class ErrorMapping
|
3
|
+
Error = Struct.new(:message, :id)
|
4
|
+
|
5
|
+
include Kartograph::DSL
|
6
|
+
|
7
|
+
kartograph do
|
8
|
+
mapping Error
|
9
|
+
|
10
|
+
property :id, scopes: [:read]
|
11
|
+
property :message, scopes: [:read]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.fail_with(klass, content)
|
15
|
+
error = extract_single(content, :read)
|
16
|
+
raise klass, error.message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DropletKit
|
2
|
+
class ImageActionMapping
|
3
|
+
include Kartograph::DSL
|
4
|
+
|
5
|
+
kartograph do
|
6
|
+
mapping ImageAction
|
7
|
+
root_key singular: 'action', plural: 'actions', scopes: [:read]
|
8
|
+
|
9
|
+
property :id, scopes: [:read]
|
10
|
+
property :status, scopes: [:read]
|
11
|
+
property :type, scopes: [:read]
|
12
|
+
property :started_at, scopes: [:read]
|
13
|
+
property :completed_at, scopes: [:read]
|
14
|
+
property :resource_id, scopes: [:read]
|
15
|
+
property :resource_type, scopes: [:read]
|
16
|
+
property :region, scopes: [:read]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|