Class: Runcible::Resources::Role

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

Overview

Instance Attribute Summary

Attributes inherited from Base

#logs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_http_auth_header, #add_oauth_header, #call, #combine_get_params, #config, #exception_to_log, #format_payload_json, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #log_info, #logger, #path, #process_response, #required_params

Constructor Details

This class inherits a constructor from Runcible::Base

Class Method Details

.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



9
10
11
# File 'lib/runcible/resources/role.rb', line 9

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

Instance 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)


18
19
20
21
# File 'lib/runcible/resources/role.rb', line 18

def add(id, )
  required = required_params(binding.send(:local_variables), binding, ['id'])
  call(:post, "#{path(id)}users/", :payload => { :required => required })
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)


28
29
30
# File 'lib/runcible/resources/role.rb', line 28

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