Class: JSS::Server
Overview
A class representing the currently-connected JSS Server in a JSS::APIConnection instance.
The APIConnection instance has a JSS::Server instance in its #server attribute. It is created fresh every time APIConnection#connect is called.
That’s the only time it should be instantiated, and all access should be through the #server attribute of the APIConnection instance.
Constant Summary collapse
- ACTIVATION_CODE_RSRC =
Constants
'activationcode'.freeze
- ACTIVATION_CODE_KEY =
:activation_code
Instance Attribute Summary collapse
-
#api ⇒ JSS::APIConnection
readonly
The APIConnection object that contains this instance of Server.
-
#license_type ⇒ String
readonly
The type of server licence.
-
#major_version ⇒ Object
readonly
@return [Integer].
-
#minor_version ⇒ Object
readonly
@return [Integer].
-
#product ⇒ String
(also: #product_name)
readonly
The license product name.
-
#raw_version ⇒ Object
readonly
@return [String].
-
#revision_version ⇒ Object
readonly
@return [Integer].
-
#version ⇒ Object
readonly
@return [String] The version of the JSS.
Instance Method Summary collapse
-
#activation_code ⇒ String
The activation code for the server licence.
-
#initialize(jss_data, api) ⇒ Server
constructor
Initialize! THe jss_data to be passed in is the JSON output of the ‘jssuser’ resource on the API server.
-
#organization ⇒ String
(also: #institution)
The organization to which the server is licensed.
-
#pretty_print_instance_variables ⇒ Array
Remove the api object from the instance_variables used to create pretty-print (pp) output.
Constructor Details
#initialize(jss_data, api) ⇒ Server
Initialize! THe jss_data to be passed in is the JSON output of the ‘jssuser’ resource on the API server. the jssuser resource is readable by anyone with a JSS acct regardless of their permissions. However, it’s marked as ‘deprecated’. Hopefully jamf will keep this basic level of info available for basic authentication and JSS version checking.
The ‘api’ is a reference to the JSS::APIConnection instance which this JSS::Server instance is a part of.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/jss/server.rb', line 89 def initialize(jss_data, api) @api = api @license_type = jss_data[:license_type] @product = jss_data[:product] @raw_version = jss_data[:version] parsed = JSS.parse_jss_version(@raw_version) @major_version = parsed[:major] @minor_version = parsed[:minor] @revision_version = parsed[:revision] @version = parsed[:version] end |
Instance Attribute Details
#api ⇒ JSS::APIConnection (readonly)
Returns The APIConnection object that contains this instance of Server.
72 73 74 |
# File 'lib/jss/server.rb', line 72 def api @api end |
#license_type ⇒ String (readonly)
Returns the type of server licence.
50 51 52 |
# File 'lib/jss/server.rb', line 50 def license_type @license_type end |
#major_version ⇒ Object (readonly)
@return [Integer]
59 60 61 |
# File 'lib/jss/server.rb', line 59 def major_version @major_version end |
#minor_version ⇒ Object (readonly)
@return [Integer]
62 63 64 |
# File 'lib/jss/server.rb', line 62 def minor_version @minor_version end |
#product ⇒ String (readonly) Also known as: product_name
Returns the license product name.
53 54 55 |
# File 'lib/jss/server.rb', line 53 def product @product end |
#raw_version ⇒ Object (readonly)
@return [String]
68 69 70 |
# File 'lib/jss/server.rb', line 68 def raw_version @raw_version end |
#revision_version ⇒ Object (readonly)
@return [Integer]
65 66 67 |
# File 'lib/jss/server.rb', line 65 def revision_version @revision_version end |
#version ⇒ Object (readonly)
@return [String] The version of the JSS. See the method JSS.parse_jss_version
56 57 58 |
# File 'lib/jss/server.rb', line 56 def version @version end |
Instance Method Details
#activation_code ⇒ String
Returns the activation code for the server licence.
108 109 110 111 |
# File 'lib/jss/server.rb', line 108 def activation_code @act_code_data ||= @api.get_rsrc(ACTIVATION_CODE_RSRC)[ACTIVATION_CODE_KEY] @act_code_data[:code] end |
#organization ⇒ String Also known as: institution
Returns the organization to which the server is licensed.
102 103 104 105 |
# File 'lib/jss/server.rb', line 102 def organization @act_code_data ||= @api.get_rsrc(ACTIVATION_CODE_RSRC)[ACTIVATION_CODE_KEY] @act_code_data[:organization_name] end |
#pretty_print_instance_variables ⇒ Array
Remove the api object from the instance_variables used to create pretty-print (pp) output.
119 120 121 122 123 |
# File 'lib/jss/server.rb', line 119 def pretty_print_instance_variables vars = instance_variables.sort vars.delete :@api vars end |