Sha256: cf72f6b5d9ffd6768f7ad5737d06ce05e956a3098627ca4acdea557635e7362a

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

module Fog
  module Identity
    class HuaweiCloud
      class V2
        class Real
          ##
          # Retrieves an EC2 credential for a user.  Requires administrator
          # credentials.
          #
          # ==== Parameters
          # * user_id<~String>: The id of the user to retrieve the credential
          #   for
          # * access<~String>: The access key of the credential to retrieve
          #
          # ==== Returns
          # * response<~Excon::Response>:
          #   * body<~Hash>:
          #     * 'credential'<~Hash>: The EC2 credential
          #       * 'access'<~String>: The access key
          #       * 'secret'<~String>: The secret key
          #       * 'user_id'<~String>: The user id
          #       * 'tenant_id'<~String>: The tenant id

          def get_ec2_credential(user_id, access)
            request(
              :expects => [200, 202],
              :method  => 'GET',
              :path    => "users/#{user_id}/credentials/OS-EC2/#{access}"
            )
          rescue Excon::Errors::Unauthorized
            raise Fog::Identity::HuaweiCloud::NotFound
          end
        end

        class Mock
          def get_ec2_credential(user_id, access)
            ec2_credential = data[:ec2_credentials][user_id][access]

            raise Fog::HuaweiCloud::Identity::NotFound unless ec2_credential

            response = Excon::Response.new
            response.status = 200
            response.body = {'credential' => ec2_credential}
            response
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/identity/huaweicloud/v2/requests/get_ec2_credential.rb
fog-huaweicloud-0.0.2 lib/fog/identity/huaweicloud/v2/requests/get_ec2_credential.rb
fog-huaweicloud-0.1.3 lib/fog/identity/huaweicloud/v2/requests/get_ec2_credential.rb
fog-huaweicloud-0.1.2 lib/fog/identity/huaweicloud/v2/requests/get_ec2_credential.rb