Class: Code42::Client
- Inherits:
-
Object
- Object
- Code42::Client
- Includes:
- API::Computer, API::Org, API::PasswordReset, API::Role, API::Token, API::User
- Defined in:
- lib/code42/client.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
-
#block_computer(id) ⇒ Code42::Computer
Block a computer from backing up.
- #connection ⇒ Object
- #deactivate_org(id) ⇒ Object
- #diagnostic ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #last_response ⇒ Object
-
#ping ⇒ Boolean
Pings the server.
- #unblock_computer(id) ⇒ Object
-
#use_basic_auth(username, password) ⇒ Object
Use basic authentication for future requests.
-
#use_token_auth(token) ⇒ Object
Use token authentication for future requests.
Methods included from API::PasswordReset
Methods included from API::Token
#delete_token, #get_login_token, #get_token, #validate_token
Methods included from API::Computer
Methods included from API::Org
#activate_org, #block_org, #create_org, #create_pro_org, #find_inactive_org_by_name, #find_org_by_name, #org, #orgs, #search_orgs, #unblock_org, #update_org
Methods included from API::Role
#assign_role, #create_role, #delete_role, #role, #roles, #unassign_role, #update_role, #user_roles
Methods included from API::User
#activate_user, #block_user, #create_user, #deactivate_user, #find_user_by_channel_id, #find_user_by_id, #find_user_by_username, #permissions, #unblock_user, #update_user, #user, #user_exists?, #users
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 |
# File 'lib/code42/client.rb', line 15 def initialize( = {}) self.settings = end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
13 14 15 |
# File 'lib/code42/client.rb', line 13 def settings @settings end |
Instance Method Details
#block_computer(id) ⇒ Code42::Computer
Block a computer from backing up
53 54 55 |
# File 'lib/code42/client.rb', line 53 def block_computer(id) put("computerblock/#{id}") end |
#connection ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/code42/client.rb', line 65 def connection @connection ||= begin connection = Connection.new settings.debug && connection.use(Faraday::Response::Logger) connection end @connection.host = settings.host @connection.port = settings.port @connection.scheme = settings.scheme @connection.path_prefix = settings.api_root @connection.verify_https = settings.verify_https if settings.username && settings.password @connection.username = settings.username @connection.password = settings.password end if settings.token @connection.token = settings.token end @connection end |
#deactivate_org(id) ⇒ Object
61 62 63 |
# File 'lib/code42/client.rb', line 61 def deactivate_org(id) put("OrgDeactivation/#{id}") end |
#diagnostic ⇒ Object
46 47 48 |
# File 'lib/code42/client.rb', line 46 def diagnostic object_from_response(Diagnostic, :get, 'diagnostic') end |
#last_response ⇒ Object
19 |
# File 'lib/code42/client.rb', line 19 def last_response; connection.last_response; end |
#ping ⇒ Boolean
Pings the server
27 28 29 |
# File 'lib/code42/client.rb', line 27 def ping get('ping')['data']['success'] end |
#unblock_computer(id) ⇒ Object
57 58 59 |
# File 'lib/code42/client.rb', line 57 def unblock_computer(id) delete("computerblock/#{id}") end |
#use_basic_auth(username, password) ⇒ Object
Use basic authentication for future requests
34 35 36 37 38 |
# File 'lib/code42/client.rb', line 34 def use_basic_auth(username, password) settings.token = nil settings.username = username settings.password = password end |
#use_token_auth(token) ⇒ Object
Use token authentication for future requests
42 43 44 |
# File 'lib/code42/client.rb', line 42 def use_token_auth(token) settings.token = token.to_s end |