"""Validation schema for bulk remove ownership endpoint.""" import marshmallow from marshmallow import fields from marshmallow import validate from masters_registry.constant import error from masters_registry.constant import field_const class HeaderSchema(marshmallow.Schema): """Schema for headers of request to bulk remove ownership endpoint.""" orchard_user_id = fields.String( load_from=field_const.ORCHARD_USER_ID, required=True, error_messages={'required': error.ORCHARD_USER_ID_IS_REQUIRED}) correlation_id = fields.String( load_from=field_const.CORRELATION_ID, required=True, error_messages={'required': error.CORRELATION_ID_IS_REQUIRED}) @marshmallow.post_load def clean_orchard_user_id(self, item): """Remove prefix from Orchad-User-Id.""" item['orchard_user_id'] = item['orchard_user_id'].replace( field_const.OA_USER_ID_PREFIX, '') return item class BodySchema(marshmallow.Schema): """Schema for body of request to bulk remove ownership endpoint.""" account_id = fields.Integer(required=True, validate=validate.Range(min=1)) account_type = fields.String( required=True, validate=validate.OneOf( choices=['vendor', 'subaccount'], error='Valid account types are [{choices}]')) isrcs = fields.List(fields.String(), required=True) territories = fields.List(fields.String(), required=True)