Module: DeltaCloud
- Defined in:
- lib/documentation.rb,
lib/deltacloud.rb,
lib/base_object.rb,
lib/hwp_properties.rb,
lib/instance_state.rb,
lib/plain_formatter.rb
Overview
Copyright © 2009 Red Hat, Inc.
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: HWP, InstanceState, PlainFormatter Classes: API, ActionObject, BaseObject, BaseObjectParamError, Documentation, NoHandlerForMethod, StateFullObject
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) ⇒ true|false
Check given credentials if their are valid against backend cloud provider.
Class Method Details
.add_class(name, parent = :base) ⇒ Object
265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/base_object.rb', line 265 def self.add_class(name, parent=:base) parent_class = case parent when :base then 'BaseObject' when :action then 'ActionObject' when :state then 'StateFullObject' end @defined_classes ||= [] if @defined_classes.include?(name) DeltaCloud::API.class_eval("#{name.classify}") else DeltaCloud::API.class_eval("class #{name.classify} < DeltaCloud::#{parent_class}; end") DeltaCloud::API.const_get("#{name.classify}") end end |
.driver_name(url) ⇒ Object
Return a API driver for specified URL
60 61 62 |
# File 'lib/deltacloud.rb', line 60 def self.driver_name(url) API.new(nil, nil, url).driver_name end |
.guess_model_type(response) ⇒ Object
280 281 282 283 284 285 |
# File 'lib/base_object.rb', line 280 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 :state 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
37 38 39 |
# File 'lib/deltacloud.rb', line 37 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) ⇒ true|false
Check given credentials if their are valid against backend cloud provider
48 49 50 51 52 53 54 55 |
# File 'lib/deltacloud.rb', line 48 def self.valid_credentials?(user_name, password, api_url) api=API.new(user_name, password, api_url) result = false api.request(:get, '', :force_auth => '1') do |response| result = true if response.code.eql?(200) end return result end |