Class: Jamf::ComputerExtensionAttribute
- Inherits:
-
ExtensionAttribute
- Object
- APIObject
- ExtensionAttribute
- Jamf::ComputerExtensionAttribute
- Defined in:
- lib/jamf/api/classic/api_objects/computer_extension_attribute.rb
Overview
The definition of a Computer extension attribute in the JSS
Constant Summary collapse
- RSRC_BASE =
The base for REST resources of this class
'computerextensionattributes'.freeze
- RSRC_LIST_KEY =
the hash key used for the JSON list output of all objects in the JSS
:computer_extension_attributes
- RSRC_OBJECT_KEY =
The hash key used for the JSON object output. It’s also used in various error messages
:computer_extension_attribute
- TARGET_CLASS =
these ext attribs are related to these kinds of objects
Jamf::Computer
- ALL_TARGETS_CRITERION =
A criterion that will return all members of the TARGET_CLASS
Jamf::Criteriable::Criterion.new(and_or: 'and', name: 'Username', search_type: 'like', value: '')
- PLATFORM_MAC =
When the intput type is script, what platforms can they run on?
'Mac'.freeze
- PLATFORM_WINDOWS =
'Windows'.freeze
- PLATFORMS =
[PLATFORM_MAC, PLATFORM_WINDOWS].freeze
- LANGUAGE_VBS =
When the platform is Windows, what languages can be user?
'VBScript'.freeze
- LANGUAGE_BAT =
'Batch File'.freeze
- LANGUAGE_PSH =
'PowerShell'.freeze
- WINDOWS_SCRIPTING_LANGUAGES =
[LANGUAGE_VBS, LANGUAGE_BAT, LANGUAGE_PSH].freeze
- RECON_DISPLAY_CHOICES =
Where can it be displayed in the Recon App?
[ 'Computer', 'User and Location', 'Purchasing', 'Extension Attributes' ].freeze
- DEFAULT_RECON_DISPLAY_CHOICE =
'Extension Attributes'.freeze
- OBJECT_HISTORY_OBJECT_TYPE =
the object type for this object in the object history table. See APIObject#add_object_history_entry
73
Instance Attribute Summary collapse
-
#enabled ⇒ Boolean
(also: #enabled?)
readonly
If the input type is ‘script’, is this EA enabled?.
-
#need_to_update ⇒ Boolean
included
from Updatable
readonly
Do we have unsaved changes?.
-
#platform ⇒ String
When the @input_type is “script”, The platform on which a script will run.
-
#recon_display ⇒ String
DEPRECATED: this is no longer separate from the web_display.
-
#script ⇒ String
(also: #code)
The script code that will be executed when the @input_type is “script”,.
-
#scripting_language ⇒ String
The scripting language of the @script when @input_type is “script”, and the @platform is “Windows”.
Instance Method Summary collapse
-
#disable ⇒ void
disable this script ea.
-
#enable ⇒ void
enable this script ea.
-
#history(computer) ⇒ Array<Hash{:timestamp=>Time,:value=>String,Integer,Time}>
Return an Array of Hashes showing the history of reported values for this EA on one computer.
Constructor Details
This class inherits a constructor from Jamf::ExtensionAttribute
Instance Attribute Details
#enabled ⇒ Boolean (readonly) Also known as: enabled?
Returns if the input type is ‘script’, is this EA enabled?.
90 91 92 |
# File 'lib/jamf/api/classic/api_objects/computer_extension_attribute.rb', line 90 def enabled @enabled end |
#need_to_update ⇒ Boolean (readonly) Originally defined in module Updatable
Returns do we have unsaved changes?.
#platform ⇒ String
When the @input_type is “script”, The platform on which a script will run.
NOTE: The web app seems to let you have both Mac and Windows scripts defined when the type is “script”, however the API will only return the Mac script info if both are defined. DEPRECATED: windows EAs are no longer supported
101 102 103 |
# File 'lib/jamf/api/classic/api_objects/computer_extension_attribute.rb', line 101 def platform @platform end |
#recon_display ⇒ String
DEPRECATED: this is no longer separate from the web_display.
112 113 114 |
# File 'lib/jamf/api/classic/api_objects/computer_extension_attribute.rb', line 112 def recon_display @recon_display end |
#script ⇒ String Also known as: code
Returns the script code that will be executed when the @input_type is “script”,.
86 87 88 |
# File 'lib/jamf/api/classic/api_objects/computer_extension_attribute.rb', line 86 def script @script end |
#scripting_language ⇒ String
The scripting language of the @script when @input_type is “script”, and the @platform is “Windows”
DEPRECATED: windows EAs are no longer supported
108 109 110 |
# File 'lib/jamf/api/classic/api_objects/computer_extension_attribute.rb', line 108 def scripting_language @scripting_language end |
Instance Method Details
#disable ⇒ void
This method returns an undefined value.
disable this script ea
143 144 145 146 147 148 |
# File 'lib/jamf/api/classic/api_objects/computer_extension_attribute.rb', line 143 def disable return unless enabled? @enabled = false @need_to_update = true end |
#enable ⇒ void
This method returns an undefined value.
enable this script ea
132 133 134 135 136 137 |
# File 'lib/jamf/api/classic/api_objects/computer_extension_attribute.rb', line 132 def enable return if enabled? @enabled = true @need_to_update = true end |
#history(computer) ⇒ Array<Hash{:timestamp=>Time,:value=>String,Integer,Time}>
Return an Array of Hashes showing the history of reported values for this EA on one computer.
Each hash contains these 2 keys:
-
:value - String, Integer, or Time, depending on @data_type
-
:timestamp - Time
This method requires a MySQL database connection established via Jamf::DB_CNX.connect
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/jamf/api/classic/api_objects/computer_extension_attribute.rb', line 222 def history(computer) raise Jamf::NoSuchItemError, "EA Not In JSS! Use #create to create this #{RSRC_OBJECT_KEY}." unless @in_jss raise Jamf::InvalidConnectionError, "Database connection required for 'history' query." unless Jamf::DB_CNX.connected? computer_id = Jamf::Computer.valid_id computer, cnx: @cnx raise Jamf::NoSuchItemError, "No computer found matching '#{computer}'" unless computer_id the_query = <<-END_Q SELECT eav.value_on_client AS value, r.date_entered_epoch AS timestamp_epoch FROM extension_attribute_values eav JOIN reports r ON eav.report_id = r.report_id WHERE r.computer_id = #{computer_id} AND eav.extension_attribute_id = #{@id} ORDER BY timestamp_epoch END_Q qrez = Jamf::DB_CNX.db.query the_query history = [] qrez.each_hash do |entry| value = case @data_type when 'String' then entry['value'] when 'Integer' then entry['value'].to_i when 'Date' then Jamf.parse_time(entry['value']) end # case newhash = { value: value, timestamp: JSS.epoch_to_time(entry['timestamp_epoch']) } history << newhash end # each hash history end |