Module: Jamf::JPAPIResource
- Included in:
- CollectionResource
- Defined in:
- lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- API_SOURCE =
which API do APIObjects come from? The classic equivalent is in Jamf::APIObject
:jamf_pro
- NEW_CALLERS =
These methods are allowed to call .new
['fetch', 'create', 'all', 'cached_all', 'block in all', 'block in cached_all'].freeze
- RSRC_PREVIEW_VERSION =
The resource version for previewing new features
'preview'.freeze
Instance Attribute Summary collapse
-
#cnx ⇒ Jamf::Connection
readonly
The API connection thru which we deal with this resource.
-
#get_path ⇒ String
readonly
The path for fetching this thing from the JPAPI.
-
#update_path ⇒ String
readonly
The path for updating this thing from the JPAPI.
Class Method Summary collapse
-
.included(includer) ⇒ Object
when this module is included, also extend our Class Methods.
Instance Method Summary collapse
-
#initialize(**data) ⇒ Object
constructor.
-
#pretty_print_instance_variables ⇒ Array
Remove large cached items from the instance_variables used to create pretty-print (pp) output.
-
#save ⇒ Object
TODO: error handling.
Instance Attribute Details
#cnx ⇒ Jamf::Connection (readonly)
Returns the API connection thru which we deal with this resource.
88 89 90 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 88 def cnx @cnx end |
#get_path ⇒ String (readonly)
Returns The path for fetching this thing from the JPAPI
this gets set in the constructor in the CollectionResource or SingletonResource mixins.
94 95 96 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 94 def get_path @get_path end |
#update_path ⇒ String (readonly)
Returns The path for updating this thing from the JPAPI
this gets set in the constructor in the CollectionResource or SingletonResource mixins
We use ‘update_path’ because some items are updated via a PUT_PATH and others via a PATCH_PATH. When this gets set, it will contain the appropriate one.
104 105 106 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 104 def update_path @update_path end |
Class Method Details
.included(includer) ⇒ Object
when this module is included, also extend our Class Methods
34 35 36 37 38 39 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 34 def self.included(includer) # TODO: only allow being directly mixed in to CollectionResource and # SingletonResource modules. Jamf.load_msg "--> #{includer} is including Jamf::JPAPIResource" includer.extend(ClassMethods) end |
Instance Method Details
#initialize(**data) ⇒ Object
constructor
109 110 111 112 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 109 def initialize(**data) @cnx = data.delete :cnx super(**data) end |
#pretty_print_instance_variables ⇒ Array
Remove large cached items from the instance_variables used to create pretty-print (pp) output.
123 124 125 126 127 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 123 def pretty_print_instance_variables vars = super.sort vars.delete :@cnx vars end |
#save ⇒ Object
TODO: error handling
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 130 def save raise Jamf::UnsupportedError, "#{self.class} objects cannot be changed" unless self.class.mutable? if exist? return unless unsaved_changes? update_in_jamf else create_in_jamf end clear_unsaved_changes @id || :saved end |