Module: Unit::ApiToken::Org

Defined in:
lib/unit/models/api_token/api_token.rb,
lib/unit/models/api_token/org/create_api_token_request.rb

Defined Under Namespace

Classes: CreateApiTokenRequest

Class Method Summary collapse

Class Method Details

.create_api_token(user_id:, description:, scope:, expiration:, source_ip: nil, resources: nil) ⇒ UnitResponse, UnitError

Create a new Org API api_token by calling Unit’s API

Parameters:

  • user_id (String)
  • description (String)
  • scope (Array<String>)
  • expiration (Datetime)
  • source_ip (String) (defaults to: nil)
    • optional

  • resources (Array<RestrictedResource>) (defaults to: nil)
    • optional

Returns:

See Also:



18
19
20
21
# File 'lib/unit/models/api_token/api_token.rb', line 18

def create_api_token(user_id:, description:, scope:, expiration:, source_ip: nil, resources: nil)
  request = CreateApiTokenRequest.new(user_id, description, scope, expiration, source_ip, resources)
  Unit::Resource::ApiTokenResource.create_org_api_token(request)
end

.list_tokens(user_id:) ⇒ UnitResponse, UnitError

Get Org API tokens by calling Unit’s API

Parameters:

  • user_id (String)

Returns:

See Also:



27
28
29
# File 'lib/unit/models/api_token/api_token.rb', line 27

def list_tokens(user_id:)
  Unit::Resource::ApiTokenResource.list_org_tokens(user_id)
end

.revoke_token(user_id:, token_id:) ⇒ UnitResponse, UnitError

Revoke Org API api_token by calling Unit’s API

Parameters:

  • user_id (String)
  • token_id (String)

Returns:

See Also:



36
37
38
# File 'lib/unit/models/api_token/api_token.rb', line 36

def revoke_token(user_id:, token_id:)
  Unit::Resource::ApiTokenResource.revoke_org_token(user_id, token_id)
end