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
@return [Faraday::Connection] the underlying C-API connection object
@return [Time] when this connection was connected
@return [Boolean] are we connected right now?
@return [Boolean] are we connected right now?
@return [Faraday::Connection] the underlying JPAPI connection object
@return [Faraday::Response] The response from the most recent API call
@return [Time] when this connection was connected
@return [String,Symbol] an arbitrary name that can be given to this
connection during initialization, using the name: parameter. defaults to user@hostname:port
@return [Integer] Seconds before an http connection open times out
@return [String] any path in the URL below the hostname. See {#connect}
@return [Boolean] are we using a sticky session?
@return [Boolean] are we using a sticky session?
@return [Boolean] are we using a sticky session?
@return [Integer] Seconds before an http request times out
@return [Jamf::Connection::Token] the token used for connecting
Public Instance Methods
@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
@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
@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
@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
@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
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
@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
@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
@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
@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
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
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
@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
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
@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