|
1 | 1 | Upload Content
|
2 | 2 | ==============
|
3 | 3 |
|
4 |
| -Upload a file to Pulp |
5 |
| ---------------------- |
| 4 | +One-shot upload a file to Pulp |
| 5 | +------------------------------ |
6 | 6 |
|
7 |
| -Each artifact in Pulp represents a file. They can be created during sync or created manually by uploading a file:: |
| 7 | +Each artifact in Pulp represents a file. They can be created during sync or created manually by uploading a file via |
| 8 | +one-shot upload. One-shot upload takes a file you specify, creates an artifact, and creates content from that artifact. |
| 9 | +The python plugin will inspect the file and populate its metadata. |
8 | 10 |
|
9 |
| - $ export ARTIFACT_HREF=$(http --form POST $BASE_ADDR/pulp/api/v3/artifacts/ file@./shelf_reader-0.1-py2-none-any.whl | jq -r '._href') |
| 11 | +.. literalinclude:: ../_scripts/upload.sh |
| 12 | + :language: bash |
10 | 13 |
|
11 |
| -Response:: |
| 14 | +Content GET Response:: |
12 | 15 |
|
13 | 16 | {
|
14 |
| - "_href": "/pulp/api/v3/artifacts/1/", |
15 |
| - ... |
| 17 | + "_artifact": null, |
| 18 | + "_created": "2019-07-25T13:57:55.178993Z", |
| 19 | + "_href": "/pulp/api/v3/content/python/packages/6172ff0f-3e11-4b5f-8460-bd6a72616747/", |
| 20 | + "_type": "python.python", |
| 21 | + "author": "", |
| 22 | + "author_email": "", |
| 23 | + "classifiers": [], |
| 24 | + "description": "", |
| 25 | + "download_url": "", |
| 26 | + "filename": "shelf_reader-0.1-py2-none-any.whl", |
| 27 | + "home_page": "", |
| 28 | + "keywords": "", |
| 29 | + "license": "", |
| 30 | + "maintainer": "", |
| 31 | + "maintainer_email": "", |
| 32 | + "metadata_version": "", |
| 33 | + "name": "[]", |
| 34 | + "obsoletes_dist": "[]", |
| 35 | + "packagetype": "bdist_wheel", |
| 36 | + "platform": "", |
| 37 | + "project_url": "", |
| 38 | + "provides_dist": "[]", |
| 39 | + "requires_dist": "[]", |
| 40 | + "requires_external": "[]", |
| 41 | + "requires_python": "", |
| 42 | + "summary": "", |
| 43 | + "supported_platform": "", |
| 44 | + "version": "0.1" |
16 | 45 | }
|
17 | 46 |
|
| 47 | +Reference: `Python Content Usage <../restapi.html#tag/content>`_ |
18 | 48 |
|
19 |
| -Reference (pulpcore): `Artifact API Usage |
20 |
| -<https://docs.pulpproject.org/en/3.0/nightly/restapi.html#tag/artifacts>`_ |
21 |
| - |
22 |
| -Create content from an artifact |
23 |
| -------------------------------- |
| 49 | +Add content to a repository during one-shot upload |
| 50 | +-------------------------------------------------- |
24 | 51 |
|
25 |
| -Now that Pulp has the wheel, its time to make it into a unit of content. The python plugin will |
26 |
| -inspect the file and populate its metadata:: |
| 52 | +One-shot upload can also optionally add the content being created to a repository you specify. |
27 | 53 |
|
28 |
| - $ http POST $BASE_ADDR/pulp/api/v3/content/python/packages/ _artifact=$ARTIFACT_HREF filename=shelf_reader-0.1-py2-none-any.whl |
| 54 | +.. literalinclude:: ../_scripts/upload_with_repo.sh |
| 55 | + :language: bash |
29 | 56 |
|
30 |
| -Response:: |
| 57 | +Repository GET Response:: |
31 | 58 |
|
32 | 59 | {
|
33 |
| - "_href": "/pulp/api/v3/content/python/packages/1/", |
34 |
| - "_artifact": "/pulp/api/v3/artifacts/1/", |
35 |
| - "digest": "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c", |
36 |
| - "filename": "shelf_reader-0.1-py2-none-any.whl", |
37 |
| - "type": "python" |
| 60 | + "_created": "2019-07-25T14:03:48.378437Z", |
| 61 | + "_href": "/pulp/api/v3/repositories/135f468f-0c61-4337-9f37-0cd911244bec/versions/1/", |
| 62 | + "base_version": null, |
| 63 | + "content_summary": { |
| 64 | + "added": { |
| 65 | + "python.python": { |
| 66 | + "count": 1, |
| 67 | + "href": "/pulp/api/v3/content/python/packages/?repository_version_added=/pulp/api/v3/repositories/135f468f-0c61-4337-9f37-0cd911244bec/versions/1/" |
| 68 | + } |
| 69 | + }, |
| 70 | + "present": { |
| 71 | + "python.python": { |
| 72 | + "count": 1, |
| 73 | + "href": "/pulp/api/v3/content/python/packages/?repository_version=/pulp/api/v3/repositories/135f468f-0c61-4337-9f37-0cd911244bec/versions/1/" |
| 74 | + } |
| 75 | + }, |
| 76 | + "removed": {} |
| 77 | + }, |
| 78 | + "number": 1 |
38 | 79 | }
|
39 | 80 |
|
40 |
| -Create a variable for convenience:: |
41 |
| - |
42 |
| - $ export CONTENT_HREF=$(http $BASE_ADDR/pulp/api/v3/content/python/packages/ | jq -r '.results[] | select(.filename == "shelf_reader-0.1-py2-none-any.whl") | ._href') |
43 |
| - |
44 |
| -Reference: `Python Content API Usage <../restapi.html#tag/content>`_ |
45 | 81 |
|
46 |
| -Add content to a repository |
47 |
| ---------------------------- |
| 82 | +Reference: `Python Repository Usage <../restapi.html#tag/repositories>`_ |
48 | 83 |
|
49 |
| -See :ref:`add-remove` |
| 84 | +For other ways to add content to a repository, see :ref:`add-remove` |
0 commit comments