Class: Jamf::TimeZones
- Inherits:
-
SingletonResource
- Object
- JSONObject
- Resource
- SingletonResource
- Jamf::TimeZones
- Extended by:
- Immutable
- Defined in:
- lib/jamf/api/resources/singleton_resources/time_zones.rb
Overview
A list of known timezones
Constant Summary collapse
- RSRC_VERSION =
Constants
'v1'.freeze
- RSRC_PATH =
'time-zones'.freeze
- OBJECT_MODEL =
{ # @!attribute checkInFrequency # @return [integer] timeZones: { class: Jamf::TimeZone, multi: true, read_only: true, aliases: [:list] } }.freeze
Class Method Summary collapse
-
.displayNames(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #displayNames.
-
.id_for_name(name, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #id_for_name.
-
.ids_by_name(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #ids_by_name.
-
.list(refresh = false, cnx: Jamf.cnx) ⇒ Array<Jamf::TimeZone>
All the zomes available.
- .mutable? ⇒ Boolean extended from Immutable
-
.name_for_id(id, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #name_for_id.
-
.names_by_id(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #names_by_id.
-
.region_for_id(id, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #name_for_id.
-
.region_for_name(name, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #region_for_name.
-
.regions(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #regions.
-
.regions_by_id(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #regions_by_id.
-
.regions_by_name(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #regions_by_name.
-
.zoneIds(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #zoneIds.
Instance Method Summary collapse
-
#displayNames ⇒ Array<String>
(also: #names)
The available zone names.
-
#id_for_name(name) ⇒ String
return a zone id from its name, case-insensitive.
-
#ids_by_name ⇒ Hash
Name => id.
-
#initialize(data, cnx: Jamf.cnx) ⇒ TimeZones
constructor
TEMP? until this endpoint is brought up to standards the data from the API is a raw Array, but it should be a Hash containing an array.
-
#name_for_id(id) ⇒ String
return a zone name from its id, case-insensitive.
-
#names_by_id ⇒ Hash
Id => name.
-
#region_for_id(id) ⇒ String
return a zones from its id, case-insensitive.
-
#region_for_name(name) ⇒ String
return a zone name from its id, case-insensitive.
-
#regions ⇒ Array<String>
The available zone regions.
-
#regions_by_id ⇒ Hash
Id => region.
-
#regions_by_name ⇒ Hash
Name => region.
-
#zoneIds ⇒ Array<String>
(also: #ids)
The available zone ids.
Constructor Details
#initialize(data, cnx: Jamf.cnx) ⇒ TimeZones
TEMP? until this endpoint is brought up to standards the data from the API is a raw Array, but it should be a Hash containing an array.
65 66 67 68 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 65 def initialize(data, cnx: Jamf.cnx) data = { timeZones: data } super data, cnx: cnx end |
Class Method Details
.displayNames(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #displayNames
82 83 84 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 82 def self.displayNames(refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).displayNames end |
.id_for_name(name, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #id_for_name
119 120 121 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 119 def self.id_for_name(name, refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).id_for_name name end |
.ids_by_name(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #ids_by_name
99 100 101 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 99 def self.ids_by_name(refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).ids_by_name end |
.list(refresh = false, cnx: Jamf.cnx) ⇒ Array<Jamf::TimeZone>
Returns all the zomes available.
77 78 79 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 77 def self.list(refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).timeZones end |
.mutable? ⇒ Boolean Originally defined in module Immutable
.name_for_id(id, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #name_for_id
124 125 126 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 124 def self.name_for_id(id, refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).name_for_id id end |
.names_by_id(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #names_by_id
104 105 106 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 104 def self.names_by_id(refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).names_by_id end |
.region_for_id(id, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #name_for_id
134 135 136 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 134 def self.region_for_id(id, refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).region_for_id id end |
.region_for_name(name, refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #region_for_name
129 130 131 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 129 def self.region_for_name(name, refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).region_for_name name end |
.regions(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #regions
94 95 96 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 94 def self.regions(refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).regions end |
.regions_by_id(refresh = false, cnx: Jamf.cnx) ⇒ Object
Class level wrapper for #regions_by_id
109 110 111 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 109 def self.regions_by_id(refresh = false, cnx: Jamf.cnx) fetch(refresh, cnx: cnx).regions_by_id end |
Instance Method Details
#displayNames ⇒ Array<String> Also known as: names
Returns the available zone names.
143 144 145 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 143 def displayNames @names ||= timeZones.map(&:displayName) end |
#id_for_name(name) ⇒ String
return a zone id from its name, case-insensitive
182 183 184 185 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 182 def id_for_name(name) name = names.select { |n| n.casecmp? name }.first ids_by_name[name] end |
#ids_by_name ⇒ Hash
Returns name => id.
160 161 162 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 160 def ids_by_name @ids_by_name ||= timeZones.map { |tz| [tz.displayName, tz.zoneId] }.to_h end |
#name_for_id(id) ⇒ String
return a zone name from its id, case-insensitive
190 191 192 193 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 190 def name_for_id(id) id = ids.select { |n| n.casecmp? id }.first names_by_id[id] end |
#names_by_id ⇒ Hash
Returns id => name.
165 166 167 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 165 def names_by_id @names_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.displayName] }.to_h end |
#region_for_id(id) ⇒ String
return a zones from its id, case-insensitive
206 207 208 209 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 206 def region_for_id(id) id = ids.select { |n| n.casecmp? id }.first regions_by_id[id] end |
#region_for_name(name) ⇒ String
return a zone name from its id, case-insensitive
198 199 200 201 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 198 def region_for_name(name) name = names.select { |n| n.casecmp? name }.first regions_by_name[name] end |
#regions ⇒ Array<String>
Returns the available zone regions.
155 156 157 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 155 def regions @regions ||= timeZones.map(&:region).uniq end |
#regions_by_id ⇒ Hash
Returns id => region.
170 171 172 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 170 def regions_by_id @regions_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.region] }.to_h end |
#regions_by_name ⇒ Hash
Returns name => region.
175 176 177 |
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 175 def regions_by_name @regions_by_name ||= timeZones.map { |tz| [tz.displayName, tz.region] }.to_h end |