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



55
56
57
# File 'lib/jamf/api/connection/attributes.rb', line 55

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



70
71
72
# File 'lib/jamf/api/connection/attributes.rb', line 70

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?



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

def connected
  @connected
end

#jp_cnxFaraday::Connection (readonly)

Returns the underlying JPAPI connection object.

Returns:

  • (Faraday::Connection)

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

Returns The response from the most recent API call.

Returns:

  • (Faraday::Response)

    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

#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



42
43
44
# File 'lib/jamf/api/connection/attributes.rb', line 42

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



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

def open_timeout
  @open_timeout
end

#server_pathString (readonly)

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

Returns:



64
65
66
# File 'lib/jamf/api/connection/attributes.rb', line 64

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?



74
75
76
# File 'lib/jamf/api/connection/attributes.rb', line 74

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.
    


87
88
89
# File 'lib/jamf/api/connection/attributes.rb', line 87

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



49
50
51
# File 'lib/jamf/api/connection/attributes.rb', line 49

def timeout
  @timeout
end

#tokenJamf::Connection::Token (readonly)

Returns the token used for connecting.

Returns:



61
62
63
# File 'lib/jamf/api/connection/attributes.rb', line 61

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



145
146
147
148
# File 'lib/jamf/api/connection/attributes.rb', line 145

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



151
152
153
154
# File 'lib/jamf/api/connection/attributes.rb', line 151

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



209
210
211
212
# File 'lib/jamf/api/connection/attributes.rb', line 209

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



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

Returns:

  • (Boolean)

    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

#portInteger

Returns The port of the Jamf Pro server API connection.

Returns:

  • (Integer)

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

Returns:

  • (Boolean)

    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_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



197
198
199
200
# File 'lib/jamf/api/connection/attributes.rb', line 197

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



184
185
186
187
# File 'lib/jamf/api/connection/attributes.rb', line 184

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



165
166
167
168
# File 'lib/jamf/api/connection/attributes.rb', line 165

def user
  validate_token
  @token.user
end

#validate_tokenvoid

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

Returns:

  • (Boolean)

    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