cloudability 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +5 -9
- data/cloudability.gemspec +1 -0
- data/lib/cloudability.rb +18 -15
- data/lib/cloudability/client/users.rb +57 -0
- data/lib/cloudability/version.rb +1 -1
- data/spec/{cloduability → cloudability}/billing_spec.rb +6 -9
- data/spec/{cloduability → cloudability}/budgets_spec.rb +5 -8
- data/spec/{cloduability → cloudability}/cost_spec.rb +14 -17
- data/spec/{cloduability → cloudability}/credentials_spec.rb +3 -6
- data/spec/{cloduability → cloudability}/organizations_spec.rb +15 -18
- data/spec/{cloduability → cloudability}/usage_spec.rb +8 -11
- data/spec/cloudability/users_spec.rb +38 -0
- data/spec/fixtures/budgets +1 -1
- data/spec/fixtures/users/add_user +17 -0
- data/spec/fixtures/users/delete_user +17 -0
- data/spec/fixtures/users/update_user +17 -0
- data/spec/fixtures/users/users +17 -0
- data/spec/spec_helper.rb +2 -1
- metadata +57 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddc770d8cb1f5cdd7e1546ddddc42fae2048ac06
|
4
|
+
data.tar.gz: f6226c701edf4e9705c8ccf7970c7b350993c1fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33f8e41eb9ff120c543a5727037a74ec04c24afc0680b414038b6622b9fc3067bf28ca856eda6053c89e38cb8d168ca9c5f2671e79324b0e090591226a5419a5
|
7
|
+
data.tar.gz: 464394c8237dc1f7f6d5aa0903e8d641ea8a9b0bf8daf58bff8f5e76058a5dab997712853d76a35ea8c2ed2a55411776114b9c496013394c98fbd2225495c3f3
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -4,8 +4,9 @@ Cloudability
|
|
4
4
|
[![Build Status](https://travis-ci.org/ColbyAley/cloudability.png?branch=master)](https://travis-ci.org/ColbyAley/cloudability)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/ColbyAley/cloudability.png)](https://codeclimate.com/github/ColbyAley/cloudability)
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/ColbyAley/cloudability/badge.png)](https://coveralls.io/r/ColbyAley/cloudability)
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/cloudability.png)](http://badge.fury.io/rb/cloudability)
|
7
8
|
|
8
|
-
Ruby wrapper for the [Cloudability API](http://developers.cloudability.com/). Supports most
|
9
|
+
Ruby wrapper for the [Cloudability API](http://developers.cloudability.com/). Supports most public API endpoints, including some legacy ones such as budgets. Converts JSON responses to objects with Hashie::Mash.
|
9
10
|
|
10
11
|
This is the README for version 0.1.0 of the gem. v0.1.0 introduces a radically different interface. If you're still on v0.0.5, please refer to it's [README](https://github.com/ColbyAley/cloudability/tree/v0.0.5).
|
11
12
|
|
@@ -34,10 +35,10 @@ Or install it yourself as:
|
|
34
35
|
* Cost Reporrts
|
35
36
|
* Usage Reports
|
36
37
|
|
37
|
-
You will need to generate an API token to use the API. Read more [here](https://support.cloudability.com/hc/en-us/articles/
|
38
|
+
You will need to generate an API token to use the API. Read more [here](https://support.cloudability.com/hc/en-us/articles/204308448-API-setup-and-documentation).
|
39
|
+
|
40
|
+
Feel free to shoot me an email at colby@aley.me if you have any questions or need help.
|
38
41
|
|
39
|
-
Feel free to shoot me an email at colby@cloudability.com if you have any questions or need help.
|
40
|
-
|
41
42
|
### Examples
|
42
43
|
|
43
44
|
@client = Cloudability::Client.new(auth_token: 'auth_token')
|
@@ -79,11 +80,6 @@ Feel free to shoot me an email at colby@cloudability.com if you have any questio
|
|
79
80
|
@client.usage_measures # List measures supported by server
|
80
81
|
@client.usage_filters # List filters supported by the server
|
81
82
|
|
82
|
-
## TODO:
|
83
|
-
* Better tests!
|
84
|
-
* More endpoints!
|
85
|
-
* More awesomeness!
|
86
|
-
|
87
83
|
## Contributing
|
88
84
|
|
89
85
|
1. Fork it
|
data/cloudability.gemspec
CHANGED
data/lib/cloudability.rb
CHANGED
@@ -7,6 +7,7 @@ require 'cloudability/client/usage_reports'
|
|
7
7
|
require 'cloudability/client/budgets'
|
8
8
|
require 'cloudability/client/credentials'
|
9
9
|
require 'cloudability/client/organizations'
|
10
|
+
require 'cloudability/client/users'
|
10
11
|
|
11
12
|
require 'cloudability/version'
|
12
13
|
|
@@ -16,17 +17,19 @@ module Cloudability
|
|
16
17
|
class RequestError < StandardError; end
|
17
18
|
|
18
19
|
class Client
|
19
|
-
include
|
20
|
-
include
|
21
|
-
include
|
22
|
-
include
|
23
|
-
include
|
24
|
-
include
|
20
|
+
include BillingReports
|
21
|
+
include UsageReports
|
22
|
+
include CostReports
|
23
|
+
include Budgets
|
24
|
+
include Credentials
|
25
|
+
include Organizations
|
26
|
+
include Users
|
27
|
+
|
25
28
|
include HTTParty
|
26
29
|
|
27
|
-
def initialize(
|
28
|
-
raise ArgumentError, "You must provide an auth token" if
|
29
|
-
@auth_token =
|
30
|
+
def initialize(opts={})
|
31
|
+
raise ArgumentError, "You must provide an auth token" if opts[:auth_token].nil?
|
32
|
+
@auth_token = opts[:auth_token]
|
30
33
|
end
|
31
34
|
|
32
35
|
base_uri 'https://app.cloudability.com/api'
|
@@ -61,12 +64,12 @@ module Cloudability
|
|
61
64
|
array.map { |element| Hashie::Mash.new(element) }
|
62
65
|
end
|
63
66
|
|
64
|
-
def options(
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
def options(opts={})
|
68
|
+
opts[:query] ||= {}
|
69
|
+
opts[:headers] ||= {}
|
70
|
+
opts[:headers]['User-Agent'] = "Cloudability-Ruby #{Cloudability::VERSION}"
|
71
|
+
opts[:query][:auth_token] = @auth_token
|
72
|
+
opts
|
70
73
|
end
|
71
74
|
|
72
75
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Cloudability
|
2
|
+
class Client
|
3
|
+
module Users
|
4
|
+
# Documentation: http://developers.cloudability.com/resources/users/
|
5
|
+
|
6
|
+
# List users in your organization.
|
7
|
+
#
|
8
|
+
# @return [Array] array of Hashie::Mashes
|
9
|
+
def users
|
10
|
+
request = get '/1/users'
|
11
|
+
convert_to_mashes(request)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Add a user to your organization
|
15
|
+
#
|
16
|
+
# @param [String] email of user
|
17
|
+
# @param [Hash] options
|
18
|
+
# @option [String] full_name
|
19
|
+
# @option [String] role
|
20
|
+
# @option [Boolean] restricted
|
21
|
+
# @option [Array] new_shared_dimension_filter_set_ids
|
22
|
+
# @option [Integer] default_dimension_filter_set_id
|
23
|
+
# @return [Array] array of Hashie::Mashes
|
24
|
+
def add_user(email, options={})
|
25
|
+
options[:email] = email
|
26
|
+
|
27
|
+
payload = {user: options}
|
28
|
+
request = post '/1/users', payload
|
29
|
+
Hashie::Mash.new request
|
30
|
+
end
|
31
|
+
|
32
|
+
# Update a user in your organization
|
33
|
+
#
|
34
|
+
# @param [Integer] ID of user
|
35
|
+
# @param [Hash] options
|
36
|
+
# @option [String] full_name
|
37
|
+
# @option [String] role
|
38
|
+
# @option [Boolean] restricted
|
39
|
+
# @option [Array] new_shared_dimension_filter_set_ids
|
40
|
+
# @option [Integer] default_dimension_filter_set_id
|
41
|
+
# @return [Array] array of Hashie::Mashes
|
42
|
+
def update_user(id, options={})
|
43
|
+
payload = {user: options}
|
44
|
+
request = put "/1/users/#{id}", payload
|
45
|
+
Hashie::Mash.new request
|
46
|
+
end
|
47
|
+
|
48
|
+
# Delete a user in your organization
|
49
|
+
#
|
50
|
+
# @param [Integer] ID of user
|
51
|
+
# @return [Boolean] success
|
52
|
+
def delete_user(id)
|
53
|
+
delete "/1/users/#{id}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/cloudability/version.rb
CHANGED
@@ -1,35 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cloudability::Client::BillingReports do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@client = Cloudability::Client.new(auth_token: 'token')
|
7
|
-
end
|
4
|
+
let(:client) { Cloudability::Client.new(auth_token: 'token') }
|
8
5
|
|
9
6
|
describe '#billing_reports' do
|
10
7
|
it 'should be an array' do
|
11
8
|
stub_get('/1/billing_reports?auth_token=token', 'billing_reports')
|
12
|
-
|
9
|
+
client.billing_report.should be_kind_of Array
|
13
10
|
end
|
14
11
|
|
15
12
|
it 'should be an array of Hashie::Mashes' do
|
16
13
|
stub_get('/1/billing_reports?auth_token=token', 'billing_reports')
|
17
|
-
|
14
|
+
client.billing_report.each{|report| report.should be_kind_of Hashie::Mash }
|
18
15
|
end
|
19
16
|
|
20
17
|
it 'should have a currency attrubute on every element' do
|
21
18
|
stub_get('/1/billing_reports?auth_token=token', 'billing_reports')
|
22
|
-
|
19
|
+
client.billing_report.each{|report| report.currency.should_not be_nil }
|
23
20
|
end
|
24
21
|
|
25
22
|
it 'should return results by service' do
|
26
23
|
stub_get('/1/billing_reports?auth_token=token&by=service', 'billing_reports')
|
27
|
-
expect {
|
24
|
+
expect { client.billing_report(by: 'service') }.not_to raise_exception
|
28
25
|
end
|
29
26
|
|
30
27
|
it 'should return results given by service, given the vendor and period' do
|
31
28
|
stub_get('/1/billing_reports?auth_token=token&by=service&vendor=Amazon&period=2012-03-01', 'billing_reports')
|
32
|
-
expect {
|
29
|
+
expect { client.billing_report(by: 'service', vendor: 'Amazon', period: '2012-03-01') }.not_to raise_exception
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
@@ -1,30 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cloudability::Client::Budgets do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@client = Cloudability::Client.new(auth_token: 'token')
|
7
|
-
end
|
4
|
+
let(:client) { Cloudability::Client.new(auth_token: 'token') }
|
8
5
|
|
9
6
|
describe '#budgets' do
|
10
7
|
it 'should be an array' do
|
11
8
|
stub_get('/1/budgets/index?auth_token=token', 'budgets')
|
12
|
-
|
9
|
+
client.budgets.should be_kind_of Array
|
13
10
|
end
|
14
11
|
|
15
12
|
it 'should be an array of Hashie::Mashes' do
|
16
13
|
stub_get('/1/budgets/index?auth_token=token', 'budgets')
|
17
|
-
|
14
|
+
client.budgets.each{|budget| budget.should be_kind_of Hashie::Mash }
|
18
15
|
end
|
19
16
|
|
20
17
|
it 'should be mappable by ID' do
|
21
18
|
stub_get('/1/budgets/index?auth_token=token', 'budgets')
|
22
|
-
|
19
|
+
client.budgets.map(&:id).should be_kind_of Array
|
23
20
|
end
|
24
21
|
|
25
22
|
it 'should be mappable by ID and not be empty' do
|
26
23
|
stub_get('/1/budgets/index?auth_token=token', 'budgets')
|
27
|
-
|
24
|
+
client.budgets.map(&:id).should_not be_empty
|
28
25
|
end
|
29
26
|
end
|
30
27
|
end
|
@@ -1,79 +1,76 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cloudability::Client::CostReports do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@client = Cloudability::Client.new(auth_token: 'token')
|
7
|
-
end
|
4
|
+
let(:client) { Cloudability::Client.new(auth_token: 'token') }
|
8
5
|
|
9
6
|
describe '#cost_reports' do
|
10
7
|
it 'should be an array' do
|
11
8
|
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports')
|
12
|
-
|
9
|
+
client.cost_reports.should be_kind_of Array
|
13
10
|
end
|
14
11
|
|
15
12
|
it 'should be mappable by ID' do
|
16
13
|
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports')
|
17
|
-
|
14
|
+
client.cost_reports.map(&:id).should be_kind_of Array
|
18
15
|
end
|
19
16
|
|
20
17
|
it 'should be mappable by ID and not be empty' do
|
21
18
|
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports')
|
22
|
-
|
19
|
+
client.cost_reports.map(&:id).should_not be_empty
|
23
20
|
end
|
24
21
|
|
25
22
|
it 'should be mappable by category and not be empty' do
|
26
23
|
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports')
|
27
|
-
|
24
|
+
client.cost_reports.map(&:category).should_not be_empty
|
28
25
|
end
|
29
26
|
|
30
27
|
it 'should be an array of Hashie::Mashes' do
|
31
28
|
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports')
|
32
|
-
|
29
|
+
client.cost_reports.each{|report| report.should be_kind_of Hashie::Mash }
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
36
33
|
describe '#cost_measures' do
|
37
34
|
it 'should be an array' do
|
38
35
|
stub_get('/1/reporting/cost/measures?auth_token=token', 'cost/measures')
|
39
|
-
|
36
|
+
client.cost_measures.should be_kind_of Array
|
40
37
|
end
|
41
38
|
|
42
39
|
it 'should be mappable by type' do
|
43
40
|
stub_get('/1/reporting/cost/measures?auth_token=token', 'cost/measures')
|
44
|
-
|
41
|
+
client.cost_measures.map(&:type).should be_kind_of Array
|
45
42
|
end
|
46
43
|
|
47
44
|
it 'should be mappable by type and not be empty' do
|
48
45
|
stub_get('/1/reporting/cost/measures?auth_token=token', 'cost/measures')
|
49
|
-
|
46
|
+
client.cost_measures.map(&:type).should_not be_empty
|
50
47
|
end
|
51
48
|
|
52
49
|
it 'should be an array of Hashie::Mashes' do
|
53
50
|
stub_get('/1/reporting/cost/measures?auth_token=token', 'cost/measures')
|
54
|
-
|
51
|
+
client.cost_measures.each{|measure| measure.should be_kind_of Hashie::Mash }
|
55
52
|
end
|
56
53
|
end
|
57
54
|
|
58
55
|
describe '#cost_filters' do
|
59
56
|
it 'should be an array' do
|
60
57
|
stub_get('/1/reporting/cost/filters?auth_token=token', 'cost/filters')
|
61
|
-
|
58
|
+
client.cost_filters.should be_kind_of Array
|
62
59
|
end
|
63
60
|
|
64
61
|
it 'should not be an empty array' do
|
65
62
|
stub_get('/1/reporting/cost/filters?auth_token=token', 'cost/filters')
|
66
|
-
|
63
|
+
client.cost_filters.should_not be_empty
|
67
64
|
end
|
68
65
|
|
69
66
|
it 'should not be an empty array' do
|
70
67
|
stub_get('/1/reporting/cost/filters?auth_token=token', 'cost/filters')
|
71
|
-
|
68
|
+
client.cost_filters.should_not be_empty
|
72
69
|
end
|
73
70
|
|
74
71
|
it 'should be an array of strings' do
|
75
72
|
stub_get('/1/reporting/cost/filters?auth_token=token', 'cost/filters')
|
76
|
-
|
73
|
+
client.cost_filters.each{|filter| filter.should be_kind_of String }
|
77
74
|
end
|
78
75
|
end
|
79
76
|
end
|
@@ -1,20 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cloudability::Client::Credentials do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@client = Cloudability::Client.new(auth_token: 'token')
|
7
|
-
end
|
4
|
+
let(:client) { Cloudability::Client.new(auth_token: 'token') }
|
8
5
|
|
9
6
|
describe '#credentials' do
|
10
7
|
it 'should be an array' do
|
11
8
|
stub_get('/0/credentials/index?auth_token=token', 'credentials')
|
12
|
-
|
9
|
+
client.credentials.should be_kind_of Array
|
13
10
|
end
|
14
11
|
|
15
12
|
it 'should be an array of Hashie::Mashes' do
|
16
13
|
stub_get('/0/credentials/index?auth_token=token', 'credentials')
|
17
|
-
|
14
|
+
client.credentials.each{|report| report.should be_kind_of Hashie::Mash }
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
@@ -1,83 +1,80 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cloudability::Client::Organizations do
|
4
|
+
let(:client) { Cloudability::Client.new(auth_token: 'token') }
|
4
5
|
|
5
|
-
before do
|
6
|
-
@client = Cloudability::Client.new(auth_token: 'token')
|
7
|
-
end
|
8
|
-
|
9
6
|
describe '#my_organization' do
|
10
7
|
it 'should be a Hashie::Mashe' do
|
11
8
|
stub_get('/1/organizations?auth_token=token', 'organization')
|
12
|
-
|
9
|
+
client.my_organization.should be_kind_of Hashie::Mash
|
13
10
|
end
|
14
11
|
end
|
15
12
|
|
16
13
|
describe '#organization_invitations' do
|
17
14
|
it 'should be an Array' do
|
18
15
|
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations')
|
19
|
-
|
16
|
+
client.organization_invitations.should be_kind_of Array
|
20
17
|
end
|
21
18
|
|
22
19
|
it 'should be an array of Hashie::Mashes' do
|
23
20
|
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations')
|
24
|
-
|
21
|
+
client.organization_invitations.each{|invite| invite.should be_kind_of Hashie::Mash }
|
25
22
|
end
|
26
23
|
|
27
24
|
it 'should be mappable by ID' do
|
28
25
|
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations')
|
29
|
-
|
26
|
+
client.organization_invitations.map(&:id).should be_kind_of Array
|
30
27
|
end
|
31
28
|
|
32
29
|
it 'should be mappable by ID and not be empty' do
|
33
30
|
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations')
|
34
|
-
|
31
|
+
client.organization_invitations.map(&:id).should_not be_empty
|
35
32
|
end
|
36
33
|
end
|
37
34
|
|
38
35
|
describe '#organization_roles' do
|
39
36
|
it 'should be an Array' do
|
40
37
|
stub_get('/1/organizations/roles?auth_token=token', 'organization_roles')
|
41
|
-
|
38
|
+
client.organization_roles.should be_kind_of Array
|
42
39
|
end
|
43
40
|
|
44
41
|
it 'should be an array of Hashie::Mashes' do
|
45
42
|
stub_get('/1/organizations/roles?auth_token=token', 'organization_roles')
|
46
|
-
|
43
|
+
client.organization_roles.each{|role| role.should be_kind_of Hashie::Mash }
|
47
44
|
end
|
48
45
|
end
|
49
46
|
|
50
47
|
describe '#invite_user' do
|
51
48
|
it 'should be a Hashie::Mash' do
|
52
49
|
stub_post('/1/organizations/invitations?auth_token=token&email=colbyaleyrb%40gmail.com', 'organization_invitation')
|
53
|
-
|
50
|
+
client.invite_user('colbyaleyrb@gmail.com').should be_kind_of Hashie::Mash
|
54
51
|
end
|
55
52
|
|
56
53
|
it 'should accept a hash with email and name' do
|
57
54
|
stub_post('/1/organizations/invitations?auth_token=token&email=colbyaleyrb%40gmail.com&name=colby', 'organization_invitation')
|
58
|
-
expect {
|
55
|
+
expect { client.invite_user('colbyaleyrb@gmail.com', name: 'colby') }.not_to raise_exception
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
62
59
|
describe '#delete_invite' do
|
63
60
|
it 'should should not raise an exception when id is provided' do
|
64
61
|
stub_delete('/1/organizations/invitations/1?auth_token=token', 'organization_invitation')
|
65
|
-
expect {
|
62
|
+
expect { client.delete_invite(1) }.not_to raise_exception
|
66
63
|
end
|
67
64
|
|
68
65
|
it 'should require id as an argument' do
|
69
|
-
expect {
|
66
|
+
expect { client.delete_invite }.to raise_exception(ArgumentError)
|
70
67
|
end
|
71
68
|
end
|
72
69
|
|
73
70
|
describe '#update_invite' do
|
74
71
|
it 'should should not raise an exception when id and role_id are provided' do
|
75
72
|
stub_put('/1/organizations/invitations/1?role_id=1&auth_token=token', 'organization_invitation')
|
76
|
-
expect {
|
73
|
+
expect { client.update_invite(1,1) }.not_to raise_exception
|
77
74
|
end
|
78
75
|
|
79
76
|
it 'should require id and role_id as arguments' do
|
80
|
-
expect {
|
77
|
+
expect { client.update_invite }.to raise_exception(ArgumentError)
|
81
78
|
end
|
82
79
|
end
|
83
|
-
end
|
80
|
+
end
|
@@ -1,44 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cloudability::Client::UsageReports do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@client = Cloudability::Client.new(auth_token: 'token')
|
7
|
-
end
|
4
|
+
let(:client) { Cloudability::Client.new(auth_token: 'token') }
|
8
5
|
|
9
6
|
describe '#usage_reports' do
|
10
7
|
it 'should be an array' do
|
11
8
|
stub_get('/1/reporting?auth_token=token', 'usage/reports')
|
12
|
-
|
9
|
+
client.usage_reports.should be_kind_of Array
|
13
10
|
end
|
14
11
|
|
15
12
|
it 'should be an array of Hashie::Mashes' do
|
16
13
|
stub_get('/1/reporting?auth_token=token', 'usage/reports')
|
17
|
-
|
14
|
+
client.usage_reports.each{|report| report.should be_kind_of Hashie::Mash }
|
18
15
|
end
|
19
16
|
end
|
20
17
|
|
21
18
|
describe '#usage_measures' do
|
22
19
|
it 'should be an array' do
|
23
20
|
stub_get('/1/reporting/measures?auth_token=token', 'usage/measures')
|
24
|
-
|
21
|
+
client.usage_measures.should be_kind_of Array
|
25
22
|
end
|
26
23
|
|
27
24
|
it 'should be an array of Hashie::Mashes' do
|
28
25
|
stub_get('/1/reporting/measures?auth_token=token', 'usage/measures')
|
29
|
-
|
26
|
+
client.usage_measures.each{|measure| measure.should be_kind_of Hashie::Mash }
|
30
27
|
end
|
31
28
|
end
|
32
29
|
|
33
30
|
describe '#usage_filters' do
|
34
31
|
it 'should be an array' do
|
35
32
|
stub_get('/1/reporting/filters?auth_token=token', 'usage/filters')
|
36
|
-
|
33
|
+
client.usage_filters.should be_kind_of Array
|
37
34
|
end
|
38
35
|
|
39
36
|
it 'should be an array of strings' do
|
40
37
|
stub_get('/1/reporting/filters?auth_token=token', 'usage/filters')
|
41
|
-
|
38
|
+
client.usage_filters.each{|filter| filter.should be_kind_of String }
|
42
39
|
end
|
43
40
|
end
|
44
|
-
end
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cloudability::Client::Users do
|
4
|
+
let(:client) { Cloudability::Client.new(auth_token: 'token') }
|
5
|
+
|
6
|
+
describe '#users' do
|
7
|
+
it 'should return an array' do
|
8
|
+
stub_get('/1/users?auth_token=token', 'users/users')
|
9
|
+
client.users.should be_kind_of Array
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should return an array of Hashie::Mashes' do
|
13
|
+
stub_get('/1/users?auth_token=token', 'users/users')
|
14
|
+
client.users.each{|user| user.should be_kind_of Hashie::Mash }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#add_user' do
|
19
|
+
it 'should return a Hashie::Mash' do
|
20
|
+
stub_post('/1/users?user[email]=colbyaley%40gmail.com&auth_token=token', 'users/add_user')
|
21
|
+
client.add_user('colbyaley@gmail.com').should be_kind_of Hashie::Mash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#update_user' do
|
26
|
+
it 'should return a Hashie::Mash' do
|
27
|
+
stub_put('/1/users/23052?user[full_name]=Colby%20Aley&auth_token=token', 'users/update_user')
|
28
|
+
client.update_user('23052', full_name: 'Colby Aley').should be_kind_of Hashie::Mash
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#delete_user' do
|
33
|
+
it 'should return "true"' do
|
34
|
+
stub_delete('/1/users/23052?auth_token=token', 'users/delete_user')
|
35
|
+
client.delete_user('23052').body.should eq("true")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/fixtures/budgets
CHANGED
@@ -15,4 +15,4 @@ X-Runtime: 0.194231
|
|
15
15
|
X-Rack-Cache: miss
|
16
16
|
Origin: app.cloudability.com
|
17
17
|
|
18
|
-
[{"predicted_monthly_spend":{"cents":1111111,"currency":{"id":111,"key":"usd","priority":1,"iso_code":"USD"}},"subject":"1111-1111-1111","type":"Account","currency":"USD","id":1111,"is_active":true,"threshold":"50000.0"},{"predicted_monthly_spend":{"cents":1111111,"currency":{"id":111,"key":"usd","priority":1,"iso_code":"USD"}},"subject":"colby@cloudability.com","type":"User","currency":"USD","id":1111,"is_active":true,"threshold":"100000.0"}]
|
18
|
+
[{"predicted_monthly_spend":{"cents":1111111,"currency":{"id":111,"key":"usd","priority":1,"iso_code":"USD"}},"subject":"1111-1111-1111","type":"Account","currency":"USD","id":1111,"is_active":true,"threshold":"50000.0"},{"predicted_monthly_spend":{"cents":1111111,"currency":{"id":111,"key":"usd","priority":1,"iso_code":"USD"}},"subject":"colby@cloudability.com","type":"User","currency":"USD","id":1111,"is_active":true,"threshold":"100000.0"}]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
HTTP/1.1 201 Created
|
2
|
+
Server: nginx/1.7.4
|
3
|
+
Date: Sun, 01 Nov 2015 20:10:30 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 191
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 201 Created
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
10
|
+
ETag: "52d5a5192986be3fea6505d5140bfe45"
|
11
|
+
Cache-Control: max-age=0, private, must-revalidate
|
12
|
+
X-Request-Id: e4edf6d852b2334add97ea58c9f5e43e
|
13
|
+
X-Runtime: 0.596605
|
14
|
+
X-Rack-Cache: invalidate, pass
|
15
|
+
X-Frame-Options: DENY
|
16
|
+
|
17
|
+
{"id":23052,"email":"colbyaley@gmail.com","full_name":null,"invitation":"pending","role":"User","restricted":false,"shared_dimension_filter_set_ids":[],"default_dimension_filter_set_id":null}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.7.5
|
3
|
+
Date: Sun, 01 Nov 2015 20:25:23 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 4
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
10
|
+
ETag: "b326b5062b2f0e69046810717534cb09"
|
11
|
+
Cache-Control: max-age=0, private, must-revalidate
|
12
|
+
X-Request-Id: 785c003402e2a15e4d0f09c858e46ff6
|
13
|
+
X-Runtime: 0.290896
|
14
|
+
X-Rack-Cache: invalidate, pass
|
15
|
+
X-Frame-Options: DENY
|
16
|
+
|
17
|
+
true
|
@@ -0,0 +1,17 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.7.7
|
3
|
+
Date: Sun, 01 Nov 2015 20:19:18 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 916
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
10
|
+
ETag: "1c5a29a9175969252b4352d2e56cf740"
|
11
|
+
Cache-Control: max-age=0, private, must-revalidate
|
12
|
+
X-Request-Id: 9e130fc8db3c2fc363866a16cf380ba2
|
13
|
+
X-Runtime: 0.069726
|
14
|
+
X-Rack-Cache: invalidate, pass
|
15
|
+
X-Frame-Options: DENY
|
16
|
+
|
17
|
+
{"id":23052,"full_name":"Colby Aley","email":"colbyaley@gmail.com","is_organization_admin":false,"is_billing_contact":false,"currency":{"key":"usd","symbol":"$","symbol_first":true,"thousands_separator":",","decimal_mark":".","subunit_to_unit":100},"invitation":"pending","role":"User","restricted":false,"shared_dimension_filter_set_ids":[],"default_dimension_filter_set_id":null,"is_enterprise":true,"ri_az_transfer_beta":false,"custom_rate_card_beta":false,"advanced_charting_beta":false,"dashboard_beta":true,"cost_cube_estimates_beta":true,"extended_account_groups_beta":false,"cost_per_hour_beta":false,"ri_portfolio_beta":false,"company":"Colby Aley","company_size":"2_3","company_sector":"software_and_web","time_zone":"Pacific Time (US \u0026 Canada)","language":"en-us","summary_period":"daily","summary_hour":6,"show_credentials":false,"exclude_credits":null,"exclude_capex":null,"config_state":"created"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.7.8
|
3
|
+
Date: Sun, 01 Nov 2015 20:03:37 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Content-Length: 391
|
6
|
+
Connection: keep-alive
|
7
|
+
Status: 200 OK
|
8
|
+
Strict-Transport-Security: max-age=31536000
|
9
|
+
X-UA-Compatible: IE=Edge,chrome=1
|
10
|
+
ETag: "18cfa380bed0c270c4ed01171c03a1c8"
|
11
|
+
Cache-Control: max-age=0, private, must-revalidate
|
12
|
+
X-Request-Id: 32e5e4dadaf751516b61af1b124026ec
|
13
|
+
X-Runtime: 0.052354
|
14
|
+
X-Rack-Cache: miss
|
15
|
+
X-Frame-Options: DENY
|
16
|
+
|
17
|
+
[{"id":23051,"email":"colby@immun.io","full_name":null,"invitation":"pending","role":"User","restricted":false,"shared_dimension_filter_set_ids":[],"default_dimension_filter_set_id":null},{"id":5902,"email":"colby@aley.me","full_name":"Colby Aley","invitation":"accepted","role":"Administrator","restricted":false,"shared_dimension_filter_set_ids":[],"default_dimension_filter_set_id":null}]
|
data/spec/spec_helper.rb
CHANGED
@@ -4,6 +4,7 @@ Coveralls.wear!
|
|
4
4
|
require 'bundler'
|
5
5
|
require 'fakeweb'
|
6
6
|
require 'cloudability'
|
7
|
+
require 'pry'
|
7
8
|
|
8
9
|
# Borrowed this Fixtures/Fakeweb implimentation
|
9
10
|
# fromt the gauges-gem library.
|
@@ -47,4 +48,4 @@ FakeWeb.allow_net_connect = false
|
|
47
48
|
FakeWeb.allow_net_connect = %r[^https?://coveralls.io/api/v1/jobs]
|
48
49
|
|
49
50
|
# Creating fixtures:
|
50
|
-
# curl -is https://app.cloudability.com/api/0/billing_reports?auth_token=token&by=account > spec/fixtures/billing_report
|
51
|
+
# curl -is https://app.cloudability.com/api/0/billing_reports?auth_token=token&by=account > spec/fixtures/billing_report
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colby Aley
|
@@ -9,90 +9,104 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 0.9.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.9.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: hashie
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: fakeweb
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rake
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ~>
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0.6'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - ~>
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0.6'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: coveralls
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: pry
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
96
110
|
- !ruby/object:Gem::Version
|
97
111
|
version: '0'
|
98
112
|
description: Ruby wrapper for the Cloudability API
|
@@ -103,8 +117,8 @@ executables: []
|
|
103
117
|
extensions: []
|
104
118
|
extra_rdoc_files: []
|
105
119
|
files:
|
106
|
-
- .gitignore
|
107
|
-
- .travis.yml
|
120
|
+
- ".gitignore"
|
121
|
+
- ".travis.yml"
|
108
122
|
- Gemfile
|
109
123
|
- LICENSE.txt
|
110
124
|
- README.md
|
@@ -117,13 +131,15 @@ files:
|
|
117
131
|
- lib/cloudability/client/credentials.rb
|
118
132
|
- lib/cloudability/client/organizations.rb
|
119
133
|
- lib/cloudability/client/usage_reports.rb
|
134
|
+
- lib/cloudability/client/users.rb
|
120
135
|
- lib/cloudability/version.rb
|
121
|
-
- spec/
|
122
|
-
- spec/
|
123
|
-
- spec/
|
124
|
-
- spec/
|
125
|
-
- spec/
|
126
|
-
- spec/
|
136
|
+
- spec/cloudability/billing_spec.rb
|
137
|
+
- spec/cloudability/budgets_spec.rb
|
138
|
+
- spec/cloudability/cost_spec.rb
|
139
|
+
- spec/cloudability/credentials_spec.rb
|
140
|
+
- spec/cloudability/organizations_spec.rb
|
141
|
+
- spec/cloudability/usage_spec.rb
|
142
|
+
- spec/cloudability/users_spec.rb
|
127
143
|
- spec/fixtures/billing_reports
|
128
144
|
- spec/fixtures/budgets
|
129
145
|
- spec/fixtures/cost/filters
|
@@ -138,6 +154,10 @@ files:
|
|
138
154
|
- spec/fixtures/usage/filters
|
139
155
|
- spec/fixtures/usage/measures
|
140
156
|
- spec/fixtures/usage/reports
|
157
|
+
- spec/fixtures/users/add_user
|
158
|
+
- spec/fixtures/users/delete_user
|
159
|
+
- spec/fixtures/users/update_user
|
160
|
+
- spec/fixtures/users/users
|
141
161
|
- spec/spec_helper.rb
|
142
162
|
homepage: https://github.com/colbyaley/cloudability
|
143
163
|
licenses:
|
@@ -149,27 +169,28 @@ require_paths:
|
|
149
169
|
- lib
|
150
170
|
required_ruby_version: !ruby/object:Gem::Requirement
|
151
171
|
requirements:
|
152
|
-
- -
|
172
|
+
- - ">="
|
153
173
|
- !ruby/object:Gem::Version
|
154
174
|
version: '0'
|
155
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
176
|
requirements:
|
157
|
-
- -
|
177
|
+
- - ">="
|
158
178
|
- !ruby/object:Gem::Version
|
159
179
|
version: '0'
|
160
180
|
requirements: []
|
161
181
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.4.5
|
163
183
|
signing_key:
|
164
184
|
specification_version: 4
|
165
185
|
summary: Ruby wrapper for the Cloudability API built with HTTParty
|
166
186
|
test_files:
|
167
|
-
- spec/
|
168
|
-
- spec/
|
169
|
-
- spec/
|
170
|
-
- spec/
|
171
|
-
- spec/
|
172
|
-
- spec/
|
187
|
+
- spec/cloudability/billing_spec.rb
|
188
|
+
- spec/cloudability/budgets_spec.rb
|
189
|
+
- spec/cloudability/cost_spec.rb
|
190
|
+
- spec/cloudability/credentials_spec.rb
|
191
|
+
- spec/cloudability/organizations_spec.rb
|
192
|
+
- spec/cloudability/usage_spec.rb
|
193
|
+
- spec/cloudability/users_spec.rb
|
173
194
|
- spec/fixtures/billing_reports
|
174
195
|
- spec/fixtures/budgets
|
175
196
|
- spec/fixtures/cost/filters
|
@@ -184,4 +205,9 @@ test_files:
|
|
184
205
|
- spec/fixtures/usage/filters
|
185
206
|
- spec/fixtures/usage/measures
|
186
207
|
- spec/fixtures/usage/reports
|
208
|
+
- spec/fixtures/users/add_user
|
209
|
+
- spec/fixtures/users/delete_user
|
210
|
+
- spec/fixtures/users/update_user
|
211
|
+
- spec/fixtures/users/users
|
187
212
|
- spec/spec_helper.rb
|
213
|
+
has_rdoc:
|