class TencentCloud::Common::Credential

Attributes

secret_id[RW]
secret_key[RW]
token[RW]

Public Class Methods

new(secret_id, secret_key, token = nil) click to toggle source

Tencent Cloud Credentials. Access console.cloud.tencent.com/cam/capi to manage your credentials. :param secret_id: The secret id of your credential. :type secret_id: string :param secret_key: The secret key of your credential. :type secret_key: string :param token: The federation token of your credential, if this field

is specified, secret_id and secret_key should be set
accordingly, see: https://cloud.tencent.com/document/product/598/13896
# File lib/tencent_cloud/common/credential.rb, line 18
def initialize(secret_id, secret_key, token = nil)
  self.secret_id = secret_id if validate(:secret_id, secret_id)
  self.secret_key = secret_key if validate(:secret_key, secret_key)
  self.token = token
end

Private Instance Methods

validate(key, value) click to toggle source
# File lib/tencent_cloud/common/credential.rb, line 26
def validate(key, value)
  value = value.to_s
  if value.nil? || value.strip.empty?
    raise Exception::TencentCloudSDKException, "InvalidCredential, #{key} should not be none or empty"
  end
  raise TencentCloudSDKException("InvalidCredential, #{key} should not contain spaces") if value.strip != value

  true
end