Class: GlobusClient::Identity

Inherits:
Object
  • Object
show all
Defined in:
lib/globus_client/identity.rb

Overview

Lookup of a Globus identity ID

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Identity

Returns a new instance of Identity.



6
7
8
# File 'lib/globus_client/identity.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#get_identity(user_id) ⇒ Hash

Returns id and status of Globus identity.

Parameters:

  • user_id (String)

    the username in the form of an email addresss

Returns:

  • (Hash)

    id and status of Globus identity



12
13
14
15
16
17
18
19
20
# File 'lib/globus_client/identity.rb', line 12

def get_identity(user_id)
  response = client.get(
    base_url: client.config.auth_url,
    path: '/v2/api/identities',
    params: { usernames: user_id }
  )

  response['identities'].find { |id| id['username'] == user_id }
end

#get_identity_id(user_id) ⇒ String

Returns UUID for Globus identity.

Parameters:

  • user_id (String)

    the username in the form of an email addresss

Returns:

  • (String)

    UUID for Globus identity



30
31
32
# File 'lib/globus_client/identity.rb', line 30

def get_identity_id(user_id)
  get_identity(user_id)['id']
end

#valid?(user_id) ⇒ Boolean

Returns whether the account has a valid status.

Parameters:

  • user_id (String)

    the username in the form of an email addresss

Returns:

  • (Boolean)

    whether the account has a valid status



24
25
26
# File 'lib/globus_client/identity.rb', line 24

def valid?(user_id)
  %w[used private unused].include?(get_identity(user_id)['status'])
end