Class: Fog::Vcloud::Real
- Inherits:
-
Object
- Object
- Fog::Vcloud::Real
- Extended by:
- Generators
- Includes:
- Shared
- Defined in:
- lib/fog/vcloud.rb,
lib/fog/vcloud/requests/login.rb,
lib/fog/vcloud/requests/get_vdc.rb,
lib/fog/vcloud/requests/get_network.rb,
lib/fog/vcloud/requests/get_versions.rb,
lib/fog/vcloud/requests/get_organization.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#login_uri ⇒ Object
writeonly
Sets the attribute login_uri.
-
#versions_uri ⇒ Object
readonly
Returns the value of attribute versions_uri.
Instance Method Summary collapse
- #default_organization_uri ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #login ⇒ Object
- #reload ⇒ Object
-
#request(params) ⇒ Object
If the cookie isn’t set, do a get_organizations call to set it and try the request.
- #supporting_versions ⇒ Object
Methods included from Generators
basic_request, unauthenticated_basic_request
Methods included from Shared
#ensure_unparsed, #supported_versions, #xmlns
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
91 92 93 94 95 96 97 98 99 |
# File 'lib/fog/vcloud.rb', line 91 def initialize( = {}) @connections = {} @versions_uri = URI.parse([:versions_uri]) @module = [:module] @version = [:version] @username = [:username] @password = [:password] @persistent = [:persistent] end |
Instance Attribute Details
#login_uri=(value) ⇒ Object
Sets the attribute login_uri
84 85 86 |
# File 'lib/fog/vcloud.rb', line 84 def login_uri=(value) @login_uri = value end |
#versions_uri ⇒ Object (readonly)
Returns the value of attribute versions_uri.
85 86 87 |
# File 'lib/fog/vcloud.rb', line 85 def versions_uri @versions_uri end |
Instance Method Details
#default_organization_uri ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/fog/vcloud.rb', line 101 def default_organization_uri @default_organization_uri ||= begin unless @login_results do_login end case @login_results.body[:Org] when Array @login_results.body[:Org].first[:href] when Hash @login_results.body[:Org][:href] else nil end end end |
#login ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fog/vcloud/requests/login.rb', line 7 def login unauthenticated_request({ :expects => 200, :headers => { 'Authorization' => }, :method => 'POST', :parse => true, :uri => login_uri }) end |
#reload ⇒ Object
117 118 119 |
# File 'lib/fog/vcloud.rb', line 117 def reload @connections.each_value { |k,v| v.reset if v } end |
#request(params) ⇒ Object
If the cookie isn’t set, do a get_organizations call to set it and try the request. If we get an Unauthorized error, we assume the token expired, re-auth and try again
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/fog/vcloud.rb', line 124 def request(params) unless @cookie do_login end begin do_request(params) rescue Excon::Errors::Unauthorized => e do_login do_request(params) end end |
#supporting_versions ⇒ Object
87 88 89 |
# File 'lib/fog/vcloud.rb', line 87 def supporting_versions ["0.8"] end |