|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +Aries Cloud Agent |
| 5 | +
|
| 6 | +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) |
| 7 | +
|
| 8 | +The version of the OpenAPI document: v1.2.1.post20250327 |
| 9 | +Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 10 | +
|
| 11 | +Do not edit the class manually. |
| 12 | +""" # noqa: E501 |
| 13 | + |
| 14 | + |
| 15 | +from __future__ import annotations |
| 16 | + |
| 17 | +import pprint |
| 18 | +from typing import Any, ClassVar, Dict, List, Optional, Set |
| 19 | + |
| 20 | +import orjson |
| 21 | +from pydantic import BaseModel, Field, StrictBool, StrictStr |
| 22 | +from typing_extensions import Self |
| 23 | + |
| 24 | +from aries_cloudcontroller.models.anoncreds_requested_creds_requested_attr import ( |
| 25 | + AnoncredsRequestedCredsRequestedAttr, |
| 26 | +) |
| 27 | +from aries_cloudcontroller.models.anoncreds_requested_creds_requested_pred import ( |
| 28 | + AnoncredsRequestedCredsRequestedPred, |
| 29 | +) |
| 30 | +from aries_cloudcontroller.util import DEFAULT_PYDANTIC_MODEL_CONFIG |
| 31 | + |
| 32 | + |
| 33 | +class AnoncredsPresSpec(BaseModel): |
| 34 | + """ |
| 35 | + AnoncredsPresSpec |
| 36 | + """ # noqa: E501 |
| 37 | + |
| 38 | + requested_attributes: Dict[str, AnoncredsRequestedCredsRequestedAttr] = Field( |
| 39 | + description="Nested object mapping proof request attribute referents to requested-attribute specifiers" |
| 40 | + ) |
| 41 | + requested_predicates: Dict[str, AnoncredsRequestedCredsRequestedPred] = Field( |
| 42 | + description="Nested object mapping proof request predicate referents to requested-predicate specifiers" |
| 43 | + ) |
| 44 | + self_attested_attributes: Dict[str, StrictStr] = Field( |
| 45 | + description="Self-attested attributes to build into proof" |
| 46 | + ) |
| 47 | + trace: Optional[StrictBool] = Field( |
| 48 | + default=None, description="Whether to trace event (default false)" |
| 49 | + ) |
| 50 | + __properties: ClassVar[List[str]] = [ |
| 51 | + "requested_attributes", |
| 52 | + "requested_predicates", |
| 53 | + "self_attested_attributes", |
| 54 | + "trace", |
| 55 | + ] |
| 56 | + |
| 57 | + model_config = DEFAULT_PYDANTIC_MODEL_CONFIG |
| 58 | + |
| 59 | + def to_str(self) -> str: |
| 60 | + """Returns the string representation of the model using alias""" |
| 61 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 62 | + |
| 63 | + def to_json(self) -> str: |
| 64 | + """Returns the JSON representation of the model using alias""" |
| 65 | + return self.model_dump_json(by_alias=True, exclude_unset=True) |
| 66 | + |
| 67 | + @classmethod |
| 68 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 69 | + """Create an instance of AnoncredsPresSpec from a JSON string""" |
| 70 | + return cls.from_dict(orjson.loads(json_str)) |
| 71 | + |
| 72 | + def to_dict(self) -> Dict[str, Any]: |
| 73 | + """Return the dictionary representation of the model using alias. |
| 74 | +
|
| 75 | + This has the following differences from calling pydantic's |
| 76 | + `self.model_dump(by_alias=True)`: |
| 77 | +
|
| 78 | + * `None` is only added to the output dict for nullable fields that |
| 79 | + were set at model initialization. Other fields with value `None` |
| 80 | + are ignored. |
| 81 | + """ |
| 82 | + excluded_fields: Set[str] = set([]) |
| 83 | + |
| 84 | + _dict = self.model_dump( |
| 85 | + by_alias=True, |
| 86 | + exclude=excluded_fields, |
| 87 | + exclude_none=True, |
| 88 | + ) |
| 89 | + # override the default output from pydantic by calling `to_dict()` of each value in requested_attributes (dict) |
| 90 | + _field_dict = {} |
| 91 | + if self.requested_attributes: |
| 92 | + for _key_requested_attributes in self.requested_attributes: |
| 93 | + if self.requested_attributes[_key_requested_attributes]: |
| 94 | + _field_dict[_key_requested_attributes] = self.requested_attributes[ |
| 95 | + _key_requested_attributes |
| 96 | + ].to_dict() |
| 97 | + _dict["requested_attributes"] = _field_dict |
| 98 | + # override the default output from pydantic by calling `to_dict()` of each value in requested_predicates (dict) |
| 99 | + _field_dict = {} |
| 100 | + if self.requested_predicates: |
| 101 | + for _key_requested_predicates in self.requested_predicates: |
| 102 | + if self.requested_predicates[_key_requested_predicates]: |
| 103 | + _field_dict[_key_requested_predicates] = self.requested_predicates[ |
| 104 | + _key_requested_predicates |
| 105 | + ].to_dict() |
| 106 | + _dict["requested_predicates"] = _field_dict |
| 107 | + return _dict |
| 108 | + |
| 109 | + @classmethod |
| 110 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 111 | + """Create an instance of AnoncredsPresSpec from a dict""" |
| 112 | + if obj is None: |
| 113 | + return None |
| 114 | + |
| 115 | + if not isinstance(obj, dict): |
| 116 | + return cls.model_validate(obj) |
| 117 | + |
| 118 | + _obj = cls.model_validate( |
| 119 | + { |
| 120 | + "requested_attributes": ( |
| 121 | + dict( |
| 122 | + (_k, AnoncredsRequestedCredsRequestedAttr.from_dict(_v)) |
| 123 | + for _k, _v in obj["requested_attributes"].items() |
| 124 | + ) |
| 125 | + if obj.get("requested_attributes") is not None |
| 126 | + else None |
| 127 | + ), |
| 128 | + "requested_predicates": ( |
| 129 | + dict( |
| 130 | + (_k, AnoncredsRequestedCredsRequestedPred.from_dict(_v)) |
| 131 | + for _k, _v in obj["requested_predicates"].items() |
| 132 | + ) |
| 133 | + if obj.get("requested_predicates") is not None |
| 134 | + else None |
| 135 | + ), |
| 136 | + "self_attested_attributes": obj.get("self_attested_attributes"), |
| 137 | + "trace": obj.get("trace"), |
| 138 | + } |
| 139 | + ) |
| 140 | + return _obj |
0 commit comments