Skip to content

Commit

Permalink
Support permissions for DA and DDA
Browse files Browse the repository at this point in the history
Signed-off-by: George J Padayatti <[email protected]>
  • Loading branch information
georgepadayatti committed Sep 14, 2022
1 parent bf127bd commit 964cb13
Show file tree
Hide file tree
Showing 31 changed files with 276 additions and 226 deletions.
9 changes: 3 additions & 6 deletions dexa_protocol/v1_0/handlers/accept_dda_handler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from aries_cloudagent.messaging.base_handler import (
BaseHandler,
BaseResponder,
RequestContext
RequestContext,
)
from dexa_protocol.v1_0.messages.negotiation.accept_dda import AcceptDDAMessage
from dexa_sdk.managers.dexa_manager import DexaManager
from ..messages.negotiation.accept_dda import AcceptDDAMessage


class AcceptDDAMessageHandler(BaseHandler):
Expand All @@ -19,7 +19,4 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
mgr = DexaManager(context)

# Process the message.
await mgr.process_accept_dda_message(
context.message,
context.message_receipt
)
await mgr.process_accept_dda_message(context.message, context.message_receipt)
11 changes: 5 additions & 6 deletions dexa_protocol/v1_0/handlers/dda_negotiation_receipt_handler.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from aries_cloudagent.messaging.base_handler import (
BaseHandler,
BaseResponder,
RequestContext
RequestContext,
)
from dexa_sdk.managers.dexa_manager import DexaManager
from ..messages.negotiation.dda_negotiation_receipt import (
DDANegotiationReceiptMessage
from dexa_protocol.v1_0.messages.negotiation.dda_negotiation_receipt import (
DDANegotiationReceiptMessage,
)
from dexa_sdk.managers.dexa_manager import DexaManager


class DDANegotiationReceiptHandler(BaseHandler):
Expand All @@ -22,6 +22,5 @@ async def handle(self, context: RequestContext, responder: BaseResponder):

# Process dda negotiation receipt message.
await mgr.process_dda_negotiation_receipt_message(
context.message,
context.message_receipt
context.message, context.message_receipt
)
24 changes: 24 additions & 0 deletions dexa_protocol/v1_0/handlers/deactivate_dda_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from aries_cloudagent.messaging.base_handler import (
BaseHandler,
BaseResponder,
RequestContext,
)
from dexa_protocol.v1_0.messages.deactivate_dda import DeactivateDDAMessage
from dexa_sdk.managers.dexa_manager import DexaManager


class DeactivateDDAMessageHandler(BaseHandler):
"""Deactivate DDA message handler logic"""

async def handle(self, context: RequestContext, responder: BaseResponder):
"""Handle function"""

assert isinstance(context.message, DeactivateDDAMessage)

# Initialise the manager.
mgr = DexaManager(context)

# Process the message.
await mgr.process_deactivate_dda_message(
context.message, context.message_receipt
)
9 changes: 3 additions & 6 deletions dexa_protocol/v1_0/handlers/delete_dda_handler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from aries_cloudagent.messaging.base_handler import (
BaseHandler,
BaseResponder,
RequestContext
RequestContext,
)
from dexa_protocol.v1_0.messages.marketplace.delete_dda import DeleteDDAMessage
from dexa_sdk.managers.dexa_manager import DexaManager
from ..messages.marketplace.delete_dda import DeleteDDAMessage


class DeleteDDAMessageHandler(BaseHandler):
Expand All @@ -19,7 +19,4 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
mgr = DexaManager(context)

# Process publish dda request message.
await mgr.process_delete_dda_message(
context.message,
context.message_receipt
)
await mgr.process_delete_dda_message(context.message, context.message_receipt)
10 changes: 6 additions & 4 deletions dexa_protocol/v1_0/handlers/list_marketplace_dda_handler.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
"""Basic message handler."""
import json
from loguru import logger

from aries_cloudagent.messaging.base_handler import (
BaseHandler,
BaseResponder,
RequestContext,
)
from dexa_protocol.v1_0.messages.marketplace.list_marketplace_dda import (
ListMarketplaceDDAMessage,
)
from dexa_sdk.managers.dexa_manager import DexaManager
from ..messages.marketplace.list_marketplace_dda import ListMarketplaceDDAMessage
from loguru import logger


class ListMarketplaceDDAMessageHandler(BaseHandler):
Expand All @@ -33,6 +36,5 @@ async def handle(self, context: RequestContext, responder: BaseResponder):

# Process the message
await mgr.process_list_marketplace_dda_message(
context.message,
context.message_receipt
context.message, context.message_receipt
)
9 changes: 3 additions & 6 deletions dexa_protocol/v1_0/handlers/offer_dda_handler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from aries_cloudagent.messaging.base_handler import (
BaseHandler,
BaseResponder,
RequestContext
RequestContext,
)
from dexa_protocol.v1_0.messages.negotiation.offer_dda import OfferDDAMessage
from dexa_sdk.managers.dexa_manager import DexaManager
from ..messages.negotiation.offer_dda import OfferDDAMessage


class OfferDDAMessageHandler(BaseHandler):
Expand All @@ -19,7 +19,4 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
mgr = DexaManager(context)

# Process the message.
await mgr.process_offer_dda_message(
context.message,
context.message_receipt
)
await mgr.process_offer_dda_message(context.message, context.message_receipt)
7 changes: 3 additions & 4 deletions dexa_protocol/v1_0/handlers/publish_dda_handler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from aries_cloudagent.messaging.base_handler import (
BaseHandler,
BaseResponder,
RequestContext
RequestContext,
)
from dexa_protocol.v1_0.messages.marketplace.publish_dda import PublishDDAMessage
from dexa_sdk.managers.dexa_manager import DexaManager
from ..messages.marketplace.publish_dda import PublishDDAMessage


class PublishDDAMessageHandler(BaseHandler):
Expand All @@ -20,6 +20,5 @@ async def handle(self, context: RequestContext, responder: BaseResponder):

# Process publish dda request message.
await mgr.process_publish_dda_request_message(
context.message,
context.message_receipt
context.message, context.message_receipt
)
9 changes: 3 additions & 6 deletions dexa_protocol/v1_0/handlers/request_dda_handler.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from aries_cloudagent.messaging.base_handler import (
BaseHandler,
BaseResponder,
RequestContext
RequestContext,
)
from dexa_protocol.v1_0.messages.negotiation.request_dda import RequestDDAMessage
from dexa_sdk.managers.dexa_manager import DexaManager
from ..messages.negotiation.request_dda import RequestDDAMessage


class RequestDDAMessageHandler(BaseHandler):
Expand All @@ -19,7 +19,4 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
mgr = DexaManager(context)

# Process publish dda request message.
await mgr.process_request_dda_message(
context.message,
context.message_receipt
)
await mgr.process_request_dda_message(context.message, context.message_receipt)
4 changes: 3 additions & 1 deletion dexa_protocol/v1_0/message_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
OFFER_DDA = f"dda-negotiation/1.0/offer-dda"
ACCEPT_DDA = f"dda-negotiation/1.0/accept-dda"
NEGOTIATION_RECEIPT = f"dda-negotiation/1.0/receipt"
DEACTIVATE_DDA = f"dda/1.0/deactivate"


PROTOCOL_PACKAGE = "dexa_protocol.v1_0"
Expand All @@ -31,6 +32,7 @@
REQUEST_DDA: f"{PROTOCOL_PACKAGE}.messages.negotiation.request_dda.RequestDDAMessage",
OFFER_DDA: f"{PROTOCOL_PACKAGE}.messages.negotiation.offer_dda.OfferDDAMessage",
ACCEPT_DDA: f"{PROTOCOL_PACKAGE}.messages.negotiation.accept_dda.AcceptDDAMessage",
NEGOTIATION_RECEIPT: f"{PROTOCOL_PACKAGE}.messages.negotiation.dda_negotiation_receipt.DDANegotiationReceiptMessage"
NEGOTIATION_RECEIPT: f"{PROTOCOL_PACKAGE}.messages.negotiation.dda_negotiation_receipt.DDANegotiationReceiptMessage",
DEACTIVATE_DDA: f"{PROTOCOL_PACKAGE}.messages.deactivate_dda.DeactivateDDAMessage",
}
)
31 changes: 31 additions & 0 deletions dexa_protocol/v1_0/messages/deactivate_dda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from dexa_protocol.v1_0.message_types import DEACTIVATE_DDA, PROTOCOL_PACKAGE
from dexa_protocol.v1_0.models.deactivate_dda_model import (
DeactivateDDABodyModel,
DeactivateDDABodyModelSchema,
)
from marshmallow import EXCLUDE, fields

HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers.deactivate_dda_handler.DeactivateDDAMessageHandler"
)


class DeactivateDDAMessage(AgentMessage):
class Meta:
handler_class = HANDLER_CLASS
message_type = DEACTIVATE_DDA
schema_class = "DeactivateDDAMessageSchema"

def __init__(self, *, body: DeactivateDDABodyModel, **kwargs):
super().__init__(**kwargs)

self.body = body


class DeactivateDDAMessageSchema(AgentMessageSchema):
class Meta:
model_class = DeactivateDDAMessage
unknown = EXCLUDE

body = fields.Nested(DeactivateDDABodyModelSchema)
12 changes: 7 additions & 5 deletions dexa_protocol/v1_0/messages/marketplace/delete_dda.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from marshmallow import EXCLUDE, fields
from ...message_types import PROTOCOL_PACKAGE, DELETE_DDA
from ...models.delete_dda_model import (
from dexa_protocol.v1_0.message_types import DELETE_DDA, PROTOCOL_PACKAGE
from dexa_protocol.v1_0.models.delete_dda_model import (
DeleteDDAModel,
DeleteDDAModelSchema
DeleteDDAModelSchema,
)
from marshmallow import EXCLUDE, fields

HANDLER_CLASS = f"{PROTOCOL_PACKAGE}.handlers.delete_dda_handler.DeleteDDAMessageHandler"
HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers.delete_dda_handler.DeleteDDAMessageHandler"
)


