ruby-jss 1.2.9 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +196 -1
- data/lib/jamf.rb +10 -3
- data/lib/jamf/api/abstract_classes/collection_resource.rb +329 -150
- data/lib/jamf/api/abstract_classes/generic_reference.rb +9 -1
- data/lib/jamf/api/abstract_classes/json_object.rb +107 -83
- data/lib/jamf/api/abstract_classes/prestage.rb +55 -30
- data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +21 -0
- data/lib/jamf/api/abstract_classes/resource.rb +4 -4
- data/lib/jamf/api/abstract_classes/singleton_resource.rb +1 -1
- data/lib/jamf/api/connection.rb +20 -12
- data/lib/jamf/api/connection/api_error.rb +8 -8
- data/lib/jamf/api/connection/token.rb +36 -15
- data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +14 -1
- data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
- data/lib/jamf/api/json_objects/device_enrollment_device_sync_state.rb +81 -0
- data/lib/jamf/api/json_objects/locale.rb +59 -0
- data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
- data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
- data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
- data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
- data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
- data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
- data/lib/jamf/api/mixins/change_log.rb +201 -51
- data/lib/jamf/api/mixins/filterable.rb +51 -0
- data/lib/jamf/api/mixins/pageable.rb +208 -0
- data/lib/jamf/api/mixins/sortable.rb +59 -0
- data/lib/jamf/api/resources/collection_resources/building.rb +19 -8
- data/lib/jamf/api/resources/collection_resources/category.rb +5 -3
- data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +11 -4
- data/lib/jamf/api/resources/collection_resources/department.rb +1 -1
- data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +13 -13
- data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
- data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +24 -22
- data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
- data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
- data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +14 -14
- data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
- data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
- data/lib/jamf/configuration.rb +7 -9
- data/lib/jamf/ruby_extensions.rb +1 -0
- data/lib/jamf/ruby_extensions/array.rb +1 -1
- data/lib/jamf/ruby_extensions/array/utils.rb +3 -3
- data/lib/jamf/ruby_extensions/dig.rb +52 -0
- data/lib/jamf/validate.rb +63 -24
- data/lib/jamf/version.rb +1 -1
- data/lib/jss.rb +4 -1
- data/lib/jss/api_connection.rb +110 -397
- data/lib/jss/api_object.rb +16 -13
- data/lib/jss/api_object/advanced_search.rb +27 -26
- data/lib/jss/api_object/app_store_country_codes.rb +298 -0
- data/lib/jss/api_object/categorizable.rb +1 -1
- data/lib/jss/api_object/computer.rb +5 -1
- data/lib/jss/api_object/configuration_profile.rb +34 -3
- data/lib/jss/api_object/directory_binding.rb +273 -0
- data/lib/jss/api_object/directory_binding_type.rb +96 -0
- data/lib/jss/api_object/directory_binding_type/active_directory.rb +539 -0
- data/lib/jss/api_object/directory_binding_type/admitmac.rb +594 -0
- data/lib/jss/api_object/directory_binding_type/centrify.rb +226 -0
- data/lib/jss/api_object/directory_binding_type/open_directory.rb +178 -0
- data/lib/jss/api_object/directory_binding_type/powerbroker_identity_services.rb +73 -0
- data/lib/jss/api_object/disk_encryption_configurations.rb +114 -0
- data/lib/jss/api_object/distribution_point.rb +97 -37
- data/lib/jss/api_object/dock_item.rb +143 -0
- data/lib/jss/api_object/ebook.rb +1 -2
- data/lib/jss/api_object/extendable.rb +68 -32
- data/lib/jss/api_object/extension_attribute.rb +4 -3
- data/lib/jss/api_object/group.rb +33 -2
- data/lib/jss/api_object/mac_application.rb +107 -8
- data/lib/jss/api_object/mobile_device.rb +3 -0
- data/lib/jss/api_object/mobile_device_application.rb +12 -0
- data/lib/jss/api_object/network_segment.rb +195 -70
- data/lib/jss/api_object/package.rb +105 -40
- data/lib/jss/api_object/patch_source.rb +10 -9
- data/lib/jss/api_object/policy.rb +491 -7
- data/lib/jss/api_object/printer.rb +446 -0
- data/lib/jss/api_object/scopable.rb +10 -15
- data/lib/jss/api_object/scopable/scope.rb +386 -71
- data/lib/jss/api_object/self_servable.rb +17 -9
- data/lib/jss/api_object/uploadable.rb +1 -1
- data/lib/jss/api_object/user.rb +42 -1
- data/lib/jss/api_object/vpp_account.rb +209 -0
- data/lib/jss/api_object/vppable.rb +169 -13
- data/lib/jss/composer.rb +1 -1
- data/lib/jss/exceptions.rb +3 -0
- data/lib/jss/server.rb +15 -0
- data/lib/jss/utility.rb +8 -22
- data/lib/jss/validate.rb +53 -10
- data/lib/jss/version.rb +1 -1
- metadata +50 -22
@@ -40,7 +40,7 @@ module Jamf
|
|
40
40
|
|
41
41
|
UPDATABLE = true
|
42
42
|
|
43
|
-
RSRC_VERSION = '
|
43
|
+
RSRC_VERSION = 'v2'.freeze
|
44
44
|
|
45
45
|
RSRC_PATH = 'check-in'.freeze
|
46
46
|
|
@@ -54,79 +54,79 @@ module Jamf
|
|
54
54
|
|
55
55
|
# @!attribute isCreateHooks
|
56
56
|
# @return [Boolean]
|
57
|
-
|
57
|
+
createHooks: {
|
58
58
|
class: :boolean
|
59
59
|
},
|
60
60
|
|
61
61
|
# @!attribute isHookLog
|
62
62
|
# @return [Boolean]
|
63
|
-
|
63
|
+
hookLog: {
|
64
64
|
class: :boolean
|
65
65
|
},
|
66
66
|
|
67
67
|
# @!attribute isHookPolicies
|
68
68
|
# @return [Boolean]
|
69
|
-
|
69
|
+
hookPolicies: {
|
70
70
|
class: :boolean
|
71
71
|
},
|
72
72
|
|
73
73
|
# @!attribute isHookHideRestore
|
74
74
|
# @return [Boolean]
|
75
|
-
|
75
|
+
hookHideRestore: {
|
76
76
|
class: :boolean
|
77
77
|
},
|
78
78
|
|
79
79
|
# @!attribute isHookMCX
|
80
80
|
# @return [Boolean]
|
81
|
-
|
81
|
+
hookMcx: {
|
82
82
|
class: :boolean
|
83
83
|
},
|
84
84
|
|
85
85
|
# @!attribute isBackgroundHooks
|
86
86
|
# @return [Boolean]
|
87
|
-
|
87
|
+
backgroundHooks: {
|
88
88
|
class: :boolean
|
89
89
|
},
|
90
90
|
|
91
91
|
# @!attribute isHookDisplayStatus
|
92
92
|
# @return [Boolean]
|
93
|
-
|
93
|
+
hookDisplayStatus: {
|
94
94
|
class: :boolean
|
95
95
|
},
|
96
96
|
|
97
97
|
# @!attribute isCreateStartupScript
|
98
98
|
# @return [Boolean]
|
99
|
-
|
99
|
+
createStartupScript: {
|
100
100
|
class: :boolean
|
101
101
|
},
|
102
102
|
|
103
103
|
# @!attribute isStartupLog
|
104
104
|
# @return [Boolean]
|
105
|
-
|
105
|
+
startupLog: {
|
106
106
|
class: :boolean
|
107
107
|
},
|
108
108
|
|
109
109
|
# @!attribute isStartupPolicies
|
110
110
|
# @return [Boolean]
|
111
|
-
|
111
|
+
startupPolicies: {
|
112
112
|
class: :boolean
|
113
113
|
},
|
114
114
|
|
115
115
|
# @!attribute isStartupSSH
|
116
116
|
# @return [Boolean]
|
117
|
-
|
117
|
+
startupSsh: {
|
118
118
|
class: :boolean
|
119
119
|
},
|
120
120
|
|
121
121
|
# @!attribute isStartupMCX
|
122
122
|
# @return [Boolean]
|
123
|
-
|
123
|
+
startupMcx: {
|
124
124
|
class: :boolean
|
125
125
|
},
|
126
126
|
|
127
127
|
# @!attribute isEnableLocalConfigurationProfiles
|
128
128
|
# @return [Boolean]
|
129
|
-
|
129
|
+
enableLocalConfigurationProfiles: {
|
130
130
|
class: :boolean
|
131
131
|
}
|
132
132
|
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# Copyright 2020 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
# The Module
|
27
|
+
module Jamf
|
28
|
+
|
29
|
+
# Classes
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
# A list of known timezones
|
33
|
+
class Locales < Jamf::SingletonResource
|
34
|
+
|
35
|
+
# Mix-Ins
|
36
|
+
#####################################
|
37
|
+
|
38
|
+
extend Jamf::Immutable
|
39
|
+
|
40
|
+
# Constants
|
41
|
+
#####################################
|
42
|
+
|
43
|
+
RSRC_VERSION = 'v1'.freeze
|
44
|
+
|
45
|
+
RSRC_PATH = 'locales'.freeze
|
46
|
+
|
47
|
+
OBJECT_MODEL = {
|
48
|
+
|
49
|
+
# @!attribute checkInFrequency
|
50
|
+
# @return [integer]
|
51
|
+
locales: {
|
52
|
+
class: Jamf::Locale,
|
53
|
+
multi: true,
|
54
|
+
read_only: true,
|
55
|
+
aliases: [:list]
|
56
|
+
}
|
57
|
+
|
58
|
+
}.freeze # end OBJECT_MODEL
|
59
|
+
|
60
|
+
parse_object_model
|
61
|
+
|
62
|
+
# TEMP? until this endpoint is brought up to standards
|
63
|
+
# the data from the API is a raw Array, but it should be a
|
64
|
+
# Hash containing an array.
|
65
|
+
def initialize(data, cnx: Jamf.cnx)
|
66
|
+
data = { locales: data }
|
67
|
+
super data, cnx: cnx
|
68
|
+
end
|
69
|
+
|
70
|
+
# Class Methods
|
71
|
+
#####################################
|
72
|
+
|
73
|
+
# @return [Array<Jamf::Locale>] all the locales available
|
74
|
+
#
|
75
|
+
def self.list(refresh = false, cnx: Jamf.cnx)
|
76
|
+
fetch(refresh, cnx: cnx).locales
|
77
|
+
end
|
78
|
+
|
79
|
+
# Class level wrapper for #descriptions
|
80
|
+
def self.descriptions(refresh = false, cnx: Jamf.cnx)
|
81
|
+
fetch(refresh, cnx: cnx).descriptions
|
82
|
+
end
|
83
|
+
# how to alias a class method
|
84
|
+
singleton_class.send(:alias_method, :names, :descriptions)
|
85
|
+
|
86
|
+
# Class level wrapper for #identifiers
|
87
|
+
def self.identifiers(refresh = false, cnx: Jamf.cnx)
|
88
|
+
fetch(refresh, cnx: cnx).identifiers
|
89
|
+
end
|
90
|
+
singleton_class.send(:alias_method, :ids, :identifiers)
|
91
|
+
|
92
|
+
# Class level wrapper for #ids_by_desc
|
93
|
+
def self.ids_by_desc(refresh = false, cnx: Jamf.cnx)
|
94
|
+
fetch(refresh, cnx: cnx).ids_by_desc
|
95
|
+
end
|
96
|
+
|
97
|
+
# Class level wrapper for #descs_by_id
|
98
|
+
def self.descs_by_id(refresh = false, cnx: Jamf.cnx)
|
99
|
+
fetch(refresh, cnx: cnx).descs_by_id
|
100
|
+
end
|
101
|
+
|
102
|
+
# Class level wrapper for #id_for_desc
|
103
|
+
def self.id_for_desc(desc, refresh = false, cnx: Jamf.cnx)
|
104
|
+
fetch(refresh, cnx: cnx).id_for_desc desc
|
105
|
+
end
|
106
|
+
|
107
|
+
# Class level wrapper for #desc_for_id
|
108
|
+
def self.desc_for_id(id, refresh = false, cnx: Jamf.cnx)
|
109
|
+
fetch(refresh, cnx: cnx).desc_for_id id
|
110
|
+
end
|
111
|
+
|
112
|
+
# Instance Methods
|
113
|
+
#####################################
|
114
|
+
|
115
|
+
# @return [Array<String>] the available descriptions
|
116
|
+
def descriptions
|
117
|
+
@descriptions ||= locales.map(&:description)
|
118
|
+
end
|
119
|
+
alias names descriptions
|
120
|
+
|
121
|
+
# @return [Array<String>] the available identifiers
|
122
|
+
def identifiers
|
123
|
+
@identifiers ||= locales.map(&:identifier)
|
124
|
+
end
|
125
|
+
alias ids identifiers
|
126
|
+
|
127
|
+
# @return [Hash] name => code
|
128
|
+
def ids_by_desc
|
129
|
+
@ids_by_desc ||= locales.map { |l| [l.description, l.identifier] }.to_h
|
130
|
+
end
|
131
|
+
|
132
|
+
# @return [Hash] code => name
|
133
|
+
def descs_by_id
|
134
|
+
@descs_by_id ||= locales.map { |l| [l.identifier, l.description] }.to_h
|
135
|
+
end
|
136
|
+
|
137
|
+
# return an identifier from its description, case-insensitive
|
138
|
+
# @param desc[String] the description of a locale
|
139
|
+
# @return [String]
|
140
|
+
def id_for_desc(desc)
|
141
|
+
desc = descriptions.select { |n| n.casecmp? desc }.first
|
142
|
+
ids_by_desc[desc]
|
143
|
+
end
|
144
|
+
|
145
|
+
# return a description from its identifier, case-insensitive
|
146
|
+
# @param name[String] the identifier of a local
|
147
|
+
# @return [String]
|
148
|
+
def desc_for_id(id)
|
149
|
+
id = identifiers.select { |n| n.casecmp? id }.first
|
150
|
+
descs_by_id[id]
|
151
|
+
end
|
152
|
+
|
153
|
+
end # class
|
154
|
+
|
155
|
+
end # module
|
@@ -0,0 +1,213 @@
|
|
1
|
+
# Copyright 2020 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
# The Module
|
27
|
+
module Jamf
|
28
|
+
|
29
|
+
# Classes
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
# A list of known timezones
|
33
|
+
class TimeZones < Jamf::SingletonResource
|
34
|
+
|
35
|
+
# Mix-Ins
|
36
|
+
#####################################
|
37
|
+
|
38
|
+
extend Jamf::Immutable
|
39
|
+
|
40
|
+
# Constants
|
41
|
+
#####################################
|
42
|
+
|
43
|
+
RSRC_VERSION = 'v1'.freeze
|
44
|
+
|
45
|
+
RSRC_PATH = 'time-zones'.freeze
|
46
|
+
|
47
|
+
OBJECT_MODEL = {
|
48
|
+
|
49
|
+
# @!attribute checkInFrequency
|
50
|
+
# @return [integer]
|
51
|
+
timeZones: {
|
52
|
+
class: Jamf::TimeZone,
|
53
|
+
multi: true,
|
54
|
+
read_only: true,
|
55
|
+
aliases: [:list]
|
56
|
+
}
|
57
|
+
|
58
|
+
}.freeze # end OBJECT_MODEL
|
59
|
+
|
60
|
+
parse_object_model
|
61
|
+
|
62
|
+
# TEMP? until this endpoint is brought up to standards
|
63
|
+
# the data from the API is a raw Array, but it should be a
|
64
|
+
# Hash containing an array.
|
65
|
+
def initialize(data, cnx: Jamf.cnx)
|
66
|
+
data = { timeZones: data }
|
67
|
+
super data, cnx: cnx
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
# Class Methods
|
73
|
+
#####################################
|
74
|
+
|
75
|
+
# @return [Array<Jamf::TimeZone>] all the zomes available
|
76
|
+
#
|
77
|
+
def self.list(refresh = false, cnx: Jamf.cnx)
|
78
|
+
fetch(refresh, cnx: cnx).timeZones
|
79
|
+
end
|
80
|
+
|
81
|
+
# Class level wrapper for #displayNames
|
82
|
+
def self.displayNames(refresh = false, cnx: Jamf.cnx)
|
83
|
+
fetch(refresh, cnx: cnx).displayNames
|
84
|
+
end
|
85
|
+
singleton_class.send(:alias_method, :names, :displayNames)
|
86
|
+
|
87
|
+
# Class level wrapper for #zoneIds
|
88
|
+
def self.zoneIds(refresh = false, cnx: Jamf.cnx)
|
89
|
+
fetch(refresh, cnx: cnx).zoneIds
|
90
|
+
end
|
91
|
+
singleton_class.send(:alias_method, :ids, :zoneIds)
|
92
|
+
|
93
|
+
# Class level wrapper for #regions
|
94
|
+
def self.regions(refresh = false, cnx: Jamf.cnx)
|
95
|
+
fetch(refresh, cnx: cnx).regions
|
96
|
+
end
|
97
|
+
|
98
|
+
# Class level wrapper for #ids_by_name
|
99
|
+
def self.ids_by_name(refresh = false, cnx: Jamf.cnx)
|
100
|
+
fetch(refresh, cnx: cnx).ids_by_name
|
101
|
+
end
|
102
|
+
|
103
|
+
# Class level wrapper for #names_by_id
|
104
|
+
def self.names_by_id(refresh = false, cnx: Jamf.cnx)
|
105
|
+
fetch(refresh, cnx: cnx).names_by_id
|
106
|
+
end
|
107
|
+
|
108
|
+
# Class level wrapper for #regions_by_id
|
109
|
+
def self.regions_by_id(refresh = false, cnx: Jamf.cnx)
|
110
|
+
fetch(refresh, cnx: cnx).regions_by_id
|
111
|
+
end
|
112
|
+
|
113
|
+
# Class level wrapper for #regions_by_name
|
114
|
+
def self.regions_by_name(refresh = false, cnx: Jamf.cnx)
|
115
|
+
fetch(refresh, cnx: cnx).regions_by_name
|
116
|
+
end
|
117
|
+
|
118
|
+
# Class level wrapper for #id_for_name
|
119
|
+
def self.id_for_name(name, refresh = false, cnx: Jamf.cnx)
|
120
|
+
fetch(refresh, cnx: cnx).id_for_name name
|
121
|
+
end
|
122
|
+
|
123
|
+
# Class level wrapper for #name_for_id
|
124
|
+
def self.name_for_id(id, refresh = false, cnx: Jamf.cnx)
|
125
|
+
fetch(refresh, cnx: cnx).name_for_id id
|
126
|
+
end
|
127
|
+
|
128
|
+
# Class level wrapper for #region_for_name
|
129
|
+
def self.region_for_name(name, refresh = false, cnx: Jamf.cnx)
|
130
|
+
fetch(refresh, cnx: cnx).region_for_name name
|
131
|
+
end
|
132
|
+
|
133
|
+
# Class level wrapper for #name_for_id
|
134
|
+
def self.region_for_id(id, refresh = false, cnx: Jamf.cnx)
|
135
|
+
fetch(refresh, cnx: cnx).region_for_id id
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
# Instance Methods
|
140
|
+
#####################################
|
141
|
+
|
142
|
+
# @return [Array<String>] the available zone names
|
143
|
+
def displayNames
|
144
|
+
@names ||= timeZones.map(&:displayName)
|
145
|
+
end
|
146
|
+
alias names displayNames
|
147
|
+
|
148
|
+
# @return [Array<String>] the available zone ids
|
149
|
+
def zoneIds
|
150
|
+
@ids ||= timeZones.map(&:zoneId)
|
151
|
+
end
|
152
|
+
alias ids zoneIds
|
153
|
+
|
154
|
+
# @return [Array<String>] the available zone regions
|
155
|
+
def regions
|
156
|
+
@regions ||= timeZones.map(&:region).uniq
|
157
|
+
end
|
158
|
+
|
159
|
+
# @return [Hash] name => id
|
160
|
+
def ids_by_name
|
161
|
+
@ids_by_name ||= timeZones.map { |tz| [tz.displayName, tz.zoneId] }.to_h
|
162
|
+
end
|
163
|
+
|
164
|
+
# @return [Hash] id => name
|
165
|
+
def names_by_id
|
166
|
+
@names_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.displayName] }.to_h
|
167
|
+
end
|
168
|
+
|
169
|
+
# @return [Hash] id => region
|
170
|
+
def regions_by_id
|
171
|
+
@regions_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.region] }.to_h
|
172
|
+
end
|
173
|
+
|
174
|
+
# @return [Hash] name => region
|
175
|
+
def regions_by_name
|
176
|
+
@regions_by_name ||= timeZones.map { |tz| [tz.displayName, tz.region] }.to_h
|
177
|
+
end
|
178
|
+
|
179
|
+
# return a zone id from its name, case-insensitive
|
180
|
+
# @param name[String] the name of a zone
|
181
|
+
# @return [String]
|
182
|
+
def id_for_name(name)
|
183
|
+
name = names.select { |n| n.casecmp? name }.first
|
184
|
+
ids_by_name[name]
|
185
|
+
end
|
186
|
+
|
187
|
+
# return a zone name from its id, case-insensitive
|
188
|
+
# @param name[String] the name of a zone
|
189
|
+
# @return [String]
|
190
|
+
def name_for_id(id)
|
191
|
+
id = ids.select { |n| n.casecmp? id }.first
|
192
|
+
names_by_id[id]
|
193
|
+
end
|
194
|
+
|
195
|
+
# return a zone name from its id, case-insensitive
|
196
|
+
# @param name[String] the name of a zone
|
197
|
+
# @return [String]
|
198
|
+
def region_for_name(name)
|
199
|
+
name = names.select { |n| n.casecmp? name }.first
|
200
|
+
regions_by_name[name]
|
201
|
+
end
|
202
|
+
|
203
|
+
# return a zones from its id, case-insensitive
|
204
|
+
# @param name[String] the name of a zone
|
205
|
+
# @return [String]
|
206
|
+
def region_for_id(id)
|
207
|
+
id = ids.select { |n| n.casecmp? id }.first
|
208
|
+
regions_by_id[id]
|
209
|
+
end
|
210
|
+
|
211
|
+
end # class
|
212
|
+
|
213
|
+
end # module
|