Module mydata_did.v1_0.messages.read_did

Expand source code
from marshmallow import EXCLUDE, fields

from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from aries_cloudagent.messaging.models.base import BaseModel, BaseModelSchema

from ..message_types import PROTOCOL_PACKAGE, READ_DID
from ..utils.regex import MYDATA_DID

HANDLER_CLASS = (
    f"{PROTOCOL_PACKAGE}.handlers"
    ".read_did_handler.ReadDIDHandler"
)

class ReadDIDMessageBody(BaseModel):
    """
    Read DID message body class
    """    
    class Meta:

        # Schema class
        schema_class = "ReadDIDMessageBodySchema"
    
    def __init__(self, *, did: str, **kwargs):
        """
        Initialize ReadDIDMessageBody instance

        Args:
            did: The DID to be read
        """

        super().__init__(**kwargs)

        # The DID to be read
        self.did = did

class ReadDIDMessageBodySchema(BaseModelSchema):
    """
    Read DID message body schema class
    """
    class Meta:
        # Message body model
        model_class = ReadDIDMessageBody

        # Unknown fields to exclude from the schema
        unknown = EXCLUDE
    
    # The DID to be read
    did = fields.Str(data_key="did", **MYDATA_DID)

class ReadDIDMessage(AgentMessage):
    """
    Message class for reading a DID.
    """
    class Meta:

        # Handler class that can handle this message
        handler_class = HANDLER_CLASS

        # Message type
        message_type = READ_DID

        # Message schema class
        schema_class = "ReadDIDMessageSchema"

    def __init__(self, *, from_did, to_did, created_time, body: ReadDIDMessageBody, **kwargs):
        """
        Initialize a ReadDIDMessage message instance.

        Args:
            from_did: Sender DID
            to_did: Reciepient DID
            created_time: Time the message was created
            body: Message body
        """

        super().__init__(**kwargs)

        # Set attributes
        self.from_did = from_did
        self.to_did = to_did
        self.created_time = created_time
        self.body = body

class ReadDIDMessageSchema(AgentMessageSchema):
    """
    Schema class for reading a DID.
    """
    
    class Meta:

        # The message class that this schema is for
        model_class = ReadDIDMessage

        # Unknown fields to exclude from the schema (handled by marshmallow)
        unknown = EXCLUDE
    
    # From DID
    from_did = fields.Str(data_key="from", **MYDATA_DID)

    # To DID
    to_did = fields.Str(data_key="to", **MYDATA_DID)

    # Created time
    created_time = fields.Str(data_key="created_time")

    # Message body
    body = fields.Nested(ReadDIDMessageBodySchema, required=True)

Classes

class ReadDIDMessage (*, from_did, to_did, created_time, body: ReadDIDMessageBody, **kwargs)

Message class for reading a DID.

Initialize a ReadDIDMessage message instance.

Args

from_did
Sender DID
to_did
Reciepient DID
created_time
Time the message was created
body
Message body
Expand source code
class ReadDIDMessage(AgentMessage):
    """
    Message class for reading a DID.
    """
    class Meta:

        # Handler class that can handle this message
        handler_class = HANDLER_CLASS

        # Message type
        message_type = READ_DID

        # Message schema class
        schema_class = "ReadDIDMessageSchema"

    def __init__(self, *, from_did, to_did, created_time, body: ReadDIDMessageBody, **kwargs):
        """
        Initialize a ReadDIDMessage message instance.

        Args:
            from_did: Sender DID
            to_did: Reciepient DID
            created_time: Time the message was created
            body: Message body
        """

        super().__init__(**kwargs)

        # Set attributes
        self.from_did = from_did
        self.to_did = to_did
        self.created_time = created_time
        self.body = body

Ancestors

  • aries_cloudagent.messaging.agent_message.AgentMessage
  • aries_cloudagent.messaging.models.base.BaseModel
  • abc.ABC

Class variables

var Meta
class ReadDIDMessageBody (*, did: str, **kwargs)

Read DID message body class

Initialize ReadDIDMessageBody instance

Args

did
The DID to be read
Expand source code
class ReadDIDMessageBody(BaseModel):
    """
    Read DID message body class
    """    
    class Meta:

        # Schema class
        schema_class = "ReadDIDMessageBodySchema"
    
    def __init__(self, *, did: str, **kwargs):
        """
        Initialize ReadDIDMessageBody instance

        Args:
            did: The DID to be read
        """

        super().__init__(**kwargs)

        # The DID to be read
        self.did = did

Ancestors

  • aries_cloudagent.messaging.models.base.BaseModel
  • abc.ABC

Class variables

var Meta
class ReadDIDMessageBodySchema (*args, **kwargs)

Read DID message body schema class

Initialize BaseModelSchema.

Raises

TypeError
If model_class is not set on Meta
Expand source code
class ReadDIDMessageBodySchema(BaseModelSchema):
    """
    Read DID message body schema class
    """
    class Meta:
        # Message body model
        model_class = ReadDIDMessageBody

        # Unknown fields to exclude from the schema
        unknown = EXCLUDE
    
    # The DID to be read
    did = fields.Str(data_key="did", **MYDATA_DID)

Ancestors

  • aries_cloudagent.messaging.models.base.BaseModelSchema
  • marshmallow.schema.Schema
  • marshmallow.base.SchemaABC

Class variables

var Meta
var opts
class ReadDIDMessageSchema (*args, **kwargs)

Schema class for reading a DID.

Initialize an instance of AgentMessageSchema.

Raises

TypeError
If Meta.model_class has not been set
Expand source code
class ReadDIDMessageSchema(AgentMessageSchema):
    """
    Schema class for reading a DID.
    """
    
    class Meta:

        # The message class that this schema is for
        model_class = ReadDIDMessage

        # Unknown fields to exclude from the schema (handled by marshmallow)
        unknown = EXCLUDE
    
    # From DID
    from_did = fields.Str(data_key="from", **MYDATA_DID)

    # To DID
    to_did = fields.Str(data_key="to", **MYDATA_DID)

    # Created time
    created_time = fields.Str(data_key="created_time")

    # Message body
    body = fields.Nested(ReadDIDMessageBodySchema, required=True)

Ancestors

  • aries_cloudagent.messaging.agent_message.AgentMessageSchema
  • aries_cloudagent.messaging.models.base.BaseModelSchema
  • marshmallow.schema.Schema
  • marshmallow.base.SchemaABC

Class variables

var Meta
var opts