API: files¶
Repository¶
- class pubtools.pulplib.FileRepository[source]¶
A
Repository
for generic file distribution.Method generated by attrs for class FileRepository.
- importer¶
An object of
FileImporter
that is associated with the repository.New in version 2.39.0.
- upload_file(file_obj, relative_url=None, **kwargs)[source]¶
Upload a file to this repository.
- Parameters:
file_obj (str, file object) –
If it’s a string, then it’s the path of a file to upload.
Otherwise, it should be a file-like object pointing at the bytes to upload. The client takes ownership of this file object; it should not be modified elsewhere, and will be closed when upload completes.
relative_url (str) –
Path that should be used in remote repository, can either be a path to a directory or a path to a file, e.g:
if relative_url is ‘foo/bar/’ and file_obj has name ‘f.txt’, the resulting remote path wll be ‘foo/bar/f.txt’.
if relative_url is ‘foo/bar/f.txt’, no matter what the name of file_obj is, the remote path is ‘foo/bar/f.txt’.
If omitted, the local name of the file will be used. Or, if file_obj is a file object without a name attribute, passing relative_url is mandatory.
kwargs –
Additional field values to set on the uploaded unit.
Any
FileUnit
fields documented as mutable may be included here (for example,cdn_path
). An error will occur if attempting to set other fields.
- Returns:
- Future[list of
Task
] A future which is resolved after content has been imported to this repo.
- Future[list of
- Raises:
DetachedException – If this instance is not attached to a Pulp client.
New in version 1.2.0.
New in version 2.20.0: Added ability to set mutable fields on upload.
Units¶
- class pubtools.pulplib.FileUnit[source]¶
A
Unit
representing a generic file.New in version 1.5.0.
Method generated by attrs for class FileUnit.
- path¶
Full path for this file in the Pulp repository.
This may include leading directory components, but in the common case, this is only a basename.
- size¶
Size of this file, in bytes.
- sha256sum¶
SHA256 checksum of this file, as a hex string.
- description¶
A user-oriented terse description of this file.
This field is mutable and may be set by
upload_file()
orupdate_content()
.New in version 2.20.0.
- version¶
A version string associated with this file.
This string can be used for display purposes to group related files together. For example, files
"oc-4.8.10-linux.tar.gz"
and"openshift-install-linux-4.8.10.tar.gz"
in a repo may both have a version string of"4.8.10"
to indicate that the files relate to the same product version.This field is mutable and may be set by
upload_file()
orupdate_content()
.New in version 2.23.0.
- display_order¶
An ordering hint associated with this file.
In cases where a UI displays a list of files from Pulp, it is suggested that files by default should be ordered by this field ascending.
This field is mutable and may be set by
upload_file()
orupdate_content()
.New in version 2.23.0.
- cdn_path¶
A path, relative to the CDN root, from which this file can be downloaded once published.
This path will not point to any specific repository. However, the file must have been published via at least one repository before this path can be accessed.
This field is mutable and may be set by
upload_file()
orupdate_content()
.New in version 2.20.0.
- cdn_published¶
Approximate
datetime
in UTC at which this file first became available atcdn_path
, orNone
if this information is unavailable.This field is mutable and may be set by
upload_file()
orupdate_content()
.New in version 2.20.0.
- repository_memberships¶
IDs of repositories containing the unit, or
None
if this information is unavailable.New in version 2.6.0.
- unit_id¶
The unique ID of this unit, if known.
New in version 2.20.0.