Skip to content

Commit 9534a30

Browse files
committed
🎨 Add AnoncredsPresSpec models
1 parent 0ebb068 commit 9534a30

6 files changed

+327
-2
lines changed

aries_cloudcontroller/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
AnoncredsPresentationReqPredSpecNonRevoked,
8787
AnoncredsPresentationRequest,
8888
AnoncredsPresentationRequestNonRevoked,
89+
AnoncredsPresSpec,
90+
AnoncredsRequestedCredsRequestedAttr,
91+
AnoncredsRequestedCredsRequestedPred,
8992
AnonCredsSchema,
9093
AttachDecorator,
9194
AttachDecoratorData,

aries_cloudcontroller/models/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# import models into model package
2626
from aries_cloudcontroller.models.aml_record import AMLRecord
2727
from aries_cloudcontroller.models.anon_creds_schema import AnonCredsSchema
28+
from aries_cloudcontroller.models.anoncreds_pres_spec import AnoncredsPresSpec
2829
from aries_cloudcontroller.models.anoncreds_presentation_req_attr_spec import (
2930
AnoncredsPresentationReqAttrSpec,
3031
)
@@ -43,6 +44,12 @@
4344
from aries_cloudcontroller.models.anoncreds_presentation_request_non_revoked import (
4445
AnoncredsPresentationRequestNonRevoked,
4546
)
47+
from aries_cloudcontroller.models.anoncreds_requested_creds_requested_attr import (
48+
AnoncredsRequestedCredsRequestedAttr,
49+
)
50+
from aries_cloudcontroller.models.anoncreds_requested_creds_requested_pred import (
51+
AnoncredsRequestedCredsRequestedPred,
52+
)
4653
from aries_cloudcontroller.models.attach_decorator import AttachDecorator
4754
from aries_cloudcontroller.models.attach_decorator_data import AttachDecoratorData
4855
from aries_cloudcontroller.models.attach_decorator_data1_jws import (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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.util import DEFAULT_PYDANTIC_MODEL_CONFIG
25+
26+
27+
class AnoncredsRequestedCredsRequestedAttr(BaseModel):
28+
"""
29+
AnoncredsRequestedCredsRequestedAttr
30+
""" # noqa: E501
31+
32+
cred_id: StrictStr = Field(
33+
description="Wallet credential identifier (typically but not necessarily a UUID)"
34+
)
35+
revealed: Optional[StrictBool] = Field(
36+
default=None, description="Whether to reveal attribute in proof (default true)"
37+
)
38+
__properties: ClassVar[List[str]] = ["cred_id", "revealed"]
39+
40+
model_config = DEFAULT_PYDANTIC_MODEL_CONFIG
41+
42+
def to_str(self) -> str:
43+
"""Returns the string representation of the model using alias"""
44+
return pprint.pformat(self.model_dump(by_alias=True))
45+
46+
def to_json(self) -> str:
47+
"""Returns the JSON representation of the model using alias"""
48+
return self.model_dump_json(by_alias=True, exclude_unset=True)
49+
50+
@classmethod
51+
def from_json(cls, json_str: str) -> Optional[Self]:
52+
"""Create an instance of AnoncredsRequestedCredsRequestedAttr from a JSON string"""
53+
return cls.from_dict(orjson.loads(json_str))
54+
55+
def to_dict(self) -> Dict[str, Any]:
56+
"""Return the dictionary representation of the model using alias.
57+
58+
This has the following differences from calling pydantic's
59+
`self.model_dump(by_alias=True)`:
60+
61+
* `None` is only added to the output dict for nullable fields that
62+
were set at model initialization. Other fields with value `None`
63+
are ignored.
64+
"""
65+
excluded_fields: Set[str] = set([])
66+
67+
_dict = self.model_dump(
68+
by_alias=True,
69+
exclude=excluded_fields,
70+
exclude_none=True,
71+
)
72+
return _dict
73+
74+
@classmethod
75+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
76+
"""Create an instance of AnoncredsRequestedCredsRequestedAttr from a dict"""
77+
if obj is None:
78+
return None
79+
80+
if not isinstance(obj, dict):
81+
return cls.model_validate(obj)
82+
83+
_obj = cls.model_validate(
84+
{"cred_id": obj.get("cred_id"), "revealed": obj.get("revealed")}
85+
)
86+
return _obj
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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, StrictStr
22+
from typing_extensions import Annotated, Self
23+
24+
from aries_cloudcontroller.util import DEFAULT_PYDANTIC_MODEL_CONFIG
25+
26+
27+
class AnoncredsRequestedCredsRequestedPred(BaseModel):
28+
"""
29+
AnoncredsRequestedCredsRequestedPred
30+
""" # noqa: E501
31+
32+
cred_id: StrictStr = Field(
33+
description="Wallet credential identifier (typically but not necessarily a UUID)"
34+
)
35+
timestamp: Optional[
36+
Annotated[int, Field(le=18446744073709551615, strict=True, ge=0)]
37+
] = Field(
38+
default=None, description="Epoch timestamp of interest for non-revocation proof"
39+
)
40+
__properties: ClassVar[List[str]] = ["cred_id", "timestamp"]
41+
42+
model_config = DEFAULT_PYDANTIC_MODEL_CONFIG
43+
44+
def to_str(self) -> str:
45+
"""Returns the string representation of the model using alias"""
46+
return pprint.pformat(self.model_dump(by_alias=True))
47+
48+
def to_json(self) -> str:
49+
"""Returns the JSON representation of the model using alias"""
50+
return self.model_dump_json(by_alias=True, exclude_unset=True)
51+
52+
@classmethod
53+
def from_json(cls, json_str: str) -> Optional[Self]:
54+
"""Create an instance of AnoncredsRequestedCredsRequestedPred from a JSON string"""
55+
return cls.from_dict(orjson.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+
_dict = self.model_dump(
70+
by_alias=True,
71+
exclude=excluded_fields,
72+
exclude_none=True,
73+
)
74+
return _dict
75+
76+
@classmethod
77+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
78+
"""Create an instance of AnoncredsRequestedCredsRequestedPred from a dict"""
79+
if obj is None:
80+
return None
81+
82+
if not isinstance(obj, dict):
83+
return cls.model_validate(obj)
84+
85+
_obj = cls.model_validate(
86+
{"cred_id": obj.get("cred_id"), "timestamp": obj.get("timestamp")}
87+
)
88+
return _obj

aries_cloudcontroller/models/v20_pres_spec_by_format_request.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from pydantic import BaseModel, Field, StrictBool
2222
from typing_extensions import Self
2323

24+
from aries_cloudcontroller.models.anoncreds_pres_spec import AnoncredsPresSpec
2425
from aries_cloudcontroller.models.dif_pres_spec import DIFPresSpec
2526
from aries_cloudcontroller.models.indy_pres_spec import IndyPresSpec
2627
from aries_cloudcontroller.util import DEFAULT_PYDANTIC_MODEL_CONFIG
@@ -31,7 +32,7 @@ class V20PresSpecByFormatRequest(BaseModel):
3132
V20PresSpecByFormatRequest
3233
""" # noqa: E501
3334

34-
anoncreds: Optional[IndyPresSpec] = Field(
35+
anoncreds: Optional[AnoncredsPresSpec] = Field(
3536
default=None, description="Presentation specification for anoncreds"
3637
)
3738
auto_remove: Optional[StrictBool] = Field(
@@ -112,7 +113,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
112113
_obj = cls.model_validate(
113114
{
114115
"anoncreds": (
115-
IndyPresSpec.from_dict(obj["anoncreds"])
116+
AnoncredsPresSpec.from_dict(obj["anoncreds"])
116117
if obj.get("anoncreds") is not None
117118
else None
118119
),

0 commit comments

Comments
 (0)