Class: Jamf::Script
- Inherits:
-
CollectionResource
- Object
- JSONObject
- Resource
- CollectionResource
- Jamf::Script
- Includes:
- ChangeLog, Referable
- Defined in:
- lib/jamf/api/resources/collection_resources/script.rb
Overview
A building defined in the JSS
Constant Summary collapse
- RSRC_VERSION =
Constants
'v1'.freeze
- RSRC_PATH =
'scripts'.freeze
- PRIORITY_BEFORE =
'BEFORE'.freeze
- PRIORITY_AFTER =
'AFTER'.freeze
- PRIORITY_AT_REBOOT =
'AT_REBOOT'.freeze
- PRIORTIES =
[ PRIORITY_BEFORE, PRIORITY_AFTER, PRIORITY_AT_REBOOT ].freeze
- OBJECT_MODEL =
Object Model / Attributes See APIObject class documentation for details of how the OBJECT_MODEL hash works.
{ # @!attribute [r] id # @return [Integer] id: { class: :j_id, identifier: :primary, readonly: true, filter_key: true }, # @!attribute name # @return [String] name: { class: :string, identifier: true, filter_key: true }, # @!attribute info # @return [String] info: { class: :string, filter_key: true }, # @!attribute notes # @return [String] notes: { class: :string, filter_key: true }, # @!attribute priority # @return [String] priority: { class: :string, enum: Jamf::Script::PRIORTIES, filter_key: true }, # TODO: Jamf should standardize object references # this should be a Category::Reference object # @!attribute categoryId # @return [Integer] categoryId: { class: :j_id, filter_key: true }, # @!attribute categoryName # @return [String] categoryName: { class: :string, filter_key: true }, # @!attribute osRequirements # @return [String] osRequirements: { class: :string, filter_key: true }, # @!attribute scriptContents # @return [String] scriptContents: { class: :string, validate: :script_contents, aliases: %i[code], filter_key: true }, # @!attribute parameter4 # @return [String] parameter4: { class: :string, filter_key: true }, # @!attribute parameter5 # @return [String] parameter5: { class: :string, filter_key: true }, # @!attribute parameter6 # @return [String] parameter6: { class: :string, filter_key: true }, # @!attribute parameter7 # @return [String] parameter7: { class: :string, filter_key: true }, # @!attribute parameter8 # @return [String] parameter8: { class: :string, filter_key: true }, # @!attribute parameter9 # @return [String] parameter9: { class: :string, filter_key: true }, # @!attribute parameter10 # @return [String] parameter10: { class: :string, filter_key: true }, # @!attribute parameter11 # @return [String] parameter11: { class: :string, filter_key: true } }.freeze
Instance Attribute Summary collapse
- #categoryId ⇒ Integer
- #categoryName ⇒ String
- #id ⇒ Integer readonly
- #info ⇒ String
- #name ⇒ String
- #notes ⇒ String
- #osRequirements ⇒ String
- #parameter10 ⇒ String
- #parameter11 ⇒ String
- #parameter4 ⇒ String
- #parameter5 ⇒ String
- #parameter6 ⇒ String
- #parameter7 ⇒ String
- #parameter8 ⇒ String
- #parameter9 ⇒ String
- #priority ⇒ String
- #scriptContents ⇒ String
Class Method Summary collapse
-
.download(cnx: Jamf.cnx, **ident_and_val) ⇒ String
Retrieve a script's code without instantiating.
Instance Method Summary collapse
-
#add_change_log_note(note, cnx: Jamf.cnx) ⇒ void
included
from ChangeLog
Add a note to this resource's change log.
-
#change_log(sort: nil, filter: nil, paged: nil, page_size: nil, refresh: false, cnx: Jamf.cnx) ⇒ Array<Jamf::ChangeLogEntry>
included
from ChangeLog
The change and note history for this resource.
-
#change_log_count(cnx: Jamf.cnx) ⇒ Integer
included
from ChangeLog
how many change log entries are there? needed when using paged #change_log calls.
-
#next_page_of_change_log ⇒ Array<Jamf::ChangeHistoryEntry>
included
from ChangeLog
Fetch the next page of a paged #change_log request Returns an empty array if there's been no paged request or if the last one has no more pages.
Constructor Details
This class inherits a constructor from Jamf::JSONObject
Instance Attribute Details
#categoryId ⇒ Integer
|
# File 'lib/jamf/api/resources/collection_resources/script.rb', line 105
|
#id ⇒ Integer (readonly)
|
# File 'lib/jamf/api/resources/collection_resources/script.rb', line 63
|
Class Method Details
.download(cnx: Jamf.cnx, **ident_and_val) ⇒ String
Retrieve a script's code without instantiating
Specify an ident key, either id: or name: and the value for that ident e.g. `download id: 123` or `download name: 'myscript'`
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/jamf/api/resources/collection_resources/script.rb', line 207 def self.download(cnx: Jamf.cnx, **ident_and_val) ident, value = ident_and_val.first if ident == :id begin return cnx.download "#{rsrc_path}/#{value}/download" rescue => e raise Jamf::NoSuchItemError, "No script with #{ident} = #{value}" if e.httpStatus == 404 raise e end # begin end # if id = raw_data(cnx: cnx, **ident_and_val)&.dig(:id) raise Jamf::NoSuchItemError, "No script with #{ident} = #{value}" unless id cnx.download "#{rsrc_path}/#{id}/download" end |
Instance Method Details
#add_change_log_note(note, cnx: Jamf.cnx) ⇒ void Originally defined in module ChangeLog
This method returns an undefined value.
Add a note to this resource's change log.
If the change history has been cached already, the cache is flushed after adding the note.
#change_log(sort: nil, filter: nil, paged: nil, page_size: nil, refresh: false, cnx: Jamf.cnx) ⇒ Array<Jamf::ChangeLogEntry> Originally defined in module ChangeLog
The change and note history for this resource. This is a collection of objects as a sub-resource of some primary resource. As such, retriving the change log returns an array of objects, and can be paged, sorted and filtered.
This method is very similar to CollectionResource.all, see the docs for that method for more details
successive page.
#change_log_count(cnx: Jamf.cnx) ⇒ Integer Originally defined in module ChangeLog
how many change log entries are there? needed when using paged #change_log calls