Module: Jamf::Scopable

Included in:
ConfigurationProfile, MacApplication, MobileDeviceApplication, PatchPolicy, Policy, RestrictedSoftware
Defined in:
lib/jamf/api/classic/api_objects/scopable.rb,
lib/jamf/api/classic/api_objects/scopable/scope.rb

Overview

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 Scope class.

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

Classes that mix in this module must:

  • Set a Constant SCOPE_TARGET_KEY that is either :computers or :mobile_devices

  • Include the result of self.scope.scope_xml in their own rest_xml output if they are Updatable or Creatable

Defined Under Namespace

Classes: Scope

Constant Summary collapse

SCOPABLE =

Constants

true

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scopeObject

Attribtues



65
66
67
# File 'lib/jamf/api/classic/api_objects/scopable.rb', line 65

def scope
  @scope
end

Instance Method Details

#parse_scopevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

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



77
78
79
80
# File 'lib/jamf/api/classic/api_objects/scopable.rb', line 77

def parse_scope
  @scope = Jamf::Scopable::Scope.new self.class::SCOPE_TARGET_KEY, @init_data[:scope], container: self
  @scope.container ||= self
end

#should_updatevoid

This method returns an undefined value.

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



104
105
106
# File 'lib/jamf/api/classic/api_objects/scopable.rb', line 104

def should_update
  @need_to_update = true if @in_jss
end

#updateObject

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



111
112
113
114
115
116
117
118
# File 'lib/jamf/api/classic/api_objects/scopable.rb', line 111

def update
  super
  @scope.should_update = false
rescue Jamf::ConflictError => e
  raise Jamf::InvalidDataError, 'Potentially non-existant LDAP user or group in new scope values.' if scope.unable_to_verify_ldap_entries == true

  raise e
end