|
| 1 | +""" |
| 2 | + Patch API V1 |
| 3 | +
|
| 4 | + The core API used to integrate with Patch's service # noqa: E501 |
| 5 | +
|
| 6 | + The version of the OpenAPI document: v1 |
| 7 | + Contact: developers@usepatch.com |
| 8 | + Generated by: https://openapi-generator.tech |
| 9 | +""" |
| 10 | + |
| 11 | + |
| 12 | +import re # noqa: F401 |
| 13 | +import sys # noqa: F401 |
| 14 | + |
| 15 | +from patch_api.model_utils import ( # noqa: F401 |
| 16 | + ApiTypeError, |
| 17 | + ModelComposed, |
| 18 | + ModelNormal, |
| 19 | + ModelSimple, |
| 20 | + cached_property, |
| 21 | + change_keys_js_to_python, |
| 22 | + convert_js_args_to_python_args, |
| 23 | + date, |
| 24 | + datetime, |
| 25 | + file_type, |
| 26 | + none_type, |
| 27 | + validate_get_composed_info, |
| 28 | +) |
| 29 | +from ..model_utils import OpenApiModel |
| 30 | +from patch_api.exceptions import ApiAttributeError |
| 31 | + |
| 32 | + |
| 33 | +class Allocation(ModelNormal): |
| 34 | + """NOTE: This class is auto generated by OpenAPI Generator. |
| 35 | + Ref: https://openapi-generator.tech |
| 36 | +
|
| 37 | + Do not edit the class manually. |
| 38 | +
|
| 39 | + Attributes: |
| 40 | + allowed_values (dict): The key is the tuple path to the attribute |
| 41 | + and the for var_name this is (var_name,). The value is a dict |
| 42 | + with a capitalized key describing the allowed value and an allowed |
| 43 | + value. These dicts store the allowed enum values. |
| 44 | + attribute_map (dict): The key is attribute name |
| 45 | + and the value is json key in definition. |
| 46 | + discriminator_value_class_map (dict): A dict to go from the discriminator |
| 47 | + variable value to the discriminator class name. |
| 48 | + validations (dict): The key is the tuple path to the attribute |
| 49 | + and the for var_name this is (var_name,). The value is a dict |
| 50 | + that stores validations for max_length, min_length, max_items, |
| 51 | + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, |
| 52 | + inclusive_minimum, and regex. |
| 53 | + additional_properties_type (tuple): A tuple of classes accepted |
| 54 | + as additional properties values. |
| 55 | + """ |
| 56 | + |
| 57 | + allowed_values = {} |
| 58 | + |
| 59 | + validations = {} |
| 60 | + |
| 61 | + @cached_property |
| 62 | + def additional_properties_type(): |
| 63 | + """ |
| 64 | + This must be a method because a model may have properties that are |
| 65 | + of type self, this must run after the class is loaded |
| 66 | + """ |
| 67 | + return ( |
| 68 | + bool, |
| 69 | + date, |
| 70 | + datetime, |
| 71 | + dict, |
| 72 | + float, |
| 73 | + int, |
| 74 | + list, |
| 75 | + str, |
| 76 | + none_type, |
| 77 | + ) # noqa: E501 |
| 78 | + |
| 79 | + _nullable = False |
| 80 | + |
| 81 | + @cached_property |
| 82 | + def openapi_types(): |
| 83 | + """ |
| 84 | + This must be a method because a model may have properties that are |
| 85 | + of type self, this must run after the class is loaded |
| 86 | +
|
| 87 | + Returns |
| 88 | + openapi_types (dict): The key is attribute name |
| 89 | + and the value is attribute type. |
| 90 | + """ |
| 91 | + return { |
| 92 | + "id": (str,), # noqa: E501 |
| 93 | + "production": (bool,), # noqa: E501 |
| 94 | + "mass_g": (int,), # noqa: E501 |
| 95 | + } |
| 96 | + |
| 97 | + @cached_property |
| 98 | + def discriminator(): |
| 99 | + return None |
| 100 | + |
| 101 | + attribute_map = { |
| 102 | + "id": "id", # noqa: E501 |
| 103 | + "production": "production", # noqa: E501 |
| 104 | + "mass_g": "mass_g", # noqa: E501 |
| 105 | + } |
| 106 | + |
| 107 | + read_only_vars = {} |
| 108 | + |
| 109 | + _composed_schemas = {} |
| 110 | + |
| 111 | + @classmethod |
| 112 | + @convert_js_args_to_python_args |
| 113 | + def _from_openapi_data(cls, id, production, mass_g, *args, **kwargs): # noqa: E501 |
| 114 | + """Allocation - a model defined in OpenAPI |
| 115 | +
|
| 116 | + Args: |
| 117 | + id (str): A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in. |
| 118 | + production (bool): A boolean indicating if this project is a production or test mode project. |
| 119 | + mass_g (int): The amount (in grams) of allocated carbon offsets. |
| 120 | +
|
| 121 | + Keyword Args: |
| 122 | + _check_type (bool): if True, values for parameters in openapi_types |
| 123 | + will be type checked and a TypeError will be |
| 124 | + raised if the wrong type is input. |
| 125 | + Defaults to True |
| 126 | + _path_to_item (tuple/list): This is a list of keys or values to |
| 127 | + drill down to the model in received_data |
| 128 | + when deserializing a response |
| 129 | + _spec_property_naming (bool): True if the variable names in the input data |
| 130 | + are serialized names, as specified in the OpenAPI document. |
| 131 | + False if the variable names in the input data |
| 132 | + are pythonic names, e.g. snake case (default) |
| 133 | + _configuration (Configuration): the instance to use when |
| 134 | + deserializing a file_type parameter. |
| 135 | + If passed, type conversion is attempted |
| 136 | + If omitted no type conversion is done. |
| 137 | + _visited_composed_classes (tuple): This stores a tuple of |
| 138 | + classes that we have traveled through so that |
| 139 | + if we see that class again we will not use its |
| 140 | + discriminator again. |
| 141 | + When traveling through a discriminator, the |
| 142 | + composed schema that is |
| 143 | + is traveled through is added to this set. |
| 144 | + For example if Animal has a discriminator |
| 145 | + petType and we pass in "Dog", and the class Dog |
| 146 | + allOf includes Animal, we move through Animal |
| 147 | + once using the discriminator, and pick Dog. |
| 148 | + Then in Dog, we will make an instance of the |
| 149 | + Animal class but this time we won't travel |
| 150 | + through its discriminator because we passed in |
| 151 | + _visited_composed_classes = (Animal,) |
| 152 | + """ |
| 153 | + |
| 154 | + _check_type = kwargs.pop("_check_type", True) |
| 155 | + _spec_property_naming = kwargs.pop("_spec_property_naming", False) |
| 156 | + _path_to_item = kwargs.pop("_path_to_item", ()) |
| 157 | + _configuration = kwargs.pop("_configuration", None) |
| 158 | + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) |
| 159 | + |
| 160 | + self = super(OpenApiModel, cls).__new__(cls) |
| 161 | + |
| 162 | + if args: |
| 163 | + raise ApiTypeError( |
| 164 | + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." |
| 165 | + % ( |
| 166 | + args, |
| 167 | + self.__class__.__name__, |
| 168 | + ), |
| 169 | + path_to_item=_path_to_item, |
| 170 | + valid_classes=(self.__class__,), |
| 171 | + ) |
| 172 | + |
| 173 | + self._data_store = {} |
| 174 | + self._check_type = _check_type |
| 175 | + self._spec_property_naming = _spec_property_naming |
| 176 | + self._path_to_item = _path_to_item |
| 177 | + self._configuration = _configuration |
| 178 | + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) |
| 179 | + |
| 180 | + self.id = id |
| 181 | + self.production = production |
| 182 | + self.mass_g = mass_g |
| 183 | + for var_name, var_value in kwargs.items(): |
| 184 | + if ( |
| 185 | + var_name not in self.attribute_map |
| 186 | + and self._configuration is not None |
| 187 | + and self._configuration.discard_unknown_keys |
| 188 | + and self.additional_properties_type is None |
| 189 | + ): |
| 190 | + # discard variable. |
| 191 | + continue |
| 192 | + setattr(self, var_name, var_value) |
| 193 | + return self |
| 194 | + |
| 195 | + required_properties = set( |
| 196 | + [ |
| 197 | + "_data_store", |
| 198 | + "_check_type", |
| 199 | + "_spec_property_naming", |
| 200 | + "_path_to_item", |
| 201 | + "_configuration", |
| 202 | + "_visited_composed_classes", |
| 203 | + ] |
| 204 | + ) |
| 205 | + |
| 206 | + @convert_js_args_to_python_args |
| 207 | + def __init__(self, id, production, mass_g, *args, **kwargs): # noqa: E501 |
| 208 | + """Allocation - a model defined in OpenAPI |
| 209 | +
|
| 210 | + Args: |
| 211 | + id (str): A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in. |
| 212 | + production (bool): A boolean indicating if this project is a production or test mode project. |
| 213 | + mass_g (int): The amount (in grams) of allocated carbon offsets. |
| 214 | +
|
| 215 | + Keyword Args: |
| 216 | + _check_type (bool): if True, values for parameters in openapi_types |
| 217 | + will be type checked and a TypeError will be |
| 218 | + raised if the wrong type is input. |
| 219 | + Defaults to True |
| 220 | + _path_to_item (tuple/list): This is a list of keys or values to |
| 221 | + drill down to the model in received_data |
| 222 | + when deserializing a response |
| 223 | + _spec_property_naming (bool): True if the variable names in the input data |
| 224 | + are serialized names, as specified in the OpenAPI document. |
| 225 | + False if the variable names in the input data |
| 226 | + are pythonic names, e.g. snake case (default) |
| 227 | + _configuration (Configuration): the instance to use when |
| 228 | + deserializing a file_type parameter. |
| 229 | + If passed, type conversion is attempted |
| 230 | + If omitted no type conversion is done. |
| 231 | + _visited_composed_classes (tuple): This stores a tuple of |
| 232 | + classes that we have traveled through so that |
| 233 | + if we see that class again we will not use its |
| 234 | + discriminator again. |
| 235 | + When traveling through a discriminator, the |
| 236 | + composed schema that is |
| 237 | + is traveled through is added to this set. |
| 238 | + For example if Animal has a discriminator |
| 239 | + petType and we pass in "Dog", and the class Dog |
| 240 | + allOf includes Animal, we move through Animal |
| 241 | + once using the discriminator, and pick Dog. |
| 242 | + Then in Dog, we will make an instance of the |
| 243 | + Animal class but this time we won't travel |
| 244 | + through its discriminator because we passed in |
| 245 | + _visited_composed_classes = (Animal,) |
| 246 | + """ |
| 247 | + |
| 248 | + _check_type = kwargs.pop("_check_type", True) |
| 249 | + _spec_property_naming = kwargs.pop("_spec_property_naming", False) |
| 250 | + _path_to_item = kwargs.pop("_path_to_item", ()) |
| 251 | + _configuration = kwargs.pop("_configuration", None) |
| 252 | + _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) |
| 253 | + |
| 254 | + if args: |
| 255 | + raise ApiTypeError( |
| 256 | + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." |
| 257 | + % ( |
| 258 | + args, |
| 259 | + self.__class__.__name__, |
| 260 | + ), |
| 261 | + path_to_item=_path_to_item, |
| 262 | + valid_classes=(self.__class__,), |
| 263 | + ) |
| 264 | + |
| 265 | + self._data_store = {} |
| 266 | + self._check_type = _check_type |
| 267 | + self._spec_property_naming = _spec_property_naming |
| 268 | + self._path_to_item = _path_to_item |
| 269 | + self._configuration = _configuration |
| 270 | + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) |
| 271 | + |
| 272 | + self.id = id |
| 273 | + self.production = production |
| 274 | + self.mass_g = mass_g |
| 275 | + for var_name, var_value in kwargs.items(): |
| 276 | + if ( |
| 277 | + var_name not in self.attribute_map |
| 278 | + and self._configuration is not None |
| 279 | + and self._configuration.discard_unknown_keys |
| 280 | + and self.additional_properties_type is None |
| 281 | + ): |
| 282 | + # discard variable. |
| 283 | + continue |
| 284 | + setattr(self, var_name, var_value) |
| 285 | + if var_name in self.read_only_vars: |
| 286 | + raise ApiAttributeError( |
| 287 | + f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " |
| 288 | + f"class with read only attributes." |
| 289 | + ) |
0 commit comments