Module: Windoo::Connection::Attributes

Included in:
Windoo::Connection
Defined in:
lib/windoo/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

There are convience getters defined for them below

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cnxFaraday::Connection (readonly)

Returns The underlying connection object.

Returns:

  • (Faraday::Connection)

    The underlying connection object



46
47
48
# File 'lib/windoo/connection/attributes.rb', line 46

def cnx
  @cnx
end

#connect_timeTime (readonly) Also known as: login_time

Returns when this connection was connected.

Returns:

  • (Time)

    when this connection was connected



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

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?



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

def connected
  @connected
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



39
40
41
# File 'lib/windoo/connection/attributes.rb', line 39

def last_http_response
  @last_http_response
end

#nameString

Returns the name of this connection, an arbitrary string.

Returns:

  • (String)

    the name of this connection, an arbitrary string



27
28
29
# File 'lib/windoo/connection/attributes.rb', line 27

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



33
34
35
# File 'lib/windoo/connection/attributes.rb', line 33

def open_timeout
  @open_timeout
end

#timeoutInteger

Returns Seconds before an http request times out.

Returns:

  • (Integer)

    Seconds before an http request times out



30
31
32
# File 'lib/windoo/connection/attributes.rb', line 30

def timeout
  @timeout
end

#tokenWindoo::Connection::Token (readonly)

Returns the token used for connecting.

Returns:



36
37
38
# File 'lib/windoo/connection/attributes.rb', line 36

def token
  @token
end

Class Method Details

.included(includer) ⇒ Object



22
23
24
# File 'lib/windoo/connection/attributes.rb', line 22

def self.included(includer)
  Windoo.verbose_include(includer, self)
end

Instance Method Details

#base_urlURI::HTTPS

Returns the base URL to the server.

Returns:

  • (URI::HTTPS)

    the base URL to the server



89
90
91
92
# File 'lib/windoo/connection/attributes.rb', line 89

def base_url
  validate_connection
  @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



95
96
97
98
# File 'lib/windoo/connection/attributes.rb', line 95

def host
  validate_connection
  @token&.host
end

#keep_alive?Boolean

Returns Is the connection token being automatically refreshed?.

Returns:

  • (Boolean)

    Is the connection token being automatically refreshed?



115
116
117
118
# File 'lib/windoo/connection/attributes.rb', line 115

def keep_alive?
  validate_connection
  @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



103
104
105
106
# File 'lib/windoo/connection/attributes.rb', line 103

def port
  validate_connection
  @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?



122
123
124
125
# File 'lib/windoo/connection/attributes.rb', line 122

def pw_fallback?
  validate_connection
  @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



141
142
143
144
# File 'lib/windoo/connection/attributes.rb', line 141

def ssl_options
  validate_connection
  @token&.ssl_options
end

#ssl_versionString

Returns SSL version used for the connection.

Returns:

  • (String)

    SSL version used for the connection



128
129
130
131
# File 'lib/windoo/connection/attributes.rb', line 128

def ssl_version
  validate_connection
  @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



109
110
111
112
# File 'lib/windoo/connection/attributes.rb', line 109

def user
  validate_connection
  @token&.user
end

#validate_connectionvoid

This method returns an undefined value.

raise an error if no token yet



148
149
150
# File 'lib/windoo/connection/attributes.rb', line 148

def validate_connection
  raise Windoo::NotConnectedError, 'Not connected, use #connect first' unless connected?
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?



134
135
136
137
# File 'lib/windoo/connection/attributes.rb', line 134

def verify_cert?
  validate_connection
  @token&.verify_cert?
end