cumulus 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b48deed6888c1c227070ded977361dfd8f0d5c62
4
- data.tar.gz: a763901cc357b5fecdb5c484e7f1bdecbf0b44ce
3
+ metadata.gz: 60a289a9fffa1c8c9bbde55e8cd0cb2164aa60bb
4
+ data.tar.gz: e0266ba59256e95f5280d12cd8d780aa8800fde4
5
5
  SHA512:
6
- metadata.gz: 0f2ff9c8c724c5fb38068ddba814695522117834b549499fea111fe0bd892a1884d825668a292275f1ad20023deac17b12dd722c4aeaef82df37cb9de7d8c4cc
7
- data.tar.gz: 9f0d4ffb9dc57f3d68a74272a16ea1d9e4ccd008161aec8f0484fc7937f3a83ffbf3d9d87dac6f177dfdc25f214baac5739a1415edcf54039ee9f844e530f5b6
6
+ metadata.gz: 8c543b6d3c4a984a0de3934f88c209d9c7ded872b8b44e0c78fe19c3c27d5325879c05df96a353c0c15786f91abce512fdbcb85b99d793891c59267513f1fb24
7
+ data.tar.gz: 1669a03bc489bfae4cbe37c76b480022c4d792268cbacef001d059c878742e5d3d1e2c28917b27eaf97182529e4c090c09d4bd8849977f8bbc05a7f060a79643
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Cumulus
2
2
  ===
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/cumulus.png)](http://badge.fury.io/rb/cumulus)
5
+
4
6
  Simple CLI for analyzing cloud cost data through the Cloduability API, using the [cloudability gem](https://github.com/ColbyAley/cloudability). Caches your API key in your [.netrc](http://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-File.html) file for convenience.
5
7
 
6
8
  ## Installation
@@ -11,6 +13,7 @@ Simple CLI for analyzing cloud cost data through the Cloduability API, using the
11
13
 
12
14
  $ cumulus budgets # Get a list of your budgets.
13
15
  $ cumulus credentials # Get a list of your credentials.
16
+ $ cumulus billing --by period --count 20
14
17
  $ cumulus billing # Get your 10 most recent billing reports.
15
18
  $ cumulus billing --count=20 # Get your 20(N) most recent billing reports.
16
19
  $ cumulus invites # Get a list of your organization user invites. (must be org admin)
@@ -23,6 +23,7 @@ module Cumulus
23
23
  budget.type, budget.subject]
24
24
  end
25
25
  end
26
+
26
27
  puts Terminal::Table.new(headings: ['Predicted spend', 'Budget threshold', 'Type', 'Subject'], rows: rows)
27
28
  end
28
29
 
@@ -30,26 +31,44 @@ module Cumulus
30
31
  def credentials
31
32
  credentials = Client.new(auth_token: token).credentials
32
33
  rows = []
34
+
33
35
  credentials.each do |cred|
34
36
  rows << [cred.vendor_key, cred.nickname]
35
37
  end
38
+
36
39
  puts Terminal::Table.new(headings: ['Vendor key', 'Nickname'], rows: rows)
37
40
  end
38
41
 
39
- method_options count: :numeric
42
+ method_options count: :numeric, default: 10, desc: 'Rows to display.'
43
+ method_options by: :string, default: :period, desc: 'Dimention to report on.'
44
+ method_options period: :string, desc: 'Period to report on. YYYY-MM-DD form. First day of the month only.'
40
45
  desc 'billing', 'Displays a table of recent billing reports'
41
46
  def billing
47
+ c = Client.new(auth_token: token)
42
48
  count = options[:count] || 10
43
- reports = Client.new(auth_token: token).billing_report(by: :period).reverse[0..count]
49
+ by = options[:by] || 'period'
50
+
51
+ if options[:period]
52
+ reports = c.billing_report(by: by, period: options[:period])
53
+ else
54
+ reports = c.billing_report(by: by)
55
+ end
56
+
57
+ reports = reports[0..count].reverse
58
+
59
+ reports.sort_by!{ |r| r.spend }.reverse! # sort by spend
44
60
  rows = []
61
+
45
62
  reports.each do |report|
46
- rows << [report.period, '$' + number_with_delimiter(report.spend).to_s]
63
+ dimention = dimention_to_attribute(by)
64
+ rows << [report[dimention], '$' + number_with_delimiter(report.spend).to_s]
47
65
  end
48
- puts Terminal::Table.new(headings: ['Period', 'Spend'], rows: rows)
66
+
67
+ puts Terminal::Table.new(headings: [by.capitalize, 'Spend'], rows: rows)
49
68
  end
50
69
 
51
70
  method_options state: :string
52
- method_options role: :string
71
+ method_options role: :string
53
72
  desc 'invites', 'Displays a table of organization invitations'
54
73
  def invites
55
74
  invites = Client.new(auth_token: token).organization_invitations
@@ -61,6 +80,7 @@ module Cumulus
61
80
  invites.each do |invite|
62
81
  rows << [invite.user.full_name, invite.user.email, invite.organization_role.label, invite.state]
63
82
  end
83
+
64
84
  puts Terminal::Table.new(headings: ['Name', 'Email', 'Role', 'State'], rows: rows)
65
85
  end
66
86
 
@@ -86,6 +106,19 @@ module Cumulus
86
106
 
87
107
  private
88
108
 
109
+ # Maps dimention to attribute for billing command.
110
+ #
111
+ # @param [String] dimention
112
+ # @return [Symbol] attribute
113
+ def dimention_to_attribute(dimention)
114
+ case dimention
115
+ when 'period'
116
+ :period
117
+ else
118
+ (dimention + '_name').to_sym
119
+ end
120
+ end
121
+
89
122
  def token
90
123
  n = Netrc.read
91
124
  if !n["app.cloudability.com"].nil? && token = n["app.cloudability.com"][0]
@@ -123,4 +156,4 @@ module Cumulus
123
156
  end
124
157
 
125
158
  end
126
- end
159
+ end
@@ -1,3 +1,3 @@
1
1
  module Cumulus
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cumulus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colby Aley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-27 00:00:00.000000000 Z
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cloudability