module Jamf::Scopable

A mix-in module for handling scoping data for objects in the JSS.

The JSS objects that can be scoped use similar data to represent that scoping. This module provides a consistant way to deal with scoping data via some instance methods and the {Scopable::Scope} class.

When this module is mixed in to a {Jamf::APIObject} subclass, instances of the subclass will have a @scope attribute containing a {Jamf::Scopable::Scope} instance

Classes that mix in this module must:

Constants

SCOPABLE

Constants

Attributes

scope[R]

Attribtues

Public Instance Methods

parse_scope() click to toggle source

@api private

Call this during initialization of objects that have a scope and the scope instance will be created from @init_data

@return [void]

   # File lib/jamf/api/classic/api_objects/scopable.rb
77 def parse_scope
78   @scope = Jamf::Scopable::Scope.new self.class::SCOPE_TARGET_KEY, @init_data[:scope], container: self
79   @scope.container ||= self
80 end
scope=(new_scope) click to toggle source

Change the scope

@param new_scope the new scope

@return [void]

   # File lib/jamf/api/classic/api_objects/scopable.rb
88 def scope=(new_scope)
89   raise Jamf::InvalidDataError, 'Jamf::Scopable::Scope instance required' unless new_criteria.is_a?(Jamf::Scopable::Scope)
90 
91   unless self.class::SCOPE_TARGET_KEY == new_scope.target_key
92     raise Jamf::InvalidDataError,
93           "Scope object must have target_key of :#{self.class::SCOPE_TARGET_KEY}"
94   end
95 
96   @scope = new_scope
97   @need_to_update = true
98 end
should_update() click to toggle source

When the scope changes, it calls this to tell us that an update is needed.

@return [void]

    # File lib/jamf/api/classic/api_objects/scopable.rb
104 def should_update
105   @need_to_update = true if @in_jss
106 end
update() click to toggle source

A wrapper around the update method, to try catching 409 conflict errors when we couldn’t verify all ldap users/groups due to lack of ldap connections

Calls superclass method
    # File lib/jamf/api/classic/api_objects/scopable.rb
111 def update
112   super
113   @scope.should_update = false
114 rescue Jamf::ConflictError => e
115   raise Jamf::InvalidDataError, 'Potentially non-existant LDAP user or group in new scope values.' if scope.unable_to_verify_ldap_entries == true
116 
117   raise e
118 end