Class: IBM::Cloud::SDK::IAM

Inherits:
BaseService show all
Defined in:
lib/ibm/cloud/sdk/iam.rb,
lib/ibm/cloud/sdk/iam/token.rb

Defined Under Namespace

Classes: Token

Instance Method Summary collapse

Methods inherited from BaseService

#delete, endpoint, #get, #post

Constructor Details

#initialize(api_key) ⇒ IAM

Returns a new instance of IAM.



9
10
11
# File 'lib/ibm/cloud/sdk/iam.rb', line 9

def initialize(api_key)
  @api_key = api_key
end

Instance Method Details

#endpointObject



5
6
7
# File 'lib/ibm/cloud/sdk/iam.rb', line 5

def endpoint
  "https://iam.cloud.ibm.com".freeze
end

#get_identity_tokenObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ibm/cloud/sdk/iam.rb', line 13

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