Source code for cadrumo.application.bucket_maintenance.contracts
"""Pydantic command + result records for :class:`BucketMaintenanceService`.Used by: :mod:`~._service` to implement bucket operations.The contract records sit at the package boundary so a programmaticcaller (a CLI handler or another adapter) gets the same typedinput + output shape that the service consumes. Closed-value axes aretyped as their core enums per the architecture-boundaries discipline.Every bucket selector is a :class:`BucketId`."""from__future__importannotationsfrompydanticimportBaseModel,Field,model_validatorfrom...core.errors.hierarchyimportpydantic_validation_boundaryfrom...core.identity.bucketimportBucketIdfrom...core.modelsimportSTRICT_FROZEN_CONFIGfrom...domain.retention.floorimportRetentionFloorAssessmentfrom...domain.user_profile.valuesimportProfileSetupStatefrom..bucket_deletion_contractsimportBucketDeletionFingerprint
[docs]classAssessBucketDeletionCommand(BaseModel):"""Read-only deletion-assessment intent for one explicit bucket."""model_config=STRICT_FROZEN_CONFIGbucket_id:BucketId
[docs]classBucketDeletionAssessment(BaseModel):"""Assessment of an explicit bucket target before deletion. The existing and absent forms are mutually exclusive. An existing assessment carries the bucket label, optional profile setup state, deletion fingerprint, and :class:`RetentionFloorAssessment`; an absent assessment carries none of those values. """model_config=STRICT_FROZEN_CONFIGbucket_id:BucketIdexists:boollabel:str|None=Field(default=None,min_length=1,max_length=160)setup_state:ProfileSetupState|None=Nonefingerprint:BucketDeletionFingerprint|None=Noneretention:RetentionFloorAssessment|None=None@model_validator(mode="after")@pydantic_validation_boundarydef_validate_existence_shape(self)->BucketDeletionAssessment:present_fields=(self.label,self.fingerprint,self.retention)ifself.existsandany(valueisNoneforvalueinpresent_fields):raiseValueError("existing deletion assessment requires label, fingerprint, and retention")ifnotself.existsandany(valueisnotNoneforvalueinpresent_fields):raiseValueError("absent deletion assessment cannot carry bucket metadata")returnself