Class: Windoo::Connection
- Inherits:
-
Object
- Object
- Windoo::Connection
- Includes:
- Actions, Attributes, Connect, Constants
- Defined in:
- lib/windoo/connection.rb,
lib/windoo/connection/token.rb,
lib/windoo/connection/actions.rb,
lib/windoo/connection/connect.rb,
lib/windoo/connection/constants.rb,
lib/windoo/connection/attributes.rb
Overview
Instances of this class represent a connection to a Jamf Title Editor
Defined Under Namespace
Modules: Actions, Attributes, Connect, Constants Classes: Token
Constant Summary collapse
- HTTPS_SCHEME =
When using included modules to define constants, the constants have to be defined at the level where they will be referenced, or else they aren’t available to other broken-out-and-included sub modules
See cultivatehq.com/posts/ruby-constant-resolution/ for an explanation
'https'
- SSL_PORT =
443
- DFT_SSL_VERSION =
'TLSv1_2'
- DFT_OPEN_TIMEOUT =
60
- DFT_TIMEOUT =
60
- RSRC_VERSION =
the entire API is at this path
'v2'
- PP_VARS =
Only these variables are displayed with PrettyPrint This avoids displaying lots of extraneous data
%i[ @name @connected @open_timeout @timeout @connect_time ].freeze
Instance Attribute Summary
Attributes included from Attributes
#cnx, #connect_time, #connected, #last_http_response, #name, #open_timeout, #timeout, #token
Instance Method Summary collapse
-
#default? ⇒ Boolean
is this the default connection?.
-
#initialize(url = nil, **params) ⇒ Connection
constructor
Instantiate a connection object.
-
#next_refresh ⇒ Object
@deprecated, use .token.next_refresh.
-
#pretty_print_instance_variables ⇒ Array
Only selected items are displayed with prettyprint otherwise its too much data in irb.
-
#secs_to_refresh ⇒ Object
@deprecated, use .token.secs_to_refresh.
-
#time_to_refresh ⇒ Object
@deprecated, use .token.time_to_refresh.
-
#to_s ⇒ String
A useful string about this connection.
Methods included from Actions
#delete, #get, included, #post, #put
Methods included from Connect
#connect, #disconnect, included, #validate_connected
Methods included from Attributes
#base_url, #host, included, #keep_alive?, #port, #pw_fallback?, #ssl_options, #ssl_version, #user, #validate_connection, #verify_cert?
Methods included from Constants
Constructor Details
#initialize(url = nil, **params) ⇒ Connection
Instantiate a connection object.
If name: is provided it will be stored as the Connection’s name attribute.
if no url is provided and params are empty, or contains only a :name key, then you must call #connect with all the connection parameters before accessing a server.
See Windoo::Connection::Connect#connect for the parameters
35 36 37 38 39 40 41 42 |
# File 'lib/windoo/connection.rb', line 35 def initialize(url = nil, **params) @name = params.delete :name @connected = false return if url.nil? && params.empty? connect url, **params end |
Instance Method Details
#default? ⇒ Boolean
is this the default connection?
86 87 88 |
# File 'lib/windoo/connection.rb', line 86 def default? self == Windoo.cnx end |
#next_refresh ⇒ Object
@deprecated, use .token.next_refresh
71 72 73 |
# File 'lib/windoo/connection.rb', line 71 def next_refresh @token.next_refresh end |
#pretty_print_instance_variables ⇒ Array
Only selected items are displayed with prettyprint otherwise its too much data in irb.
66 67 68 |
# File 'lib/windoo/connection.rb', line 66 def pretty_print_instance_variables PP_VARS end |
#secs_to_refresh ⇒ Object
@deprecated, use .token.secs_to_refresh
76 77 78 |
# File 'lib/windoo/connection.rb', line 76 def secs_to_refresh @token.secs_to_refresh end |
#time_to_refresh ⇒ Object
@deprecated, use .token.time_to_refresh
81 82 83 |
# File 'lib/windoo/connection.rb', line 81 def time_to_refresh @token.time_to_refresh end |
#to_s ⇒ String
A useful string about this connection
51 52 53 54 55 56 57 58 59 |
# File 'lib/windoo/connection.rb', line 51 def to_s return 'not connected' unless connected? if name.to_s.start_with? "#{user}@" name else "#{user}@#{host}:#{port}, name: #{name}" end end |