Class: Jamf::SingletonResource Abstract

Inherits:
Resource show all
Extended by:
BaseClass
Defined in:
lib/jamf/api/base_classes/singleton_resource.rb

Overview

This class is abstract.

A Singleton Resource in the API.

See Resource for details and required constants

Direct Known Subclasses

AppStoreCountryCodes, Locales, TimeZones

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Jamf::JSONObject

Class Method Details

.allocate(*args, &block) ⇒ Object Originally defined in module BaseClass

Can’t allocate if base class

.base_class?Boolean Originally defined in module BaseClass

Returns:

  • (Boolean)

.fetch(reload = false, cnx: Jamf.cnx) ⇒ Jamf::SingletonResource

Return a SingletonResource from the API, from the cache if already cached or retrieving from the API and caching it if neededl

Parameters:

  • reload (Boolean) (defaults to: false)

    If already cached, re-cache from the API. WARNING: unsaved changes will be lost.

  • version (String)

    the API resource version to use. Defaults to the RSRC_VERSION for the class.

  • cnx (Jamf::Connection) (defaults to: Jamf.cnx)

    The API connection to use

Returns:



58
59
60
61
62
63
64
65
66
# File 'lib/jamf/api/base_classes/singleton_resource.rb', line 58

def self.fetch(reload = false, cnx: Jamf.cnx)
  stop_if_base_class
  cnx.singleton_cache[self] = nil if reload
  cached = cnx.singleton_cache[self]
  return cached if cached

  data = cnx.get rsrc_path
  cnx.singleton_cache[self] = new data, cnx: cnx
end

.flushcache(cnx: Jamf.cnx) ⇒ Object

fetch



68
69
70
71
# File 'lib/jamf/api/base_classes/singleton_resource.rb', line 68

def self.flushcache(cnx: Jamf.cnx)
  stop_if_base_class
  cnx.singleton_cache[self] = nil
end

.new(*args, &block) ⇒ Object Originally defined in module BaseClass

Can’t instantiate if base_class

.stop_if_base_class(action = DEFAULT_ACTION) ⇒ Object Originally defined in module BaseClass

raise an exception if this class is a base class

Instance Method Details

#exist?Boolean

singltons always exist

Returns:

  • (Boolean)


82
83
84
# File 'lib/jamf/api/base_classes/singleton_resource.rb', line 82

def exist?
  true
end

#rsrc_pathObject

only have one path



77
78
79
# File 'lib/jamf/api/base_classes/singleton_resource.rb', line 77

def rsrc_path
  self.class.rsrc_path
end