Class: OpConnect::Client
- Inherits:
-
Object
- Object
- OpConnect::Client
- Includes:
- Files, Items, Vaults, Configurable, Connection
- Defined in:
- lib/op_connect/client.rb,
lib/op_connect/client/files.rb,
lib/op_connect/client/items.rb,
lib/op_connect/client/vaults.rb
Defined Under Namespace
Instance Attribute Summary
Attributes included from Configurable
#access_token, #adapter, #api_endpoint, #stubs, #user_agent
Instance Method Summary collapse
- #activity(**params) ⇒ Object
- #health ⇒ Object
- #heartbeat ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
- #metrics ⇒ Object
Methods included from Files
#get_file, #get_file_content, #list_files
Methods included from Items
#create_item, #delete_item, #get_item, #list_items, #replace_item, #update_item
Methods included from Vaults
Methods included from Connection
#connection, #delete, #get, #last_response, #patch, #post, #put
Methods included from Configurable
#configure, keys, #reset!, #same_options?
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 |
# File 'lib/op_connect/client.rb', line 13 def initialize( = {}) OpConnect::Configurable.keys.each do |key| value = .key?(key) ? [key] : OpConnect.instance_variable_get(:"@#{key}") instance_variable_set(:"@#{key}", value) end end |
Instance Method Details
#activity(**params) ⇒ Object
26 27 28 |
# File 'lib/op_connect/client.rb', line 26 def activity(**params) get("activity", params: params).body.map { |a| APIRequest.new(a) } end |
#health ⇒ Object
37 38 39 |
# File 'lib/op_connect/client.rb', line 37 def health ServerHealth.new get("/health").body end |
#heartbeat ⇒ Object
30 31 32 33 34 35 |
# File 'lib/op_connect/client.rb', line 30 def heartbeat return true if get("/heartbeat").status == 200 false rescue OpConnect::Error false end |
#inspect ⇒ Object
20 21 22 23 24 |
# File 'lib/op_connect/client.rb', line 20 def inspect inspected = super inspected.gsub!(@access_token, ("*" * 24).to_s) if @access_token inspected end |
#metrics ⇒ Object
41 42 43 |
# File 'lib/op_connect/client.rb', line 41 def metrics get("/metrics").body end |