Module: JSS::Scopable

Included in:
ConfigurationProfile, MobileDeviceApplication, Policy, RestrictedSoftware
Defined in:
lib/jss/api_object/scopable.rb,
lib/jss.rb,
lib/jss/api_object/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



71
72
73
# File 'lib/jss/api_object/scopable.rb', line 71

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



85
86
87
88
# File 'lib/jss/api_object/scopable.rb', line 85

def parse_scope
  @scope = JSS::Scopable::Scope.new self.class::SCOPE_TARGET_KEY, @init_data[:scope]
  @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.



110
111
112
# File 'lib/jss/api_object/scopable.rb', line 110

def should_update
  @need_to_update = true if @in_jss
end

#updateObject

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



119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/jss/api_object/scopable.rb', line 119

def update
  begin
    super

  rescue RestClient::Conflict => conflict
    if  self.scope.unable_to_verify_ldap_entries == true
      raise JSS::InvalidDataError, "Potentially non-existant LDAP user or group in new scope values."
    else
      raise conflict
    end

  end # begin
end