module Jamf::Prestage

The Shared Code for ComputerPrestage and MobileDevicePrestage

Constants

ALL_SCOPES_OBJECT

The class-level scopes method returns one of these objects

ALT_IDENTIFIERS

Identifiers not marked in the superclass’s OAPI_PROPERTIES constant which usually only marks ‘:id’. These values are unique in the collection

INSTANCE_SCOPE_OBJECT

the instance level scope method or the class level serials_for_prestage method returns one of these.

NON_UNIQUE_IDENTIFIERS

Values which are useful as identifiers, but are not necessarily unique in the collection - e.g. more than one computer can have the same name WARNING When more than one item in the collection has the same value for one of these fields, which one is used, returned, selected, is undefined You Have Been Warned!

SCOPE_PATH

The scope of a prestage is all the SN’s that have been assigned to it

Public Class Methods

included(includer) click to toggle source

when this module is included, also extend our Class Methods

   # File lib/jamf/api/jamf_pro/mixins/prestage.rb
32 def self.included(includer)
33   Jamf.load_msg "--> #{includer} is including Jamf::Prestage"
34   includer.extend(ClassMethods)
35 end

Public Instance Methods

add(*sns_to_assign)
Alias for: assign
assign(*sns_to_assign) click to toggle source

Assign

    # File lib/jamf/api/jamf_pro/mixins/prestage.rb
289 def assign(*sns_to_assign)
290   scope = self.class.assign(*sns_to_assign, to_prestage: @id, cnx: @cnx)
291   @versionLock = scope.versionLock
292 end
Also aliased as: add
assigned?(sn) click to toggle source

Is this SN assigned to this prestage?

This method uses the instance’s scope object, from a different API path than the class-level .assigned? method.

@param sn the sn to look for

@return [Boolean]

    # File lib/jamf/api/jamf_pro/mixins/prestage.rb
282 def assigned?(sn)
283   assigned_sns.include? sn
284 end
Also aliased as: include?, scoped?
assigned_sns() click to toggle source

@return [Array<String>] the serialnumbers assigned to this prestage

    # File lib/jamf/api/jamf_pro/mixins/prestage.rb
269 def assigned_sns
270   scope.assignments.map(&:serialNumber)
271 end
include?(sn)
Alias for: assigned?
remove(*sns_to_unassign)
Alias for: unassign
scope(refresh = false) click to toggle source

The scope data for this prestage -

@param refresh reload from the API? DEPRECATED:

the data is always read from the API. If making many calls at once,
consisider capturing the data in your own variable

@return [PrestageScope]

    # File lib/jamf/api/jamf_pro/mixins/prestage.rb
256 def scope(refresh = false) # rubocop:disable Lint/UnusedMethodArgument
257   scope = INSTANCE_SCOPE_OBJECT.new @cnx.get(scope_path)
258 
259   # TODO: is this the best way to deal with fetching a scope that
260   # is more updated than the rest of the object?
261   unless scope.versionLock == @versionLock
262     raise Jamf::VersionLockError, "The #{self.class} '#{displayName}' has been modified since it was fetched. Please refetch and try again"
263   end
264 
265   scope
266 end
scope_path() click to toggle source

The scope endpoint for this instance

    # File lib/jamf/api/jamf_pro/mixins/prestage.rb
302 def scope_path
303   @scope_path ||= self.class.scope_path(id)
304 end
scoped?(sn)
Alias for: assigned?
unassign(*sns_to_unassign) click to toggle source
    # File lib/jamf/api/jamf_pro/mixins/prestage.rb
295 def unassign(*sns_to_unassign)
296   scope = self.class.unassign(*sns_to_unassign, from_prestage: @id, cnx: @cnx)
297   @versionLock = scope.versionLock
298 end
Also aliased as: remove