Uploading Content¶
Uploading a unit into a repository is a four step process:
- Create an upload request in Pulp. Pulp will provide an ID that is used for subsequent operations.
- Upload the bits for the new file. For large files, this can be done through multiple calls. This step is entirely optional; it is possible that a unit purely consists of metadata and possibly creating relationships to other units.
- Once the file is uploaded, metadata about the unit itself is provided to Pulp along with a destination repository. The repository’s importer is contacted to perform the import which adds the unit to the database and associates it to the repository.
- Once the caller is finished importing the uploaded file, a request is sent to Pulp to delete the uploaded file from Pulp’s temporary storage.
Uploaded files are not in the Pulp inventory until the import step. Units must be imported into a repository that has an importer associated with it that is capable of handling the unit type.
Creating an Upload Request¶
Informs Pulp of the desire to upload a new content unit. Pulp will perform any preparation steps in the server and return an upload ID that is used to further work with the upload request.
/pulp/api/v2/content/uploads/
- 201 - if the request to upload a file is granted
- 500 - if the server cannot initialize the storage location for the file to be uploaded
Sample 201 Response Body:
{
"_href": "/pulp/api/v2/content/uploads/cfb1fed0-752b-439e-aa68-fba68eababa3/",
"upload_id': "cfb1fed0-752b-439e-aa68-fba68eababa3"
}
Upload Bits¶
Sends a portion of the contents of the file being uploaded to the server. If the entire file cannot be sent in a single call, the caller may divide up the file and provide offset information for Pulp to use when assembling it.
/pulp/api/v2/content/uploads/<upload_id>/<offset/
- 200 - if the content was successfully saved to the file
Note: * When uploading a whole file in a single request, you must still specify the offset of 0.
Import into a Repository¶
Provides metadata about the uploaded unit and requests Pulp import it into the inventory and associate it with the given repository. This call is made on the repository itself and the URL reflects this accordingly.
/pulp/api/v2/repositories/<repo_id>/actions/import_upload/
- upload_id (string) - identifies the upload request being imported
- unit_type_id (string) - identifies the type of unit the upload represents
- unit_key (object) - unique identifier for the new unit; the contents are contingent on the type of unit being uploaded
- unit_metadata (object) - (optional) extra metadata describing the unit; the contents will vary based on the importer handling the import
- override_config (object) - (optional) importer configuration values that override the importer’s default configuration
- 202 - if the request for the import was accepted but postponed until later
Tags:
The task created will have the following tags. "pulp:repository:<repo_id>",
"pulp:action:import_upload"
Sample Request:
{
"override_config": {},
"unit_type_id": "srpm",
"upload_id": "768b18c1-fef1-4443-bd5b-a4cc9bda3b03",
"unit_key": {},
"unit_metadata": {"checksum_type": null}
}
Delete an Upload Request¶
Once the uploaded file has been successfully imported and no further operations are desired, the caller should delete the upload request from the server.
/pulp/api/v2/content/uploads/<upload_id>/
- 200 - if the upload was successfully deleted
- 404 - if the given upload ID is not found
List All Upload Requests¶
Returns an array of IDs for all upload requests currently in the server.
/pulp/api/v2/content/uploads/
- 200 - for a successful lookup
Sample 200 Response Body:
{
"upload_ids': ["cfb1fed0-752b-439e-aa68-fba68eababa3"]
}