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', 'block in page' ].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.
102 103 104 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 102 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.
108 109 110 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 108 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.
118 119 120 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 118 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
122 123 124 125 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 122 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.
136 137 138 139 140 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 136 def pretty_print_instance_variables vars = super.sort vars.delete :@cnx vars end |
#save ⇒ Object
TODO: error handling
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/jamf/api/jamf_pro/mixins/jpapi_resource.rb', line 143 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 |