Module: Fog::Compute::Google::Shared
- Defined in:
- lib/fog/google/compute.rb,
lib/fog/google/requests/compute/delete_server.rb
Instance Attribute Summary collapse
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #build_excon_response(body, status = 200) ⇒ Object
- #find_zone(zone_name) ⇒ Object
- #shared_initialize(options = {}) ⇒ Object
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
149 150 151 |
# File 'lib/fog/google/compute.rb', line 149 def api_version @api_version end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
149 150 151 |
# File 'lib/fog/google/compute.rb', line 149 def project @project end |
Instance Method Details
#build_excon_response(body, status = 200) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/fog/google/compute.rb', line 159 def build_excon_response(body, status=200) response = Excon::Response.new response.body = body if response.body and response.body["error"] response.status = response.body["error"]["code"] if response.body["error"]["errors"] msg = response.body["error"]["errors"].map{|error| error["message"]}.join(", ") else msg = "Error [#{response.body["error"]["code"]}]: #{response.body["error"]["message"] || "GCE didn't return an error message"}" end case response.status when 404 raise Fog::Errors::NotFound.new(msg) else raise Fog::Errors::Error.new(msg) end else response.status = status end response end |
#find_zone(zone_name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/google/requests/compute/delete_server.rb', line 5 def find_zone(zone_name) if zone_name.nil? list_zones.body['items'].each do |zone| if get_server(server_name, zone['name']).status == 200 return zone['name'] end end else if zone_name.is_a? Excon::Response return zone_name.body["name"] end end return zone_name end |
#shared_initialize(options = {}) ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/fog/google/compute.rb', line 151 def shared_initialize( = {}) @project = [:google_project] @api_version = 'v1' base_url = 'https://www.googleapis.com/compute/' @api_url = base_url + api_version + '/projects/' @default_network = 'default' end |