module Jamf::Connection::Attributes

This module defines general attributes of a connection object

These attributes actually come from the token:

base_url, host, port, user, keep_alive?, ssl_version, verify_cert?,
ssl_options, pw_fallback?, jamf_version, jamf_build

There are convience getters defined for them below

Attributes

c_cnx[R]

@return [Faraday::Connection] the underlying C-API connection object

connect_time[R]

@return [Time] when this connection was connected

connected[R]

@return [Boolean] are we connected right now?

connected?[R]

@return [Boolean] are we connected right now?

jp_cnx[R]

@return [Faraday::Connection] the underlying JPAPI connection object

last_http_response[R]

@return [Faraday::Response] The response from the most recent API call

login_time[R]

@return [Time] when this connection was connected

name[R]

@return [String,Symbol] an arbitrary name that can be given to this

connection during initialization, using the name: parameter.
defaults to user@hostname:port
open_timeout[R]

@return [Integer] Seconds before an http connection open times out

server_path[R]

@return [String] any path in the URL below the hostname. See {#connect}

sticky?[R]

@return [Boolean] are we using a sticky session?

sticky_session[R]

@return [Boolean] are we using a sticky session?

sticky_session?[R]

@return [Boolean] are we using a sticky session?

timeout[R]

@return [Integer] Seconds before an http request times out

token[R]

@return [Jamf::Connection::Token] the token used for connecting

Public Instance Methods

base_url() click to toggle source

@return [URI::HTTPS] the base URL to the server

    # File lib/jamf/api/connection/attributes.rb
145 def base_url
146   validate_token
147   @token.base_url
148 end
host() click to toggle source

@return [String] the hostname of the Jamf Pro server API connection

    # File lib/jamf/api/connection/attributes.rb
151 def host
152   validate_token
153   @token.host
154 end
Also aliased as: server, hostname
hostname()
Alias for: host
jamf_build() click to toggle source

@return [String] the build of the Jamf Pro server

    # File lib/jamf/api/connection/attributes.rb
209 def jamf_build
210   validate_token
211   @token.jamf_build
212 end
jamf_version() click to toggle source

@return [Gem::Version] the version of the Jamf Pro server

    # File lib/jamf/api/connection/attributes.rb
203 def jamf_version
204   validate_token
205   @token.jamf_version
206 end
keep_alive?() click to toggle source

@return [Boolean] Is the connection token being automatically refreshed?

    # File lib/jamf/api/connection/attributes.rb
171 def keep_alive?
172   validate_token
173   @token.keep_alive?
174 end
open_timeout=(new_timeout) click to toggle source

Reset the open-connection timeout for the rest connection

@param timeout the new timeout in seconds

@return [void]

    # File lib/jamf/api/connection/attributes.rb
138 def open_timeout=(new_timeout)
139   @open_timeout = new_timeout.to_i
140   @c_cnx.options.open_timeout = @open_timeout if @c_cnx
141   @jp_cnx.options.open_timeout = @open_timeout if @jp_cnx
142 end
port() click to toggle source

@return [Integer] The port of the Jamf Pro server API connection

    # File lib/jamf/api/connection/attributes.rb
159 def port
160   validate_token
161   @token.port
162 end
pw_fallback?() click to toggle source

@return [Boolean] If keep_alive is true, is the password Cached in memory

to use if the refresh fails?
    # File lib/jamf/api/connection/attributes.rb
178 def pw_fallback?
179   validate_token
180   @token.pw_fallback?
181 end
server()
Alias for: host
ssl_options() click to toggle source

@return [Hash] the ssl version and verify cert, to pass into faraday connections

    # File lib/jamf/api/connection/attributes.rb
197 def ssl_options
198   validate_token
199   @token.ssl_options
200 end
ssl_version() click to toggle source

@return [String] SSL version used for the connection

    # File lib/jamf/api/connection/attributes.rb
184 def ssl_version
185   validate_token
186   @token.ssl_version
187 end
sticky_session=(value) click to toggle source

Turn sticky-sessions on or off. If turning on, host must be a Jamf Cloud server, with a hostname ending with Jamf::Connection::JAMFCLOUD_DOMAIN

@param value [Boolean] should we use a sticky session?

@return [void]

    # File lib/jamf/api/connection/attributes.rb
 98 def sticky_session=(value)
 99   @sticky_session ||= false
100 
101   # convert boolean-y to boolean
102   value = value ? true : false
103 
104   return if @sticky_session == value
105 
106   if value
107     raise Jamf::UnsupportedError, 'Sticky Sessions may only be used with Jamf Cloud servers.' unless host.end_with? Jamf::Connection::JAMFCLOUD_DOMAIN
108 
109     @sticky_session = true
110     enable_sticky_session Jamf.cnx.jp_cnx.head.headers
111 
112   else
113     @sticky_session = false
114     @sticky_session_cookie = nil
115     @c_cnx&.headers&.delete Jamf::Connection::COOKIE_HEADER
116     @jp_cnx&.headers&.delete Jamf::Connection::COOKIE_HEADER
117   end
118 end
timeout=(new_timeout) click to toggle source

Reset the response timeout for the rest connection

@param timeout the new timeout in seconds

@return [void]

    # File lib/jamf/api/connection/attributes.rb
126 def timeout=(new_timeout)
127   @timeout = new_timeout.to_i
128   @c_cnx.options.timeout = @timeout if @c_cnx
129   @jp_cnx.options.timeout = @timeout if @jp_cnx
130 end
user() click to toggle source

@return [String] the username who’s connected to the JSS API

    # File lib/jamf/api/connection/attributes.rb
165 def user
166   validate_token
167   @token.user
168 end
validate_token() click to toggle source

raise an error if no token yet @return [void]

    # File lib/jamf/api/connection/attributes.rb
216 def validate_token
217   raise Jamf::InvalidConnectionError, 'No token available, use #connect first' unless @token
218 end
verify_cert()
Alias for: verify_cert?
verify_cert?() click to toggle source

@return [Boolean] Should the SSL certifcate from the server be verified?

    # File lib/jamf/api/connection/attributes.rb
190 def verify_cert?
191   validate_token
192   @token.verify_cert?
193 end
Also aliased as: verify_cert