"""Notification Subscription schema.""" from marshmallow import Schema, fields from marshmallow.validate import OneOf from notifications.constants.subscriptions import FEED_TYPES, SUBSCRIPTION_TYPES from notifications.validation.relationship import SCHEMA_MAP LABEL_SUBSCRIPTION = 'label' class NotificationSubscriptionParams(Schema): """NotificationSubscription URL Param schema. Properties: - undelete (bool): Re-enable deleted subscription if exists """ undelete = fields.Boolean(required=False) class NotificationSubscription(Schema): """NotificationSubscription schema. Properties: - notification_type (str): The notification type (email, etc) - feed_type (str): The name of the feed (social_spike, etc) """ notification_type = fields.String(required=True, validate=OneOf(SUBSCRIPTION_TYPES)) feed_type = fields.String(required=True, validate=OneOf(FEED_TYPES)) followed_entity = fields.String( required=False, validate=OneOf([*list(SCHEMA_MAP.keys()), LABEL_SUBSCRIPTION]) )