nexuscli.api.cleanup_policy package

Submodules

nexuscli.api.cleanup_policy.collection module

class nexuscli.api.cleanup_policy.collection.CleanupPolicyCollection(client=None)

Bases: object

A class to manage Nexus 3 Cleanup Policies.

Parameters:client (nexuscli.nexus_client.NexusClient) – the client instance that will be used to perform operations against the Nexus 3 service. You must provide this at instantiation or set it before calling any methods that require connectivity to Nexus.
GROOVY_SCRIPT_NAME = 'nexus3-cli-cleanup-policy'

Groovy script used by this class

create_or_update(cleanup_policy)

Creates the given Cleanup Policy in the Nexus repository. If a policy with the same name already exists, it will be updated.

Parameters:cleanup_policy (CleanupPolicy) – the policy to create or update.
Raises:exception.NexusClientCreateCleanupPolicyError – when the Nexus API returns an error or unexpected result.
get_by_name(name)

Get a Nexus 3 cleanup policy by its name.

Parameters:name (str) – name of the wanted policy
Returns:the requested object
Return type:CleanupPolicy
Raises:exception.NexusClientInvalidRepository – when a repository with the given name isn’t found.
list()

Return all cleanup policies.

Returns:every policy as a list of CleanupPolicy instances.
Return type:list[CleanupPolicy]

nexuscli.api.cleanup_policy.model module

class nexuscli.api.cleanup_policy.model.CleanupPolicy(client, **kwargs)

Bases: object

Represents a Nexus Cleanup Policy.

Parameters:
  • client (nexuscli.nexus_client.NexusClient) – the client instance that will be used to perform operations against the Nexus 3 service. You must provide this at instantiation or set it before calling any methods that require connectivity to Nexus.
  • name (str) – name of the new policy.
  • format (str) – ‘all’ or the name of the repository format this policy applies to.
  • mode (str) – ‘delete’
  • criteria (dict) –

    the deletion criteria for the policy. Supports one or more of the following attributes:

    • lastDownloaded (int): days since artefact last downloaded;
    • lastBlobUpdated (int): days since last update to artefact;
configuration

Nexus 3 Cleanup Policy representation as a python dict. The dict returned by this property can be converted to JSON for use with the nexus3-cli-cleanup-policy groovy script created by the CleanupPolicyCollection methods.

Example structure and attributes common to all repositories:

>>> cleanup_policy = {
>>>     'name': 'my-policy',
>>>     'format': 'bower',
>>>     'mode': 'delete',
>>>     'criteria': {
>>>         'lastDownloaded': 172800,
>>>         'lastBlobUpdated': 86400
>>>     }
>>> }

Depending on the repository type and format (recipe), other attributes will be present.

Returns:cleanup policy as a dict
Return type:dict

nexuscli.api.cleanup_policy.validations module

nexuscli.api.cleanup_policy.validations.policy_criteria(raw_policy)

Ensures the policy criteria fields are valid. Will transform strings to the correct type where needed.

Parameters:raw_policy – as returned by the CleanupPolicy configuration
Raises:ValueError – when a criterion has an invalid value.
nexuscli.api.cleanup_policy.validations.policy_name(raw_policy)

Ensure the policy has a name

Raises:ValueError – when the name attribute is missing.

Module contents