class DeleteDDAMessage(AgentMessage):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from dexa_protocol.v1_0.message_types import LIST_MARKETPLACE_DDA, PROTOCOL_PACKAGE
from marshmallow import EXCLUDE
from ...message_types import PROTOCOL_PACKAGE, LIST_MARKETPLACE_DDA


HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers.list_marketplace_dda_handler.ListMarketplaceDDAMessageHandler"
)
HANDLER_CLASS = f"{PROTOCOL_PACKAGE}.handlers.list_marketplace_dda_handler.ListMarketplaceDDAMessageHandler"


class ListMarketplaceDDAMessage(AgentMessage):
Expand All @@ -29,7 +26,6 @@ def __init__(self, **kwargs):


class ListMarketplaceDDAMessageSchema(AgentMessageSchema):

class Meta:
# Model class
model_class = ListMarketplaceDDAMessage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from marshmallow import EXCLUDE, fields
from ...message_types import PROTOCOL_PACKAGE, LIST_MARKETPLACE_DDA_RESPONSE
from ...models.list_marketplace_dda_response_model import (
from dexa_protocol.v1_0.message_types import (
LIST_MARKETPLACE_DDA_RESPONSE,
PROTOCOL_PACKAGE,
)
from dexa_protocol.v1_0.models.list_marketplace_dda_response_model import (
ListMarketplaceDDAResponseBody,
ListMarketplaceDDAResponseBodySchema
ListMarketplaceDDAResponseBodySchema,
)
from marshmallow import EXCLUDE, fields

HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers.list_marketplace_dda_response_handler"
Expand Down Expand Up @@ -36,7 +39,6 @@ def __init__(self, body: ListMarketplaceDDAResponseBody, **kwargs):


class ListMarketplaceDDAResponseMessageSchema(AgentMessageSchema):

class Meta:
# Model class
model_class = ListMarketplaceDDAResponseMessage
Expand Down
13 changes: 7 additions & 6 deletions dexa_protocol/v1_0/messages/marketplace/publish_dda.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from marshmallow import EXCLUDE, fields
from ...message_types import PROTOCOL_PACKAGE, PUBLISH_DDA
from ...models.publish_dda_model import (
from dexa_protocol.v1_0.message_types import PROTOCOL_PACKAGE, PUBLISH_DDA
from dexa_protocol.v1_0.models.publish_dda_model import (
PublishDDAModel,
PublishDDAModelSchema
PublishDDAModelSchema,
)
from marshmallow import EXCLUDE, fields

HANDLER_CLASS = f"{PROTOCOL_PACKAGE}.handlers.publish_dda_handler.PublishDDAMessageHandler"
HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers.publish_dda_handler.PublishDDAMessageHandler"
)


class PublishDDAMessage(AgentMessage):
Expand All @@ -32,7 +34,6 @@ def __init__(self, *, body: PublishDDAModel, **kwargs):


class PublishDDAMessageSchema(AgentMessageSchema):

class Meta:
# Model class
model_class = PublishDDAMessage
Expand Down
13 changes: 8 additions & 5 deletions dexa_protocol/v1_0/messages/negotiation/accept_dda.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from marshmallow import EXCLUDE, fields
from ...message_types import PROTOCOL_PACKAGE, ACCEPT_DDA
from ...models.accept_dda_model import (
from dexa_protocol.v1_0.message_types import ACCEPT_DDA, PROTOCOL_PACKAGE
from dexa_protocol.v1_0.models.accept_dda_model import (
AcceptDDAMessageBodyModel,
AcceptDDAMessageBodyModelSchema
AcceptDDAMessageBodyModelSchema,
)
from marshmallow import EXCLUDE, fields

HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers.accept_dda_handler.AcceptDDAMessageHandler"
)
HANDLER_CLASS = f"{PROTOCOL_PACKAGE}.handlers.accept_dda_handler.AcceptDDAMessageHandler"


class AcceptDDAMessage(AgentMessage):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from marshmallow import EXCLUDE, fields
from ...message_types import PROTOCOL_PACKAGE, NEGOTIATION_RECEIPT
from ...models.dda_negotiation_receipt_model import (
from dexa_protocol.v1_0.message_types import NEGOTIATION_RECEIPT, PROTOCOL_PACKAGE
from dexa_protocol.v1_0.models.dda_negotiation_receipt_model import (
DDANegotiationReceiptBodyModel,
DDANegotiationReceiptBodyModelSchema
DDANegotiationReceiptBodyModelSchema,
)
from marshmallow import EXCLUDE, fields

HANDLER_CLASS = (
f"{PROTOCOL_PACKAGE}.handlers.dda_negotiation_receipt_handler.DDANegotiationReceiptHandler"
)
HANDLER_CLASS = f"{PROTOCOL_PACKAGE}.handlers.dda_negotiation_receipt_handler.DDANegotiationReceiptHandler"


class DDANegotiationReceiptMessage(AgentMessage):
Expand Down
Empty file.
8 changes: 4 additions & 4 deletions dexa_protocol/v1_0/messages/negotiation/offer_dda.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from aries_cloudagent.messaging.agent_message import AgentMessage, AgentMessageSchema
from marshmallow import EXCLUDE, fields
from ...message_types import PROTOCOL_PACKAGE, OFFER_DDA
from ...models.offer_dda_model import (
from dexa_protocol.v1_0.message_types import OFFER_DDA, PROTOCOL_PACKAGE
from dexa_protocol.v1_0.models.offer_dda_model import (
OfferDDAMessageBodyModel,
OfferDDAMessageBodyModelSchema
OfferDDAMessageBodyModelSchema,
)
from marshmallow import EXCLUDE, fields

HANDLER_CLASS = f"{PROTOCOL_PACKAGE}.handlers.offer_dda_handler.OfferDDAMessageHandler"

Expand Down
Loading

0 comments on commit 964cb13

Please sign in to comment.