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

#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



98
99
100
101
# File 'lib/jamf/api/connection/attributes.rb', line 98

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



104
105
106
107
# File 'lib/jamf/api/connection/attributes.rb', line 104

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



162
163
164
165
# File 'lib/jamf/api/connection/attributes.rb', line 162

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



156
157
158
159
# File 'lib/jamf/api/connection/attributes.rb', line 156

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?



124
125
126
127
# File 'lib/jamf/api/connection/attributes.rb', line 124

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



112
113
114
115
# File 'lib/jamf/api/connection/attributes.rb', line 112

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?



131
132
133
134
# File 'lib/jamf/api/connection/attributes.rb', line 131

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



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

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



137
138
139
140
# File 'lib/jamf/api/connection/attributes.rb', line 137

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



118
119
120
121
# File 'lib/jamf/api/connection/attributes.rb', line 118

def user
  validate_token
  @token.user
end

#validate_tokenvoid

This method returns an undefined value.

raise an error if no token yet



169
170
171
# File 'lib/jamf/api/connection/attributes.rb', line 169

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?



143
144
145
146
# File 'lib/jamf/api/connection/attributes.rb', line 143

def verify_cert?
  validate_token
  @token.verify_cert?
end