Skip to content

Commit 4936443

Browse files
stevsmitSteven Smith
andauthored
modularizes policy api content (quay#1202)
Co-authored-by: Steven Smith <[email protected]>
1 parent 5f17dd4 commit 4936443

7 files changed

+380
-0
lines changed

api/master.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ include::modules/org-proxy-cache-configuration-api.adoc[leveloffset=+3]
9191
include::modules/repo-permission-api.adoc[leveloffset=+2]
9292
include::modules/user-permissions-repo.adoc[leveloffset=+3]
9393
include::modules/team-permissions-api.adoc[leveloffset=+3]
94+
//policy
95+
include::modules/repo-policy-api.adoc[leveloffset=+2]
96+
include::modules/creating-org-policy-api.adoc[leveloffset=+3]
97+
include::modules/creating-policy-api-current-user.adoc[leveloffset=+3]
98+
include::modules/creating-repository-policy-api.adoc[leveloffset=+3]
99+
include::modules/creating-policy-api-other-user.adoc[leveloffset=+3]
94100
95101
// team member management?
96102
include::modules/managing-team-members-api.adoc[leveloffset=+3]
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
[id="creating-org-policy-api"]
2+
= Creating an auto-prune policy for a namespace by using the {productname} API
3+
4+
You can use {productname} API endpoints to manage auto-pruning policies for an namespace.
5+
6+
.Prerequisites
7+
8+
* You have set `BROWSER_API_CALLS_XHR_ONLY: false` in your `config.yaml` file.
9+
* You have created an OAuth access token.
10+
* You have logged into {productname}.
11+
12+
.Procedure
13+
14+
. Enter the following link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#createorganizationautoprunepolicy[`POST /api/v1/organization/{orgname}/autoprunepolicy/`] command create a new policy that limits the number of tags allowed in an organization:
15+
+
16+
[source,terminal]
17+
----
18+
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags", "value": 10}' http://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/
19+
----
20+
+
21+
Alternatively, you can can set tags to expire for a specified time after their creation date:
22+
+
23+
[source,terminal]
24+
----
25+
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{
26+
"method": "creation_date", "value": "7d"}' http://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/
27+
----
28+
+
29+
.Example output
30+
[source,terminal]
31+
----
32+
{"uuid": "73d64f05-d587-42d9-af6d-e726a4a80d6e"}
33+
----
34+
35+
. Optional. You can add an additional policy to an organization and pass in the `tagPattern` and `tagPatternMatches` fields to prune only tags that match the given regex pattern. For example:
36+
+
37+
[source,terminal]
38+
----
39+
$ curl -X POST \
40+
-H "Authorization: Bearer <bearer_token>" \
41+
-H "Content-Type: application/json" \
42+
-d '{
43+
"method": "creation_date",
44+
"value": "7d",
45+
"tagPattern": "^v*",
46+
"tagPatternMatches": <true> <1>
47+
}' \
48+
"https://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/"
49+
----
50+
<1> Setting `tagPatternMatches` to `true` makes it so that tags that match the given regex pattern will be pruned. In this example, tags that match `^v*` are pruned.
51+
+
52+
.Example output
53+
+
54+
[source,terminal]
55+
----
56+
{"uuid": "ebf7448b-93c3-4f14-bf2f-25aa6857c7b0"}
57+
----
58+
59+
. You can update your organization's auto-prune policy by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#updateorganizationautoprunepolicy[`PUT /api/v1/organization/{orgname}/autoprunepolicy/{policy_uuid}`] command. For example:
60+
+
61+
[source,terminal]
62+
----
63+
$ curl -X PUT -H "Authorization: Bearer <bearer_token>" -H "Content-Type: application/json" -d '{
64+
"method": "creation_date",
65+
"value": "4d",
66+
"tagPattern": "^v*",
67+
"tagPatternMatches": true
68+
}' "<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/<uuid>"
69+
----
70+
+
71+
This command does not return output. Continue to the next step.
72+
73+
. Check your auto-prune policy by entering the following command:
74+
+
75+
[source,terminal]
76+
----
77+
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/
78+
----
79+
+
80+
.Example output
81+
+
82+
[source,terminal]
83+
----
84+
{"policies": [{"uuid": "ebf7448b-93c3-4f14-bf2f-25aa6857c7b0", "method": "creation_date", "value": "4d", "tagPattern": "^v*", "tagPatternMatches": true}, {"uuid": "da4d0ad7-3c2d-4be8-af63-9c51f9a501bc", "method": "number_of_tags", "value": 10, "tagPattern": null, "tagPatternMatches": true}, {"uuid": "17b9fd96-1537-4462-a830-7f53b43f94c2", "method": "creation_date", "value": "7d", "tagPattern": "^v*", "tagPatternMatches": true}]}
85+
----
86+
87+
. You can delete the auto-prune policy for your organization by entering the following command. Note that deleting the policy requires the UUID.
88+
+
89+
[source,terminal]
90+
----
91+
$ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/73d64f05-d587-42d9-af6d-e726a4a80d6e
92+
----
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[id="creating-policy-api-current-user"]
2+
= Creating an auto-prune policy for a namespace for the current user by using the API
3+
4+
You can use {productname} API endpoints to manage auto-pruning policies for your account.
5+
6+
[NOTE]
7+
====
8+
The use of `/user/` in the following commands represents the user that is currently logged into {productname}.
9+
====
10+
11+
.Prerequisites
12+
13+
* You have set `BROWSER_API_CALLS_XHR_ONLY: false` in your `config.yaml` file.
14+
* You have created an OAuth access token.
15+
* You have logged into {productname}.
16+
17+
.Procedure
18+
19+
. Enter the following `POST` command create a new policy that limits the number of tags for the current user:
20+
+
21+
[source,terminal]
22+
----
23+
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags", "value": 10}' http://<quay-server.example.com>/api/v1/user/autoprunepolicy/
24+
----
25+
+
26+
.Example output
27+
+
28+
[source,terminal]
29+
----
30+
{"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859"}
31+
----
32+
33+
. Check your auto-prune policy by entering the following command:
34+
+
35+
[source,terminal]
36+
----
37+
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/
38+
----
39+
+
40+
Alternatively, you can include the UUID:
41+
+
42+
[source,terminal]
43+
----
44+
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859
45+
----
46+
+
47+
.Example output
48+
+
49+
[source,terminal]
50+
----
51+
{"policies": [{"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859", "method": "number_of_tags", "value": 10}]}
52+
----
53+
54+
. You can delete the auto-prune policy by entering the following command. Note that deleting the policy requires the UUID.
55+
+
56+
[source,terminal]
57+
----
58+
$ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859
59+
----
60+
+
61+
.Example output
62+
+
63+
[source,terminal]
64+
----
65+
{"uuid": "8c03f995-ca6f-4928-b98d-d75ed8c14859"}
66+
----
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
2+
[id="creating-policy-api-other-user"]
3+
= Creating an auto-prune policy on a repository for a user with the API
4+
5+
You can use {productname} API endpoints to manage auto-pruning policies on a repository for user accounts that are not your own, so long as you have `admin` privileges on the repository.
6+
7+
.Prerequisites
8+
9+
* You have set `BROWSER_API_CALLS_XHR_ONLY: false` in your `config.yaml` file.
10+
* You have created an OAuth access token.
11+
* You have logged into {productname}.
12+
* You have `admin` privileges on the repository that you are creating the policy for.
13+
14+
.Procedure
15+
16+
. Enter the following link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#createuserautoprunepolicy[`POST /api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/`] command create a new policy that limits the number of tags for the user:
17+
+
18+
[source,terminal]
19+
----
20+
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags","value": 2}' https://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/
21+
----
22+
+
23+
.Example output
24+
+
25+
[source,terminal]
26+
----
27+
{"uuid": "7726f79c-cbc7-490e-98dd-becdc6fefce7"}
28+
----
29+
30+
. Optional. You can add an additional policy for the current user and pass in the `tagPattern` and `tagPatternMatches` fields to prune only tags that match the given regex pattern. For example:
31+
+
32+
[source,terminal]
33+
----
34+
$ curl -X POST \
35+
-H "Authorization: Bearer <bearer_token>" \
36+
-H "Content-Type: application/json" \
37+
-d '{
38+
"method": "creation_date",
39+
"value": "7d",
40+
"tagPattern": "^v*",
41+
"tagPatternMatches": true
42+
}' \
43+
"http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/"
44+
----
45+
+
46+
.Example output
47+
+
48+
[source,terminal]
49+
----
50+
{"uuid": "b3797bcd-de72-4b71-9b1e-726dabc971be"}
51+
----
52+
53+
. You can update your policy for the current user by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#updateuserautoprunepolicy[`PUT /api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>`] command. For example:
54+
+
55+
[source,terminal]
56+
----
57+
$ curl -X PUT -H "Authorization: Bearer <bearer_token>" -H "Content-Type: application/json" -d '{
58+
"method": "creation_date",
59+
"value": "4d",
60+
"tagPattern": "^test.",
61+
"tagPatternMatches": true
62+
}' "https://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>"
63+
----
64+
+
65+
Updating a policy does not return output in the CLI.
66+
67+
. Check your auto-prune policy by entering the following command:
68+
+
69+
[source,terminal]
70+
----
71+
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/
72+
----
73+
+
74+
Alternatively, you can include the UUID:
75+
+
76+
[source,terminal]
77+
----
78+
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/7726f79c-cbc7-490e-98dd-becdc6fefce7
79+
----
80+
+
81+
.Example output
82+
+
83+
[source,terminal]
84+
----
85+
{"uuid": "81ee77ec-496a-4a0a-9241-eca49437d15b", "method": "creation_date", "value": "7d", "tagPattern": "^v*", "tagPatternMatches": true}
86+
----
87+
88+
. You can delete the auto-prune policy by entering the following command. Note that deleting the policy requires the UUID.
89+
+
90+
[source,terminal]
91+
----
92+
$ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>
93+
----
94+
+
95+
.Example output
96+
+
97+
[source,terminal]
98+
----
99+
{"uuid": "7726f79c-cbc7-490e-98dd-becdc6fefce7"}
100+
----
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
[id="creating-repository-policy-api"]
2+
= Creating an auto-prune policy for a repository using the {productname} API
3+
4+
You can use {productname} API endpoints to manage auto-pruning policies for an repository.
5+
6+
.Prerequisites
7+
8+
* You have set `BROWSER_API_CALLS_XHR_ONLY: false` in your `config.yaml` file.
9+
* You have created an OAuth access token.
10+
* You have logged into {productname}.
11+
12+
.Procedure
13+
14+
. Enter the following link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#updateorganizationautoprunepolicy[`POST /api/v1/repository/{repository}/autoprunepolicy/`] command create a new policy that limits the number of tags allowed in an organization:
15+
+
16+
[source,terminal]
17+
----
18+
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags","value": 2}' http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/
19+
----
20+
+
21+
Alternatively, you can can set tags to expire for a specified time after their creation date:
22+
+
23+
[source,terminal]
24+
----
25+
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "creation_date", "value": "7d"}' http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/
26+
----
27+
+
28+
.Example output
29+
+
30+
[source,terminal]
31+
----
32+
{"uuid": "ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7"}
33+
----
34+
35+
. Optional. You can add an additional policy and pass in the `tagPattern` and `tagPatternMatches` fields to prune only tags that match the given regex pattern. For example:
36+
+
37+
[source,terminal]
38+
----
39+
$ curl -X POST \
40+
-H "Authorization: Bearer <access_token>" \
41+
-H "Content-Type: application/json" \
42+
-d '{
43+
"method": "<creation_date>",
44+
"value": "<7d>",
45+
"tagPattern": "<^test.>*",
46+
"tagPatternMatches": <false> <1>
47+
}' \
48+
"https://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/"
49+
----
50+
<1> Setting `tagPatternMatches` to `false` makes it so that tags that all tags that _do not_ match the given regex pattern are pruned. In this example, all tags _but_ `^test.` are pruned.
51+
+
52+
.Example output
53+
+
54+
[source,terminal]
55+
----
56+
{"uuid": "b53d8d3f-2e73-40e7-96ff-736d372cd5ef"}
57+
----
58+
59+
. You can update your policy for the repository by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#updaterepositoryautoprunepolicy[`PUT /api/v1/repository/{repository}/autoprunepolicy/{policy_uuid}`] command and passing in the UUID. For example:
60+
+
61+
[source,terminal]
62+
----
63+
$ curl -X PUT \
64+
-H "Authorization: Bearer <bearer_token>" \
65+
-H "Content-Type: application/json" \
66+
-d '{
67+
"method": "number_of_tags",
68+
"value": "5",
69+
"tagPattern": "^test.*",
70+
"tagPatternMatches": true
71+
}' \
72+
"https://quay-server.example.com/api/v1/repository/<namespace>/<repo_name>/autoprunepolicy/<uuid>"
73+
----
74+
+
75+
This command does not return output. Continue to the next step to check your auto-prune policy.
76+
77+
. Check your auto-prune policy by entering the following command:
78+
+
79+
[source,terminal]
80+
----
81+
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/
82+
----
83+
+
84+
Alternatively, you can include the UUID:
85+
+
86+
[source,terminal]
87+
----
88+
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7
89+
----
90+
+
91+
.Example output
92+
+
93+
[source,terminal]
94+
----
95+
{"policies": [{"uuid": "ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7", "method": "number_of_tags", "value": 10}]}
96+
----
97+
98+
. You can delete the auto-prune policy by entering the following command. Note that deleting the policy requires the UUID.
99+
+
100+
[source,terminal]
101+
----
102+
$ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7
103+
----
104+
+
105+
.Example output
106+
+
107+
[source,terminal]
108+
----
109+
{"uuid": "ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7"}
110+
----

modules/managing-namespace-auto-pruning-policies.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
[id="managing-namespace-auto-pruning-policies"]
33
= Managing auto-pruning policies using the {productname} UI
44

5+
//All API content in this module needs removed and replaced with the modules that exist in the /api/ guide.
6+
57
All auto-pruning policies, with the exception of a registry-wide auto pruning policy, are created using the {productname} v2 UI or by using the API. This can be done after you have configured your {productname} `config.yaml` file to enable the auto-pruning feature and the v2 UI.
68

79
[NOTE]

0 commit comments

Comments
 (0)