module Jamf::Connection::DefaultConnection
Jamf
module methods and aliases for dealing with the default connection This is extended into the Jamf
module itself
Public Instance Methods
The current default Jamf::Connection
instance.
@return [Jamf::Connection]
# File lib/jamf/api/connection/default_connection.rb 40 def cnx 41 @default_connection ||= Jamf::Connection.new name: :default 42 end
Use the given Jamf::Connection
object as the default connection, replacing the one that currently exists.
@param connection [Jamf::Connection] The default Connection
to use for future
API calls
@return [APIConnection] The connection now being used.
# File lib/jamf/api/connection/default_connection.rb 75 def cnx=(connection) 76 raise 'API connections must be instances of Jamf::Connection' unless connection.is_a? Jamf::Connection 77 78 @default_connection = connection 79 end
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
@param (See Jamf::Connection#initialize)
@return [String] the to_s output of the new connection
# File lib/jamf/api/connection/default_connection.rb 56 def connect(url = nil, **params) 57 params[:name] ||= :default 58 @default_connection = Jamf::Connection.new url, **params 59 @default_connection.to_s 60 end
Disconnect the default connection
# File lib/jamf/api/connection/default_connection.rb 87 def disconnect 88 @default_connection.disconnect if @default_connection&.connected? 89 end
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.
# File lib/jamf/api/connection/default_connection.rb 95 def logout 96 @default_connection.logout if @default_connection&.connected? 97 end