-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-test.http
More file actions
291 lines (222 loc) · 7.54 KB
/
api-test.http
File metadata and controls
291 lines (222 loc) · 7.54 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
### GitLab to GitHub Migrator API Tests
### Use with VS Code REST Client extension or similar tools
###
### Prerequisites:
### 1. Make sure the service is running: ./migrator -c config.json
### 2. Update @repoPath with actual repository path from your GitLab
### 3. Ensure GitLab and GitHub API tokens are configured in config.json
###
### If you get ECONNRESET errors, try using 127.0.0.1 instead of localhost
@baseUrl = http://localhost:8080
@baseUrlIPv4 = http://127.0.0.1:8080
@apiPrefix = /api/v1/migration
### Variables - Update these with your actual repository paths
@repoPath = sikatech/eshop/services/agent-service
@nestedRepoPath = sikatech/eshop/services/core-service
@githubOrg = sika365
@mappingFile = repositories.json
### Variables for GitLab API
@gitlabUrl = https://gitlab.sikapp.ir
@gitlabAdminToken = glpat-UMW2hQcyt8tPYz75fzri
##################################################
### 1. List All Repositories from GitLab
### Lists all repositories in the configured GitLab group
### including nested groups
##################################################
GET {{baseUrl}}{{apiPrefix}}/repositories
Content-Type: application/json
###
### Alternative: Use IPv4 if localhost doesn't work
GET {{baseUrlIPv4}}{{apiPrefix}}/repositories
Content-Type: application/json
###
##################################################
### 2. Get Repository Details
### Get detailed information about a specific repository
### Replace {{repoPath}} with actual repository path
##################################################
GET {{baseUrl}}{{apiPrefix}}/repositories/{{repoPath}}
Content-Type: application/json
###
##################################################
### 3. Get Migration Status for a Repository
### Check if a repository has been migrated to GitHub
### Returns: gitlab_path, github_name, migrated (bool), is_nested (bool)
##################################################
GET {{baseUrl}}{{apiPrefix}}/status/{{repoPath}}
Content-Type: application/json
###
##################################################
### 4. Migrate Single Repository (Dry Run)
### Test migration without actually creating repositories
### This will show what would be migrated without making changes
##################################################
POST {{baseUrl}}{{apiPrefix}}/repositories/{{repoPath}}/migrate
Content-Type: application/json
{
"dry_run": true
}
###
##################################################
### 5. Migrate Single Repository (Actual Migration)
### ⚠️ WARNING: This will actually migrate the repository!
### Make sure you want to proceed before running this.
###
### This will:
### - Create repository in GitHub
### - Migrate code (branches, tags, history)
### - Migrate issues, labels, milestones
### - Migrate merge requests as pull requests
### - Migrate wikis (if enabled)
##################################################
POST {{baseUrl}}{{apiPrefix}}/repositories/{{repoPath}}/migrate
Content-Type: application/json
{
"dry_run": false
}
###
##################################################
### 6. Migrate All Repositories (Dry Run)
##################################################
POST {{baseUrl}}{{apiPrefix}}/migrate-all
Content-Type: application/json
{
"dry_run": true
}
###
##################################################
### 7. Migrate All Repositories (Actual Migration)
##################################################
POST {{baseUrl}}{{apiPrefix}}/migrate-all
Content-Type: application/json
{
"dry_run": false
}
###
##################################################
### 8. Export Repositories to JSON File
### Phase 1: Discovery - Export all GitLab repositories to JSON
### This creates a mapping file with GitLab to GitHub name mappings
### You can review and edit the JSON file before migration
##################################################
### Export repositories to default file
POST {{baseUrl}}{{apiPrefix}}/export
Content-Type: application/json
{
"output_path": "{{mappingFile}}"
}
###
### Export repositories to custom file
POST {{baseUrl}}{{apiPrefix}}/export
Content-Type: application/json
{
"output_path": "my-repositories.json"
}
###
##################################################
### 9. Import Repositories from JSON File
### Read repository mappings from a JSON file
### This validates the file and returns repository count
##################################################
### Import repositories from JSON file
POST {{baseUrl}}{{apiPrefix}}/import
Content-Type: application/json
{
"input_path": "{{mappingFile}}"
}
###
##################################################
### 10. Migrate from JSON File (Two-Phase Approach)
### Phase 2: Migration - Migrate repositories from JSON file
### This reads the JSON file and migrates each repository
### The JSON file can be updated with migration status
##################################################
### Migrate from JSON file (Dry Run)
POST {{baseUrl}}{{apiPrefix}}/migrate-from-file
Content-Type: application/json
{
"input_path": "{{mappingFile}}",
"output_path": "{{mappingFile}}",
"dry_run": true
}
###
### Migrate from JSON file (Actual Migration)
### ⚠️ WARNING: This will actually migrate repositories!
### Make sure you've reviewed the JSON file before running this.
POST {{baseUrl}}{{apiPrefix}}/migrate-from-file
Content-Type: application/json
{
"input_path": "{{mappingFile}}",
"output_path": "{{mappingFile}}",
"dry_run": false
}
###
### Migrate from JSON file without updating the file
POST {{baseUrl}}{{apiPrefix}}/migrate-from-file
Content-Type: application/json
{
"input_path": "{{mappingFile}}",
"dry_run": false
}
###
##################################################
### 11. Test with Different Repository Paths
### Test nested repository paths
### Example: sikatech/eshop/services/core-service
### Will be mapped to: eshop-core-service (using last-group strategy)
##################################################
### Get nested repository details
GET {{baseUrl}}{{apiPrefix}}/repositories/{{nestedRepoPath}}
Content-Type: application/json
###
### Test migration with nested path (Dry Run)
POST {{baseUrl}}{{apiPrefix}}/repositories/{{nestedRepoPath}}/migrate
Content-Type: application/json
{
"dry_run": true
}
###
### Get migration status for nested repository
GET {{baseUrl}}{{apiPrefix}}/status/{{nestedRepoPath}}
Content-Type: application/json
###
##################################################
### 12. Health Check
### Check if the service is running
##################################################
GET {{baseUrl}}/health
Content-Type: application/json
###
##################################################
### 13. Test Error Cases
##################################################
### Test with non-existent repository
GET {{baseUrl}}{{apiPrefix}}/repositories/non-existent/repo
Content-Type: application/json
###
### Test migration with invalid path
POST {{baseUrl}}{{apiPrefix}}/repositories/invalid/path/migrate
Content-Type: application/json
{
"dry_run": true
}
###
### Test with empty request body (should use default dry_run=false)
POST {{baseUrl}}{{apiPrefix}}/migrate-all
Content-Type: application/json
{
}
###
##################################################
### 14. GitLab Maintenance Mode
### Enable/Disable GitLab maintenance mode
### Requires admin access token (PRIVATE-TOKEN)
##################################################
### Enable Maintenance Mode
PUT {{gitlabUrl}}/api/v4/application/settings?maintenance_mode=true&maintenance_mode_message=Maintenance
PRIVATE-TOKEN: {{gitlabAdminToken}}
###
### Disable Maintenance Mode
PUT {{gitlabUrl}}/api/v4/application/settings?maintenance_mode=false
PRIVATE-TOKEN: {{gitlabAdminToken}}
###