intersight_client 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,381 +0,0 @@
1
- {{#description}}
2
- # {{{.}}}
3
- {{/description}}
4
- class {{classname}}{{#parent}} < {{{.}}}{{/parent}}
5
- {{#vars}}
6
- {{#description}}
7
- # {{{.}}}
8
- {{/description}}
9
- attr_accessor :{{{name}}}
10
-
11
- {{/vars}}
12
- {{#hasEnums}}
13
- class EnumAttributeValidator
14
- attr_reader :datatype
15
- attr_reader :allowable_values
16
-
17
- def initialize(datatype, allowable_values)
18
- @allowable_values = allowable_values.map do |value|
19
- case datatype.to_s
20
- when /Integer/i
21
- value.to_i
22
- when /Float/i
23
- value.to_f
24
- else
25
- value
26
- end
27
- end
28
- end
29
-
30
- def valid?(value)
31
- !value || allowable_values.include?(value)
32
- end
33
- end
34
-
35
- {{/hasEnums}}
36
- # Attribute mapping from ruby-style variable name to JSON key.
37
- def self.attribute_map
38
- {
39
- {{#vars}}
40
- :'{{{name}}}' => :'{{{baseName}}}'{{^-last}},{{/-last}}
41
- {{/vars}}
42
- }
43
- end
44
-
45
- # Returns all the JSON keys this model knows about{{#parent}}, including the ones defined in its parent(s){{/parent}}
46
- def self.acceptable_attributes
47
- {{^parent}}
48
- attribute_map.values
49
- {{/parent}}
50
- {{#parent}}
51
- attribute_map.values.concat(superclass.acceptable_attributes)
52
- {{/parent}}
53
- end
54
-
55
- # Returns the key-value map of all the JSON attributes this model knows about{{#parent}}, including the ones defined in its parent(s){{/parent}}
56
- def self.acceptable_attribute_map
57
- {{^parent}}
58
- attribute_map
59
- {{/parent}}
60
- {{#parent}}
61
- attribute_map.merge(superclass.acceptable_attribute_map)
62
- {{/parent}}
63
- end
64
-
65
- # Attribute type mapping.
66
- def self.openapi_types
67
- {
68
- {{#vars}}
69
- :'{{{name}}}' => :'{{{dataType}}}'{{^-last}},{{/-last}}
70
- {{/vars}}
71
- }
72
- end
73
-
74
- # List of attributes with nullable: true
75
- def self.openapi_nullable
76
- Set.new([
77
- {{#vars}}
78
- {{#isNullable}}
79
- :'{{{name}}}'{{^-last}},{{/-last}}
80
- {{/isNullable}}
81
- {{/vars}}
82
- ])
83
- end
84
-
85
- {{#anyOf}}
86
- {{#-first}}
87
- # List of class defined in anyOf (OpenAPI v3)
88
- def self.openapi_any_of
89
- [
90
- {{/-first}}
91
- :'{{{.}}}'{{^-last}},{{/-last}}
92
- {{#-last}}
93
- ]
94
- end
95
-
96
- {{/-last}}
97
- {{/anyOf}}
98
- {{#allOf}}
99
- {{#-first}}
100
- # List of class defined in allOf (OpenAPI v3)
101
- def self.openapi_all_of
102
- [
103
- {{/-first}}
104
- :'{{{.}}}'{{^-last}},{{/-last}}
105
- {{#-last}}
106
- ]
107
- end
108
-
109
- {{/-last}}
110
- {{/allOf}}
111
- {{#discriminator}}
112
- {{#propertyName}}
113
- # discriminator's property name in OpenAPI v3
114
- def self.openapi_discriminator_name
115
- :'{{{.}}}'
116
- end
117
-
118
- {{/propertyName}}
119
- {{/discriminator}}
120
- # Initializes the object
121
- # @param [Hash] attributes Model attributes in the form of hash
122
- def initialize(attributes = {})
123
- if (!attributes.is_a?(Hash))
124
- fail ArgumentError, "The input argument (attributes) must be a hash in `{{{moduleName}}}::{{{classname}}}` initialize method"
125
- end
126
-
127
- # check to see if the attribute exists and convert string to symbol for hash key
128
- attributes = attributes.each_with_object({}) { |(k, v), h|
129
- if (!self.class.acceptable_attribute_map.key?(k.to_sym))
130
- fail ArgumentError, "`#{k}` is not a valid attribute in `#{self.class.name}`. Please check the name to make sure it's valid. List of attributes: " + self.class.acceptable_attribute_map.keys.inspect
131
- end
132
- h[k.to_sym] = v
133
- }
134
- {{#parent}}
135
-
136
- # call parent's initialize
137
- super(attributes)
138
- {{/parent}}
139
- {{#vars}}
140
-
141
- if attributes.key?(:'{{{name}}}')
142
- {{#isArray}}
143
- if (value = attributes[:'{{{name}}}']).is_a?(Array)
144
- self.{{{name}}} = value
145
- end
146
- {{/isArray}}
147
- {{#isMap}}
148
- if (value = attributes[:'{{{name}}}']).is_a?(Hash)
149
- self.{{{name}}} = value
150
- end
151
- {{/isMap}}
152
- {{^isContainer}}
153
- self.{{{name}}} = attributes[:'{{{name}}}']
154
- {{/isContainer}}
155
- {{#defaultValue}}
156
- else
157
- self.{{{name}}} = {{{defaultValue}}}
158
- {{/defaultValue}}
159
- end
160
- {{/vars}}
161
- end
162
-
163
- # Show invalid properties with the reasons. Usually used together with valid?
164
- # @return Array for valid properties with the reasons
165
- def list_invalid_properties
166
- invalid_properties = {{^parent}}Array.new{{/parent}}{{#parent}}super{{/parent}}
167
- {{#vars}}
168
- {{^isNullable}}
169
- {{#required}}
170
- if @{{{name}}}.nil?
171
- invalid_properties.push('invalid value for "{{{name}}}", {{{name}}} cannot be nil.')
172
- end
173
-
174
- {{/required}}
175
- {{/isNullable}}
176
- {{#hasValidation}}
177
- {{#maxLength}}
178
- if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}}
179
- invalid_properties.push('invalid value for "{{{name}}}", the character length must be smaller than or equal to {{{maxLength}}}.')
180
- end
181
-
182
- {{/maxLength}}
183
- {{#minLength}}
184
- if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length < {{{minLength}}}
185
- invalid_properties.push('invalid value for "{{{name}}}", the character length must be great than or equal to {{{minLength}}}.')
186
- end
187
-
188
- {{/minLength}}
189
- {{#maximum}}
190
- if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
191
- invalid_properties.push('invalid value for "{{{name}}}", must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.')
192
- end
193
-
194
- {{/maximum}}
195
- {{#minimum}}
196
- if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
197
- invalid_properties.push('invalid value for "{{{name}}}", must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.')
198
- end
199
-
200
- {{/minimum}}
201
- {{#pattern}}
202
- pattern = Regexp.new({{{pattern}}})
203
- if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ pattern
204
- invalid_properties.push("invalid value for \"{{{name}}}\", must conform to the pattern #{pattern}.")
205
- end
206
-
207
- {{/pattern}}
208
- {{#maxItems}}
209
- if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}}
210
- invalid_properties.push('invalid value for "{{{name}}}", number of items must be less than or equal to {{{maxItems}}}.')
211
- end
212
-
213
- {{/maxItems}}
214
- {{#minItems}}
215
- if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}}
216
- invalid_properties.push('invalid value for "{{{name}}}", number of items must be greater than or equal to {{{minItems}}}.')
217
- end
218
-
219
- {{/minItems}}
220
- {{/hasValidation}}
221
- {{/vars}}
222
- invalid_properties
223
- end
224
-
225
- # Check to see if the all the properties in the model are valid
226
- # @return true if the model is valid
227
- def valid?
228
- {{#vars}}
229
- {{^isNullable}}
230
- {{#required}}
231
- return false if @{{{name}}}.nil?
232
- {{/required}}
233
- {{/isNullable}}
234
- {{#isEnum}}
235
- {{^isContainer}}
236
- {{{name}}}_validator = EnumAttributeValidator.new('{{{dataType}}}', [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])
237
- return false unless {{{name}}}_validator.valid?(@{{{name}}})
238
- {{/isContainer}}
239
- {{/isEnum}}
240
- {{#hasValidation}}
241
- {{#maxLength}}
242
- return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}}
243
- {{/maxLength}}
244
- {{#minLength}}
245
- return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length < {{{minLength}}}
246
- {{/minLength}}
247
- {{#maximum}}
248
- return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
249
- {{/maximum}}
250
- {{#minimum}}
251
- return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
252
- {{/minimum}}
253
- {{#pattern}}
254
- return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}})
255
- {{/pattern}}
256
- {{#maxItems}}
257
- return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}}
258
- {{/maxItems}}
259
- {{#minItems}}
260
- return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}}
261
- {{/minItems}}
262
- {{/hasValidation}}
263
- {{/vars}}
264
- {{#anyOf}}
265
- {{#-first}}
266
- _any_of_found = false
267
- self.class.openapi_any_of.each do |_class|
268
- _any_of = {{moduleName}}.const_get(_class).build_from_hash(self.to_hash)
269
- if _any_of.valid?
270
- _any_of_found = true
271
- end
272
- end
273
-
274
- if !_any_of_found
275
- return false
276
- end
277
-
278
- {{/-first}}
279
- {{/anyOf}}
280
- true{{#parent}} && super{{/parent}}
281
- end
282
-
283
- {{#vars}}
284
- {{#isEnum}}
285
- {{^isContainer}}
286
- # Custom attribute writer method checking allowed values (enum).
287
- # @param [Object] {{{name}}} Object to be assigned
288
- def {{{name}}}=({{{name}}})
289
- validator = EnumAttributeValidator.new('{{{dataType}}}', [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])
290
- unless validator.valid?({{{name}}})
291
- fail ArgumentError, "invalid value for \"{{{name}}}\", must be one of #{validator.allowable_values}."
292
- end
293
- @{{{name}}} = {{{name}}}
294
- end
295
-
296
- {{/isContainer}}
297
- {{/isEnum}}
298
- {{^isEnum}}
299
- {{#hasValidation}}
300
- # Custom attribute writer method with validation
301
- # @param [Object] {{{name}}} Value to be assigned
302
- def {{{name}}}=({{{name}}})
303
- {{^isNullable}}
304
- {{#required}}
305
- if {{{name}}}.nil?
306
- fail ArgumentError, '{{{name}}} cannot be nil'
307
- end
308
-
309
- {{/required}}
310
- {{/isNullable}}
311
- {{#maxLength}}
312
- if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length > {{{maxLength}}}
313
- fail ArgumentError, 'invalid value for "{{{name}}}", the character length must be smaller than or equal to {{{maxLength}}}.'
314
- end
315
-
316
- {{/maxLength}}
317
- {{#minLength}}
318
- if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length < {{{minLength}}}
319
- fail ArgumentError, 'invalid value for "{{{name}}}", the character length must be great than or equal to {{{minLength}}}.'
320
- end
321
-
322
- {{/minLength}}
323
- {{#maximum}}
324
- if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
325
- fail ArgumentError, 'invalid value for "{{{name}}}", must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.'
326
- end
327
-
328
- {{/maximum}}
329
- {{#minimum}}
330
- if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
331
- fail ArgumentError, 'invalid value for "{{{name}}}", must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.'
332
- end
333
-
334
- {{/minimum}}
335
- {{#pattern}}
336
- pattern = Regexp.new({{{pattern}}})
337
- if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} !~ pattern
338
- fail ArgumentError, "invalid value for \"{{{name}}}\", must conform to the pattern #{pattern}."
339
- end
340
-
341
- {{/pattern}}
342
- {{#maxItems}}
343
- if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length > {{{maxItems}}}
344
- fail ArgumentError, 'invalid value for "{{{name}}}", number of items must be less than or equal to {{{maxItems}}}.'
345
- end
346
-
347
- {{/maxItems}}
348
- {{#minItems}}
349
- if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length < {{{minItems}}}
350
- fail ArgumentError, 'invalid value for "{{{name}}}", number of items must be greater than or equal to {{{minItems}}}.'
351
- end
352
-
353
- {{/minItems}}
354
- @{{{name}}} = {{{name}}}
355
- end
356
-
357
- {{/hasValidation}}
358
- {{/isEnum}}
359
- {{/vars}}
360
- # Checks equality by comparing each attribute.
361
- # @param [Object] Object to be compared
362
- def ==(o)
363
- return true if self.equal?(o)
364
- self.class == o.class{{#vars}} &&
365
- {{name}} == o.{{name}}{{/vars}}{{#parent}} && super(o){{/parent}}
366
- end
367
-
368
- # @see the `==` method
369
- # @param [Object] Object to be compared
370
- def eql?(o)
371
- self == o
372
- end
373
-
374
- # Calculates hash code according to all attributes.
375
- # @return [Integer] Hash code
376
- def hash
377
- [{{#vars}}{{name}}{{^-last}}, {{/-last}}{{/vars}}].hash
378
- end
379
-
380
- {{> base_object}}
381
- end
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/git_push.sh DELETED
@@ -1,57 +0,0 @@
1
- #!/bin/sh
2
- # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3
- #
4
- # Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
5
-
6
- git_user_id=$1
7
- git_repo_id=$2
8
- release_note=$3
9
- git_host=$4
10
-
11
- if [ "$git_host" = "" ]; then
12
- git_host="github.com"
13
- echo "[INFO] No command line input provided. Set \$git_host to $git_host"
14
- fi
15
-
16
- if [ "$git_user_id" = "" ]; then
17
- git_user_id="GIT_USER_ID"
18
- echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
- fi
20
-
21
- if [ "$git_repo_id" = "" ]; then
22
- git_repo_id="GIT_REPO_ID"
23
- echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24
- fi
25
-
26
- if [ "$release_note" = "" ]; then
27
- release_note="Minor update"
28
- echo "[INFO] No command line input provided. Set \$release_note to $release_note"
29
- fi
30
-
31
- # Initialize the local directory as a Git repository
32
- git init
33
-
34
- # Adds the files in the local repository and stages them for commit.
35
- git add .
36
-
37
- # Commits the tracked changes and prepares them to be pushed to a remote repository.
38
- git commit -m "$release_note"
39
-
40
- # Sets the new remote
41
- git_remote=$(git remote)
42
- if [ "$git_remote" = "" ]; then # git remote not defined
43
-
44
- if [ "$GIT_TOKEN" = "" ]; then
45
- echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
46
- git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
47
- else
48
- git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
49
- fi
50
-
51
- fi
52
-
53
- git pull origin master
54
-
55
- # Pushes (Forces) the changes in the local repository up to the remote repository
56
- echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
57
- git push origin master 2>&1 | grep -v 'To https'