class IBM::Cloud::SDK::IAM

Attributes

api_key[R]

Public Class Methods

new(api_key) click to toggle source
# File lib/ibm/cloud/sdk/iam.rb, line 13
def initialize(api_key)
  @api_key = api_key
  RestClient.log = logger
end

Public Instance Methods

endpoint() click to toggle source
# File lib/ibm/cloud/sdk/iam.rb, line 9
def endpoint
  "https://iam.cloud.ibm.com".freeze
end
get_identity_token() click to toggle source
# File lib/ibm/cloud/sdk/iam.rb, line 18
def get_identity_token
  payload = {
    :grant_type => "urn:ibm:params:oauth:grant-type:apikey",
    :apikey     => api_key
  }

  result = post("identity/token", payload)

  require "ibm/cloud/sdk/iam/token"
  Token.new(*result.values_at("token_type", "access_token"))
end

Private Instance Methods

headers() click to toggle source
# File lib/ibm/cloud/sdk/iam.rb, line 34
def headers
  {
    "Content-Type" => "application/x-www-form-urlencoded",
    "Accept"       => "application/json"
  }
end