vault-usage-client 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -4
- data/README.md +23 -1
- data/lib/vault-usage-client/client.rb +7 -2
- data/lib/vault-usage-client/version.rb +1 -1
- data/test/client_test.rb +10 -0
- data/vault-usage-client.gemspec +3 -3
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 396f74ea5ff90f39ec688dba59339a3eb7abcd59
|
4
|
+
data.tar.gz: b102e37d9f160b8ea762837bbbc3ff62ee7fd5d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72451c5898b32134424a27efdc97b40213866c6dee9cf80fdbc88a4d5071dcfc75dd6748e4697b72c92cf11f663c57e1788719d3c316ff5c8a222107b6a85805
|
7
|
+
data.tar.gz: bd44043d3dd67c23c7fef8f0319fc818679fb8504d4a271cfc17330de548b2be1321d34eab89c973930c52fa28995b8241e95f4980c14614c62b858dca9c0d25
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
vault-usage-client (0.0.
|
5
|
-
colorize
|
6
|
-
excon
|
7
|
-
multi_json
|
4
|
+
vault-usage-client (0.0.12)
|
5
|
+
colorize
|
6
|
+
excon
|
7
|
+
multi_json
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -82,3 +82,6 @@ DEPENDENCIES
|
|
82
82
|
vault-test-tools
|
83
83
|
vault-usage-client!
|
84
84
|
yard
|
85
|
+
|
86
|
+
BUNDLED WITH
|
87
|
+
1.10.6
|
data/README.md
CHANGED
@@ -118,7 +118,7 @@ The `events` result is an `Array` of objects matching this format:
|
|
118
118
|
detail: {<key1>: <value1>,
|
119
119
|
<key2>: <value2>,
|
120
120
|
...}},
|
121
|
-
...]
|
121
|
+
...]
|
122
122
|
```
|
123
123
|
|
124
124
|
In some cases it can be useful to exclude event data for certain
|
@@ -134,6 +134,28 @@ events = client.usage_for_user(user_hid, start_time, stop_time,
|
|
134
134
|
|
135
135
|
You can pass one or more product names to exclude.
|
136
136
|
|
137
|
+
#### Retrieving a single usage event
|
138
|
+
|
139
|
+
A usage event can be retrieved with the client:
|
140
|
+
|
141
|
+
```
|
142
|
+
event_id = '3b1086ea-07df-4324-a35f-b28a1474bd9b'
|
143
|
+
event = client.usage_for_event(event_id)
|
144
|
+
```
|
145
|
+
|
146
|
+
The `event` result is an object matching this format:
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
{id: '<event-uuid>',
|
150
|
+
product: '<name>',
|
151
|
+
consumer: '<consumer-hid>',
|
152
|
+
start_time: <Time>,
|
153
|
+
stop_time: <Time>,
|
154
|
+
detail: {<key1>: <value1>,
|
155
|
+
<key2>: <value2>,
|
156
|
+
...}}
|
157
|
+
```
|
158
|
+
|
137
159
|
### App ownership events
|
138
160
|
|
139
161
|
App ownership events represent ownership of an app, for a period of
|
@@ -152,6 +152,10 @@ module Vault::Usage
|
|
152
152
|
# @param exclude [Array] Optionally, a list of product names, such as
|
153
153
|
# `['platform:dyno:physical', 'addon:memcache:100mb']`, to be excluded
|
154
154
|
# from usage data.
|
155
|
+
# @param callback_url [String] The URL vault-usage will callback after generating
|
156
|
+
# usage events JSON
|
157
|
+
# @param snapshot [Boolean] Whether or not to return only events that were open
|
158
|
+
# at the start_time
|
155
159
|
# @raise [InvalidTimeError] Raised if a non-UTC start or stop time is
|
156
160
|
# provided.
|
157
161
|
# @raise [Excon::Errors::HTTPStatusError] Raised if the server returns an
|
@@ -170,7 +174,7 @@ module Vault::Usage
|
|
170
174
|
# ...}},
|
171
175
|
# ...]}
|
172
176
|
# ```
|
173
|
-
def usage_for_user(user_hid, start_time, stop_time, exclude=nil, callback_url =
|
177
|
+
def usage_for_user(user_hid, start_time, stop_time, exclude=nil, callback_url=nil, snapshot=false)
|
174
178
|
unless start_time.zone.eql?('UTC')
|
175
179
|
raise InvalidTimeError.new('Start time must be in UTC.')
|
176
180
|
end
|
@@ -178,8 +182,9 @@ module Vault::Usage
|
|
178
182
|
raise InvalidTimeError.new('Stop time must be in UTC.')
|
179
183
|
end
|
180
184
|
path = "/users/#{user_hid}/usage/#{iso_format(start_time)}/" +
|
181
|
-
|
185
|
+
"#{iso_format(stop_time)}"
|
182
186
|
query = {}
|
187
|
+
query[:snapshot] = true if snapshot
|
183
188
|
unless exclude.nil? || exclude.empty?
|
184
189
|
query[:exclude] = exclude.join(',')
|
185
190
|
end
|
data/test/client_test.rb
CHANGED
@@ -278,6 +278,16 @@ class ClientTest < Vault::TestCase
|
|
278
278
|
@client.usage_for_user(@user_hid, @start_time, @stop_time, nil,'http://example.com'))
|
279
279
|
end
|
280
280
|
|
281
|
+
def test_usage_for_user_with_callback_url_and_snapshot
|
282
|
+
Excon.stub(method: :get) do |request|
|
283
|
+
assert_equal({callback_url: 'http://example.com', snapshot: true}, request[:query])
|
284
|
+
Excon.stubs.pop
|
285
|
+
{status: 200, body: MultiJson.dump({job_id: 'DEADBEEF'})}
|
286
|
+
end
|
287
|
+
assert_equal('DEADBEEF',
|
288
|
+
@client.usage_for_user(@user_hid, @start_time, @stop_time, nil,'http://example.com', true))
|
289
|
+
end
|
290
|
+
|
281
291
|
# Client.usage_for_user comma-separates product names, when many are
|
282
292
|
# provided in the exclusion list, and passes them to the server using a
|
283
293
|
# single query argument.
|
data/vault-usage-client.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.require_paths = ['lib']
|
18
18
|
gem.executables = ['vault-usage']
|
19
19
|
|
20
|
-
gem.add_dependency 'excon'
|
21
|
-
gem.add_dependency 'multi_json'
|
22
|
-
gem.add_dependency 'colorize'
|
20
|
+
gem.add_dependency 'excon'
|
21
|
+
gem.add_dependency 'multi_json'
|
22
|
+
gem.add_dependency 'colorize'
|
23
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vault-usage-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Continanza
|
@@ -9,50 +9,50 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: excon
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0
|
20
|
+
version: '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
|
-
version: 0
|
27
|
+
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: multi_json
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
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
|
-
version:
|
41
|
+
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: colorize
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0
|
48
|
+
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0
|
55
|
+
version: '0'
|
56
56
|
description: Client for Vault::Usage
|
57
57
|
email:
|
58
58
|
- csquared@heroku.com
|