| [3a89adb] | 1 | # coding: utf-8
|
|---|
| 2 |
|
|---|
| 3 | from __future__ import absolute_import
|
|---|
| 4 | from datetime import date, datetime # noqa: F401
|
|---|
| 5 |
|
|---|
| 6 | from typing import List, Dict # noqa: F401
|
|---|
| 7 |
|
|---|
| 8 | from {{modelPackage}}.base_model_ import Model
|
|---|
| 9 | {{#models}}
|
|---|
| 10 | {{#model}}
|
|---|
| 11 | {{#pyImports}}
|
|---|
| 12 | {{import}}
|
|---|
| 13 | {{/pyImports}}
|
|---|
| 14 | {{/model}}
|
|---|
| 15 | {{/models}}
|
|---|
| 16 | from {{packageName}} import util
|
|---|
| 17 |
|
|---|
| 18 | {{#imports}}
|
|---|
| 19 | {{{import}}} # noqa: E501
|
|---|
| 20 | {{/imports}}
|
|---|
| 21 |
|
|---|
| 22 | {{#models}}
|
|---|
| 23 | {{#model}}
|
|---|
| 24 | class {{classname}}(Model):
|
|---|
| [43fd35c] | 25 | """NOTE: This class is auto generated by OpenAPI Generator
|
|---|
| 26 | (https://openapi-generator.tech).
|
|---|
| [3a89adb] | 27 |
|
|---|
| 28 | Do not edit the class manually.
|
|---|
| 29 | """{{#allowableValues}}
|
|---|
| 30 |
|
|---|
| 31 | """
|
|---|
| 32 | allowed enum values
|
|---|
| 33 | """
|
|---|
| 34 | {{#enumVars}}
|
|---|
| 35 | {{name}} = {{{value}}}{{^-last}}
|
|---|
| 36 | {{/-last}}
|
|---|
| 37 | {{/enumVars}}{{/allowableValues}}
|
|---|
| 38 |
|
|---|
| 39 | def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
|
|---|
| 40 | """{{classname}} - a model defined in OpenAPI
|
|---|
| 41 |
|
|---|
| 42 | {{#vars}}
|
|---|
| 43 | :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501
|
|---|
| 44 | :type {{name}}: {{dataType}}
|
|---|
| 45 | {{/vars}}
|
|---|
| 46 | """
|
|---|
| 47 | self.openapi_types = {
|
|---|
| 48 | {{#vars}}
|
|---|
| 49 | '{{name}}': {{{dataType}}}{{#hasMore}},{{/hasMore}}
|
|---|
| 50 | {{/vars}}
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | self.attribute_map = {
|
|---|
| 54 | {{#vars}}
|
|---|
| 55 | '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}}
|
|---|
| 56 | {{/vars}}
|
|---|
| 57 | }
|
|---|
| 58 | {{#vars}}{{#-first}}
|
|---|
| 59 | {{/-first}}
|
|---|
| 60 | self._{{name}} = {{name}}
|
|---|
| 61 | {{/vars}}
|
|---|
| 62 |
|
|---|
| 63 | @classmethod
|
|---|
| 64 | def from_dict(cls, dikt){{^supportPython2}} -> '{{classname}}'{{/supportPython2}}:
|
|---|
| 65 | """Returns the dict as a model
|
|---|
| 66 |
|
|---|
| 67 | :param dikt: A dict.
|
|---|
| 68 | :type: dict
|
|---|
| 69 | :return: The {{name}} of this {{classname}}. # noqa: E501
|
|---|
| 70 | :rtype: {{classname}}
|
|---|
| 71 | """
|
|---|
| 72 | return util.deserialize_model(dikt, cls){{#vars}}{{#-first}}
|
|---|
| 73 |
|
|---|
| 74 | {{/-first}}
|
|---|
| 75 | @property
|
|---|
| 76 | def {{name}}(self):
|
|---|
| 77 | """Gets the {{name}} of this {{classname}}.
|
|---|
| 78 |
|
|---|
| 79 | {{#description}}
|
|---|
| 80 | {{{description}}} # noqa: E501
|
|---|
| 81 | {{/description}}
|
|---|
| 82 |
|
|---|
| 83 | :return: The {{name}} of this {{classname}}.
|
|---|
| 84 | :rtype: {{dataType}}
|
|---|
| 85 | """
|
|---|
| 86 | return self._{{name}}
|
|---|
| 87 |
|
|---|
| 88 | @{{name}}.setter
|
|---|
| 89 | def {{name}}(self, {{name}}):
|
|---|
| 90 | """Sets the {{name}} of this {{classname}}.
|
|---|
| 91 |
|
|---|
| 92 | {{#description}}
|
|---|
| 93 | {{{description}}} # noqa: E501
|
|---|
| 94 | {{/description}}
|
|---|
| 95 |
|
|---|
| 96 | :param {{name}}: The {{name}} of this {{classname}}.
|
|---|
| 97 | :type {{name}}: {{dataType}}
|
|---|
| 98 | """
|
|---|
| 99 | {{#isEnum}}
|
|---|
| 100 | allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501
|
|---|
| 101 | {{#isContainer}}
|
|---|
| 102 | {{#isListContainer}}
|
|---|
| 103 | if not set({{{name}}}).issubset(set(allowed_values)):
|
|---|
| 104 | raise ValueError(
|
|---|
| 105 | "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501
|
|---|
| 106 | .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501
|
|---|
| 107 | ", ".join(map(str, allowed_values)))
|
|---|
| 108 | )
|
|---|
| 109 | {{/isListContainer}}
|
|---|
| 110 | {{#isMapContainer}}
|
|---|
| 111 | if not set({{{name}}}.keys()).issubset(set(allowed_values)):
|
|---|
| 112 | raise ValueError(
|
|---|
| 113 | "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501
|
|---|
| 114 | .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501
|
|---|
| 115 | ", ".join(map(str, allowed_values)))
|
|---|
| 116 | )
|
|---|
| 117 | {{/isMapContainer}}
|
|---|
| 118 | {{/isContainer}}
|
|---|
| 119 | {{^isContainer}}
|
|---|
| 120 | if {{{name}}} not in allowed_values:
|
|---|
| 121 | raise ValueError(
|
|---|
| 122 | "Invalid value for `{{{name}}}` ({0}), must be one of {1}"
|
|---|
| 123 | .format({{{name}}}, allowed_values)
|
|---|
| 124 | )
|
|---|
| 125 | {{/isContainer}}
|
|---|
| 126 | {{/isEnum}}
|
|---|
| 127 | {{^isEnum}}
|
|---|
| 128 | {{#required}}
|
|---|
| 129 | if {{name}} is None:
|
|---|
| 130 | raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501
|
|---|
| 131 | {{/required}}
|
|---|
| 132 | {{#hasValidation}}
|
|---|
| 133 | {{#maxLength}}
|
|---|
| 134 | if {{name}} is not None and len({{name}}) > {{maxLength}}:
|
|---|
| 135 | raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501
|
|---|
| 136 | {{/maxLength}}
|
|---|
| 137 | {{#minLength}}
|
|---|
| 138 | if {{name}} is not None and len({{name}}) < {{minLength}}:
|
|---|
| 139 | raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501
|
|---|
| 140 | {{/minLength}}
|
|---|
| 141 | {{#maximum}}
|
|---|
| 142 | if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501
|
|---|
| 143 | raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501
|
|---|
| 144 | {{/maximum}}
|
|---|
| 145 | {{#minimum}}
|
|---|
| 146 | if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501
|
|---|
| 147 | raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501
|
|---|
| 148 | {{/minimum}}
|
|---|
| 149 | {{#pattern}}
|
|---|
| 150 | if {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501
|
|---|
| 151 | raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501
|
|---|
| 152 | {{/pattern}}
|
|---|
| 153 | {{#maxItems}}
|
|---|
| 154 | if {{name}} is not None and len({{name}}) > {{maxItems}}:
|
|---|
| 155 | raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501
|
|---|
| 156 | {{/maxItems}}
|
|---|
| 157 | {{#minItems}}
|
|---|
| 158 | if {{name}} is not None and len({{name}}) < {{minItems}}:
|
|---|
| 159 | raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501
|
|---|
| 160 | {{/minItems}}
|
|---|
| 161 | {{/hasValidation}}
|
|---|
| 162 | {{/isEnum}}
|
|---|
| 163 |
|
|---|
| 164 | self._{{name}} = {{name}}{{^-last}}
|
|---|
| 165 |
|
|---|
| 166 | {{/-last}}
|
|---|
| 167 | {{/vars}}
|
|---|
| 168 |
|
|---|
| 169 | {{/model}}
|
|---|
| 170 | {{/models}}
|
|---|