Class: Code42::Client
- Inherits:
-
Object
- Object
- Code42::Client
- Includes:
- API::Computer, API::Org, 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
- #diagnostic ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#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::Token
#delete_token, #get_login_token, #get_token, #validate_token
Methods included from API::Computer
Methods included from API::Org
#create_org, #create_pro_org, #find_org_by_name, #org, #orgs, #search_orgs, #update_org
Methods included from API::Role
Methods included from API::User
#block_user, #create_user, #find_user_by_channel_id, #find_user_by_id, #find_user_by_username, #unblock_user, #user, #user_exists?, #users
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/code42/client.rb', line 14 def initialize( = {}) self.settings = end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
12 13 14 |
# File 'lib/code42/client.rb', line 12 def settings @settings end |
Instance Method Details
#block_computer(id) ⇒ Code42::Computer
Block a computer from backing up
50 51 52 |
# File 'lib/code42/client.rb', line 50 def block_computer(id) put("computerblock/#{id}") end |
#connection ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/code42/client.rb', line 58 def connection @connection = Connection.new( host: settings.host, port: settings.port, scheme: settings.scheme, path_prefix: settings.api_root, verify_https: settings.verify_https, ) if settings.debug @connection.use Faraday::Response::Logger end if settings.username && settings.password @connection.username = settings.username @connection.password = settings.password end if settings.token @connection.token = settings.token end @connection end |
#diagnostic ⇒ Object
43 44 45 |
# File 'lib/code42/client.rb', line 43 def diagnostic object_from_response(Diagnostic, :get, 'diagnostic') end |
#ping ⇒ Boolean
Pings the server
24 25 26 |
# File 'lib/code42/client.rb', line 24 def ping get('ping')['data']['success'] end |
#unblock_computer(id) ⇒ Object
54 55 56 |
# File 'lib/code42/client.rb', line 54 def unblock_computer(id) delete("computerblock/#{id}") end |
#use_basic_auth(username, password) ⇒ Object
Use basic authentication for future requests
31 32 33 34 35 |
# File 'lib/code42/client.rb', line 31 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
39 40 41 |
# File 'lib/code42/client.rb', line 39 def use_token_auth(token) settings.token = token.to_s end |