Module: Jamf::Connection::DefaultConnection
- Included in:
- Jamf
- Defined in:
- lib/jamf/api/connection/default_connection.rb
Overview
Jamf module methods and aliases for dealing with the default connection This is extended into the Jamf module itself
Instance Method Summary collapse
-
#cnx ⇒ Jamf::Connection
(also: #api, #api_connection, #connection, #default_connection)
The current default Jamf::Connection instance.
-
#cnx=(connection) ⇒ APIConnection
(also: #use_connection, #use_api_connection, #use_api, #activate_connection)
Use the given Jamf::Connection object as the default connection, replacing the one that currently exists.
-
#connect(url = nil, **params) ⇒ String
(also: #login, #new_api_connection, #new_api, #new_cnx, #new_connection)
Create a new Connection object and use it as the default for all future API calls.
-
#disconnect ⇒ Object
Disconnect the default connection.
-
#logout ⇒ Object
Log out the default connection This not only disconnects the connection, but tells the server to invalidate the token that was used, meaning that token cannot be used elsewhere before its expiration time.
Instance Method Details
#cnx ⇒ Jamf::Connection Also known as: api, api_connection, connection, default_connection
The current default Jamf::Connection instance.
40 41 42 |
# File 'lib/jamf/api/connection/default_connection.rb', line 40 def cnx @default_connection ||= Jamf::Connection.new name: :default end |
#cnx=(connection) ⇒ APIConnection Also known as: use_connection, use_api_connection, use_api, activate_connection
Use the given Jamf::Connection object as the default connection, replacing the one that currently exists.
75 76 77 78 79 |
# File 'lib/jamf/api/connection/default_connection.rb', line 75 def cnx=(connection) raise 'API connections must be instances of Jamf::Connection' unless connection.is_a? Jamf::Connection @default_connection = connection end |
#connect(url = nil, **params) ⇒ String Also known as: login, new_api_connection, new_api, new_cnx, new_connection
Create a new Connection object and use it as the default for all future API calls. This will replace the existing default connection with a totally new one
56 57 58 59 60 |
# File 'lib/jamf/api/connection/default_connection.rb', line 56 def connect(url = nil, **params) params[:name] ||= :default @default_connection = Jamf::Connection.new url, **params @default_connection.to_s end |
#disconnect ⇒ Object
Disconnect the default connection
87 88 89 |
# File 'lib/jamf/api/connection/default_connection.rb', line 87 def disconnect @default_connection.disconnect if @default_connection&.connected? end |
#logout ⇒ Object
Log out the default connection This not only disconnects the connection, but tells the server to invalidate the token that was used, meaning that token cannot be used elsewhere before its expiration time.
95 96 97 |
# File 'lib/jamf/api/connection/default_connection.rb', line 95 def logout @default_connection.logout if @default_connection&.connected? end |