-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ColbyAley/0.2.0
Version 0.2.0
- Loading branch information
Showing
17 changed files
with
221 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module Cloudability | ||
class Client | ||
module Users | ||
# Documentation: http://developers.cloudability.com/resources/users/ | ||
|
||
# List users in your organization. | ||
# | ||
# @return [Array] array of Hashie::Mashes | ||
def users | ||
request = get '/1/users' | ||
convert_to_mashes(request) | ||
end | ||
|
||
# Add a user to your organization | ||
# | ||
# @param [String] email of user | ||
# @param [Hash] options | ||
# @option [String] full_name | ||
# @option [String] role | ||
# @option [Boolean] restricted | ||
# @option [Array] new_shared_dimension_filter_set_ids | ||
# @option [Integer] default_dimension_filter_set_id | ||
# @return [Array] array of Hashie::Mashes | ||
def add_user(email, options={}) | ||
options[:email] = email | ||
|
||
payload = {user: options} | ||
request = post '/1/users', payload | ||
Hashie::Mash.new request | ||
end | ||
|
||
# Update a user in your organization | ||
# | ||
# @param [Integer] ID of user | ||
# @param [Hash] options | ||
# @option [String] full_name | ||
# @option [String] role | ||
# @option [Boolean] restricted | ||
# @option [Array] new_shared_dimension_filter_set_ids | ||
# @option [Integer] default_dimension_filter_set_id | ||
# @return [Array] array of Hashie::Mashes | ||
def update_user(id, options={}) | ||
payload = {user: options} | ||
request = put "/1/users/#{id}", payload | ||
Hashie::Mash.new request | ||
end | ||
|
||
# Delete a user in your organization | ||
# | ||
# @param [Integer] ID of user | ||
# @return [Boolean] success | ||
def delete_user(id) | ||
delete "/1/users/#{id}" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Cloudability | ||
VERSION = '0.1.1' | ||
VERSION = '0.2.0' | ||
end |
15 changes: 6 additions & 9 deletions
15
spec/cloduability/billing_spec.rb → spec/cloudability/billing_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,32 @@ | ||
require 'spec_helper' | ||
|
||
describe Cloudability::Client::BillingReports do | ||
|
||
before do | ||
@client = Cloudability::Client.new(auth_token: 'token') | ||
end | ||
let(:client) { Cloudability::Client.new(auth_token: 'token') } | ||
|
||
describe '#billing_reports' do | ||
it 'should be an array' do | ||
stub_get('/1/billing_reports?auth_token=token', 'billing_reports') | ||
@client.billing_report.should be_kind_of Array | ||
client.billing_report.should be_kind_of Array | ||
end | ||
|
||
it 'should be an array of Hashie::Mashes' do | ||
stub_get('/1/billing_reports?auth_token=token', 'billing_reports') | ||
@client.billing_report.each{|report| report.should be_kind_of Hashie::Mash } | ||
client.billing_report.each{|report| report.should be_kind_of Hashie::Mash } | ||
end | ||
|
||
it 'should have a currency attrubute on every element' do | ||
stub_get('/1/billing_reports?auth_token=token', 'billing_reports') | ||
@client.billing_report.each{|report| report.currency.should_not be_nil } | ||
client.billing_report.each{|report| report.currency.should_not be_nil } | ||
end | ||
|
||
it 'should return results by service' do | ||
stub_get('/1/billing_reports?auth_token=token&by=service', 'billing_reports') | ||
expect { @client.billing_report(by: 'service') }.not_to raise_exception | ||
expect { client.billing_report(by: 'service') }.not_to raise_exception | ||
end | ||
|
||
it 'should return results given by service, given the vendor and period' do | ||
stub_get('/1/billing_reports?auth_token=token&by=service&vendor=Amazon&period=2012-03-01', 'billing_reports') | ||
expect { @client.billing_report(by: 'service', vendor: 'Amazon', period: '2012-03-01') }.not_to raise_exception | ||
expect { client.billing_report(by: 'service', vendor: 'Amazon', period: '2012-03-01') }.not_to raise_exception | ||
end | ||
end | ||
end |
13 changes: 5 additions & 8 deletions
13
spec/cloduability/budgets_spec.rb → spec/cloudability/budgets_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
describe Cloudability::Client::Budgets do | ||
|
||
before do | ||
@client = Cloudability::Client.new(auth_token: 'token') | ||
end | ||
let(:client) { Cloudability::Client.new(auth_token: 'token') } | ||
|
||
describe '#budgets' do | ||
it 'should be an array' do | ||
stub_get('/1/budgets/index?auth_token=token', 'budgets') | ||
@client.budgets.should be_kind_of Array | ||
client.budgets.should be_kind_of Array | ||
end | ||
|
||
it 'should be an array of Hashie::Mashes' do | ||
stub_get('/1/budgets/index?auth_token=token', 'budgets') | ||
@client.budgets.each{|budget| budget.should be_kind_of Hashie::Mash } | ||
client.budgets.each{|budget| budget.should be_kind_of Hashie::Mash } | ||
end | ||
|
||
it 'should be mappable by ID' do | ||
stub_get('/1/budgets/index?auth_token=token', 'budgets') | ||
@client.budgets.map(&:id).should be_kind_of Array | ||
client.budgets.map(&:id).should be_kind_of Array | ||
end | ||
|
||
it 'should be mappable by ID and not be empty' do | ||
stub_get('/1/budgets/index?auth_token=token', 'budgets') | ||
@client.budgets.map(&:id).should_not be_empty | ||
client.budgets.map(&:id).should_not be_empty | ||
end | ||
end | ||
end |
31 changes: 14 additions & 17 deletions
31
spec/cloduability/cost_spec.rb → spec/cloudability/cost_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,76 @@ | ||
require 'spec_helper' | ||
|
||
describe Cloudability::Client::CostReports do | ||
|
||
before do | ||
@client = Cloudability::Client.new(auth_token: 'token') | ||
end | ||
let(:client) { Cloudability::Client.new(auth_token: 'token') } | ||
|
||
describe '#cost_reports' do | ||
it 'should be an array' do | ||
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports') | ||
@client.cost_reports.should be_kind_of Array | ||
client.cost_reports.should be_kind_of Array | ||
end | ||
|
||
it 'should be mappable by ID' do | ||
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports') | ||
@client.cost_reports.map(&:id).should be_kind_of Array | ||
client.cost_reports.map(&:id).should be_kind_of Array | ||
end | ||
|
||
it 'should be mappable by ID and not be empty' do | ||
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports') | ||
@client.cost_reports.map(&:id).should_not be_empty | ||
client.cost_reports.map(&:id).should_not be_empty | ||
end | ||
|
||
it 'should be mappable by category and not be empty' do | ||
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports') | ||
@client.cost_reports.map(&:category).should_not be_empty | ||
client.cost_reports.map(&:category).should_not be_empty | ||
end | ||
|
||
it 'should be an array of Hashie::Mashes' do | ||
stub_get('/1/reporting/cost?auth_token=token', 'cost/reports') | ||
@client.cost_reports.each{|report| report.should be_kind_of Hashie::Mash } | ||
client.cost_reports.each{|report| report.should be_kind_of Hashie::Mash } | ||
end | ||
end | ||
|
||
describe '#cost_measures' do | ||
it 'should be an array' do | ||
stub_get('/1/reporting/cost/measures?auth_token=token', 'cost/measures') | ||
@client.cost_measures.should be_kind_of Array | ||
client.cost_measures.should be_kind_of Array | ||
end | ||
|
||
it 'should be mappable by type' do | ||
stub_get('/1/reporting/cost/measures?auth_token=token', 'cost/measures') | ||
@client.cost_measures.map(&:type).should be_kind_of Array | ||
client.cost_measures.map(&:type).should be_kind_of Array | ||
end | ||
|
||
it 'should be mappable by type and not be empty' do | ||
stub_get('/1/reporting/cost/measures?auth_token=token', 'cost/measures') | ||
@client.cost_measures.map(&:type).should_not be_empty | ||
client.cost_measures.map(&:type).should_not be_empty | ||
end | ||
|
||
it 'should be an array of Hashie::Mashes' do | ||
stub_get('/1/reporting/cost/measures?auth_token=token', 'cost/measures') | ||
@client.cost_measures.each{|measure| measure.should be_kind_of Hashie::Mash } | ||
client.cost_measures.each{|measure| measure.should be_kind_of Hashie::Mash } | ||
end | ||
end | ||
|
||
describe '#cost_filters' do | ||
it 'should be an array' do | ||
stub_get('/1/reporting/cost/filters?auth_token=token', 'cost/filters') | ||
@client.cost_filters.should be_kind_of Array | ||
client.cost_filters.should be_kind_of Array | ||
end | ||
|
||
it 'should not be an empty array' do | ||
stub_get('/1/reporting/cost/filters?auth_token=token', 'cost/filters') | ||
@client.cost_filters.should_not be_empty | ||
client.cost_filters.should_not be_empty | ||
end | ||
|
||
it 'should not be an empty array' do | ||
stub_get('/1/reporting/cost/filters?auth_token=token', 'cost/filters') | ||
@client.cost_filters.should_not be_empty | ||
client.cost_filters.should_not be_empty | ||
end | ||
|
||
it 'should be an array of strings' do | ||
stub_get('/1/reporting/cost/filters?auth_token=token', 'cost/filters') | ||
@client.cost_filters.each{|filter| filter.should be_kind_of String } | ||
client.cost_filters.each{|filter| filter.should be_kind_of String } | ||
end | ||
end | ||
end |
9 changes: 3 additions & 6 deletions
9
spec/cloduability/credentials_spec.rb → spec/cloudability/credentials_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
describe Cloudability::Client::Credentials do | ||
|
||
before do | ||
@client = Cloudability::Client.new(auth_token: 'token') | ||
end | ||
let(:client) { Cloudability::Client.new(auth_token: 'token') } | ||
|
||
describe '#credentials' do | ||
it 'should be an array' do | ||
stub_get('/0/credentials/index?auth_token=token', 'credentials') | ||
@client.credentials.should be_kind_of Array | ||
client.credentials.should be_kind_of Array | ||
end | ||
|
||
it 'should be an array of Hashie::Mashes' do | ||
stub_get('/0/credentials/index?auth_token=token', 'credentials') | ||
@client.credentials.each{|report| report.should be_kind_of Hashie::Mash } | ||
client.credentials.each{|report| report.should be_kind_of Hashie::Mash } | ||
end | ||
end | ||
end |
33 changes: 15 additions & 18 deletions
33
spec/cloduability/organizations_spec.rb → spec/cloudability/organizations_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,80 @@ | ||
require 'spec_helper' | ||
|
||
describe Cloudability::Client::Organizations do | ||
let(:client) { Cloudability::Client.new(auth_token: 'token') } | ||
|
||
before do | ||
@client = Cloudability::Client.new(auth_token: 'token') | ||
end | ||
|
||
describe '#my_organization' do | ||
it 'should be a Hashie::Mashe' do | ||
stub_get('/1/organizations?auth_token=token', 'organization') | ||
@client.my_organization.should be_kind_of Hashie::Mash | ||
client.my_organization.should be_kind_of Hashie::Mash | ||
end | ||
end | ||
|
||
describe '#organization_invitations' do | ||
it 'should be an Array' do | ||
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations') | ||
@client.organization_invitations.should be_kind_of Array | ||
client.organization_invitations.should be_kind_of Array | ||
end | ||
|
||
it 'should be an array of Hashie::Mashes' do | ||
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations') | ||
@client.organization_invitations.each{|invite| invite.should be_kind_of Hashie::Mash } | ||
client.organization_invitations.each{|invite| invite.should be_kind_of Hashie::Mash } | ||
end | ||
|
||
it 'should be mappable by ID' do | ||
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations') | ||
@client.organization_invitations.map(&:id).should be_kind_of Array | ||
client.organization_invitations.map(&:id).should be_kind_of Array | ||
end | ||
|
||
it 'should be mappable by ID and not be empty' do | ||
stub_get('/1/organizations/invitations?auth_token=token', 'organization_invitations') | ||
@client.organization_invitations.map(&:id).should_not be_empty | ||
client.organization_invitations.map(&:id).should_not be_empty | ||
end | ||
end | ||
|
||
describe '#organization_roles' do | ||
it 'should be an Array' do | ||
stub_get('/1/organizations/roles?auth_token=token', 'organization_roles') | ||
@client.organization_roles.should be_kind_of Array | ||
client.organization_roles.should be_kind_of Array | ||
end | ||
|
||
it 'should be an array of Hashie::Mashes' do | ||
stub_get('/1/organizations/roles?auth_token=token', 'organization_roles') | ||
@client.organization_roles.each{|role| role.should be_kind_of Hashie::Mash } | ||
client.organization_roles.each{|role| role.should be_kind_of Hashie::Mash } | ||
end | ||
end | ||
|
||
describe '#invite_user' do | ||
it 'should be a Hashie::Mash' do | ||
stub_post('/1/organizations/invitations?auth_token=token&email=colbyaleyrb%40gmail.com', 'organization_invitation') | ||
@client.invite_user('[email protected]').should be_kind_of Hashie::Mash | ||
client.invite_user('[email protected]').should be_kind_of Hashie::Mash | ||
end | ||
|
||
it 'should accept a hash with email and name' do | ||
stub_post('/1/organizations/invitations?auth_token=token&email=colbyaleyrb%40gmail.com&name=colby', 'organization_invitation') | ||
expect { @client.invite_user('[email protected]', name: 'colby') }.not_to raise_exception | ||
expect { client.invite_user('[email protected]', name: 'colby') }.not_to raise_exception | ||
end | ||
end | ||
|
||
describe '#delete_invite' do | ||
it 'should should not raise an exception when id is provided' do | ||
stub_delete('/1/organizations/invitations/1?auth_token=token', 'organization_invitation') | ||
expect { @client.delete_invite(1) }.not_to raise_exception | ||
expect { client.delete_invite(1) }.not_to raise_exception | ||
end | ||
|
||
it 'should require id as an argument' do | ||
expect { @client.delete_invite }.to raise_exception(ArgumentError) | ||
expect { client.delete_invite }.to raise_exception(ArgumentError) | ||
end | ||
end | ||
|
||
describe '#update_invite' do | ||
it 'should should not raise an exception when id and role_id are provided' do | ||
stub_put('/1/organizations/invitations/1?role_id=1&auth_token=token', 'organization_invitation') | ||
expect { @client.update_invite(1,1) }.not_to raise_exception | ||
expect { client.update_invite(1,1) }.not_to raise_exception | ||
end | ||
|
||
it 'should require id and role_id as arguments' do | ||
expect { @client.update_invite }.to raise_exception(ArgumentError) | ||
expect { client.update_invite }.to raise_exception(ArgumentError) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.