Module: DeltaCloud
- Defined in:
- lib/errors.rb,
lib/deltacloud.rb,
lib/base_object.rb,
lib/documentation.rb,
lib/hwp_properties.rb,
lib/instance_state.rb
Overview
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Modules: HTTPError, HWP, InstanceState Classes: API, ActionObject, BaseObject, BaseObjectParamError, Documentation, NoHandlerForMethod, StatefulObject
Class Method Summary collapse
- .add_class(name, parent = :base) ⇒ Object
-
.driver_name(url) ⇒ Object
Return a API driver for specified URL.
- .guess_model_type(response) ⇒ Object
-
.new(user_name, password, api_url, &block) ⇒ DeltaCloud::API
Get a new API client instance.
-
.valid_credentials?(user_name, password, api_url, opts = {}) ⇒ true|false
Check given credentials if their are valid against backend cloud provider.
Class Method Details
.add_class(name, parent = :base) ⇒ Object
361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/base_object.rb', line 361 def self.add_class(name, parent=:base) parent = parent.to_s parent_class = "#{parent.classify}Object" @defined_classes ||= [] class_name = "#{parent.classify}::#{name.classify}" unless @defined_classes.include?(class_name) DeltaCloud::API.class_eval("class #{class_name} < DeltaCloud::#{parent_class}; end") @defined_classes << class_name end DeltaCloud::API.const_get(parent.classify).const_get(name.classify) end |
.driver_name(url) ⇒ Object
Return a API driver for specified URL
64 65 66 |
# File 'lib/deltacloud.rb', line 64 def self.driver_name(url) API.new(nil, nil, url).driver_name end |
.guess_model_type(response) ⇒ Object
374 375 376 377 378 379 |
# File 'lib/base_object.rb', line 374 def self.guess_model_type(response) response = Nokogiri::XML(response.to_s) return :action if ((response/'//actions').length >= 1) and ((response/'//state').length == 0) return :stateful if ((response/'//actions').length >= 1) and ((response/'//state').length >= 1) return :base end |
.new(user_name, password, api_url, &block) ⇒ DeltaCloud::API
Get a new API client instance
def self.new(user_name, password, api_url, opts={}, &block)
opts ||= {}
API.new(user_name, password, api_url, opts, &block)
end
41 42 43 |
# File 'lib/deltacloud.rb', line 41 def self.new(user_name, password, api_url, &block) API.new(user_name, password, api_url, &block) end |
.valid_credentials?(user_name, password, api_url, opts = {}) ⇒ true|false
Check given credentials if their are valid against backend cloud provider
52 53 54 55 56 57 58 59 |
# File 'lib/deltacloud.rb', line 52 def self.valid_credentials?(user_name, password, api_url, opts={}) api=API.new(user_name, password, api_url, opts) result = false api.request(:get, '', :force_auth => '1') do |response| result = true if response.code.eql?(200) end return result end |