bitballoon 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitballoon (0.0.11)
4
+ bitballoon (0.1.0)
5
5
  highline
6
6
  oauth2 (>= 0.9.2)
7
7
  slop
data/README.md CHANGED
@@ -80,6 +80,13 @@ Or a zip file:
80
80
  bitballoon deploy /path/to/my/site.zip
81
81
  ```
82
82
 
83
+ If there is no .bitballoon file yet, you can deploy to an existing site by passing in the ID:
84
+
85
+ ```ruby
86
+ bitballoon deploy /path/to/my/site.zip --site-id YOUR_SITE_ID
87
+ ```
88
+
89
+
83
90
  Sites
84
91
  =====
85
92
 
@@ -344,3 +351,64 @@ Remove a snippet
344
351
  site.snippet.get(id).destroy
345
352
  end
346
353
  ```
354
+
355
+ DNS Zones
356
+ =========
357
+
358
+ Resellers can manage DNS Zones through the ruby client. To use this feature your access token must belong to a reseller administrator.
359
+
360
+ Create a DNS Zone
361
+
362
+ ```ruby
363
+ bitballoon.dns_zones.create(:name => "www.example.com", :user_id => "1234")
364
+ ```
365
+
366
+ Get all DNS Zones
367
+
368
+ ```ruby
369
+ bitballoon.dns_zones.all
370
+ ```
371
+
372
+ Delete a DNS Zone
373
+
374
+ ```ruby
375
+ dns_zone.destroy
376
+ ```
377
+
378
+ Get all dns records for a zone
379
+
380
+ ```ruby
381
+ dns_zone.dns_records.all
382
+ ```
383
+
384
+ Adding a new record (supported types: A, CNAME, TXT, MX)
385
+
386
+ ```ruby
387
+ dns_zone.dns_records.create(:hostname => "www", :type => "CNAME", :value => "bitballoon.com", :ttl => "500")
388
+ ```
389
+
390
+ Deleting a record
391
+
392
+ ```ruby
393
+ dns_record.destroy
394
+ ```
395
+
396
+ Access Tokens
397
+ =============
398
+
399
+ Resellers can create and revoke access tokens on behalf of their users. To use this feature your access token must belong to a reseller administrator.
400
+
401
+ Create access token:
402
+
403
+ ```ruby
404
+ bitballoon.access_tokens.create(:user => {:email => "test@example.com", :uid => 123})
405
+ ```
406
+
407
+ The user must have either an email or a uid or both. Both email and uid must be unique within your reseller account. The uid would typically correspond to your internal database id for the user. If the users doesn't exist, a new user will be created on the fly.
408
+
409
+ Revoke access token:
410
+
411
+ ```ruby
412
+ bitballoon.access_tokens.get("token-string").destroy
413
+ ```
414
+
data/lib/bitballoon.rb CHANGED
@@ -10,6 +10,8 @@ require "bitballoon/files"
10
10
  require "bitballoon/snippets"
11
11
  require "bitballoon/users"
12
12
  require "bitballoon/deploys"
13
+ require "bitballoon/dns_zones"
14
+ require "bitballoon/access_tokens"
13
15
  require "bitballoon/multipass"
14
16
 
15
17
  module BitBalloon; end
@@ -0,0 +1,5 @@
1
+ module BitBalloon
2
+ class AccessToken < Model
3
+ fields :id, :access_token, :user_id, :created_at
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "bitballoon/access_token"
2
+
3
+ module BitBalloon
4
+ class AccessTokens < CollectionProxy
5
+ path "/access_tokens"
6
+ end
7
+ end
@@ -55,6 +55,14 @@ module BitBalloon
55
55
  Users.new(self)
56
56
  end
57
57
 
58
+ def dns_zones
59
+ DnsZones.new(self)
60
+ end
61
+
62
+ def access_tokens
63
+ AccessTokens.new(self)
64
+ end
65
+
58
66
  def request(verb, path, opts={}, &block)
59
67
  retries = 0
60
68
  begin
@@ -19,8 +19,8 @@ module BitBalloon
19
19
  end
20
20
 
21
21
  def all(options = {})
