Skip to content

Commit

Permalink
Adds repo API endpoints (#1203)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Smith <[email protected]>
  • Loading branch information
stevsmit and Steven Smith authored Jan 22, 2025
1 parent 4936443 commit 10606e9
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 4 deletions.
4 changes: 4 additions & 0 deletions api/master.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ include::modules/creating-org-policy-api.adoc[leveloffset=+3]
include::modules/creating-policy-api-current-user.adoc[leveloffset=+3]
include::modules/creating-repository-policy-api.adoc[leveloffset=+3]
include::modules/creating-policy-api-other-user.adoc[leveloffset=+3]
//repo
include::modules/repo-manage-api.adoc[leveloffset=+2]
// team member management?
include::modules/managing-team-members-api.adoc[leveloffset=+3]
Expand Down
6 changes: 3 additions & 3 deletions modules/adding-a-new-tag-to-image-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ You can add a new tag, or restore an old one, to an image by using the API.

.Prerequisites

* You have link:https://access.redhat.com/documentation/en-us/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#creating-oauth-access-token[Created an OAuth access token].
* You have link:https://access.redhat.com/documentation/en-us/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#creating-oauth-access-token[Created an OAuth access token].
* You have set `BROWSER_API_CALLS_XHR_ONLY: false` in your `config.yaml` file.
.Procedure

. You can change which image a tag points to or create a new tag by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#changetag[`PUT /api/v1/repository/{repository}/tag/{tag}`] command:
. You can change which image a tag points to or create a new tag by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#changetag[`PUT /api/v1/repository/{repository}/tag/{tag}`] command:
+
[source,terminal]
----
Expand All @@ -31,7 +31,7 @@ $ curl -X PUT \
"Updated"
----

. You can restore a repository tag to its previous image by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#restoretag[`POST /api/v1/repository/{repository}/tag/{tag}/restore`] command. For example:
. You can restore a repository tag to its previous image by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#restoretag[`POST /api/v1/repository/{repository}/tag/{tag}/restore`] command. For example:
+
[source,terminal]
----
Expand Down
4 changes: 4 additions & 0 deletions modules/repo-manage-api.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[id="repo-manage-api"]
= Creating and configuring repositories by using the {productname} API

Repositories can be created, retrieved, changed, and deleted by using the {productname} API.
120 changes: 119 additions & 1 deletion modules/repo-policy-api.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,122 @@
[id="policy-api"]
= Managing auto-prune policies by using the {productname} API

Auto-prune policies can be created, retrieved, changed, and delete for organizations, repositories, and users by using the {productname} API.
Auto-prune policies can be created, retrieved, changed, and delete for organizations, repositories, and users by using the {productname} API.

.Procedure

. Enter the following command to create a repository using the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#createrepo[`POST /api/v1/repository`] endpoint:
+
[source,terminal]
----
$ curl -X POST \
-H "Authorization: Bearer <bearer_token>" \
-H "Content-Type: application/json" \
-d '{
"repository": "<new_repository_name>",
"visibility": "<private>",
"description": "<This is a description of the new repository>."
}' \
"https://quay-server.example.com/api/v1/repository"
----
+
.Example output
+
[source,terminal]
----
{"namespace": "quayadmin", "name": "<new_repository_name>", "kind": "image"}
----

. You can list a repositories with the link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#listrepos[`GET /api/v1/repository`] endpoint. For example:
+
[source,terminal]
----
$ curl -X GET \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
"https://quay-server.example.com/api/v1/repository?public=true&starred=false&namespace=<NAMESPACE>"
----
+
.Example output
+
[source,terminal]
----
{"repositories": [{"namespace": "quayadmin", "name": "busybox", "description": null, "is_public": false, "kind": "image", "state": "MIRROR", "is_starred": false, "quota_report": {"quota_bytes": 2280675, "configured_quota": 2199023255552}}]}
----

. Visibility can be changed from public to private with the link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#changerepovisibility[`POST /api/v1/repository/{repository}/changevisibility`] endpoint:
+
[source,terminal]
----
$ curl -X POST \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"visibility": "private"
}' \
"https://quay-server.example.com/api/v1/repository/<NAMESPACE>/<REPO_NAME>/changevisibility"
----
.Example output
+
[source,terminal]
----
{"success": true}
----

. You can check the {productname} UI, or you can enter the following link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#getrepo[`GET /api/v1/repository/{repository}`] command to return details about a repository:
+
[source,terminal]
----
$ curl -X GET -H "Authorization: Bearer <bearer_token>" "<quay-server.example.com>/api/v1/repository/<namespace>/<repository_name>"
----
+
Example output
+
[source,terminal]
----
{"detail": "Not Found", "error_message": "Not Found", "error_type": "not_found", "title": "not_found", "type": "http://quay-server.example.com/api/v1/error/not_found", "status": 404}
----

. Repository descriptions can be updated with the link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#updaterepo[`PUT /api/v1/repository/{repository}`] endpoint:
+
[source,terminal]
----
$ curl -X PUT \
-H "Authorization: Bearer <bearer_token>" \
-H "Content-Type: application/json" \
-d '{
"description": "This is an updated description for the repository."
}' \
"https://quay-server.example.com/api/v1/repository/<NAMESPACE>/<REPOSITORY>"
----
+
.Example output
+
[source,terminal]
----
{"success": true}
----

. Enter the following command to delete a repository using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#deleterepository[`DELETE /api/v1/repository/{repository}`] endpoint:
+
[source,terminal]
----
$ curl -X DELETE -H "Authorization: Bearer <bearer_token>" "<quay-server.example.com>/api/v1/repository/<namespace>/<repository_name>"
----
+
This command does not return output in the CLI.

////
. The link:https://docs.redhat.com/en/documentation/red_hat_quay/3/html-single/red_hat_quay_api_guide/index#changerepostate[`PUT /api/v1/repository/{repository}/changestate`] API endpoint can be used to change the state of the repository:
+
[source,terminal]
----
----
+
.Example output
+
[source,terminal]
----
----
////

0 comments on commit 10606e9

Please sign in to comment.