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.
38 39 40 |
# File 'lib/jamf/api/connection/attributes.rb', line 38 def c_cnx @c_cnx end |
#connect_time ⇒ Time (readonly) Also known as: login_time
Returns when this connection was connected.
53 54 55 |
# File 'lib/jamf/api/connection/attributes.rb', line 53 def connect_time @connect_time end |
#connected ⇒ Boolean (readonly) Also known as: connected?
Returns are we connected right now?.
28 29 30 |
# File 'lib/jamf/api/connection/attributes.rb', line 28 def connected @connected end |
#jp_cnx ⇒ Faraday::Connection (readonly)
Returns the underlying JPAPI connection object.
41 42 43 |
# File 'lib/jamf/api/connection/attributes.rb', line 41 def jp_cnx @jp_cnx end |
#last_http_response ⇒ Faraday::Response (readonly)
Returns The response from the most recent API call.
50 51 52 |
# File 'lib/jamf/api/connection/attributes.rb', line 50 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.
25 26 27 |
# File 'lib/jamf/api/connection/attributes.rb', line 25 def name @name end |
#open_timeout ⇒ Integer
Returns Seconds before an http connection open times out.
35 36 37 |
# File 'lib/jamf/api/connection/attributes.rb', line 35 def open_timeout @open_timeout end |
#server_path ⇒ String (readonly)
Returns any path in the URL below the hostname. See Connect#connect.
47 48 49 |
# File 'lib/jamf/api/connection/attributes.rb', line 47 def server_path @server_path end |
#sticky_session ⇒ Boolean Also known as: sticky_session?, sticky?
Returns are we using a sticky session?.
57 58 59 |
# File 'lib/jamf/api/connection/attributes.rb', line 57 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.
70 71 72 |
# File 'lib/jamf/api/connection/attributes.rb', line 70 def end |
#timeout ⇒ Integer
Returns Seconds before an http request times out.
32 33 34 |
# File 'lib/jamf/api/connection/attributes.rb', line 32 def timeout @timeout end |
#token ⇒ Jamf::Connection::Token (readonly)
Returns the token used for connecting.
44 45 46 |
# File 'lib/jamf/api/connection/attributes.rb', line 44 def token @token end |
Instance Method Details
#base_url ⇒ URI::HTTPS
Returns the base URL to the server.
128 129 130 131 |
# File 'lib/jamf/api/connection/attributes.rb', line 128 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.
134 135 136 137 |
# File 'lib/jamf/api/connection/attributes.rb', line 134 def host validate_token @token.host end |
#jamf_build ⇒ String
Returns the build of the Jamf Pro server.
192 193 194 195 |
# File 'lib/jamf/api/connection/attributes.rb', line 192 def jamf_build validate_token @token.jamf_build end |
#jamf_version ⇒ Gem::Version
Returns the version of the Jamf Pro server.
186 187 188 189 |
# File 'lib/jamf/api/connection/attributes.rb', line 186 def jamf_version validate_token @token.jamf_version end |
#keep_alive? ⇒ Boolean
Returns Is the connection token being automatically refreshed?.
154 155 156 157 |
# File 'lib/jamf/api/connection/attributes.rb', line 154 def keep_alive? validate_token @token.keep_alive? end |
#port ⇒ Integer
Returns The port of the Jamf Pro server API connection.
142 143 144 145 |
# File 'lib/jamf/api/connection/attributes.rb', line 142 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?.
161 162 163 164 |
# File 'lib/jamf/api/connection/attributes.rb', line 161 def pw_fallback? validate_token @token.pw_fallback? end |
#ssl_options ⇒ Hash
Returns the ssl version and verify cert, to pass into faraday connections.
180 181 182 183 |
# File 'lib/jamf/api/connection/attributes.rb', line 180 def validate_token @token. end |
#ssl_version ⇒ String
Returns SSL version used for the connection.
167 168 169 170 |
# File 'lib/jamf/api/connection/attributes.rb', line 167 def ssl_version validate_token @token.ssl_version end |
#user ⇒ String
Returns the username who’s connected to the JSS API.
148 149 150 151 |
# File 'lib/jamf/api/connection/attributes.rb', line 148 def user validate_token @token.user end |
#validate_token ⇒ void
This method returns an undefined value.
raise an error if no token yet
199 200 201 |
# File 'lib/jamf/api/connection/attributes.rb', line 199 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?.
173 174 175 176 |
# File 'lib/jamf/api/connection/attributes.rb', line 173 def verify_cert? validate_token @token.verify_cert? end |