Module mydata_did.patched_protocols.present_proof.v1_0.messages.presentation_request
A presentation request content message.
Expand source code
"""A presentation request content message."""
from typing import Sequence
from marshmallow import EXCLUDE, fields
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from aries_cloudagent.messaging.decorators.attach_decorator import (
AttachDecorator,
AttachDecoratorSchema,
)
from ..message_types import PRESENTATION_REQUEST, PROTOCOL_PACKAGE
HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers."
"presentation_request_handler.PresentationRequestHandler"
)
class PresentationRequest(AgentMessage):
"""Class representing a presentation request."""
class Meta:
"""PresentationRequest metadata."""
handler_class = HANDLER_CLASS
schema_class = "PresentationRequestSchema"
message_type = PRESENTATION_REQUEST
def __init__(
self,
_id: str = None,
*,
comment: str = None,
request_presentations_attach: Sequence[AttachDecorator] = None,
**kwargs,
):
"""
Initialize presentation request object.
Args:
request_presentations_attach: proof request attachments
comment: optional comment
"""
super().__init__(_id=_id, **kwargs)
self.comment = comment
self.request_presentations_attach = (
list(request_presentations_attach) if request_presentations_attach else []
)
def indy_proof_request(self, index: int = 0):
"""
Retrieve and decode indy proof request from attachment.
Args:
index: ordinal in attachment list to decode and return
(typically, list has length 1)
"""
return self.request_presentations_attach[index].indy_dict
class PresentationRequestSchema(AgentMessageSchema):
"""Presentation request schema."""
class Meta:
"""Presentation request schema metadata."""
model_class = PresentationRequest
unknown = EXCLUDE
comment = fields.Str(
description="Human-readable comment", required=False, allow_none=True
)
request_presentations_attach = fields.Nested(
AttachDecoratorSchema,
required=True,
many=True,
data_key="request_presentations~attach",
)
Classes
class PresentationRequest (*, comment: str = None, request_presentations_attach: Sequence[aries_cloudagent.messaging.decorators.attach_decorator.AttachDecorator] = None, **kwargs)
-
Class representing a presentation request.
Initialize presentation request object.
Args
request_presentations_attach
- proof request attachments
comment
- optional comment
Expand source code
class PresentationRequest(AgentMessage): """Class representing a presentation request.""" class Meta: """PresentationRequest metadata.""" handler_class = HANDLER_CLASS schema_class = "PresentationRequestSchema" message_type = PRESENTATION_REQUEST def __init__( self, _id: str = None, *, comment: str = None, request_presentations_attach: Sequence[AttachDecorator] = None, **kwargs, ): """ Initialize presentation request object. Args: request_presentations_attach: proof request attachments comment: optional comment """ super().__init__(_id=_id, **kwargs) self.comment = comment self.request_presentations_attach = ( list(request_presentations_attach) if request_presentations_attach else [] ) def indy_proof_request(self, index: int = 0): """ Retrieve and decode indy proof request from attachment. Args: index: ordinal in attachment list to decode and return (typically, list has length 1) """ return self.request_presentations_attach[index].indy_dict
Ancestors
- aries_cloudagent.messaging.agent_message.AgentMessage
- aries_cloudagent.messaging.models.base.BaseModel
- abc.ABC
Class variables
var Meta
-
PresentationRequest metadata.
Methods
def indy_proof_request(self, index: int = 0)
-
Retrieve and decode indy proof request from attachment.
Args
index
- ordinal in attachment list to decode and return (typically, list has length 1)
Expand source code
def indy_proof_request(self, index: int = 0): """ Retrieve and decode indy proof request from attachment. Args: index: ordinal in attachment list to decode and return (typically, list has length 1) """ return self.request_presentations_attach[index].indy_dict
class PresentationRequestSchema (*args, **kwargs)
-
Presentation request schema.
Initialize an instance of AgentMessageSchema.
Raises
TypeError
- If Meta.model_class has not been set
Expand source code
class PresentationRequestSchema(AgentMessageSchema): """Presentation request schema.""" class Meta: """Presentation request schema metadata.""" model_class = PresentationRequest unknown = EXCLUDE comment = fields.Str( description="Human-readable comment", required=False, allow_none=True ) request_presentations_attach = fields.Nested( AttachDecoratorSchema, required=True, many=True, data_key="request_presentations~attach", )
Ancestors
- aries_cloudagent.messaging.agent_message.AgentMessageSchema
- aries_cloudagent.messaging.models.base.BaseModelSchema
- marshmallow.schema.Schema
- marshmallow.base.SchemaABC
Class variables
var Meta
-
Presentation request schema metadata.
var opts