Class: OpConnect::Client

Inherits:
Object
  • Object
show all
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

Modules: Files, Items, Vaults

Instance Attribute Summary

Attributes included from Configurable

#access_token, #adapter, #api_endpoint, #stubs, #user_agent

Instance Method Summary collapse

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

#get_vault, #list_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(options = {})
  OpConnect::Configurable.keys.each do |key|
    value = options.key?(key) ? options[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

#healthObject



37
38
39
# File 'lib/op_connect/client.rb', line 37

def health
  ServerHealth.new get("/health").body
end

#heartbeatObject



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

#inspectObject



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

#metricsObject



41
42
43
# File 'lib/op_connect/client.rb', line 41

def metrics
  get("/metrics").body
end