Skip to content

Commit 38b2951

Browse files
stevsmitSteven Smith
and
Steven Smith
authored
Adds mirror API proc (#1195)
Co-authored-by: Steven Smith <stevsmit@stevsmit-thinkpadt14gen4.remote.csb>
1 parent 09969fd commit 38b2951

7 files changed

+166
-0
lines changed

api/master.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ include::modules/viewing-usage-logs-api.adoc[leveloffset=+2]
6666
include::modules/use-quay-export-logs-api.adoc[leveloffset=+2]
6767
//manifest label
6868
include::modules/adding-managing-labels-api.adoc[leveloffset=+2]
69+
//mirror
70+
include::modules/mirror-quay-api.adoc[leveloffset=+2]
6971
7072
//include::modules/proc_use-api.adoc[leveloffset=+1]
7173
@@ -126,6 +128,7 @@ include::modules/api-manifest-addManifestLabel.adoc[leveloffset=+3]
126128
include::modules/api-manifest-listManifestLabels.adoc[leveloffset=+3]
127129
include::modules/api-manifest-getRepoManifest.adoc[leveloffset=+3]
128130
131+
//example procedures provided
129132
include::modules/api-mirror.adoc[leveloffset=+2]
130133
include::modules/api-mirror-syncCancel.adoc[leveloffset=+3]
131134
include::modules/api-mirror-syncNow.adoc[leveloffset=+3]

modules/api-mirror-changeRepoMirrorConfig.adoc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,27 @@ _optional_||object
6262
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
6363
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
6464
|===
65+
66+
[discrete]
67+
== Example command
68+
69+
[source,terminal]
70+
----
71+
$ curl -X PUT "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
72+
-H "Authorization: Bearer <access_token>" \
73+
-H "Content-Type: application/json" \
74+
-d '{
75+
"is_enabled": <false>, <1>
76+
"external_reference": "<external_reference>",
77+
"external_registry_username": "<external_registry_username>",
78+
"external_registry_password": "<external_registry_password>",
79+
"sync_start_date": "<sync_start_date>",
80+
"sync_interval": <sync_interval>,
81+
"robot_username": "<robot_username>",
82+
"root_rule": {
83+
"rule": "<rule>",
84+
"rule_type": "<rule_type>"
85+
}
86+
}'
87+
----
88+
<1> Disables automatic synchronization.

modules/api-mirror-createRepoMirrorConfig.adoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,26 @@ _optional_||object
6262
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
6363
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
6464
|===
65+
66+
[discrete]
67+
== Example command
68+
69+
[source,terminal]
70+
----
71+
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
72+
-H "Authorization: Bearer <access_token>" \
73+
-H "Content-Type: application/json" \
74+
-d '{
75+
"is_enabled": <is_enabled>,
76+
"external_reference": "<external_reference>",
77+
"external_registry_username": "<external_registry_username>",
78+
"external_registry_password": "<external_registry_password>",
79+
"sync_start_date": "<sync_start_date>",
80+
"sync_interval": <sync_interval>,
81+
"robot_username": "<robot_username>",
82+
"root_rule": {
83+
"rule": "<rule>",
84+
"rule_type": "<rule_type>"
85+
}
86+
}'
87+
----

modules/api-mirror-getRepoMirrorConfig.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ _required_|The full path of the repository. e.g. namespace/name|string
3333
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
3434
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
3535
|===
36+
37+
[discrete]
38+
== Example command
39+
40+
[source,terminal]
41+
----
42+
$ curl -X GET "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
43+
-H "Authorization: Bearer <access_token>"
44+
----

modules/api-mirror-syncCancel.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ _required_|The full path of the repository. e.g. namespace/name|string
3333
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
3434
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
3535
|===
36+
37+
[discrete]
38+
== Example command
39+
40+
[source,terminal]
41+
----
42+
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-cancel" \
43+
----

modules/api-mirror-syncNow.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,12 @@ _required_|The full path of the repository. e.g. namespace/name|string
3333
|403|Unauthorized access|&lt;&lt;_apierror,ApiError&gt;&gt;
3434
|404|Not found|&lt;&lt;_apierror,ApiError&gt;&gt;
3535
|===
36+
37+
[discrete]
38+
== Example command
39+
40+
[source,terminal]
41+
----
42+
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-now" \
43+
-H "Authorization: Bearer <access_token>"
44+
----

modules/mirror-quay-api.adoc

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
:_content-type: CONCEPT
2+
[id="quay-mirror-api"]
3+
= Using the API to mirror a repository
4+
5+
{productname} administrators can mirror external repositories by using the API.
6+
7+
.Prerequisites
8+
9+
* You have set `FEATURE_REPO_MIRROR: true` in your `config.yaml` file.
10+
11+
.Procedure
12+
13+
* 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:
14+
+
15+
[source,terminal]
16+
----
17+
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
18+
-H "Authorization: Bearer <access_token>" \
19+
-H "Content-Type: application/json" \
20+
-d '{
21+
"is_enabled": <is_enabled>,
22+
"external_reference": "<external_reference>",
23+
"external_registry_username": "<external_registry_username>",
24+
"external_registry_password": "<external_registry_password>",
25+
"sync_start_date": "<sync_start_date>",
26+
"sync_interval": <sync_interval>,
27+
"robot_username": "<robot_username>",
28+
"root_rule": {
29+
"rule": "<rule>",
30+
"rule_type": "<rule_type>"
31+
}
32+
}'
33+
----
34+
35+
* 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:
36+
+
37+
[source,terminal]
38+
----
39+
$ curl -X GET "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
40+
-H "Authorization: Bearer <access_token>"
41+
----
42+
+
43+
.Example output
44+
+
45+
[source,terminal]
46+
----
47+
{"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"}
48+
----
49+
50+
* 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:
51+
+
52+
[source,terminal]
53+
----
54+
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-now" \
55+
-H "Authorization: Bearer <access_token>"
56+
----
57+
+
58+
This command does not return output in the CLI.
59+
60+
* 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:
61+
+
62+
[source,terminal]
63+
----
64+
$ curl -X POST "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror/sync-cancel" \
65+
----
66+
+
67+
This command does not return output in the CLI.
68+
69+
* 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:
70+
+
71+
[source,terminal]
72+
----
73+
$ curl -X PUT "https://<quay-server.example.com>/api/v1/repository/<namespace>/<repo>/mirror" \
74+
-H "Authorization: Bearer <access_token>" \
75+
-H "Content-Type: application/json" \
76+
-d '{
77+
"is_enabled": <false>, <1>
78+
"external_reference": "<external_reference>",
79+
"external_registry_username": "<external_registry_username>",
80+
"external_registry_password": "<external_registry_password>",
81+
"sync_start_date": "<sync_start_date>",
82+
"sync_interval": <sync_interval>,
83+
"robot_username": "<robot_username>",
84+
"root_rule": {
85+
"rule": "<rule>",
86+
"rule_type": "<rule_type>"
87+
}
88+
}'
89+
----
90+
<1> Disables automatic synchronization.

0 commit comments

Comments
 (0)