imperium 0.2.1 → 0.2.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: 2dda117c132b075ad9351a9940055f2f53d29d36
4
- data.tar.gz: a8ef9b691469f852dd0bbd67bbd0f3f654351565
3
+ metadata.gz: 040c01db1f3d464524d6b66f0b0e52f7c8fc3553
4
+ data.tar.gz: 65991cbb6b16acce1c2b3d408eaa6ae3e6ec67be
5
5
  SHA512:
6
- metadata.gz: fbb5a5c2fcd8b83edfa988b6b76d8e242bb95a056633a528685e6e00762ee376d42373196741fdd731210953e9a39f0d86729847093e9b27ff8bcbe3c934d66a
7
- data.tar.gz: 8ca0ecaa2c8afbb24d02589d9667a0a97066a07a825a56816d3668d71bc2c88e9a17c854ec1a0b7ba21eebbcca1312039329d00aa05ac033ff3fc269dd23ce1d
6
+ metadata.gz: 897ac12a4b8a4616dfe37e3175c69a1ffa3d76d6dff7e7ab0c5beb6370fd39fbb02c32a817dde2e6c87a5fa420c6f5202113e1172fd79821be1d00797cfd062e
7
+ data.tar.gz: 01d52982aab2dbb960229c7cf2b90b85f577054a894de8c58aa478de1cb0477d7b8038ecc7b573ed94070e02b02cb6f15a0083171785d09d929c0df47bd516a5
data/lib/imperium.rb CHANGED
@@ -3,6 +3,8 @@ require 'imperium/error'
3
3
  require 'imperium/configuration'
4
4
  require 'imperium/client'
5
5
  require 'imperium/http_client'
6
+ require 'imperium/event_fire_response'
7
+ require 'imperium/events'
6
8
  require 'imperium/kv'
7
9
  require 'imperium/kv_pair'
8
10
  require 'imperium/kv_get_response'
@@ -0,0 +1,13 @@
1
+ require_relative 'response'
2
+
3
+ module Imperium
4
+ # EventResponse is a wrapper for the raw HTTP::Message response from the API
5
+ #
6
+ # @note This class doesn't really make sense to be instantiated outside of
7
+ # {Events#fire}
8
+ class EventFireResponse < Response
9
+ def id
10
+ parsed_body['ID']
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ module Imperium
2
+ # A client for the Events API.
3
+ class Events < Client
4
+ self.path_prefix = 'v1/event'.freeze
5
+
6
+ # {#fire fire} an event using the {.default_client}
7
+ # @see #fire
8
+ def self.fire(name, payload = nil, dc: nil, node: nil, service: nil, tag: nil)
9
+ default_client.fire(name, payload, dc: dc, node: node, service: service, tag: tag)
10
+ end
11
+
12
+ # Fire the event
13
+ #
14
+ # @example Firing an event with a payload
15
+ # response = Imperium::Events.fire('foo/bar', 'mypayload') # => EventResponse...
16
+ #
17
+ # @param [String] name The name of the event
18
+ # @param [String] payload Additional data to send as payload of the event
19
+ # @param [String] dc Specify the datacenter to use for the request
20
+ # @param [String] node Specifies a regular expression to filter by node name
21
+ # @param [String] service Specifies a regular expression to filter by service name
22
+ # @param [String] tag Specifies a regular expression to filter by tag
23
+ # @return [EventResponse]
24
+ def fire(name, payload = nil, dc: nil, node: nil, service: nil, tag: nil)
25
+ query = {}
26
+ query[:dc] = dc if dc
27
+ query[:node] = node if node
28
+ query[:service] = service if service
29
+ query[:tag] = tag if tag
30
+ response = @http_client.put(prefix_path("fire/#{name}"),
31
+ payload, query: query)
32
+ EventFireResponse.new(response)
33
+ end
34
+ end
35
+ end
@@ -44,7 +44,7 @@ module Imperium
44
44
  private
45
45
 
46
46
  def parsed_body
47
- JSON.parse(content)
47
+ @parsed_body ||= JSON.parse(content)
48
48
  end
49
49
  end
50
50
  end
@@ -1,3 +1,3 @@
1
1
  module Imperium
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Pickett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-19 00:00:00.000000000 Z
11
+ date: 2017-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -160,6 +160,8 @@ files:
160
160
  - lib/imperium/client.rb
161
161
  - lib/imperium/configuration.rb
162
162
  - lib/imperium/error.rb
163
+ - lib/imperium/event_fire_response.rb
164
+ - lib/imperium/events.rb
163
165
  - lib/imperium/http_client.rb
164
166
  - lib/imperium/kv.rb
165
167
  - lib/imperium/kv_get_response.rb