Class: Jamf::TimeZones

Inherits:
SingletonResource show all
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

Instance Method Summary collapse

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.

Returns:



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

Returns:

  • (Boolean)

.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

.regions_by_name(refresh = false, cnx: Jamf.cnx) ⇒ Object

Class level wrapper for #regions_by_name



114
115
116
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 114

def self.regions_by_name(refresh = false, cnx: Jamf.cnx)
  fetch(refresh, cnx: cnx).regions_by_name
end

.zoneIds(refresh = false, cnx: Jamf.cnx) ⇒ Object

Class level wrapper for #zoneIds



88
89
90
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 88

def self.zoneIds(refresh = false, cnx: Jamf.cnx)
  fetch(refresh, cnx: cnx).zoneIds
end

Instance Method Details

#displayNamesArray<String> Also known as: names

Returns the available zone names.

Returns:



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

Parameters:

  • name (String)

    the name of a zone

Returns:



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_nameHash

Returns name => id.

Returns:

  • (Hash)

    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

Parameters:

  • name (String)

    the name of a zone

Returns:



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_idHash

Returns id => name.

Returns:

  • (Hash)

    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

Parameters:

  • name (String)

    the name of a zone

Returns:



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

Parameters:

  • name (String)

    the name of a zone

Returns:



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

#regionsArray<String>

Returns the available zone regions.

Returns:



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_idHash

Returns id => region.

Returns:

  • (Hash)

    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_nameHash

Returns name => region.

Returns:

  • (Hash)

    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

#zoneIdsArray<String> Also known as: ids

Returns the available zone ids.

Returns:



149
150
151
# File 'lib/jamf/api/resources/singleton_resources/time_zones.rb', line 149

def zoneIds
  @ids ||= timeZones.map(&:zoneId)
end