Class: Code42::Client
- Inherits:
-
Object
- Object
- Code42::Client
- Extended by:
- Forwardable
- Includes:
- API::Computer, API::Destination, API::Diagnostic, API::Org, API::PasswordReset, API::ProductLicense, API::Role, API::Server, API::ServerConnectionString, API::ServerSettings, API::StorePoint, 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
- #connection ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #last_response ⇒ Object
-
#ping ⇒ Boolean
Pings the server.
-
#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::ServerConnectionString
Methods included from API::Diagnostic
Methods included from API::StorePoint
#find_store_point_by_id, #find_store_points_by_name, #store_points, #update_store_point
Methods included from API::PasswordReset
Methods included from API::Server
#create_server, #server, #servers
Methods included from API::Destination
#create_destination, #destination, #destinations
Methods included from API::ServerSettings
#server_settings, #update_server_settings
Methods included from API::ProductLicense
#add_product_license, #product_licenses, #remove_product_license
Methods included from API::Token
#apply_mlk, #delete_token, #get_login_token, #get_token, #validate_token
Methods included from API::Computer
#block_computer, #computer, #computers, #unblock_computer
Methods included from API::Org
#activate_org, #block_org, #create_org, #create_pro_org, #deactivate_org, #find_inactive_org_by_name, #find_org_by_name, #org, #org_share_destinations, #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.
27 28 29 |
# File 'lib/code42/client.rb', line 27 def initialize( = {}) self.settings = end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
21 22 23 |
# File 'lib/code42/client.rb', line 21 def settings @settings end |
Instance Method Details
#connection ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/code42/client.rb', line 58 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 if settings.mlk @connection.mlk = settings.mlk end @connection end |
#last_response ⇒ Object
31 |
# File 'lib/code42/client.rb', line 31 def last_response; connection.last_response; end |
#ping ⇒ Boolean
Pings the server
39 40 41 |
# File 'lib/code42/client.rb', line 39 def ping get('ping')['data']['success'] end |
#use_basic_auth(username, password) ⇒ Object
Use basic authentication for future requests
46 47 48 49 50 |
# File 'lib/code42/client.rb', line 46 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
54 55 56 |
# File 'lib/code42/client.rb', line 54 def use_token_auth(token) settings.token = token.to_s end |