|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + Permify API |
| 5 | +
|
| 6 | + Permify is an open source authorization service for creating fine-grained and scalable authorization systems. |
| 7 | +
|
| 8 | + The version of the OpenAPI document: v0.8.7 |
| 9 | + |
| 10 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 11 | +
|
| 12 | + Do not edit the class manually. |
| 13 | +""" # noqa: E501 |
| 14 | + |
| 15 | + |
| 16 | +from __future__ import annotations |
| 17 | +import pprint |
| 18 | +import re # noqa: F401 |
| 19 | +import json |
| 20 | + |
| 21 | +from pydantic import BaseModel, ConfigDict |
| 22 | +from typing import Any, ClassVar, Dict, List, Optional |
| 23 | +from permify_async.models.partials import Partials |
| 24 | +from permify_async.models.schema_partial_write_request_metadata import SchemaPartialWriteRequestMetadata |
| 25 | +from typing import Optional, Set |
| 26 | +from typing_extensions import Self |
| 27 | + |
| 28 | +class ItContainsTheTenantIdToIdentifyTheTenantAndMetadataOfTheSchemaToBeEditedWithTheCorrespondingEditsToVariousEntities(BaseModel): |
| 29 | + """ |
| 30 | + ItContainsTheTenantIdToIdentifyTheTenantAndMetadataOfTheSchemaToBeEditedWithTheCorrespondingEditsToVariousEntities |
| 31 | + """ # noqa: E501 |
| 32 | + metadata: Optional[SchemaPartialWriteRequestMetadata] = None |
| 33 | + partials: Optional[Dict[str, Partials]] = None |
| 34 | + __properties: ClassVar[List[str]] = ["metadata", "partials"] |
| 35 | + |
| 36 | + model_config = ConfigDict( |
| 37 | + populate_by_name=True, |
| 38 | + validate_assignment=True, |
| 39 | + protected_namespaces=(), |
| 40 | + ) |
| 41 | + |
| 42 | + |
| 43 | + def to_str(self) -> str: |
| 44 | + """Returns the string representation of the model using alias""" |
| 45 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 46 | + |
| 47 | + def to_json(self) -> str: |
| 48 | + """Returns the JSON representation of the model using alias""" |
| 49 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 50 | + return json.dumps(self.to_dict()) |
| 51 | + |
| 52 | + @classmethod |
| 53 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 54 | + """Create an instance of ItContainsTheTenantIdToIdentifyTheTenantAndMetadataOfTheSchemaToBeEditedWithTheCorrespondingEditsToVariousEntities from a JSON string""" |
| 55 | + return cls.from_dict(json.loads(json_str)) |
| 56 | + |
| 57 | + def to_dict(self) -> Dict[str, Any]: |
| 58 | + """Return the dictionary representation of the model using alias. |
| 59 | +
|
| 60 | + This has the following differences from calling pydantic's |
| 61 | + `self.model_dump(by_alias=True)`: |
| 62 | +
|
| 63 | + * `None` is only added to the output dict for nullable fields that |
| 64 | + were set at model initialization. Other fields with value `None` |
| 65 | + are ignored. |
| 66 | + """ |
| 67 | + excluded_fields: Set[str] = set([ |
| 68 | + ]) |
| 69 | + |
| 70 | + _dict = self.model_dump( |
| 71 | + by_alias=True, |
| 72 | + exclude=excluded_fields, |
| 73 | + exclude_none=True, |
| 74 | + ) |
| 75 | + # override the default output from pydantic by calling `to_dict()` of metadata |
| 76 | + if self.metadata: |
| 77 | + _dict['metadata'] = self.metadata.to_dict() |
| 78 | + # override the default output from pydantic by calling `to_dict()` of each value in partials (dict) |
| 79 | + _field_dict = {} |
| 80 | + if self.partials: |
| 81 | + for _key in self.partials: |
| 82 | + if self.partials[_key]: |
| 83 | + _field_dict[_key] = self.partials[_key].to_dict() |
| 84 | + _dict['partials'] = _field_dict |
| 85 | + return _dict |
| 86 | + |
| 87 | + @classmethod |
| 88 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 89 | + """Create an instance of ItContainsTheTenantIdToIdentifyTheTenantAndMetadataOfTheSchemaToBeEditedWithTheCorrespondingEditsToVariousEntities from a dict""" |
| 90 | + if obj is None: |
| 91 | + return None |
| 92 | + |
| 93 | + if not isinstance(obj, dict): |
| 94 | + return cls.model_validate(obj) |
| 95 | + |
| 96 | + _obj = cls.model_validate({ |
| 97 | + "metadata": SchemaPartialWriteRequestMetadata.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None, |
| 98 | + "partials": dict( |
| 99 | + (_k, Partials.from_dict(_v)) |
| 100 | + for _k, _v in obj["partials"].items() |
| 101 | + ) |
| 102 | + if obj.get("partials") is not None |
| 103 | + else None |
| 104 | + }) |
| 105 | + return _obj |
| 106 | + |
| 107 | + |
0 commit comments