コード例 #1
0
 def put(self, uuid: str, tag_uuid: str):
     MessageService.add_tag_to_message(uuid,
                                       tag_uuid=tag_uuid,
                                       uow=current_app.context)
     return {
         "message": f"tag {tag_uuid} successfully added from message {uuid}"
     }, 201
コード例 #2
0
 def delete(self, uuid: str, tag_uuid: str):
     MessageService.remove_tag_to_message(uuid,
                                          tag_uuid=tag_uuid,
                                          uow=current_app.context)
     return {
         "message":
         f"tag {tag_uuid} successfully deleted from message {uuid}"
     }, 202
コード例 #3
0
 def put(self, uuid: str, resource_uuid: str):
     MessageService.add_resource_to_message(uuid,
                                            resource_uuid=resource_uuid,
                                            uow=current_app.context)
     return {
         "message":
         f"resource {resource_uuid} successfully added from message {uuid}"
     }, 201
コード例 #4
0
 def delete(self, uuid: str, resource_uuid: str):
     MessageService.remove_resource_to_message(uuid,
                                               resource_uuid=resource_uuid,
                                               uow=current_app.context)
     ResourceService.delete_resource(uuid=resource_uuid,
                                     uow=current_app.context)
     return {
         "message":
         f"resource {resource_uuid} successfully deleted from message {uuid}"
     }, 202
コード例 #5
0
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('tags', type=str, help='Tags ids', action='append')
        parser.add_argument('evenement_id', type=str, help='Evenement id')
        args = parser.parse_args()
        tags: Union[str, List[str], None] = args.get("tags")
        evenement_id: Union[str, None] = args.get("evenement_id")
        if tags or evenement_id:
            messages = MessageService.list_messages_by_query(
                tag_ids=tags,
                evenement_id=evenement_id,
                uow=current_app.context)
        else:
            messages = MessageService.list_messages(current_app.context)

        return {"data": messages, "message": "success"}, 200
コード例 #6
0
    def delete(self, uuid: str, resource_uuid: str):
        parser = reqparse.RequestParser()
        parser.add_argument('resource_ids',
                            type=str,
                            help='Resource ids',
                            action='append',
                            required=True)
        args = parser.parse_args()

        resource_ids: Union[str, List[str]] = args.get("resource_ids")
        if isinstance(resource_ids, str):
            resource_ids = [resource_ids]
        for resource_uuid in resource_ids:
            MessageService.remove_resource_to_message(
                uuid, resource_uuid=resource_uuid, uow=current_app.context)
            ResourceService.delete_resource(uuid=resource_uuid,
                                            uow=current_app.context)
        return {
            "message":
            f"resources {resource_uuid} successfully deleted from message {uuid}"
        }, 202
コード例 #7
0
 def get(self, uuid: str):
     tags = MessageService.list_tags(uuid, uow=current_app.context)
     return {"data": tags, "message": "success"}, 200
コード例 #8
0
 def get(self, uuid: str, tag_uuid: str):
     tag: Dict[str, Any] = MessageService.get_message_tag(
         uuid, tag_uuid=tag_uuid, uow=current_app.context)
     return {"data": tag, "message": "success"}, 200
コード例 #9
0
 def get(self, uuid: str):
     return {
         "data": MessageService.get_by_uuid(uuid, current_app.context),
         "message": "success"
     }, 200
コード例 #10
0
def create_message(command: CreateMessage, uow: AbstractUnitOfWork):
    return MessageService.add_message(data=command.data, uow=uow)
コード例 #11
0
 def get(self, uuid: str, resource_uuid: str):
     resource: Dict[str, Any] = MessageService.get_message_resource(
         uuid, resource_uuid=resource_uuid, uow=current_app.context)
     return {"data": resource, "message": "success"}, 200