Class: Fog::KeyManager::HuaweiCloud::Real
- Inherits:
-
Object
- Object
- Fog::KeyManager::HuaweiCloud::Real
- Includes:
- HuaweiCloud::Core
- Defined in:
- lib/fog/key_manager/huaweicloud.rb,
lib/fog/key_manager/huaweicloud/requests/get_secret.rb,
lib/fog/key_manager/huaweicloud/requests/list_secrets.rb,
lib/fog/key_manager/huaweicloud/requests/create_secret.rb,
lib/fog/key_manager/huaweicloud/requests/delete_secret.rb,
lib/fog/key_manager/huaweicloud/requests/get_container.rb,
lib/fog/key_manager/huaweicloud/requests/get_secret_acl.rb,
lib/fog/key_manager/huaweicloud/requests/list_containers.rb,
lib/fog/key_manager/huaweicloud/requests/create_container.rb,
lib/fog/key_manager/huaweicloud/requests/delete_container.rb,
lib/fog/key_manager/huaweicloud/requests/delete_secret_acl.rb,
lib/fog/key_manager/huaweicloud/requests/get_container_acl.rb,
lib/fog/key_manager/huaweicloud/requests/update_secret_acl.rb,
lib/fog/key_manager/huaweicloud/requests/get_secret_payload.rb,
lib/fog/key_manager/huaweicloud/requests/replace_secret_acl.rb,
lib/fog/key_manager/huaweicloud/requests/get_secret_metadata.rb,
lib/fog/key_manager/huaweicloud/requests/delete_container_acl.rb,
lib/fog/key_manager/huaweicloud/requests/update_container_acl.rb,
lib/fog/key_manager/huaweicloud/requests/replace_container_acl.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_container(options) ⇒ Object
- #create_secret(options) ⇒ Object
- #delete_container(id) ⇒ Object
- #delete_container_acl(uuid) ⇒ Object
- #delete_secret(id) ⇒ Object
- #delete_secret_acl(uuid) ⇒ Object
- #get_container(uuid) ⇒ Object
- #get_container_acl(uuid) ⇒ Object
- #get_secret(uuid) ⇒ Object
- #get_secret_acl(uuid) ⇒ Object
- #get_secret_metadata(uuid) ⇒ Object
- #get_secret_payload(uuid) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_containers(options = {}) ⇒ Object
- #list_secrets(options = {}) ⇒ Object
- #replace_container_acl(uuid, options) ⇒ Object
- #replace_secret_acl(uuid, options) ⇒ Object
- #set_api_path ⇒ Object
- #supported_version(supported_versions, uri, auth_token, connection_options = {}) ⇒ Object
- #update_container_acl(uuid, options) ⇒ Object
- #update_secret_acl(uuid, options) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/fog/key_manager/huaweicloud.rb', line 99 def initialize( = {}) initialize_identity @huaweicloud_service_type = [:huaweicloud_service_type] || ['key-manager'] @huaweicloud_service_name = [:huaweicloud_service_name] @connection_options = [:connection_options] || {} authenticate set_api_path @persistent = [:persistent] || false @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Class Method Details
.not_found_class ⇒ Object
95 96 97 |
# File 'lib/fog/key_manager/huaweicloud.rb', line 95 def self.not_found_class Fog::KeyManager::HuaweiCloud::NotFound end |
Instance Method Details
#create_container(options) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/key_manager/huaweicloud/requests/create_container.rb', line 5 def create_container() request( :body => Fog::JSON.encode(), :expects => [201], :method => 'POST', :path => 'containers' ) end |
#create_secret(options) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/key_manager/huaweicloud/requests/create_secret.rb', line 5 def create_secret() request( :body => Fog::JSON.encode(), :expects => [201], :method => 'POST', :path => 'secrets' ) end |
#delete_container(id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/key_manager/huaweicloud/requests/delete_container.rb', line 5 def delete_container(id) request( :expects => [204], :method => 'DELETE', :path => "containers/#{id}" ) end |
#delete_container_acl(uuid) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/key_manager/huaweicloud/requests/delete_container_acl.rb', line 5 def delete_container_acl(uuid) request( :expects => [200], :method => 'DELETE', :path => "containers/#{uuid}/acl" ) end |
#delete_secret(id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/key_manager/huaweicloud/requests/delete_secret.rb', line 5 def delete_secret(id) request( :expects => [204], :method => 'DELETE', :path => "secrets/#{id}" ) end |
#delete_secret_acl(uuid) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/key_manager/huaweicloud/requests/delete_secret_acl.rb', line 5 def delete_secret_acl(uuid) request( :expects => [200], :method => 'DELETE', :path => "secrets/#{uuid}/acl" ) end |
#get_container(uuid) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/key_manager/huaweicloud/requests/get_container.rb', line 5 def get_container(uuid) request( :expects => [200], :method => 'GET', :path => "containers/#{uuid}", ) end |
#get_container_acl(uuid) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/key_manager/huaweicloud/requests/get_container_acl.rb', line 5 def get_container_acl(uuid) request( :expects => [200], :method => 'GET', :path => "containers/#{uuid}/acl" ) end |
#get_secret(uuid) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/key_manager/huaweicloud/requests/get_secret.rb', line 5 def get_secret(uuid) request( :expects => [200], :method => 'GET', :path => "secrets/#{uuid}", ) end |
#get_secret_acl(uuid) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/key_manager/huaweicloud/requests/get_secret_acl.rb', line 5 def get_secret_acl(uuid) request( :expects => [200], :method => 'GET', :path => "secrets/#{uuid}/acl" ) end |
#get_secret_metadata(uuid) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/key_manager/huaweicloud/requests/get_secret_metadata.rb', line 5 def (uuid) request( :expects => [200], :method => 'GET', :path => "secrets/#{uuid}/metadata", ) end |
#get_secret_payload(uuid) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/fog/key_manager/huaweicloud/requests/get_secret_payload.rb', line 5 def get_secret_payload(uuid) request( :expects => [200], :method => 'GET', :path => "secrets/#{uuid}/payload", :headers => { 'Accept' => '*/*' } ) end |
#list_containers(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/key_manager/huaweicloud/requests/list_containers.rb', line 5 def list_containers( = {}) request( :expects => [200], :method => 'GET', :path => 'containers', :query => ) end |
#list_secrets(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/key_manager/huaweicloud/requests/list_secrets.rb', line 5 def list_secrets( = {}) request( :expects => [200], :method => 'GET', :path => 'secrets', :query => ) end |
#replace_container_acl(uuid, options) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/key_manager/huaweicloud/requests/replace_container_acl.rb', line 5 def replace_container_acl(uuid, ) request( :body => Fog::JSON.encode(), :expects => [200], :method => 'PUT', :path => "containers/#{uuid}/acl" ) end |
#replace_secret_acl(uuid, options) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/key_manager/huaweicloud/requests/replace_secret_acl.rb', line 5 def replace_secret_acl(uuid, ) request( :body => Fog::JSON.encode(), :expects => [200], :method => 'PUT', :path => "secrets/#{uuid}/acl" ) end |
#set_api_path ⇒ Object
113 114 115 116 117 118 |
# File 'lib/fog/key_manager/huaweicloud.rb', line 113 def set_api_path @path.sub!(%r{/$}, '') unless @path.match(SUPPORTED_VERSIONS) @path = supported_version(SUPPORTED_VERSIONS, @huaweicloud_management_uri, @auth_token, @connection_options) end end |
#supported_version(supported_versions, uri, auth_token, connection_options = {}) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/fog/key_manager/huaweicloud.rb', line 120 def supported_version(supported_versions, uri, auth_token, = {}) connection = Fog::Core::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, ) response = connection.request({ :expects => [200, 204, 300], :headers => {'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => auth_token}, :method => 'GET' }) body = Fog::JSON.decode(response.body) version = nil versions = body.fetch('versions',{}).fetch('values',[]) versions.each do |v| if v.fetch('id', "").match(supported_versions) && ['current', 'supported', 'stable'].include?(v.fetch('status','').downcase) version = v['id'] end end if !version || version.empty? raise Fog::HuaweiCloud::Errors::ServiceUnavailable.new( "HuaweiCloud service only supports API versions #{supported_versions.inspect}") end version end |
#update_container_acl(uuid, options) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/key_manager/huaweicloud/requests/update_container_acl.rb', line 5 def update_container_acl(uuid, ) request( :body => Fog::JSON.encode(), :expects => [200], :method => 'PATCH', :path => "containers/#{uuid}/acl" ) end |
#update_secret_acl(uuid, options) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/key_manager/huaweicloud/requests/update_secret_acl.rb', line 5 def update_secret_acl(uuid, ) request( :body => Fog::JSON.encode(), :expects => [200], :method => 'PATCH', :path => "secrets/#{uuid}/acl" ) end |