Closed stevsmit closed 2 weeks ago
For line 570 of file anaging-namespace-auto-pruning-policies.adoc , the api should be /api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/
due to we are describing Creating an auto-prune policy on a repository for a user with the API
, It is not POST /api/v1/user/autoprunepolicy/
. The key point is repository
.
For line 597, the API should be http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/
.
For line 607, the API should be PUT /api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>
For line 616, the API should be http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>
For line 646, the command should be $ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>
@hu-weihua I updated these, but I am a little confused. I can't get any API commands with <user_account>
to work. For example, I created a test user, testuser
, but API only returned errors when attempting to get auto pruning policies for that user. eg:
stevsmit@stevsmit-thinkpadt14gen4 api (PROJQUAY-8058-regex) $ curl -X GET -H "Authorization: Bearer k1cymK1CHaVkNixG9V6UmPQq8ZFLE2xqFfgmoxQZ" quay-server.example.com/api/v1/repository/testuser/test/example/autoprunepolicy/ {"detail": "Unauthorized", "error_message": "Unauthorized", "error_type": "insufficient_scope", "title": "insufficient_scope", "type": "http://quay-server.example.com/api/v1/error/insufficient_scope", "status": 403}
If commands look good to you I'll update, but was confused about getting them to work. I suggest just looking at Commit 2.
@stevsmit I saw the link in your API is quay-server.example.com/api/v1/repository/testuser/test/example/autoprunepolicy/
, depending on my understanding, the format should be http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/.
. After the key works /api/v1/repository/
and before the key words /autoprunepolicy/.
there should be two sections. But you have three.
If you are using the nested repository, it is another story.
In my environment, I create a user named whuquay
.
whuquay/repo
% curl -k -X POST -H "Authorization: Bearer OKh5N5JQ0V8wBKeZzQar8oKeLZ3zSfDK2YRpDbUp" -H "Content-Type: application/json" -d '{ "method": "creation_date", "value": "20d", "tagPattern": "^v$", "tagPatternMatches": true}' "https://quayregistry-quay-quay-enterprise.apps.whu416aw43.qe.devcluster.openshift.com/api/v1/repository/whuquay/repo/autoprunepolicy/"|jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 141 100 49 100 92 32 61 0:00:01 0:00:01 --:--:-- 94
{
"uuid": "98e7c8f9-da22-4d75-a15a-0de9a7b14e30"
}
% curl -k -X GET -H "Authorization: Bearer OKh5N5JQ0V8wBKeZzQar8oKeLZ3zSfDK2YRpDbUp" "https://quayregistry-quay-quay-enterprise.apps.whu416aw43.qe.devcluster.openshift.com/api/v1/repository/whuquay/repo/autoprunepolicy/"|jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 156 100 156 0 0 134 0 0:00:01 0:00:01 --:--:-- 134 { "policies": [ { "uuid": "98e7c8f9-da22-4d75-a15a-0de9a7b14e30", "method": "creation_date", "value": "20d", "tagPattern": "^v$", "tagPatternMatches": true } ] }
* For the nested repository `whuquay/secondpath/repo`
% curl -k -X POST -H "Authorization: Bearer OKh5N5JQ0V8wBKeZzQar8oKeLZ3zSfDK2YRpDbUp" -H "Content-Type: application/json" -d '{ "method": "creation_date", "value": "20d", "tagPattern": "^v$", "tagPatternMatches": true}' "https://quayregistry-quay-quay-enterprise.apps.whu416aw43.qe.devcluster.openshift.com/api/v1/repository/whuquay/secondpath/repo/autoprunepolicy/"|jq . % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 141 100 49 100 92 47 89 0:00:01 0:00:01 --:--:-- 137 { "uuid": "be86a2b1-ac5b-4756-97b9-6ec5d8252e9b" }
% curl -k -X GET -H "Authorization: Bearer OKh5N5JQ0V8wBKeZzQar8oKeLZ3zSfDK2YRpDbUp" "https://quayregistry-quay-quay-enterprise.apps.whu416aw43.qe.devcluster.openshift.com/api/v1/repository/whuquay/secondpath/repo/autoprunepolicy/"|jq . % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 156 100 156 0 0 164 0 --:--:-- --:--:-- --:--:-- 164 { "policies": [ { "uuid": "be86a2b1-ac5b-4756-97b9-6ec5d8252e9b", "method": "creation_date", "value": "20d", "tagPattern": "^v$", "tagPatternMatches": true } ] }
LGTM, thanks a lot @stevsmit
In line 318-357 of file anaging-namespace-auto-pruning-policies.adoc, the APIs used in example should be
/api/v1/user/autoprunepolicy/
, not/api/v1/<user>/autoprunepolicy/
. Here the customers do not need to replace any string for/<user>/
. The API/api/v1/user/autoprunepolicy/
can recognize the current user by token. For example: