Skip to content

Commit 5f17dd4

Browse files
stevsmitSteven Smith
andauthored
Adds permission API procs (quay#1201)
Co-authored-by: Steven Smith <[email protected]>
1 parent c3b9ae9 commit 5f17dd4

File tree

4 files changed

+168
-3
lines changed

4 files changed

+168
-3
lines changed

api/master.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ include::modules/org-team-member-api.adoc[leveloffset=+3]
8787
include::modules/org-application-create-api.adoc[leveloffset=+3]
8888
//proxy-cache
8989
include::modules/org-proxy-cache-configuration-api.adoc[leveloffset=+3]
90-
91-
92-
90+
//permission
91+
include::modules/repo-permission-api.adoc[leveloffset=+2]
92+
include::modules/user-permissions-repo.adoc[leveloffset=+3]
93+
include::modules/team-permissions-api.adoc[leveloffset=+3]
9394
9495
// team member management?
9596
include::modules/managing-team-members-api.adoc[leveloffset=+3]

modules/repo-permission-api.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[id="repo-permission-api"]
2+
= Managing repository permissions by using the {productname} API
3+
4+
Repository permissions can be managed by using the {productname} API. For example, you can create, view, and delete user and team permissions.
5+
6+
The following procedures show you how to manage repository permissions by using the {productname} API.

modules/team-permissions-api.adoc

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// module included in the following assemblies:
2+
3+
// * use_quay/master.adoc
4+
5+
:_content-type: CONCEPT
6+
[id="repo-manage-team-permissions"]
7+
= Managing team permissions by using the {productname} API
8+
9+
Use the following procedure to manage team permissions by using the {productname} API.
10+
11+
. Permissions for a specified team can be returned by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#getteampermissions[`GET /api/v1/repository/{repository}/permissions/team/{teamname}`] endpoint:
12+
+
13+
[source,terminal]
14+
----
15+
$ curl -X GET \
16+
-H "Authorization: Bearer <access_token>" \
17+
"https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/team/<teamname>"
18+
----
19+
+
20+
.Example output
21+
+
22+
[source,terminal]
23+
----
24+
{"role": "write"}
25+
----
26+
27+
. Permissions for all teams can be returned with the link:[`GET /api/v1/repository/{repository}/permissions/team/`] endpoint. For example:
28+
+
29+
[source,terminal]
30+
----
31+
$ curl -X GET \
32+
-H "Authorization: Bearer <access_token>" \
33+
"https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/team/"
34+
----
35+
+
36+
.Example output
37+
+
38+
[source,terminal]
39+
----
40+
{"permissions": {"ironmanteam": {"role": "read", "name": "ironmanteam", "avatar": {"name": "ironmanteam", "hash": "8045b2361613622183e87f33a7bfc54e100a41bca41094abb64320df29ef458d", "color": "#969696", "kind": "team"}}, "sillyteam": {"role": "read", "name": "sillyteam", "avatar": {"name": "sillyteam", "hash": "f275d39bdee2766d2404e2c6dbff28fe290969242e9fcf1ffb2cde36b83448ff", "color": "#17becf", "kind": "team"}}}}
41+
----
42+
43+
. Permissions for a specified team can be changed by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#changeteampermissions[`PUT /api/v1/repository/{repository}/permissions/team/{teamname}`] command. For example:
44+
+
45+
[source,terminal]
46+
----
47+
$ curl -X PUT \
48+
-H "Authorization: Bearer <access_token>" \
49+
-H "Content-Type: application/json" \
50+
-d '{"role": "<role>"}' \
51+
"https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/team/<teamname>"
52+
----
53+
+
54+
.Example output
55+
+
56+
[source,terminal]
57+
----
58+
{"role": "admin", "name": "superteam", "avatar": {"name": "superteam", "hash": "48cb6d114200039fed5c601480653ae7371d5a8849521d4c3bf2418ea013fc0f", "color": "#9467bd", "kind": "team"}}
59+
----
60+
61+
. Team permissions can be deleted with the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#deleteteampermissions[`DELETE /api/v1/repository/{repository}/permissions/team/{teamname}`] command. For example:
62+
+
63+
[source,terminal]
64+
----
65+
$ curl -X DELETE \
66+
-H "Authorization: Bearer <access_token>" \
67+
"https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/team/<teamname>"
68+
----
69+
+
70+
This command does not return output in the CLI.

modules/user-permissions-repo.adoc

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// module included in the following assemblies:
2+
3+
// * use_quay/master.adoc
4+
5+
:_content-type: CONCEPT
6+
[id="repo-manage-user-permissions"]
7+
= Managing user permissions by using the {productname} API
8+
9+
Use the following procedure to manage user permissions by using the {productname} API.
10+
11+
.Procedure
12+
13+
. Use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#getuserpermissions[`GET /api/v1/repository/{repository}/permissions/user/{username}`] endpoint to obtain repository permissions for a user. For example:
14+
+
15+
[source,terminal]
16+
----
17+
$ curl -X GET \
18+
-H "Authorization: Bearer <access_token>" \
19+
"https://quay-server.example.com/api/v1/repository/<repository_path>/permissions/user/<username>"
20+
----
21+
+
22+
.Example output
23+
+
24+
[source,terminal]
25+
----
26+
$ {"role": "read", "name": "testuser", "is_robot": false, "avatar": {"name": "testuser", "hash": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a", "color": "#6b6ecf", "kind": "user"}, "is_org_member": false}
27+
----
28+
29+
. All user permissions can be returned with the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#listrepouserpermissions[`GET /api/v1/repository/{repository}/permissions/user/`] endpoint:
30+
+
31+
[source,terminal]
32+
----
33+
$ curl -X GET \
34+
-H "Authorization: Bearer <access_token>" \
35+
"https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/user/"
36+
----
37+
+
38+
.Example output
39+
+
40+
[source,terminal]
41+
----
42+
{"permissions": {"quayadmin": {"role": "admin", "name": "quayadmin", "is_robot": false, "avatar": {"name": "quayadmin", "hash": "6d640d802fe23b93779b987c187a4b7a4d8fbcbd4febe7009bdff58d84498fba", "color": "#f7b6d2", "kind": "user"}, "is_org_member": true}, "test+example": {"role": "admin", "name": "test+example", "is_robot": true, "avatar": {"name": "test+example", "hash": "3b03050c26e900500437beee4f7f2a5855ca7e7c5eab4623a023ee613565a60e", "color": "#a1d99b", "kind": "robot"}, "is_org_member": true}}}
43+
----
44+
45+
. Alternatively, you can use the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#getusertransitivepermission[`GET /api/v1/repository/{repository}/permissions/user/{username}/transitive`] endpoint to return only the repository permission for the user:
46+
+
47+
[source,terminal]
48+
----
49+
$ curl -X GET \
50+
-H "Authorization: Bearer <access_token>" \
51+
"https://quay-server.example.com/api/v1/repository/<repository_path>/permissions/user/<username>/transitive"
52+
----
53+
+
54+
.Example output
55+
+
56+
[source,terminal]
57+
----
58+
{"permissions": [{"role": "admin"}]}
59+
----
60+
61+
. You can change the user's permissions, such as making the user an `admin` by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#changeuserpermissions[`PUT /api/v1/repository/{repository}/permissions/user/{username}`] endpoint. For example:
62+
+
63+
[source,terminal]
64+
----
65+
$ curl -X PUT \
66+
-H "Authorization: Bearer <access_token>" \
67+
-H "Content-Type: application/json" \
68+
-d '{"role": "<role>"}' \
69+
"https://quay-server.example.com/api/v1/repository/<repository_path>/permissions/user/<username>"
70+
----
71+
+
72+
.Example output
73+
+
74+
[source,terminal]
75+
----
76+
{"role": "admin", "name": "testuser", "is_robot": false, "avatar": {"name": "testuser", "hash": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a", "color": "#6b6ecf", "kind": "user"}, "is_org_member": false}
77+
----
78+
79+
. User permissions can be deleted by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#deleteuserpermissions[`DELETE /api/v1/repository/{repository}/permissions/user/{username}`] endpoint. For example:
80+
+
81+
[source,terminal]
82+
----
83+
$ curl -X DELETE \
84+
-H "Authorization: Bearer <access_token>" \
85+
"https://quay-server.example.com/api/v1/repository/<namespace>/<repository>/permissions/user/<username>"
86+
----
87+
+
88+
This command does not return output.

0 commit comments

Comments
 (0)