Module: Jamf::Connection::Attributes
- Included in:
- Jamf::Connection
- Defined in:
- lib/jamf/api/connection/attributes.rb
Overview
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?,
, pw_fallback?, jamf_version, jamf_build
There are convience getters defined for them below
Instance Attribute Summary collapse
-
#c_cnx ⇒ Faraday::Connection
readonly
The underlying C-API connection object.
-
#connect_time ⇒ Time
(also: #login_time)
readonly
When this connection was connected.
-
#connected ⇒ Boolean
(also: #connected?)
readonly
Are we connected right now?.
-
#jp_cnx ⇒ Faraday::Connection
readonly
The underlying JPAPI connection object.
-
#last_http_response ⇒ Faraday::Response
readonly
The response from the most recent API call.
-
#name ⇒ String, Symbol
readonly
An arbitrary name that can be given to this connection during initialization, using the name: parameter.
-
#open_timeout ⇒ Integer
Seconds before an http connection open times out.
-
#server_path ⇒ String
readonly
Any path in the URL below the hostname.
-
#sticky_session ⇒ Boolean
(also: #sticky_session?, #sticky?)
Are we using a sticky session?.
-
#sticky_session_cookie ⇒ String?
readonly
The current sticky_session cookie.
-
#timeout ⇒ Integer
Seconds before an http request times out.
-
#token ⇒ Jamf::Connection::Token
readonly
The token used for connecting.
Instance Method Summary collapse
-
#base_url ⇒ URI::HTTPS
The base URL to the server.
-
#host ⇒ String
(also: #server, #hostname)
The hostname of the Jamf Pro server API connection.
-
#jamf_build ⇒ String
The build of the Jamf Pro server.
-
#jamf_version ⇒ Gem::Version
The version of the Jamf Pro server.
-
#keep_alive? ⇒ Boolean
Is the connection token being automatically refreshed?.
-
#port ⇒ Integer
The port of the Jamf Pro server API connection.
-
#pw_fallback? ⇒ Boolean
If keep_alive is true, is the password Cached in memory to use if the refresh fails?.
-
#ssl_options ⇒ Hash
The ssl version and verify cert, to pass into faraday connections.
-
#ssl_version ⇒ String
SSL version used for the connection.
-
#user ⇒ String
The username who’s connected to the JSS API.
-
#validate_token ⇒ void
raise an error if no token yet.
-
#verify_cert? ⇒ Boolean
(also: #verify_cert)
Should the SSL certifcate from the server be verified?.
Instance Attribute Details
#c_cnx ⇒ Faraday::Connection (readonly)
Returns the underlying C-API connection object.
55 56 57 |
# File 'lib/jamf/api/connection/attributes.rb', line 55 def c_cnx @c_cnx end |
#connect_time ⇒ Time (readonly) Also known as: login_time
Returns when this connection was connected.
70 71 72 |
# File 'lib/jamf/api/connection/attributes.rb', line 70 def connect_time @connect_time end |
#connected ⇒ Boolean (readonly) Also known as: connected?
Returns are we connected right now?.
45 46 47 |
# File 'lib/jamf/api/connection/attributes.rb', line 45 def connected @connected end |
#jp_cnx ⇒ Faraday::Connection (readonly)
Returns the underlying JPAPI connection object.
58 59 60 |
# File 'lib/jamf/api/connection/attributes.rb', line 58 def jp_cnx @jp_cnx end |
#last_http_response ⇒ Faraday::Response (readonly)
Returns The response from the most recent API call.
67 68 69 |
# File 'lib/jamf/api/connection/attributes.rb', line 67 def last_http_response @last_http_response end |
#name ⇒ String, Symbol (readonly)
Returns an arbitrary name that can be given to this connection during initialization, using the name: parameter. defaults to user@hostname:port.
42 43 44 |
# File 'lib/jamf/api/connection/attributes.rb', line 42 def name @name end |
#open_timeout ⇒ Integer
Returns Seconds before an http connection open times out.
52 53 54 |
# File 'lib/jamf/api/connection/attributes.rb', line 52 def open_timeout @open_timeout end |
#server_path ⇒ String (readonly)
Returns any path in the URL below the hostname. See Connect#connect.
64 65 66 |
# File 'lib/jamf/api/connection/attributes.rb', line 64 def server_path @server_path end |
#sticky_session ⇒ Boolean Also known as: sticky_session?, sticky?
Returns are we using a sticky session?.
74 75 76 |
# File 'lib/jamf/api/connection/attributes.rb', line 74 def sticky_session @sticky_session end |
#sticky_session_cookie ⇒ String? (readonly)
Returns The current sticky_session cookie. nil unless sticky_session is set to true, either as a param to ‘connect’ or via #sticky_session=
When set via .connect, the cookie is gleaned from the token creation reponse. When set via #sticky_session=, a HEAD request is made, and the cookie will be in the response.
Only valid when the connection is to a Jamf Cloud server.
87 88 89 |
# File 'lib/jamf/api/connection/attributes.rb', line 87 def end |
#timeout ⇒ Integer
Returns Seconds before an http request times out.
49 50 51 |
# File 'lib/jamf/api/connection/attributes.rb', line 49 def timeout @timeout end |
#token ⇒ Jamf::Connection::Token (readonly)
Returns the token used for connecting.
61 62 63 |
# File 'lib/jamf/api/connection/attributes.rb', line 61 def token @token end |
Instance Method Details
#base_url ⇒ URI::HTTPS
Returns the base URL to the server.
145 146 147 148 |
# File 'lib/jamf/api/connection/attributes.rb', line 145 def base_url validate_token @token.base_url end |
#host ⇒ String Also known as: server, hostname
Returns the hostname of the Jamf Pro server API connection.
151 152 153 154 |
# File 'lib/jamf/api/connection/attributes.rb', line 151 def host validate_token @token.host end |
#jamf_build ⇒ String
Returns the build of the Jamf Pro server.
209 210 211 212 |
# File 'lib/jamf/api/connection/attributes.rb', line 209 def jamf_build validate_token @token.jamf_build end |
#jamf_version ⇒ Gem::Version
Returns the version of the Jamf Pro server.
203 204 205 206 |
# File 'lib/jamf/api/connection/attributes.rb', line 203 def jamf_version validate_token @token.jamf_version end |
#keep_alive? ⇒ Boolean
Returns Is the connection token being automatically refreshed?.
171 172 173 174 |
# File 'lib/jamf/api/connection/attributes.rb', line 171 def keep_alive? validate_token @token.keep_alive? end |
#port ⇒ Integer
Returns The port of the Jamf Pro server API connection.
159 160 161 162 |
# File 'lib/jamf/api/connection/attributes.rb', line 159 def port validate_token @token.port end |
#pw_fallback? ⇒ Boolean
Returns If keep_alive is true, is the password Cached in memory to use if the refresh fails?.
178 179 180 181 |
# File 'lib/jamf/api/connection/attributes.rb', line 178 def pw_fallback? validate_token @token.pw_fallback? end |
#ssl_options ⇒ Hash
Returns the ssl version and verify cert, to pass into faraday connections.
197 198 199 200 |
# File 'lib/jamf/api/connection/attributes.rb', line 197 def validate_token @token. end |
#ssl_version ⇒ String
Returns SSL version used for the connection.
184 185 186 187 |
# File 'lib/jamf/api/connection/attributes.rb', line 184 def ssl_version validate_token @token.ssl_version end |
#user ⇒ String
Returns the username who’s connected to the JSS API.
165 166 167 168 |
# File 'lib/jamf/api/connection/attributes.rb', line 165 def user validate_token @token.user end |
#validate_token ⇒ void
This method returns an undefined value.
raise an error if no token yet
216 217 218 |
# File 'lib/jamf/api/connection/attributes.rb', line 216 def validate_token raise Jamf::InvalidConnectionError, 'No token available, use #connect first' unless @token end |
#verify_cert? ⇒ Boolean Also known as: verify_cert
Returns Should the SSL certifcate from the server be verified?.
190 191 192 193 |
# File 'lib/jamf/api/connection/attributes.rb', line 190 def verify_cert? validate_token @token.verify_cert? end |