Class: Runcible::Resources::Role

Inherits:
Base
  • Object
show all
Defined in:
lib/runcible/resources/role.rb

Overview

Class Method Summary collapse

Methods inherited from Base

add_http_auth_header, add_oauth_header, call, combine_get_params, config, config=, generate_log_message, generate_payload, get_response, log_debug, log_exception, process_response, required_params

Class Method Details

.add(id, login) ⇒ RestClient::Response

Adds a user to a role

Parameters:

  • id (String)

    the ID of the role

  • login (String)

    the login of the user being added

Returns:

  • (RestClient::Response)


43
44
45
46
# File 'lib/runcible/resources/role.rb', line 43

def self.add(id, )
  required = required_params(binding.send(:local_variables), binding, ["id"])
  call(:post, "#{path(id)}users/", :payload => { :required => required })
end

.path(id = nil) ⇒ String

Generates the API path for Roles

Parameters:

  • id (String) (defaults to: nil)

    the ID of the role

Returns:

  • (String)

    the role path, may contain the ID if passed



34
35
36
# File 'lib/runcible/resources/role.rb', line 34

def self.path(id=nil)
  (id == nil) ? "roles/" : "roles/#{id}/" 
end

.remove(id, login) ⇒ RestClient::Response

Removes a user from a role

Parameters:

  • id (String)

    the ID of the role

  • login (String)

    the login of the user being removed

Returns:

  • (RestClient::Response)


53
54
55
# File 'lib/runcible/resources/role.rb', line 53

def self.remove(id, )
  call(:delete, "#{path(id)}users/#{}/")
end