Class: Rancher::Client
- Inherits:
-
Object
- Object
- Rancher::Client
- Includes:
- Authentication, Classify, Configurable, Connection
- Defined in:
- lib/rancher/client.rb
Overview
The Main Client for talking with Rancher
Constant Summary collapse
- CONVENIENCE_HEADERS =
Header keys that can be passed in options hash to Rancher::Connection#get,Rancher::Connection#head
Set.new([:accept, :content_type])
Instance Attribute Summary collapse
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Attributes included from Configurable
#access_key, #api_endpoint, #connection_options, #default_media_type, #middleware, #proxy, #secret_key, #user_agent
Instance Method Summary collapse
-
#access_key=(value) ⇒ Object
Set Rancher access_key.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ String
Text representation of the client, masking tokens and passwords.
- #load_schema ⇒ Object
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
-
#secret_key=(value) ⇒ Object
Set Rancher secret_key.
Methods included from Classify
Methods included from Connection
#agent, #delete, #get, #head, #last_response, #paginate, #patch, #post, #put, #root
Methods included from Authentication
Methods included from Configurable
#configure, keys, #reset!, #same_options?
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rancher/client.rb', line 20 def initialize( = {}) # Use options passed in, but fall back to module defaults @types = {} Rancher::Configurable.keys.each do |key| instance_variable_set( :"@#{key}", [key] || Rancher.instance_variable_get(:"@#{key}") ) end load_schema end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
74 75 76 77 78 |
# File 'lib/rancher/client.rb', line 74 def method_missing(method_name, *args, &block) return @types[method_name] if respond_to?(method_name) super end |
Instance Attribute Details
#types ⇒ Object (readonly)
Returns the value of attribute types.
15 16 17 |
# File 'lib/rancher/client.rb', line 15 def types @types end |
Instance Method Details
#access_key=(value) ⇒ Object
Set Rancher access_key
57 58 59 60 |
# File 'lib/rancher/client.rb', line 57 def access_key=(value) reset_agent @access_key = value end |
#inspect ⇒ String
Text representation of the client, masking tokens and passwords
44 45 46 47 48 49 50 51 52 |
# File 'lib/rancher/client.rb', line 44 def inspect inspected = super if @secret_key inspected = inspected.gsub! @secret_key, "#{'*'*36}#{@secret_key[36..-1]}" end inspected end |
#load_schema ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rancher/client.rb', line 33 def load_schema response = get 'schema' response.each do |res| @types[res.get_id.to_sym] = Rancher::Type.new(res) end if response.is_a?(Rancher::Collection) end |
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
70 71 72 |
# File 'lib/rancher/client.rb', line 70 def respond_to_missing?(method_name, _include_private = false) (@types.key?(method_name)) end |
#secret_key=(value) ⇒ Object
Set Rancher secret_key
65 66 67 68 |
# File 'lib/rancher/client.rb', line 65 def secret_key=(value) reset_agent @secret_key = value end |