-
Notifications
You must be signed in to change notification settings - Fork 9
/
curl_token_by_aksk20171226.sh
109 lines (96 loc) · 4.34 KB
/
curl_token_by_aksk20171226.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# evm
BASE_URL1='https://keapi-dev.cloudappl.com'
BASE_URL2='http://hub.ingress-dev1.cloudappl.com'
# cs
BASE_URL1='https://keapi-cs.qiniu.io'
BASE_URL2='https://hub-cs.qiniu.io'
# prd
BASE_URL1='https://keapi.qiniu.com'
BASE_URL2='https://hub.qiniu.com'
1. 获取user token
curl -v -H "Content-Type: application/json" -d '{"name":"K-vx0YimUIllEOmg2GCLO9BBGSWgUboCDpz4NqCs","password":"xA-zkSiQr9JRL1h70HuIEyHGm3lluS7TS4tn6Rz5"}' "$BASE_URL1/v1/usertoken" | python -mjson.tool
{
"token": {
"expires_at": "2017-12-28T08:44:43.000000Z",
"id": "gAAAAABaQLp7UE04P5LgKkJqOy3YCroNGaRjP5SjzXyhUwgYVe1I8DOd4YnVPbJ5emBvPL3pAaII7f_zLF5zVn9kuOKVS-lRSJlfbF8Ns4PNH54YaFhVm12IV3SLpph1yDhzRFj7r6IozBQzC3qP72ZjBDf66dYZ5A", // <= 这就是user token
"issued_at": "2017-12-25T08:44:43.000000Z"
},
"user": {
"id": "3fc83ca357aa41fabde41a3e3447ef3d", // <= 这是user id
"name": "1810637316"
}
}
2. 列举所有的project,即namespace。将上一步获取的user token,放入header X-Auth-Token
请求的路径为:/v1/users/:userid/projects
curl -v -H "X-Auth-Token: gAAAAABaQLp7UE04P5LgKkJqOy3YCroNGaRjP5SjzXyhUwgYVe1I8DOd4YnVPbJ5emBvPL3pAaII7f_zLF5zVn9kuOKVS-lRSJlfbF8Ns4PNH54YaFhVm12IV3SLpph1yDhzRFj7r6IozBQzC3qP72ZjBDf66dYZ5A" "$BASE_URL1/v1/users/3fc83ca357aa41fabde41a3e3447ef3d/projects" | python -mjson.tool
[
{
"description": "",
"name": "lutaoact" // <= 这就是project name,也就是namespace, 你们可以把project和namespace理解成相同的可以互换的概念
}
]
3. 获取project token,跟上一步用的token是一样的。路径为:/v1/projects/:project/token
curl -v -H "X-Auth-Token: gAAAAABaQLp7UE04P5LgKkJqOy3YCroNGaRjP5SjzXyhUwgYVe1I8DOd4YnVPbJ5emBvPL3pAaII7f_zLF5zVn9kuOKVS-lRSJlfbF8Ns4PNH54YaFhVm12IV3SLpph1yDhzRFj7r6IozBQzC3qP72ZjBDf66dYZ5A" "$BASE_URL1/v1/projects/lutaoact/token" | python -mjson.tool
{
"project": "lutaoact",
"roles": [
"member"
],
"token": {
"expires_at": "2017-12-28T08:44:43.000000Z",
"id": "gAAAAABaQLtj3iFA0cnuGHxD3XLqZAtXrk9M8aQz3UTwbWScAlEcKcz7MALPVila3Jj3YKxXy--R1wCz5ZhshcytqzShwdjdbYYvG86WZ5A1YA1W244IFbmsPuvZq8fr9xS29WK01kpRA6csYpA7vtX57FxfmBRJYJKM8YUH9yfHavFjwv_Jcc8VLtvhU6I1sryPiYxq8m-q", // <= 这就是project token
"issued_at": "2017-12-25T08:48:35.000000Z"
},
"user": {
"id": "3fc83ca357aa41fabde41a3e3447ef3d",
"name": "1810637316"
}
}
4. 根据project token可以获取所有的repo。路径为:/v1/hub/namespaces/:namespace/repos?page=0&pageSize=20
可以根据需求传递分页信息
curl -v -H "X-Auth-Token: gAAAAABaQLtj3iFA0cnuGHxD3XLqZAtXrk9M8aQz3UTwbWScAlEcKcz7MALPVila3Jj3YKxXy--R1wCz5ZhshcytqzShwdjdbYYvG86WZ5A1YA1W244IFbmsPuvZq8fr9xS29WK01kpRA6csYpA7vtX57FxfmBRJYJKM8YUH9yfHavFjwv_Jcc8VLtvhU6I1sryPiYxq8m-q" "$BASE_URL2/v1/hub/namespaces/lutaoact/repos?page=0&pageSize=20" | python -mjson.tool
{
"page": 1,
"pageSize": 20,
"repos": [
{
"codeSource": "",
"createdAt": "2017-12-25T16:52:45.096+08:00",
"description": "",
"isCertified": false,
"isPub": false,
"labels": [
"database"
],
"logoUrl": "",
"name": "xxxxxx",
"namespace": "lutaoact",
"origin": "qiniu",
"pulls": 0,
"stars": 0,
"summary": "xxxxx",
"tags": [],
"updatedAt": "2017-12-25T16:52:45.096+08:00"
}
],
"total": 1
}
5. 根据repo获取相应的镜像,这里用的也是project token
可以根据需求传递分页信息
curl -v -H "X-Auth-Token: gAAAAABaQLtj3iFA0cnuGHxD3XLqZAtXrk9M8aQz3UTwbWScAlEcKcz7MALPVila3Jj3YKxXy--R1wCz5ZhshcytqzShwdjdbYYvG86WZ5A1YA1W244IFbmsPuvZq8fr9xS29WK01kpRA6csYpA7vtX57FxfmBRJYJKM8YUH9yfHavFjwv_Jcc8VLtvhU6I1sryPiYxq8m-q" "$BASE_URL2/v1/hub/namespaces/lutaoact/repos/xxxxxx/tags?page=1&pageSize=20&orderBy=-updatedAt" | python -mjson.tool
{
"images": [
{
"createdAt": "2017-12-25T16:59:22.249+08:00",
"hash": "sha256:9fa82f24cbb11b6b80d5c88e0e10c3306707d97ff862a3018f22f9b49cef303a",
"namespace": "lutaoact",
"repoName": "xxxxxx",
"size": 2492,
"tag": "1",
"updatedAt": "2017-12-25T16:59:22.249+08:00"
}
],
"page": 1,
"pageSize": 20,
"total": 1
}