Skip to content

Commit

Permalink
Adds mirror API proc (#1195)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Smith <stevsmit@stevsmit-thinkpadt14gen4.remote.csb>
  • Loading branch information
stevsmit and Steven Smith authored Jan 15, 2025
1 parent 67244f2 commit 9be264b
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/master.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ include::modules/viewing-usage-logs-api.adoc[leveloffset=+2]
include::modules/use-quay-export-logs-api.adoc[leveloffset=+2]
//manifest label
include::modules/adding-managing-labels-api.adoc[leveloffset=+2]
//mirror
include::modules/mirror-quay-api.adoc[leveloffset=+2]
//include::modules/proc_use-api.adoc[leveloffset=+1]
Expand Down Expand Up @@ -126,6 +128,7 @@ include::modules/api-manifest-addManifestLabel.adoc[leveloffset=+3]
include::modules/api-manifest-listManifestLabels.adoc[leveloffset=+3]
include::modules/api-manifest-getRepoManifest.adoc[leveloffset=+3]
//example procedures provided
include::modules/api-mirror.adoc[leveloffset=+2]
include::modules/api-mirror-syncCancel.adoc[leveloffset=+3]
include::modules/api-mirror-syncNow.adoc[leveloffset=+3]
Expand Down
24 changes: 24 additions & 0 deletions modules/api-mirror-changeRepoMirrorConfig.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,27 @@ _optional_||object
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
|===

[discrete]
== Example command

[source,terminal]
----
$ curl -X PUT "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"is_enabled": <false>, <1>
"external_reference": "<external_reference>",
"external_registry_username": "<external_registry_username>",
"external_registry_password": "<external_registry_password>",
"sync_start_date": "<sync_start_date>",
"sync_interval": <sync_interval>,
"robot_username": "<robot_username>",
"root_rule": {
"rule": "<rule>",
"rule_type": "<rule_type>"
}
}'
----
<1> Disables automatic synchronization.
23 changes: 23 additions & 0 deletions modules/api-mirror-createRepoMirrorConfig.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,26 @@ _optional_||object
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
|===

[discrete]
== Example command

[source,terminal]
----
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"is_enabled": <is_enabled>,
"external_reference": "<external_reference>",
"external_registry_username": "<external_registry_username>",
"external_registry_password": "<external_registry_password>",
"sync_start_date": "<sync_start_date>",
"sync_interval": <sync_interval>,
"robot_username": "<robot_username>",
"root_rule": {
"rule": "<rule>",
"rule_type": "<rule_type>"
}
}'
----
9 changes: 9 additions & 0 deletions modules/api-mirror-getRepoMirrorConfig.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ _required_|The full path of the repository. e.g. namespace/name|string
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
|===

[discrete]
== Example command

[source,terminal]
----
$ curl -X GET "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
-H "Authorization: Bearer <access_token>"
----
8 changes: 8 additions & 0 deletions modules/api-mirror-syncCancel.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ _required_|The full path of the repository. e.g. namespace/name|string
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
|===

[discrete]
== Example command

[source,terminal]
----
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-cancel" \
----
9 changes: 9 additions & 0 deletions modules/api-mirror-syncNow.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ _required_|The full path of the repository. e.g. namespace/name|string
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
|===

[discrete]
== Example command

[source,terminal]
----
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-now" \
-H "Authorization: Bearer <access_token>"
----
90 changes: 90 additions & 0 deletions modules/mirror-quay-api.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
:_content-type: CONCEPT
[id="quay-mirror-api"]
= Using the API to mirror a repository

{productname} administrators can mirror external repositories by using the API.

.Prerequisites

* You have set `FEATURE_REPO_MIRROR: true` in your `config.yaml` file.
.Procedure

* Create a new repository mirror configuration by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#createrepomirrorconfig[`POST /api/v1/repository/{repository}/mirror`] endpoint:
+
[source,terminal]
----
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"is_enabled": <is_enabled>,
"external_reference": "<external_reference>",
"external_registry_username": "<external_registry_username>",
"external_registry_password": "<external_registry_password>",
"sync_start_date": "<sync_start_date>",
"sync_interval": <sync_interval>,
"robot_username": "<robot_username>",
"root_rule": {
"rule": "<rule>",
"rule_type": "<rule_type>"
}
}'
----
* You can return information about the mirror configuration by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/3.13/html-single/red_hat_quay_api_guide/index#getrepomirrorconfig[`GET /api/v1/repository/{repository}/mirror`] endpoint:
+
[source,terminal]
----
$ curl -X GET "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
-H "Authorization: Bearer <access_token>"
----
+
.Example output
+
[source,terminal]
----
{"is_enabled": true, "mirror_type": "PULL", "external_reference": "https://quay.io/repository/argoproj/argocd", "external_registry_username": null, "external_registry_config": {}, "sync_interval": 86400, "sync_start_date": "2025-01-15T12:00:00Z", "sync_expiration_date": null, "sync_retries_remaining": 3, "sync_status": "NEVER_RUN", "root_rule": {"rule_kind": "tag_glob_csv", "rule_value": ["*.latest*"]}, "robot_username": "quayadmin+mirror_robot"}
----
* You can use the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#syncnow[`POST /api/v1/repository/{repository}/mirror/sync-now`] endpoint to sync the repositories. For example:
+
[source,terminal]
----
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-now" \
-H "Authorization: Bearer <access_token>"
----
+
This command does not return output in the CLI.
* Alternatively, you can cancel the sync with the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#synccancel[`POST /api/v1/repository/{repository}/mirror/sync-cancel`] endpoint.For example:
+
[source,terminal]
----
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-cancel" \
----
+
This command does not return output in the CLI.
* After creating a mirror configuration, you can make changes with the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#changerepomirrorconfig[`PUT /api/v1/repository/{repository}/mirror`] command. For example, you might choose to disable automatic synchronizations:
+
[source,terminal]
----
$ curl -X PUT "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"is_enabled": <false>, <1>
"external_reference": "<external_reference>",
"external_registry_username": "<external_registry_username>",
"external_registry_password": "<external_registry_password>",
"sync_start_date": "<sync_start_date>",
"sync_interval": <sync_interval>,
"robot_username": "<robot_username>",
"root_rule": {
"rule": "<rule>",
"rule_type": "<rule_type>"
}
}'
----
<1> Disables automatic synchronization.

0 comments on commit 9be264b

Please sign in to comment.