module Rundeck::Client::Token
Defines methods related to managing security.
Public Instance Methods
Create a new token for a user
@example
Rundeck.create_token('user1')
@param [String] user Create a token for this user @!macro options @return [Rundeck::ObjectifiedHash] @!macro exceptions
# File lib/rundeck/client/token.rb, line 45 def create_token(user, options = {}) objectify post("/tokens/#{user}", options)['token'] end
Delete a token
@example
Rundeck.delete_token('cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd')
@param [String] id The token id @!macro options @return [nil] if the delete is successful @!macro exceptions
# File lib/rundeck/client/token.rb, line 58 def delete_token(id, options = {}) delete("/token/#{id}", options) end
Get a specific token
@example
Rundeck.token('admin')
@param [String] id The token id @!macro options @return [Rundeck::ObjectifiedHash] @!macro exceptions
# File lib/rundeck/client/token.rb, line 32 def token(id, options = {}) objectify get("/token/#{id}", options)['token'] end
List all tokens, or all tokens for a specific user.
@example
Rundeck.tokens
@example
Rundeck.tokens('admin')
@param [String] user List tokens for this user. @!macro options @return [Rundeck::ObjectifiedHash] if there is only a single token @return [Array<Rundeck::ObjectifiedHash>] if there are multiple tokens @!macro exceptions
# 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