Policy#

pydantic model nublado.purger.models.v1.policy.Policy#

Policy for purging objects across multiple directory trees.

Parameters:

data (Any)

Show JSON schema
{
   "title": "Policy",
   "description": "Policy for purging objects across multiple directory trees.",
   "type": "object",
   "properties": {
      "directories": {
         "items": {
            "$ref": "#/$defs/DirectoryPolicy"
         },
         "title": "Directories specified in this policy",
         "type": "array"
      }
   },
   "$defs": {
      "DirectoryPolicy": {
         "description": "Policy for purging objects from a directory and its children.",
         "properties": {
            "path": {
               "format": "path",
               "title": "Directory to consider for purging",
               "type": "string"
            },
            "threshold": {
               "title": "Size in bytes demarcating large from small files",
               "type": "integer"
            },
            "intervals": {
               "$ref": "#/$defs/SizedIntervals",
               "title": "Intervals before purging large and small files"
            }
         },
         "required": [
            "path",
            "threshold",
            "intervals"
         ],
         "title": "DirectoryPolicy",
         "type": "object"
      },
      "HumanTimedelta": {
         "format": "duration",
         "type": "string"
      },
      "Intervals": {
         "description": "Intervals specify how long it must have been since a filesystem object\nwas accessed, created, or modified before that object will be considered\nfor purging.  A value of None (or a zero TimeDelta) means the object will\nnot be considered for purging on the given grounds.",
         "properties": {
            "accessInterval": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/HumanTimedelta"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Maximum time since last file access"
            },
            "creationInterval": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/HumanTimedelta"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Maximum time since file creation"
            },
            "modificationInterval": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/HumanTimedelta"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Maximum time since file modification"
            }
         },
         "title": "Intervals",
         "type": "object"
      },
      "SizedIntervals": {
         "description": "Container to hold intervals for purging large and small files.",
         "properties": {
            "large": {
               "$ref": "#/$defs/Intervals",
               "default": {
                  "accessInterval": null,
                  "creationInterval": null,
                  "modificationInterval": null
               },
               "title": "Intervals before purging large files"
            },
            "small": {
               "$ref": "#/$defs/Intervals",
               "default": {
                  "accessInterval": null,
                  "creationInterval": null,
                  "modificationInterval": null
               },
               "title": "Intervals before purging small files"
            }
         },
         "title": "SizedIntervals",
         "type": "object"
      }
   },
   "required": [
      "directories"
   ]
}

Fields:
field directories: Annotated[list[DirectoryPolicy]] [Required]#
classmethod from_file(path)#

Construct the policy from a YAML file.

Parameters:

path (Path) – Path to the policy file in YAML.

Returns:

The corresponding configuration.

Return type:

nublado.purger.config.Config

get_directories()#

Return list of directories specified in this policy, sorted by length, shortest first.

The sort order is important so that we can start with most-specific and work our way to least-specific. This is also the way ingress-nginx sorts its ingresses, and it seems to work fine there.

When traversing the list, we just pop() off the end and work our way back.

Return type:

list[Path]

to_dict()#
Return type:

dict[str, list[dict[str, Union[str, int, dict[str, dict[str, int]]]]]]