Class: CloudControl::Client
- Inherits:
-
Object
- Object
- CloudControl::Client
- Includes:
- Connection, Params
- Defined in:
- lib/cloudcontrol/client.rb
Constant Summary collapse
- IMAGES =
{suse_ent_64: "d4edfe22-e2f0-11e2-84e5-180373fb68df", ubuntu_14_04: "abef3a94-3361-4ce4-a937-5e587042586a", ubuntu_12_04: "d4ed6d40-e2f0-11e2-84e5-180373fb68df", ubuntu_10_04: "d4edba02-e2f0-11e2-84e5-180373fb68df"}
- API_URL =
{na: "https://api-na.dimensiondata.com/caas/2.8", eu: "https://api-eu.dimensiondata.com/caas/2.8", au: "https://api-au.dimensiondata.com/caas/2.8", mea: "https://api-mea.dimensiondata.com/caas/2.8", ap: "https://api-ap.dimensiondata.com/caas/2.8"}
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#api_base ⇒ Object
readonly
include CloudControl::XML.
-
#colors ⇒ Object
FILTERS client.page_size = 10 client.page_number = 1 client.order_by = ‘location,created.DESCENDING’ client.filter_with = %w(NA1 NA2), key: ‘value’.
-
#datacenter ⇒ Object
readonly
Returns the value of attribute datacenter.
-
#default_password ⇒ Object
readonly
Returns the value of attribute default_password.
-
#filter_with ⇒ Object
Returns the value of attribute filter_with.
-
#image ⇒ Object
readonly
def directory CloudControl::API::Directory.new(self) end.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#order_by ⇒ Object
Returns the value of attribute order_by.
-
#org_id ⇒ Object
readonly
include CloudControl::XML.
-
#page_number ⇒ Object
Returns the value of attribute page_number.
-
#page_size ⇒ Object
Returns the value of attribute page_size.
-
#password ⇒ Object
readonly
include CloudControl::XML.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#silent ⇒ Object
FILTERS client.page_size = 10 client.page_number = 1 client.order_by = ‘location,created.DESCENDING’ client.filter_with = %w(NA1 NA2), key: ‘value’.
-
#username ⇒ Object
readonly
include CloudControl::XML.
Instance Method Summary collapse
- #filter_params ⇒ Object
-
#initialize(api_base, org_id, username, password, colors = true, silent = true) ⇒ Client
constructor
A new instance of Client.
- #log(message, color = nil, mode = nil, error = nil) ⇒ Object
-
#log_error(message, color = nil, mode = nil) ⇒ Object
mode: bold, underscore, default.
- #vip ⇒ Object
Methods included from Params
#camelize_keys, #symbolize_keys, #underscore_keys, #url_query
Methods included from Connection
#append_query, #build_request, #log_response, #perform_request
Constructor Details
#initialize(api_base, org_id, username, password, colors = true, silent = true) ⇒ Client
Returns a new instance of Client.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cloudcontrol/client.rb', line 27 def initialize(api_base, org_id, username, password, colors = true, silent = true) @api_base = api_base @org_id = org_id @username = username @password = password @colors = colors @silent = silent if @colors require 'colorize' end end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
8 9 10 |
# File 'lib/cloudcontrol/client.rb', line 8 def account @account end |
#api_base ⇒ Object (readonly)
include CloudControl::XML
7 8 9 |
# File 'lib/cloudcontrol/client.rb', line 7 def api_base @api_base end |
#colors ⇒ Object
FILTERS client.page_size = 10 client.page_number = 1 client.order_by = ‘location,created.DESCENDING’ client.filter_with = %w(NA1 NA2), key: ‘value’
16 17 18 |
# File 'lib/cloudcontrol/client.rb', line 16 def colors @colors end |
#datacenter ⇒ Object (readonly)
Returns the value of attribute datacenter.
9 10 11 |
# File 'lib/cloudcontrol/client.rb', line 9 def datacenter @datacenter end |
#default_password ⇒ Object (readonly)
Returns the value of attribute default_password.
9 10 11 |
# File 'lib/cloudcontrol/client.rb', line 9 def default_password @default_password end |
#filter_with ⇒ Object
Returns the value of attribute filter_with.
17 18 19 |
# File 'lib/cloudcontrol/client.rb', line 17 def filter_with @filter_with end |
#image ⇒ Object (readonly)
44 45 46 |
# File 'lib/cloudcontrol/client.rb', line 44 def image @image end |
#network ⇒ Object (readonly)
Returns the value of attribute network.
8 9 10 |
# File 'lib/cloudcontrol/client.rb', line 8 def network @network end |
#order_by ⇒ Object
Returns the value of attribute order_by.
17 18 19 |
# File 'lib/cloudcontrol/client.rb', line 17 def order_by @order_by end |
#org_id ⇒ Object (readonly)
include CloudControl::XML
7 8 9 |
# File 'lib/cloudcontrol/client.rb', line 7 def org_id @org_id end |
#page_number ⇒ Object
Returns the value of attribute page_number.
17 18 19 |
# File 'lib/cloudcontrol/client.rb', line 17 def page_number @page_number end |
#page_size ⇒ Object
Returns the value of attribute page_size.
17 18 19 |
# File 'lib/cloudcontrol/client.rb', line 17 def page_size @page_size end |
#password ⇒ Object (readonly)
include CloudControl::XML
7 8 9 |
# File 'lib/cloudcontrol/client.rb', line 7 def password @password end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
8 9 10 |
# File 'lib/cloudcontrol/client.rb', line 8 def report @report end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
8 9 10 |
# File 'lib/cloudcontrol/client.rb', line 8 def server @server end |
#silent ⇒ Object
FILTERS client.page_size = 10 client.page_number = 1 client.order_by = ‘location,created.DESCENDING’ client.filter_with = %w(NA1 NA2), key: ‘value’
16 17 18 |
# File 'lib/cloudcontrol/client.rb', line 16 def silent @silent end |
#username ⇒ Object (readonly)
include CloudControl::XML
7 8 9 |
# File 'lib/cloudcontrol/client.rb', line 7 def username @username end |
Instance Method Details
#filter_params ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cloudcontrol/client.rb', line 68 def filter_params params = {} params[:page_size] = @page_size if @page_size.present? params[:page_number] = @page_number if @page_number.present? params[:order_by] = @order_by if @order_by.present? if @filter_with.present? @filter_with.each do |k, val| params[k.to_sym] = val end end params end |
#log(message, color = nil, mode = nil, error = nil) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/cloudcontrol/client.rb', line 86 def log(, color = nil, mode = nil, error=nil) return if (@silent && (not error)) if @colors color = color.to_sym if color mode = mode.to_sym if mode puts .colorize(:color => color, :mode => mode) else puts end end |
#log_error(message, color = nil, mode = nil) ⇒ Object
mode: bold, underscore, default
83 84 85 |
# File 'lib/cloudcontrol/client.rb', line 83 def log_error(, color=nil, mode=nil) log , color, mode, true end |
#vip ⇒ Object
64 65 66 |
# File 'lib/cloudcontrol/client.rb', line 64 def vip CloudControl::API::VIP.new(self) end |