class Fog::Image::HuaweiCloud::V2::Real
Public Class Methods
new(options = {})
click to toggle source
# File lib/fog/image/huaweicloud/v2.rb, line 113 def initialize(options = {}) initialize_identity options @huaweicloud_service_type = options[:huaweicloud_service_type] || ['image'] @huaweicloud_service_name = options[:huaweicloud_service_name] @huaweicloud_endpoint_type = options[:huaweicloud_endpoint_type] || 'adminURL' @connection_options = options[:connection_options] || {} authenticate set_api_path @persistent = options[:persistent] || false @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end
not_found_class()
click to toggle source
# File lib/fog/image/huaweicloud/v2.rb, line 109 def self.not_found_class Fog::Image::HuaweiCloud::NotFound end
Public Instance Methods
add_member_to_image(image_id, tenant_id)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/add_member_to_image.rb, line 6 def add_member_to_image(image_id, tenant_id) request( :expects => [200], :method => 'POST', :path => "images/#{image_id}/members", :body => Fog::JSON.encode(:member => tenant_id) ) end
add_tag_to_image(image_id, tag)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/add_tag_to_image.rb, line 6 def add_tag_to_image(image_id, tag) request( :expects => [204], :method => 'PUT', :path => "images/#{image_id}/tags/#{tag}" ) end
create_image(image)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/create_image.rb, line 6 def create_image(image) location = image.delete :location headers = {} headers["Location"] = location if location request( :headers => headers, :expects => [201], :method => 'POST', :path => "images", :body => Fog::JSON.encode(image) ) end
deactivate_image(image_id)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/deactivate_image.rb, line 6 def deactivate_image(image_id) request( :expects => 204, :method => 'POST', :path => "images/#{image_id}/actions/deactivate" ) end
delete_image(image_id)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/delete_image.rb, line 6 def delete_image(image_id) request( :expects => 204, :method => 'DELETE', :path => "images/#{image_id}" ) end
download_image(image_id, _content_range = nil, params)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/download_image.rb, line 6 def download_image(image_id, _content_range = nil, params) # TODO: implement content range handling request_hash = { :expects => [200, 204], :method => 'GET', :raw_body => true, :path => "images/#{image_id}/file", } request_hash[:response_block] = params[:response_block] if params[:response_block] request(request_hash).body end
get_image(image_id)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/get_image.rb, line 6 def get_image(image_id) request( :expects => [200, 204], :method => 'HEAD', :path => "images/#{image_id}" ) end
get_image_by_id(image_id)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/get_image_by_id.rb, line 6 def get_image_by_id(image_id) request( :expects => [200], :method => 'GET', :path => "images/#{image_id}" ) end
get_image_members(image_id)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/get_image_members.rb, line 6 def get_image_members(image_id) request( :expects => [200, 204], :method => 'GET', :path => "images/#{image_id}/members" ) end
get_member_details(image_id, member_id)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/get_member_details.rb, line 6 def get_member_details(image_id, member_id) request( :expects => [200], :method => 'GET', :path => "images/#{image_id}/members/#{member_id}" ).body end
list_images(options = {})
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/list_images.rb, line 6 def list_images(options = {}) request( :expects => [200], :method => 'GET', :path => 'images', :query => options ) end
reactivate_image(image_id)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/reactivate_image.rb, line 6 def reactivate_image(image_id) request( :expects => 204, :method => 'POST', :path => "images/#{image_id}/actions/reactivate" ) end
remove_member_from_image(image_id, member_id)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/remove_member_from_image.rb, line 6 def remove_member_from_image(image_id, member_id) request( :expects => [200, 204], :method => 'DELETE', :path => "images/#{image_id}/members/#{member_id}" ) end
remove_tag_from_image(image_id, tag)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/remove_tag_from_image.rb, line 6 def remove_tag_from_image(image_id, tag) request( :expects => [204], :method => 'DELETE', :path => "images/#{image_id}/tags/#{tag}" ) end
set_api_path()
click to toggle source
# File lib/fog/image/huaweicloud/v2.rb, line 129 def set_api_path unless @path.match(SUPPORTED_VERSIONS) @path = Fog::HuaweiCloud.get_supported_version_path(SUPPORTED_VERSIONS, @huaweicloud_management_uri, @auth_token, @connection_options) end end
set_tenant(tenant)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/set_tenant.rb, line 6 def set_tenant(tenant) @huaweicloud_must_reauthenticate = true @huaweicloud_tenant = tenant.to_s authenticate end
update_image(id, json_patch)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/update_image.rb, line 6 def update_image(id, json_patch) request( :headers => {'Content-Type' => 'application/openstack-images-v2.1-json-patch'}, :expects => [200], :method => 'PATCH', :path => "images/#{id}", :body => Fog::JSON.encode(json_patch) ) end
update_image_member(image_id, member)
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/update_image_member.rb, line 6 def update_image_member(image_id, member) request( # 'status' is the only property we can update :body => Fog::JSON.encode(member.select { |key, _value| key == 'status' }), :expects => [200], :method => 'PUT', :path => "images/#{image_id}/members/#{member['member_id']}" ) end
upload_image(image_id, body, params = {})
click to toggle source
# File lib/fog/image/huaweicloud/v2/requests/upload_image.rb, line 6 def upload_image(image_id, body, params = {}) request_hash = { :headers => {'Content-Type' => 'application/octet-stream'}, :expects => 204, :method => 'PUT', :path => "images/#{image_id}/file" } request_hash[:request_block] = params[:request_block] if params[:request_block] request_hash[:body] = body if body request(request_hash).body ensure body.close if body.respond_to?(:close) end