pds-metronome 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +164 -0
  4. data/Rakefile +10 -0
  5. data/docs/AccessManagementApi.md +300 -0
  6. data/docs/AccessType.md +15 -0
  7. data/docs/AgingOffsetUnit.md +15 -0
  8. data/docs/AgingStrategy.md +15 -0
  9. data/docs/ApiKeyData.md +28 -0
  10. data/docs/ApiKeyDataListResponse.md +20 -0
  11. data/docs/ApiKeyListResponse.md +20 -0
  12. data/docs/CreateApiKeyRequest.md +22 -0
  13. data/docs/CreateOrModifyApiKeyResponse.md +22 -0
  14. data/docs/CreateOrModifyPolicyRequest.md +22 -0
  15. data/docs/CreateOrModifyPolicyResponse.md +20 -0
  16. data/docs/DataExpiryApi.md +79 -0
  17. data/docs/ExpireItemResponse.md +20 -0
  18. data/docs/ExpireSubItemResponse.md +22 -0
  19. data/docs/ExpiryResponse.md +22 -0
  20. data/docs/ExpiryResponsePendingInner.md +79 -0
  21. data/docs/GetManyApiKeys200Response.md +79 -0
  22. data/docs/GetManyPolicies200Response.md +79 -0
  23. data/docs/ItemAccessApi.md +605 -0
  24. data/docs/ItemExpiry.md +20 -0
  25. data/docs/ItemMetadataResponse.md +28 -0
  26. data/docs/ItemOrSubItemAccessLog.md +32 -0
  27. data/docs/ItemOrSubItemPolicyResponse.md +22 -0
  28. data/docs/ModifyApiKeyRequest.md +20 -0
  29. data/docs/Permission.md +15 -0
  30. data/docs/PermissionDeniedResponse.md +30 -0
  31. data/docs/PolicyData.md +26 -0
  32. data/docs/PolicyDataListResponse.md +28 -0
  33. data/docs/PolicyListResponse.md +28 -0
  34. data/docs/PolicyManagementApi.md +379 -0
  35. data/docs/PutApiKeyRequest.md +49 -0
  36. data/docs/SignupRequest.md +18 -0
  37. data/docs/SignupResponse.md +24 -0
  38. data/docs/SubItemMetadataResponse.md +22 -0
  39. data/docs/SubItemsExpiry.md +22 -0
  40. data/docs/TelemetryApi.md +80 -0
  41. data/docs/TelemetryObservation.md +20 -0
  42. data/docs/TelemetryRequest.md +22 -0
  43. data/docs/ValidationErrorResponseInner.md +22 -0
  44. data/docs/ValidationProblem.md +22 -0
  45. data/lib/metronome/api/access_management_api.rb +285 -0
  46. data/lib/metronome/api/data_expiry_api.rb +105 -0
  47. data/lib/metronome/api/item_access_api.rb +549 -0
  48. data/lib/metronome/api/policy_management_api.rb +348 -0
  49. data/lib/metronome/api/telemetry_api.rb +84 -0
  50. data/lib/metronome/api_client.rb +393 -0
  51. data/lib/metronome/api_error.rb +58 -0
  52. data/lib/metronome/configuration.rb +312 -0
  53. data/lib/metronome/models/access_type.rb +41 -0
  54. data/lib/metronome/models/aging_offset_unit.rb +41 -0
  55. data/lib/metronome/models/aging_strategy.rb +40 -0
  56. data/lib/metronome/models/api_key_data.rb +330 -0
  57. data/lib/metronome/models/api_key_data_list_response.rb +241 -0
  58. data/lib/metronome/models/api_key_list_response.rb +241 -0
  59. data/lib/metronome/models/create_api_key_request.rb +239 -0
  60. data/lib/metronome/models/create_or_modify_api_key_response.rb +255 -0
  61. data/lib/metronome/models/create_or_modify_policy_request.rb +293 -0
  62. data/lib/metronome/models/create_or_modify_policy_response.rb +240 -0
  63. data/lib/metronome/models/expire_item_response.rb +240 -0
  64. data/lib/metronome/models/expire_sub_item_response.rb +254 -0
  65. data/lib/metronome/models/expiry_response.rb +299 -0
  66. data/lib/metronome/models/expiry_response_pending_inner.rb +55 -0
  67. data/lib/metronome/models/get_many_api_keys200_response.rb +55 -0
  68. data/lib/metronome/models/get_many_policies200_response.rb +55 -0
  69. data/lib/metronome/models/item_expiry.rb +239 -0
  70. data/lib/metronome/models/item_metadata_response.rb +274 -0
  71. data/lib/metronome/models/item_or_sub_item_access_log.rb +337 -0
  72. data/lib/metronome/models/item_or_sub_item_policy_response.rb +245 -0
  73. data/lib/metronome/models/modify_api_key_request.rb +230 -0
  74. data/lib/metronome/models/permission.rb +45 -0
  75. data/lib/metronome/models/permission_denied_response.rb +338 -0
  76. data/lib/metronome/models/policy_data.rb +364 -0
  77. data/lib/metronome/models/policy_data_list_response.rb +286 -0
  78. data/lib/metronome/models/policy_list_response.rb +286 -0
  79. data/lib/metronome/models/put_api_key_request.rb +105 -0
  80. data/lib/metronome/models/signup_request.rb +225 -0
  81. data/lib/metronome/models/signup_response.rb +266 -0
  82. data/lib/metronome/models/sub_item_metadata_response.rb +245 -0
  83. data/lib/metronome/models/sub_items_expiry.rb +255 -0
  84. data/lib/metronome/models/telemetry_observation.rb +240 -0
  85. data/lib/metronome/models/telemetry_request.rb +259 -0
  86. data/lib/metronome/models/validation_error_response_inner.rb +254 -0
  87. data/lib/metronome/models/validation_problem.rb +254 -0
  88. data/lib/metronome/version.rb +15 -0
  89. data/lib/metronome.rb +80 -0
  90. data/shell.nix +6 -0
  91. data/spec/api/access_management_api_spec.rb +82 -0
  92. data/spec/api/data_expiry_api_spec.rb +46 -0
  93. data/spec/api/item_access_api_spec.rb +132 -0
  94. data/spec/api/policy_management_api_spec.rb +94 -0
  95. data/spec/api/telemetry_api_spec.rb +46 -0
  96. data/spec/api_client_spec.rb +228 -0
  97. data/spec/configuration_spec.rb +42 -0
  98. data/spec/models/access_type_spec.rb +28 -0
  99. data/spec/models/aging_offset_unit_spec.rb +28 -0
  100. data/spec/models/aging_strategy_spec.rb +28 -0
  101. data/spec/models/api_key_data_list_response_spec.rb +40 -0
  102. data/spec/models/api_key_data_spec.rb +68 -0
  103. data/spec/models/api_key_list_response_spec.rb +40 -0
  104. data/spec/models/create_api_key_request_spec.rb +46 -0
  105. data/spec/models/create_or_modify_api_key_response_spec.rb +46 -0
  106. data/spec/models/create_or_modify_policy_request_spec.rb +46 -0
  107. data/spec/models/create_or_modify_policy_response_spec.rb +40 -0
  108. data/spec/models/expire_item_response_spec.rb +40 -0
  109. data/spec/models/expire_sub_item_response_spec.rb +46 -0
  110. data/spec/models/expiry_response_pending_inner_spec.rb +43 -0
  111. data/spec/models/expiry_response_spec.rb +46 -0
  112. data/spec/models/get_many_api_keys200_response_spec.rb +43 -0
  113. data/spec/models/get_many_policies200_response_spec.rb +43 -0
  114. data/spec/models/item_expiry_spec.rb +40 -0
  115. data/spec/models/item_metadata_response_spec.rb +64 -0
  116. data/spec/models/item_or_sub_item_access_log_spec.rb +76 -0
  117. data/spec/models/item_or_sub_item_policy_response_spec.rb +46 -0
  118. data/spec/models/modify_api_key_request_spec.rb +40 -0
  119. data/spec/models/permission_denied_response_spec.rb +82 -0
  120. data/spec/models/permission_spec.rb +28 -0
  121. data/spec/models/policy_data_list_response_spec.rb +64 -0
  122. data/spec/models/policy_data_spec.rb +58 -0
  123. data/spec/models/policy_list_response_spec.rb +64 -0
  124. data/spec/models/put_api_key_request_spec.rb +31 -0
  125. data/spec/models/signup_request_spec.rb +34 -0
  126. data/spec/models/signup_response_spec.rb +52 -0
  127. data/spec/models/sub_item_metadata_response_spec.rb +46 -0
  128. data/spec/models/sub_items_expiry_spec.rb +46 -0
  129. data/spec/models/telemetry_observation_spec.rb +40 -0
  130. data/spec/models/telemetry_request_spec.rb +46 -0
  131. data/spec/models/validation_error_response_inner_spec.rb +46 -0
  132. data/spec/models/validation_problem_spec.rb +46 -0
  133. data/spec/spec_helper.rb +111 -0
  134. metadata +260 -0
