Module: Rundeck::Client::Token

Included in:
Rundeck::Client
Defined in:
lib/rundeck/client/token.rb

Overview

Defines methods related to managing security.

Instance Method Summary collapse

Instance Method Details

#create_token(user, options = {}) ⇒ Rundeck::ObjectifiedHash

Create a new token for a user

Examples:

Rundeck.create_token('user1')

Parameters:

Options Hash (options):

  • :query (Hash)

    The parameters to pass with the request Use this hash to specify Rundeck parameters.

    • query: { project: ‘anvils’, id: ‘123456’ }

Returns:

Raises:



45
46
47
# File 'lib/rundeck/client/token.rb', line 45

def create_token(user, options = {})
  objectify post("/tokens/#{user}", options)['token']
end

#delete_token(id, options = {}) ⇒ nil

Delete a token

Examples:

Rundeck.delete_token('cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd')

Parameters:

Options Hash (options):

  • :query (Hash)

    The parameters to pass with the request Use this hash to specify Rundeck parameters.

    • query: { project: ‘anvils’, id: ‘123456’ }

Returns:

  • (nil)

    if the delete is successful

Raises:



58
59
60
# File 'lib/rundeck/client/token.rb', line 58

def delete_token(id, options = {})
  delete("/token/#{id}", options)
end

#token(id, options = {}) ⇒ Rundeck::ObjectifiedHash

Get a specific token

Examples:

Rundeck.token('admin')

Parameters:

Options Hash (options):

  • :query (Hash)

    The parameters to pass with the request Use this hash to specify Rundeck parameters.

    • query: { project: ‘anvils’, id: ‘123456’ }

Returns:

Raises:



32
33
34
# File 'lib/rundeck/client/token.rb', line 32

def token(id, options = {})
  objectify get("/token/#{id}", options)['token']
end

#tokens(user = nil, options = {}) ⇒ Rundeck::ObjectifiedHash+

List all tokens, or all tokens for a specific user.

Examples:

Rundeck.tokens
Rundeck.tokens('admin')

Parameters:

Options Hash (options):

  • :query (Hash)

    The parameters to pass with the request Use this hash to specify Rundeck parameters.

    • query: { project: ‘anvils’, id: ‘123456’ }

Returns:

Raises:



18
19
20
21
# File 'lib/rundeck/client/token.rb', line 18

def tokens(user = nil, options = {})
  path = user.nil? ? '/tokens' : "/tokens/#{user}"
  objectify get(path, options)['tokens']
end