Class: Hyperb::Client
Overview
client class
Constant Summary collapse
- REGIONS =
[ 'us-west-1', 'eu-central-1' ].freeze
Instance Attribute Summary collapse
-
#access_key ⇒ Object
Returns the value of attribute access_key.
-
#region ⇒ Object
Returns the value of attribute region.
-
#secret_key ⇒ Object
Returns the value of attribute secret_key.
Instance Method Summary collapse
- #blank?(val) ⇒ Boolean
- #credentials ⇒ Object
- #credentials? ⇒ Boolean
- #default_region ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
- #supported_region?(region) ⇒ Boolean
- #validate_and_set_region ⇒ Object
Methods included from Funcs
#call_func, #create_func, #funcs, #remove_func, #status_func
Methods included from Utils
#camelize, #check_arguments, #downcase_symbolize, #prepare_json, #underscore
Methods included from Compose
#compose_create, #compose_down, #compose_rm, #compose_up
Methods included from Services
#create_service, #inspect_service, #remove_service, #services
Methods included from Snapshots
Methods included from Network
#fip_allocate, #fip_attach, #fip_detach, #fip_name, #fip_release, #fips_ls
Methods included from Misc
Methods included from Volumes
#create_volume, #inspect_volume, #remove_volume, #volumes
Methods included from Containers
#container_logs, #container_stats, #containers, #create_container, #inspect_container, #kill_container, #remove_container, #rename_container, #start_container, #stop_container
Methods included from Images
#create_image, #images, #inspect_image, #remove_image
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 |
# File 'lib/hyperb/client.rb', line 16 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end validate_and_set_region yield(self) if block_given? end |
Instance Attribute Details
#access_key ⇒ Object
Returns the value of attribute access_key.
14 15 16 |
# File 'lib/hyperb/client.rb', line 14 def access_key @access_key end |
#region ⇒ Object
Returns the value of attribute region.
14 15 16 |
# File 'lib/hyperb/client.rb', line 14 def region @region end |
#secret_key ⇒ Object
Returns the value of attribute secret_key.
14 15 16 |
# File 'lib/hyperb/client.rb', line 14 def secret_key @secret_key end |
Instance Method Details
#blank?(val) ⇒ Boolean
51 52 53 |
# File 'lib/hyperb/client.rb', line 51 def blank?(val) val.respond_to?(:empty?) ? val.empty? : !val end |
#credentials ⇒ Object
40 41 42 43 44 45 |
# File 'lib/hyperb/client.rb', line 40 def credentials { secret_key: secret_key, access_key: access_key } end |
#credentials? ⇒ Boolean
47 48 49 |
# File 'lib/hyperb/client.rb', line 47 def credentials? credentials.values.none? { |cred| blank?(cred) } end |
#default_region ⇒ Object
32 33 34 |
# File 'lib/hyperb/client.rb', line 32 def default_region REGIONS.first end |
#supported_region?(region) ⇒ Boolean
36 37 38 |
# File 'lib/hyperb/client.rb', line 36 def supported_region?(region) REGIONS.include?(region.to_s) end |
#validate_and_set_region ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/hyperb/client.rb', line 24 def validate_and_set_region if @region.nil? @region = default_region else raise Hyperb::Error::UnsupportedRegion, @region.to_s unless supported_region?(@region) end end |