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.
23 24 25 |
# File 'lib/jamf/api/connection/default_connection.rb', line 23 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.
58 59 60 61 62 |
# File 'lib/jamf/api/connection/default_connection.rb', line 58 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
39 40 41 42 43 |
# File 'lib/jamf/api/connection/default_connection.rb', line 39 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
70 71 72 |
# File 'lib/jamf/api/connection/default_connection.rb', line 70 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.
78 79 80 |
# File 'lib/jamf/api/connection/default_connection.rb', line 78 def logout @default_connection.logout if @default_connection&.connected? end |