@@ -0,0 +1,230 @@
1
+ =begin
2
+ #Metronome API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: info@privatedataservices.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Metronome
17
+ class ModifyApiKeyRequest
18
+ attr_accessor :status
19
+
20
+ attr_accessor :permissions
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'status' => :'status',
26
+ :'permissions' => :'permissions'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'status' => :'String',
39
+ :'permissions' => :'Array<Permission>'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Metronome::ModifyApiKeyRequest` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Metronome::ModifyApiKeyRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'status')
65
+ self.status = attributes[:'status']
66
+ end
67
+
68
+ if attributes.key?(:'permissions')
69
+ if (value = attributes[:'permissions']).is_a?(Array)
70
+ self.permissions = value
71
+ end
72
+ end
73
+ end
74
+
75
+ # Show invalid properties with the reasons. Usually used together with valid?
76
+ # @return Array for valid properties with the reasons
77
+ def list_invalid_properties
78
+ invalid_properties = Array.new
79
+ invalid_properties
80
+ end
81
+
82
+ # Check to see if the all the properties in the model are valid
83
+ # @return true if the model is valid
84
+ def valid?
85
+ true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ status == o.status &&
94
+ permissions == o.permissions
95
+ end
96
+
97
+ # @see the `==` method
98
+ # @param [Object] Object to be compared
99
+ def eql?(o)
100
+ self == o
101
+ end
102
+
103
+ # Calculates hash code according to all attributes.
104
+ # @return [Integer] Hash code
105
+ def hash
106
+ [status, permissions].hash
107
+ end
108
+
109
+ # Builds the object from hash
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ # @return [Object] Returns the model itself
112
+ def self.build_from_hash(attributes)
113
+ new.build_from_hash(attributes)
114
+ end
115
+
116
+ # Builds the object from hash
117
+ # @param [Hash] attributes Model attributes in the form of hash
118
+ # @return [Object] Returns the model itself
119
+ def build_from_hash(attributes)
120
+ return nil unless attributes.is_a?(Hash)
121
+ attributes = attributes.transform_keys(&:to_sym)
122
+ self.class.openapi_types.each_pair do |key, type|
123
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
124
+ self.send("#{key}=", nil)
125
+ elsif type =~ /\AArray<(.*)>/i
126
+ # check to ensure the input is an array given that the attribute
127
+ # is documented as an array but the input is not
128
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
129
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
130
+ end
131
+ elsif !attributes[self.class.attribute_map[key]].nil?
132
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
133
+ end
134
+ end
135
+
136
+ self
137
+ end
138
+
139
+ # Deserializes the data based on type
140
+ # @param string type Data type
141
+ # @param string value Value to be deserialized
142
+ # @return [Object] Deserialized data
143
+ def _deserialize(type, value)
144
+ case type.to_sym
145
+ when :Time
146
+ Time.parse(value)
147
+ when :Date
148
+ Date.parse(value)
149
+ when :String
150
+ value.to_s
151
+ when :Integer
152
+ value.to_i
153
+ when :Float
154
+ value.to_f
155
+ when :Boolean
156
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
157
+ true
158
+ else
159
+ false
160
+ end
161
+ when :Object
162
+ # generic object (usually a Hash), return directly
163
+ value
164
+ when /\AArray<(?<inner_type>.+)>\z/
165
+ inner_type = Regexp.last_match[:inner_type]
166
+ value.map { |v| _deserialize(inner_type, v) }
167
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
168
+ k_type = Regexp.last_match[:k_type]
169
+ v_type = Regexp.last_match[:v_type]
170
+ {}.tap do |hash|
171
+ value.each do |k, v|
172
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
173
+ end
174
+ end
175
+ else # model
176
+ # models (e.g. Pet) or oneOf
177
+ klass = Metronome.const_get(type)
178
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
179
+ end
180
+ end
181
+
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_body
191
+ to_hash
192
+ end
193
+
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_hash
197
+ hash = {}
198
+ self.class.attribute_map.each_pair do |attr, param|
199
+ value = self.send(attr)
200
+ if value.nil?
201
+ is_nullable = self.class.openapi_nullable.include?(attr)
202
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
203
+ end
204
+
205
+ hash[param] = _to_hash(value)
206
+ end
207
+ hash
208
+ end
209
+
210
+ # Outputs non-array value in the form of hash
211
+ # For object, use to_hash. Otherwise, just return the value
212
+ # @param [Object] value Any valid value
213
+ # @return [Hash] Returns the value in the form of hash
214
+ def _to_hash(value)
215
+ if value.is_a?(Array)
216
+ value.compact.map { |v| _to_hash(v) }
217
+ elsif value.is_a?(Hash)
218
+ {}.tap do |hash|
219
+ value.each { |k, v| hash[k] = _to_hash(v) }
220
+ end
221
+ elsif value.respond_to? :to_hash
222
+ value.to_hash
223
+ else
224
+ value
225
+ end
226
+ end
227
+
228
+ end
229
+
230
+ end
@@ -0,0 +1,45 @@
1
+ =begin
2
+ #Metronome API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: info@privatedataservices.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Metronome
17
+ class Permission
18
+ API_KEY_WRITE = "api-key-write".freeze
19
+ API_KEY_READ = "api-key-read".freeze
20
+ POLICY_READ = "policy-read".freeze
21
+ POLICY_WRITE = "policy-write".freeze
22
+ ITEM_READ = "item-read".freeze
23
+ TELEMETRY_WRITE = "telemetry-write".freeze
24
+ EXPIRY_NOTICE_READ = "expiry-notice-read".freeze
25
+
26
+ def self.all_vars
27
+ @all_vars ||= [API_KEY_WRITE, API_KEY_READ, POLICY_READ, POLICY_WRITE, ITEM_READ, TELEMETRY_WRITE, EXPIRY_NOTICE_READ].freeze
28
+ end
29
+
30
+ # Builds the enum from string
31
+ # @param [String] The enum value in the form of the string
32
+ # @return [String] The enum value
33
+ def self.build_from_hash(value)
34
+ new.build_from_hash(value)
35
+ end
36
+
37
+ # Builds the enum from string
38
+ # @param [String] The enum value in the form of the string
39
+ # @return [String] The enum value
40
+ def build_from_hash(value)
41
+ return value if Permission.all_vars.include?(value)
42
+ raise "Invalid ENUM value #{value} for class #Permission"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,338 @@
1
+ =begin
2
+ #Metronome API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: info@privatedataservices.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Metronome
17
+ class PermissionDeniedResponse
18
+ attr_accessor :error_code
19
+
20
+ attr_accessor :customer_status
21
+
22
+ attr_accessor :api_key_status
23
+
24
+ attr_accessor :granted_permissions
25
+
26
+ attr_accessor :required_permission
27
+
28
+ attr_accessor :internal_contact
29
+
30
+ attr_accessor :message
31
+
32
+ class EnumAttributeValidator
33
+ attr_reader :datatype
34
+ attr_reader :allowable_values
35
+
36
+ def initialize(datatype, allowable_values)
37
+ @allowable_values = allowable_values.map do |value|
38
+ case datatype.to_s
39
+ when /Integer/i
40
+ value.to_i
41
+ when /Float/i
42
+ value.to_f
43
+ else
44
+ value
45
+ end
46
+ end
47
+ end
48
+
49
+ def valid?(value)
50
+ !value || allowable_values.include?(value)
51
+ end
52
+ end
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :'error_code' => :'error-code',
58
+ :'customer_status' => :'customer-status',
59
+ :'api_key_status' => :'api-key-status',
60
+ :'granted_permissions' => :'granted-permissions',
61
+ :'required_permission' => :'required-permission',
62
+ :'internal_contact' => :'internal-contact',
63
+ :'message' => :'message'
64
+ }
65
+ end
66
+
67
+ # Returns all the JSON keys this model knows about
68
+ def self.acceptable_attributes
69
+ attribute_map.values
70
+ end
71
+
72
+ # Attribute type mapping.
73
+ def self.openapi_types
74
+ {
75
+ :'error_code' => :'String',
76
+ :'customer_status' => :'String',
77
+ :'api_key_status' => :'String',
78
+ :'granted_permissions' => :'Array<Permission>',
79
+ :'required_permission' => :'Permission',
80
+ :'internal_contact' => :'String',
81
+ :'message' => :'String'
82
+ }
83
+ end
84
+
85
+ # List of attributes with nullable: true
86
+ def self.openapi_nullable
87
+ Set.new([
88
+ ])
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Metronome::PermissionDeniedResponse` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}) { |(k, v), h|
100
+ if (!self.class.attribute_map.key?(k.to_sym))
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Metronome::PermissionDeniedResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
102
+ end
103
+ h[k.to_sym] = v
104
+ }
105
+
106
+ if attributes.key?(:'error_code')
107
+ self.error_code = attributes[:'error_code']
108
+ end
109
+
110
+ if attributes.key?(:'customer_status')
111
+ self.customer_status = attributes[:'customer_status']
112
+ end
113
+
114
+ if attributes.key?(:'api_key_status')
115
+ self.api_key_status = attributes[:'api_key_status']
116
+ end
117
+
118
+ if attributes.key?(:'granted_permissions')
119
+ if (value = attributes[:'granted_permissions']).is_a?(Array)
120
+ self.granted_permissions = value
121
+ end
122
+ end
123
+
124
+ if attributes.key?(:'required_permission')
125
+ self.required_permission = attributes[:'required_permission']
126
+ end
127
+
128
+ if attributes.key?(:'internal_contact')
129
+ self.internal_contact = attributes[:'internal_contact']
130
+ end
131
+
132
+ if attributes.key?(:'message')
133
+ self.message = attributes[:'message']
134
+ end
135
+ end
136
+
137
+ # Show invalid properties with the reasons. Usually used together with valid?
138
+ # @return Array for valid properties with the reasons
139
+ def list_invalid_properties
140
+ invalid_properties = Array.new
141
+ if @error_code.nil?
142
+ invalid_properties.push('invalid value for "error_code", error_code cannot be nil.')
143
+ end
144
+
145
+ invalid_properties
146
+ end
147
+
148
+ # Check to see if the all the properties in the model are valid
149
+ # @return true if the model is valid
150
+ def valid?
151
+ return false if @error_code.nil?
152
+ error_code_validator = EnumAttributeValidator.new('String', ["unknown-customer", "account-restricted", "api-key-lacks-permission"])
153
+ return false unless error_code_validator.valid?(@error_code)
154
+ customer_status_validator = EnumAttributeValidator.new('String', ["read-write", "read-only", "disabled"])
155
+ return false unless customer_status_validator.valid?(@customer_status)
156
+ api_key_status_validator = EnumAttributeValidator.new('String', ["enabled", "disabled"])
157
+ return false unless api_key_status_validator.valid?(@api_key_status)
158
+ true
159
+ end
160
+
161
+ # Custom attribute writer method checking allowed values (enum).
162
+ # @param [Object] error_code Object to be assigned
163
+ def error_code=(error_code)
164
+ validator = EnumAttributeValidator.new('String', ["unknown-customer", "account-restricted", "api-key-lacks-permission"])
165
+ unless validator.valid?(error_code)
166
+ fail ArgumentError, "invalid value for \"error_code\", must be one of #{validator.allowable_values}."
167
+ end
168
+ @error_code = error_code
169
+ end
170
+
171
+ # Custom attribute writer method checking allowed values (enum).
172
+ # @param [Object] customer_status Object to be assigned
173
+ def customer_status=(customer_status)
174
+ validator = EnumAttributeValidator.new('String', ["read-write", "read-only", "disabled"])
175
+ unless validator.valid?(customer_status)
176
+ fail ArgumentError, "invalid value for \"customer_status\", must be one of #{validator.allowable_values}."
177
+ end
178
+ @customer_status = customer_status
179
+ end
180
+
181
+ # Custom attribute writer method checking allowed values (enum).
182
+ # @param [Object] api_key_status Object to be assigned
183
+ def api_key_status=(api_key_status)
184
+ validator = EnumAttributeValidator.new('String', ["enabled", "disabled"])
185
+ unless validator.valid?(api_key_status)
186
+ fail ArgumentError, "invalid value for \"api_key_status\", must be one of #{validator.allowable_values}."
187
+ end
188
+ @api_key_status = api_key_status
189
+ end
190
+
191
+ # Checks equality by comparing each attribute.
192
+ # @param [Object] Object to be compared
193
+ def ==(o)
194
+ return true if self.equal?(o)
195
+ self.class == o.class &&
196
+ error_code == o.error_code &&
197
+ customer_status == o.customer_status &&
198
+ api_key_status == o.api_key_status &&
199
+ granted_permissions == o.granted_permissions &&
200
+ required_permission == o.required_permission &&
201
+ internal_contact == o.internal_contact &&
202
+ message == o.message
203
+ end
204
+
205
+ # @see the `==` method
206
+ # @param [Object] Object to be compared
207
+ def eql?(o)
208
+ self == o
209
+ end
210
+
211
+ # Calculates hash code according to all attributes.
212
+ # @return [Integer] Hash code
213
+ def hash
214
+ [error_code, customer_status, api_key_status, granted_permissions, required_permission, internal_contact, message].hash
215
+ end
216
+
217
+ # Builds the object from hash
218
+ # @param [Hash] attributes Model attributes in the form of hash
219
+ # @return [Object] Returns the model itself
220
+ def self.build_from_hash(attributes)
221
+ new.build_from_hash(attributes)
222
+ end
223
+
224
+ # Builds the object from hash
225
+ # @param [Hash] attributes Model attributes in the form of hash
226
+ # @return [Object] Returns the model itself
227
+ def build_from_hash(attributes)
228
+ return nil unless attributes.is_a?(Hash)
229
+ attributes = attributes.transform_keys(&:to_sym)
230
+ self.class.openapi_types.each_pair do |key, type|
231
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
232
+ self.send("#{key}=", nil)
233
+ elsif type =~ /\AArray<(.*)>/i
234
+ # check to ensure the input is an array given that the attribute
235
+ # is documented as an array but the input is not
236
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
237
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
238
+ end
239
+ elsif !attributes[self.class.attribute_map[key]].nil?
240
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
241
+ end
242
+ end
243
+
244
+ self
245
+ end
246
+
247
+ # Deserializes the data based on type
248
+ # @param string type Data type
249
+ # @param string value Value to be deserialized
250
+ # @return [Object] Deserialized data
251
+ def _deserialize(type, value)
252
+ case type.to_sym
253
+ when :Time
254
+ Time.parse(value)
255
+ when :Date
256
+ Date.parse(value)
257
+ when :String
258
+ value.to_s
259
+ when :Integer
260
+ value.to_i
261
+ when :Float
262
+ value.to_f
263
+ when :Boolean
264
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
265
+ true
266
+ else
267
+ false
268
+ end
269
+ when :Object
270
+ # generic object (usually a Hash), return directly
271
+ value
272
+ when /\AArray<(?<inner_type>.+)>\z/
273
+ inner_type = Regexp.last_match[:inner_type]
274
+ value.map { |v| _deserialize(inner_type, v) }
275
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
276
+ k_type = Regexp.last_match[:k_type]
277
+ v_type = Regexp.last_match[:v_type]
278
+ {}.tap do |hash|
279
+ value.each do |k, v|
280
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
281
+ end
282
+ end
283
+ else # model
284
+ # models (e.g. Pet) or oneOf
285
+ klass = Metronome.const_get(type)
286
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
287
+ end
288
+ end
289
+
290
+ # Returns the string representation of the object
291
+ # @return [String] String presentation of the object
292
+ def to_s
293
+ to_hash.to_s
294
+ end
295
+
296
+ # to_body is an alias to to_hash (backward compatibility)
297
+ # @return [Hash] Returns the object in the form of hash
298
+ def to_body
299
+ to_hash
300
+ end
301
+
302
+ # Returns the object in the form of hash
303
+ # @return [Hash] Returns the object in the form of hash
304
+ def to_hash
305
+ hash = {}
306
+ self.class.attribute_map.each_pair do |attr, param|
307
+ value = self.send(attr)
308
+ if value.nil?
309
+ is_nullable = self.class.openapi_nullable.include?(attr)
310
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
311
+ end
312
+
313
+ hash[param] = _to_hash(value)
314
+ end
315
+ hash
316
+ end
317
+
318
+ # Outputs non-array value in the form of hash
319
+ # For object, use to_hash. Otherwise, just return the value
320
+ # @param [Object] value Any valid value
321
+ # @return [Hash] Returns the value in the form of hash
322
+ def _to_hash(value)
323
+ if value.is_a?(Array)
324
+ value.compact.map { |v| _to_hash(v) }
325
+ elsif value.is_a?(Hash)
326
+ {}.tap do |hash|
327
+ value.each { |k, v| hash[k] = _to_hash(v) }
328
+ end
329
+ elsif value.respond_to? :to_hash
330
+ value.to_hash
331
+ else
332
+ value
333
+ end
334
+ end
335
+
336
+ end
337
+
338
+ end