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