nexuscli.api.repository.base_models package¶
Submodules¶
nexuscli.api.repository.base_models.base_repository module¶
-
class
nexuscli.api.repository.base_models.base_repository.
BaseRepository
(*args, **kwargs)¶ Bases:
nexuscli.api.base_model.BaseModel
The base class for Nexus repositories.
- Parameters
name – name of the repository.
recipe (str) – format (recipe) of the new repository. Must be one of
RECIPES
. See Nexus documentation for details.blob_store_name (str) – name of an existing blob store; ‘default’ should work on most installations.
strict_content_type_validation (bool) – Whether to validate file extension against its content type.
-
RECIPE_NAME
= None¶ If a recipe is not given during initialisation, use this one as the default
-
TYPE
= None¶ The repository type supported by this class
-
property
recipe_name
¶ The nexus3-cli name for this repository’s recipe (format). This is almost always the same as
RECIPE_NAME
withmaven
being the notable exception.
nexuscli.api.repository.base_models.group_repository module¶
-
class
nexuscli.api.repository.base_models.group_repository.
GroupRepository
(*args, **kwargs)¶ Bases:
nexuscli.api.repository.base_models.repository.Repository
A group Nexus repository.
- Parameters
-
TYPE
= 'group'¶
nexuscli.api.repository.base_models.hosted_repository module¶
-
class
nexuscli.api.repository.base_models.hosted_repository.
HostedRepository
(*args, **kwargs)¶ Bases:
nexuscli.api.repository.base_models.repository.Repository
A hosted Nexus repository.
- Parameters
name (str) – name of the repository.
write_policy (str) – one of
WRITE_POLICIES
. See Nexus documentation for details.kwargs – see
Repository
-
TYPE
= 'hosted'¶
-
WRITE_POLICIES
= ['ALLOW', 'ALLOW_ONCE', 'DENY']¶ Nexus 3 repository write policies supported by this class.
nexuscli.api.repository.base_models.proxy_repository module¶
-
class
nexuscli.api.repository.base_models.proxy_repository.
ProxyRepository
(*args, **kwargs)¶ Bases:
nexuscli.api.repository.base_models.repository.Repository
A proxy Nexus repository.
- Parameters
name – name of the repository.
remote_url – The URL of the repository being proxied, including the protocol scheme.
auto_block – Auto-block outbound connections on the repository if remote peer is detected as unreachable/unresponsive.
content_max_age – How long (in minutes) to cache artifacts before rechecking the remote repository. Release repositories should use -1.
metadata_max_age – How long (in minutes) to cache metadata before rechecking the remote repository.
negative_cache_enabled – Cache responses for content not present in the proxied repository
negative_cache_ttl – How long to cache the fact that a file was not found in the repository (in minutes)
kwargs – see
Repository
-
TYPE
= 'proxy'¶
-
property
configuration
¶ As per
Repository.configuration
but specific to this repository recipe and type.- Return type
-
upload
(*args, **kwargs)¶ Upload artefacts. The source must be either a local file name or directory. The flatten and recurse options are honoured for directory uploads.
The destination must be a valid Nexus 3 repository path, including the repository name as the first component of the path.
- Parameters
source (str) – location of file or directory to be uploaded.
destination (str) – destination path in Nexus, including repository name and, if required, directory name (e.g. raw repos require a directory).
recurse (bool) – do not process sub directories for uploads to remote
flatten (bool) – Flatten directory structure by not reproducing local directory structure remotely
- Returns
number of files uploaded.
-
upload_directory
(*args, **kwargs)¶ Uploads all files in a directory to the specified destination directory in this repository, honouring options flatten and recurse.
nexuscli.api.repository.base_models.repository module¶
-
class
nexuscli.api.repository.base_models.repository.
Repository
(*args, **kwargs)¶ Bases:
nexuscli.api.repository.base_models.base_repository.BaseRepository
Representation of the simplest Nexus repositories.
Nexus 3 repository recipes (formats) supported by this class:
- Parameters
name – name of the repository.
nexus_client – the
NexusClient
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.recipe – format (recipe) of the new repository. Must be one of
RECIPES
. See Nexus documentation for details.blob_store_name – name of an existing blob store; ‘default’ should work on most installations.
strict_content_type_validation – Whether to validate file extension against its content type.
cleanup_policy – name of an existing repository clean-up policy.
-
TYPE
= None¶
-
property
cleanup_policy
¶ Groovy-formatted value for the cleanup/policy attribute.
-
property
configuration
¶ Repository configuration represented as a python dict. The dict returned by this property can be converted to JSON for use with the
nexus3-cli-repository-create
groovy script created by thecreate()
method.Example structure and attributes common to all repositories:
>>> common_configuration = { >>> 'name': 'my-repository', >>> 'online': True, >>> 'recipeName': 'raw', >>> '_state': 'present', >>> 'attributes': { >>> 'storage': { >>> 'blobStoreName': 'default', >>> }, >>> 'cleanup': { >>> 'policyName': None, >>> } >>> } >>> }
Depending on the repository type and format (recipe), other attributes will be present.
- Returns
repository configuration
- Return type
-
delete
(repository_path)¶ Delete artefacts, recursively if
repository_path
is a directory.
-
download
(source, destination, flatten=False, nocache=False)¶ Download artefacts. The source must be a valid Nexus 3 repository path, including the repository name as the first component of the path.
The destination must be a local file name or directory.
If a file name is given as destination, the asset may be renamed. The final destination will depend on
flatten
.- Parameters
source (str) – location of artefact or directory on the repository service.
destination (str) – path to the local file or directory.
flatten (bool) – if True, the remote path isn’t reproduced locally.
nocache (bool) – if True, force download of a directory or artefact, ignoring an existing local copy. If false, it will not re-download an existing copy if its checksum matches the one in Nexus (as determined by
nexuscli.nexus_util.has_same_hash()
).
- Returns
number of downloaded files.
- Return type
-
download_file
(download_url, destination)¶ Download an asset from Nexus artefact repository to local file system.
-
list
(repository_path: str) → Iterator[Optional[str]]¶ List all the artefacts, recursively, in a given
repository_path
.- Parameters
repository_path – location on the repository service.
- Returns
artefacts under
repository_path
.
-
list_raw
(repository_path: str) → Iterator[Dict]¶ As per
list()
but yields raw Nexus artefacts as dicts.- Parameters
repository_path – location on the repository service.
-
upload
(source, destination, recurse=True, flatten=False)¶ Upload artefacts. The source must be either a local file name or directory. The flatten and recurse options are honoured for directory uploads.
The destination must be a valid Nexus 3 repository path, including the repository name as the first component of the path.
- Parameters
source (str) – location of file or directory to be uploaded.
destination (str) – destination path in Nexus, including repository name and, if required, directory name (e.g. raw repos require a directory).
recurse (bool) – do not process sub directories for uploads to remote
flatten (bool) – Flatten directory structure by not reproducing local directory structure remotely
- Returns
number of files uploaded.
-
upload_directory
(source, destination, recurse=True, flatten=False)¶ Uploads all files in a directory to the specified destination directory in this repository, honouring options flatten and recurse.
-
upload_file
(source, destination)¶
nexuscli.api.repository.base_models.util module¶
-
nexuscli.api.repository.base_models.util.
get_files
(src_dir: Union[pathlib.Path, str], recurse: bool = True) → List[pathlib.Path]¶ Walks the given directory and collects files to be uploaded. If recurse option is False, only the files on the root of the directory will be returned.
- Parameters
src_dir – location of files
recurse – If false, only the files on the root of src_dir are returned
- Returns
file set to be used with upload_directory
- Return type