"""Schemas for POST /action endpoint.""" import marshmallow from conflict_manager.constants import error from conflict_manager.utils import schema_utils class PostActionPayloadSchema(marshmallow.Schema): """Validation schema for payload of POST /action endpoint.""" territory_standard = marshmallow.fields.String(required=True) conflicting_owner = marshmallow.fields.String(required=True) conflict_date = marshmallow.fields.String( required=True, validate=schema_utils.validate_conflict_date, error_messages=schema_utils.make_schema_error_messages( error.INVALID_DATE_MSG)) isrc = marshmallow.fields.String(required=True) release_action = marshmallow.fields.Nested('ActionSchema') assert_action = marshmallow.fields.Nested('ActionSchema') tuid = marshmallow.fields.Integer(required=True) es_id = marshmallow.fields.String(required=False) class BulkPostActionPayloadSchema(marshmallow.Schema): """Validation schema for payload of POST /action/bulk endpoint.""" actions = marshmallow.fields.List( marshmallow.fields.Nested(PostActionPayloadSchema), required=True) class ActionSchema(marshmallow.Schema): """Validation schema for release and assert action. Validator for 'release_action' and 'assert_action' keys in POST /action payload. """ conflict_ids = marshmallow.fields.List( marshmallow.fields.Integer(), required=True, validate=marshmallow.validate.Length(min=1)) reason = marshmallow.fields.String(required=True) additional_information = marshmallow.fields.String( required=False, validate=marshmallow.validate.Length(max=1000))