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?,
ssl_options, pw_fallback?, jamf_version, jamf_build

There are convience getters defined for them below

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#c_cnxFaraday::Connection (readonly)

Returns the underlying C-API connection object.

Returns:

  • (Faraday::Connection)

    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_timeTime (readonly) Also known as: login_time

Returns when this connection was connected.

Returns:

  • (Time)

    when this connection was connected



53
54
55
# File 'lib/jamf/api/connection/attributes.rb', line 53

def connect_time
  @connect_time
end

#connectedBoolean (readonly) Also known as: connected?

Returns are we connected right now?.

Returns:

  • (Boolean)

    are we connected right now?



28
29
30
# File 'lib/jamf/api/connection/attributes.rb', line 28

def connected
  @connected
end

#jp_cnxFaraday::Connection (readonly)

Returns the underlying JPAPI connection object.

Returns:

  • (Faraday::Connection)

    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_responseFaraday::Response (readonly)

Returns The response from the most recent API call.

Returns:

  • (Faraday::Response)

    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

#nameString, Symbol (readonly)

Returns an arbitrary name that can be given to this connection during initialization, using the name: parameter. defaults to user@hostname:port.

Returns:

  • (String, Symbol)

    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_timeoutInteger

Returns Seconds before an http connection open times out.

Returns:

  • (Integer)

    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_pathString (readonly)

Returns any path in the URL below the hostname. See Connect#connect.

Returns:



47
48
49
# File 'lib/jamf/api/connection/attributes.rb', line 47

def server_path
  @server_path
end

#sticky_sessionBoolean Also known as: sticky_session?, sticky?

Returns are we using a sticky session?.

Returns:

  • (Boolean)

    are we using a sticky session?



57
58
59
# File 'lib/jamf/api/connection/attributes.rb', line 57

def sticky_session
  @sticky_session
end

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.

Returns:

  • (String, nil)

    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 sticky_session_cookie
  @sticky_session_cookie
end

#timeoutInteger

Returns Seconds before an http request times out.

Returns:

  • (Integer)

    Seconds before an http request times out



32
33
34
# File 'lib/jamf/api/connection/attributes.rb', line 32

def timeout
  @timeout
end

#tokenJamf::Connection::Token (readonly)

Returns the token used for connecting.

Returns:



44
45
46
# File 'lib/jamf/api/connection/attributes.rb', line 44

def token
  @token
end

Instance Method Details

#base_urlURI::HTTPS

Returns the base URL to the server.

Returns:

  • (URI::HTTPS)

    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

#hostString Also known as: server, hostname

Returns the hostname of the Jamf Pro server API connection.

Returns:

  • (String)

    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_buildString

Returns the build of the Jamf Pro server.

Returns:

  • (String)

    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_versionGem::Version

Returns the version of the Jamf Pro server.

Returns:

  • (Gem::Version)

    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?.

Returns:

  • (Boolean)

    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

#portInteger

Returns The port of the Jamf Pro server API connection.

Returns:

  • (Integer)

    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?.

Returns:

  • (Boolean)

    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_optionsHash

Returns the ssl version and verify cert, to pass into faraday connections.

Returns:

  • (Hash)

    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 ssl_options
  validate_token
  @token.ssl_options
end

#ssl_versionString

Returns SSL version used for the connection.

Returns:

  • (String)

    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

#userString

Returns the username who’s connected to the JSS API.

Returns:

  • (String)

    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_tokenvoid

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?.

Returns:

  • (Boolean)

    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