22
- response = client.request(:get, [prefix, path].compact.join("/"), {:params => options})
23
- response.parsed.map {|attributes| model.new(client, attributes) } if response.parsed
22
+ response = client.request(:get, path, {:params => options})
23
+ response.parsed.map {|attributes| model.new(client, attributes.merge(:prefix => prefix)) } if response.parsed
24
24
  end
25
25
 
26
26
  def each(&block)
@@ -29,12 +29,12 @@ module BitBalloon
29
29
 
30
30
  def get(id)
31
31
  response = client.request(:get, ::File.join(path, id))
32
- model.new(client, response.parsed) if response.parsed
32
+ model.new(client, response.parsed.merge(:prefix => prefix)) if response.parsed
33
33
  end
34
34
 
35
35
  def create(attributes)
36
- response = client.request(:post, path, attributes)
37
- model.new(client, response.parsed) if response.parsed
36
+ response = client.request(:post, path, :body => attributes)
37
+ model.new(client, response.parsed.merge(:prefix => prefix)) if response.parsed
38
38
  end
39
39
 
40
40
  def model
@@ -42,7 +42,7 @@ module BitBalloon
42
42
  end
43
43
 
44
44
  def path
45
- self.class.path
45
+ [prefix, self.class.path].compact.join("/")
46
46
  end
47
47
  end
48
48
  end
@@ -0,0 +1,5 @@
1
+ module BitBalloon
2
+ class DnsRecord < Model
3
+ fields :id, :hostname, :type, :value, :ttl, :domain_id
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "bitballoon/dns_record"
2
+
3
+ module BitBalloon
4
+ class DnsRecords < CollectionProxy
5
+ path "/dns_records"
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module BitBalloon
2
+ class DnsZone < Model
3
+ fields :id, :name, :user_id, :created_at, :updated_at
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require "bitballoon/dns_zone"
2
+
3
+ module BitBalloon
4
+ class DnsZones < CollectionProxy
5
+ path "/dns_zones"
6
+
7
+ def dns_records
8
+ DnsRecords.new(client, path)
9
+ end
10
+ end
11
+ end
@@ -1,6 +1,6 @@
1
1
  module BitBalloon
2
2
  class Model
3
- attr_reader :client, :attributes
3
+ attr_reader :client, :attributes, :prefix
4
4
 
5
5
  def self.fields(*names)
6
6
  return @fields if names.empty?
@@ -27,6 +27,7 @@ module BitBalloon
27
27
  def initialize(client, attributes)
28
28
  @client = client
29
29
  @attributes = {}
30
+ @prefix = attributes.delete(:prefix)
30
31
  process(attributes)
31
32
  end
32
33
 
@@ -40,7 +41,7 @@ module BitBalloon
40
41
  end
41
42
 
42
43
  def update(attributes)
43
- response = client.request(:put, path, attributes)
44
+ response = client.request(:put, path, :body => attributes)
44
45
  process(response.parsed) if response.parsed
45
46
  end
46
47
 
@@ -58,7 +59,7 @@ module BitBalloon
58
59
  end
59
60
 
60
61
  def path
61
- ::File.join(collection.path, id)
62
+ ::File.join(*[prefix, collection.path, id.to_s].compact)
62
63
  end
63
64
  end
64
65
  end
@@ -1,3 +1,3 @@
1
1
  module BitBalloon
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitballoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-07 00:00:00.000000000 Z
12
+ date: 2013-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2
@@ -107,10 +107,16 @@ files:
107
107
  - bin/bitballoon
108
108
  - bitballoon.gemspec
109
109
  - lib/bitballoon.rb
110
+ - lib/bitballoon/access_token.rb
111
+ - lib/bitballoon/access_tokens.rb
110
112
  - lib/bitballoon/client.rb
111
113
  - lib/bitballoon/collection_proxy.rb
112
114
  - lib/bitballoon/deploy.rb
113
115
  - lib/bitballoon/deploys.rb
116
+ - lib/bitballoon/dns_record.rb
117
+ - lib/bitballoon/dns_records.rb
118
+ - lib/bitballoon/dns_zone.rb
119
+ - lib/bitballoon/dns_zones.rb
114
120
  - lib/bitballoon/file.rb
115
121
  - lib/bitballoon/files.rb
116
122
  - lib/bitballoon/form.rb