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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
use crate::Client;
use crate::ClientResult;
pub struct Migrations {
pub client: Client,
}
impl Migrations {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
Migrations { client }
}
/**
* List organization migrations.
*
* This function performs a `GET` to the `/orgs/{org}/migrations` endpoint.
*
* Lists the most recent migrations.
*
* FROM: <https://docs.github.com/rest/reference/migrations#list-organization-migrations>
*
* **Parameters:**
*
* * `org: &str`
* * `per_page: i64` -- Results per page (max 100).
* * `page: i64` -- Page number of the results to fetch.
* * `exclude: &[String]` -- Exclude attributes from the API response to improve performance.
*/
pub async fn list_for_org(
&self,
org: &str,
per_page: i64,
page: i64,
exclude: &[String],
) -> ClientResult<crate::Response<Vec<crate::types::Migration>>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !exclude.is_empty() {
query_args.push(("exclude".to_string(), exclude.join(" ")));
}
if page > 0 {
query_args.push(("page".to_string(), page.to_string()));
}
if per_page > 0 {
query_args.push(("per_page".to_string(), per_page.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self.client.url(
&format!(
"/orgs/{}/migrations?{}",
crate::progenitor_support::encode_path(org),
query_
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* List organization migrations.
*
* This function performs a `GET` to the `/orgs/{org}/migrations` endpoint.
*
* As opposed to `list_for_org`, this function returns all the pages of the request at once.
*
* Lists the most recent migrations.
*
* FROM: <https://docs.github.com/rest/reference/migrations#list-organization-migrations>
*/
pub async fn list_all_for_org(
&self,
org: &str,
exclude: &[String],
) -> ClientResult<crate::Response<Vec<crate::types::Migration>>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !exclude.is_empty() {
query_args.push(("exclude".to_string(), exclude.join(" ")));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self.client.url(
&format!(
"/orgs/{}/migrations?{}",
crate::progenitor_support::encode_path(org),
query_
),
None,
);
self.client
.get_all_pages(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Start an organization migration.
*
* This function performs a `POST` to the `/orgs/{org}/migrations` endpoint.
*
* Initiates the generation of a migration archive.
*
* FROM: <https://docs.github.com/rest/reference/migrations#start-an-organization-migration>
*
* **Parameters:**
*
* * `org: &str`
*/
pub async fn start_for_org(
&self,
org: &str,
body: &crate::types::MigrationsStartRequest,
) -> ClientResult<crate::Response<crate::types::Migration>> {
let url = self.client.url(
&format!(
"/orgs/{}/migrations",
crate::progenitor_support::encode_path(org),
),
None,
);
self.client
.post(
&url,
crate::Message {
body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
content_type: Some("application/json".to_string()),
},
)
.await
}
/**
* Get an organization migration status.
*
* This function performs a `GET` to the `/orgs/{org}/migrations/{migration_id}` endpoint.
*
* Fetches the status of a migration.
*
* The `state` of a migration can be one of the following values:
*
* * `pending`, which means the migration hasn't started yet.
* * `exporting`, which means the migration is in progress.
* * `exported`, which means the migration finished successfully.
* * `failed`, which means the migration failed.
*
* FROM: <https://docs.github.com/rest/reference/migrations#get-an-organization-migration-status>
*
* **Parameters:**
*
* * `org: &str`
* * `migration_id: i64` -- migration_id parameter.
* * `exclude: &[String]` -- Exclude attributes from the API response to improve performance.
*/
pub async fn get_status_for_org(
&self,
org: &str,
migration_id: i64,
exclude: &[String],
) -> ClientResult<crate::Response<crate::types::Migration>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !exclude.is_empty() {
query_args.push(("exclude".to_string(), exclude.join(" ")));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self.client.url(
&format!(
"/orgs/{}/migrations/{}?{}",
crate::progenitor_support::encode_path(org),
crate::progenitor_support::encode_path(&migration_id.to_string()),
query_
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Download an organization migration archive.
*
* This function performs a `GET` to the `/orgs/{org}/migrations/{migration_id}/archive` endpoint.
*
* Fetches the URL to a migration archive.
*
* FROM: <https://docs.github.com/rest/reference/migrations#download-an-organization-migration-archive>
*
* **Parameters:**
*
* * `org: &str`
* * `migration_id: i64` -- migration_id parameter.
*/
pub async fn download_archive_for_org(
&self,
org: &str,
migration_id: i64,
) -> ClientResult<crate::Response<()>> {
let url = self.client.url(
&format!(
"/orgs/{}/migrations/{}/archive",
crate::progenitor_support::encode_path(org),
crate::progenitor_support::encode_path(&migration_id.to_string()),
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Delete an organization migration archive.
*
* This function performs a `DELETE` to the `/orgs/{org}/migrations/{migration_id}/archive` endpoint.
*
* Deletes a previous migration archive. Migration archives are automatically deleted after seven days.
*
* FROM: <https://docs.github.com/rest/reference/migrations#delete-an-organization-migration-archive>
*
* **Parameters:**
*
* * `org: &str`
* * `migration_id: i64` -- migration_id parameter.
*/
pub async fn delete_archive_for_org(
&self,
org: &str,
migration_id: i64,
) -> ClientResult<crate::Response<()>> {
let url = self.client.url(
&format!(
"/orgs/{}/migrations/{}/archive",
crate::progenitor_support::encode_path(org),
crate::progenitor_support::encode_path(&migration_id.to_string()),
),
None,
);
self.client
.delete(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Unlock an organization repository.
*
* This function performs a `DELETE` to the `/orgs/{org}/migrations/{migration_id}/repos/{repo_name}/lock` endpoint.
*
* Unlocks a repository that was locked for migration. You should unlock each migrated repository and [delete them](https://docs.github.com/rest/reference/repos#delete-a-repository) when the migration is complete and you no longer need the source data.
*
* FROM: <https://docs.github.com/rest/reference/migrations#unlock-an-organization-repository>
*
* **Parameters:**
*
* * `org: &str`
* * `migration_id: i64` -- migration_id parameter.
* * `repo_name: &str` -- repo_name parameter.
*/
pub async fn unlock_repo_for_org(
&self,
org: &str,
migration_id: i64,
repo_name: &str,
) -> ClientResult<crate::Response<()>> {
let url = self.client.url(
&format!(
"/orgs/{}/migrations/{}/repos/{}/lock",
crate::progenitor_support::encode_path(org),
crate::progenitor_support::encode_path(&migration_id.to_string()),
crate::progenitor_support::encode_path(repo_name),
),
None,
);
self.client
.delete(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* List repositories in an organization migration.
*
* This function performs a `GET` to the `/orgs/{org}/migrations/{migration_id}/repositories` endpoint.
*
* List all the repositories for this organization migration.
*
* FROM: <https://docs.github.com/rest/reference/migrations#list-repositories-in-an-organization-migration>
*
* **Parameters:**
*
* * `org: &str`
* * `migration_id: i64` -- migration_id parameter.
* * `per_page: i64` -- Results per page (max 100).
* * `page: i64` -- Page number of the results to fetch.
*/
pub async fn list_repos_for_org(
&self,
org: &str,
migration_id: i64,
per_page: i64,
page: i64,
) -> ClientResult<crate::Response<Vec<crate::types::MinimalRepository>>> {
let mut query_args: Vec<(String, String)> = Default::default();
if page > 0 {
query_args.push(("page".to_string(), page.to_string()));
}
if per_page > 0 {
query_args.push(("per_page".to_string(), per_page.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self.client.url(
&format!(
"/orgs/{}/migrations/{}/repositories?{}",
crate::progenitor_support::encode_path(org),
crate::progenitor_support::encode_path(&migration_id.to_string()),
query_
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* List repositories in an organization migration.
*
* This function performs a `GET` to the `/orgs/{org}/migrations/{migration_id}/repositories` endpoint.
*
* As opposed to `list_repos_for_org`, this function returns all the pages of the request at once.
*
* List all the repositories for this organization migration.
*
* FROM: <https://docs.github.com/rest/reference/migrations#list-repositories-in-an-organization-migration>
*/
pub async fn list_all_repos_for_org(
&self,
org: &str,
migration_id: i64,
) -> ClientResult<crate::Response<Vec<crate::types::MinimalRepository>>> {
let url = self.client.url(
&format!(
"/orgs/{}/migrations/{}/repositories",
crate::progenitor_support::encode_path(org),
crate::progenitor_support::encode_path(&migration_id.to_string()),
),
None,
);
self.client
.get_all_pages(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Get an import status.
*
* This function performs a `GET` to the `/repos/{owner}/{repo}/import` endpoint.
*
* View the progress of an import.
*
* **Import status**
*
* This section includes details about the possible values of the `status` field of the Import Progress response.
*
* An import that does not have errors will progress through these steps:
*
* * `detecting` - the "detection" step of the import is in progress because the request did not include a `vcs` parameter. The import is identifying the type of source control present at the URL.
* * `importing` - the "raw" step of the import is in progress. This is where commit data is fetched from the original repository. The import progress response will include `commit_count` (the total number of raw commits that will be imported) and `percent` (0 - 100, the current progress through the import).
* * `mapping` - the "rewrite" step of the import is in progress. This is where SVN branches are converted to Git branches, and where author updates are applied. The import progress response does not include progress information.
* * `pushing` - the "push" step of the import is in progress. This is where the importer updates the repository on GitHub. The import progress response will include `push_percent`, which is the percent value reported by `git push` when it is "Writing objects".
* * `complete` - the import is complete, and the repository is ready on GitHub.
*
* If there are problems, you will see one of these in the `status` field:
*
* * `auth_failed` - the import requires authentication in order to connect to the original repository. To update authentication for the import, please see the [Update an import](https://docs.github.com/rest/reference/migrations#update-an-import) section.
* * `error` - the import encountered an error. The import progress response will include the `failed_step` and an error message. Contact [GitHub Support](https://support.github.com/contact?tags=rest-api) for more information.
* * `detection_needs_auth` - the importer requires authentication for the originating repository to continue detection. To update authentication for the import, please see the [Update an import](https://docs.github.com/rest/reference/migrations#update-an-import) section.
* * `detection_found_nothing` - the importer didn't recognize any source control at the URL. To resolve, [Cancel the import](https://docs.github.com/rest/reference/migrations#cancel-an-import) and [retry](https://docs.github.com/rest/reference/migrations#start-an-import) with the correct URL.
* * `detection_found_multiple` - the importer found several projects or repositories at the provided URL. When this is the case, the Import Progress response will also include a `project_choices` field with the possible project choices as values. To update project choice, please see the [Update an import](https://docs.github.com/rest/reference/migrations#update-an-import) section.
*
* **The project_choices field**
*
* When multiple projects are found at the provided URL, the response hash will include a `project_choices` field, the value of which is an array of hashes each representing a project choice. The exact key/value pairs of the project hashes will differ depending on the version control type.
*
* **Git LFS related fields**
*
* This section includes details about Git LFS related fields that may be present in the Import Progress response.
*
* * `use_lfs` - describes whether the import has been opted in or out of using Git LFS. The value can be `opt_in`, `opt_out`, or `undecided` if no action has been taken.
* * `has_large_files` - the boolean value describing whether files larger than 100MB were found during the `importing` step.
* * `large_files_size` - the total size in gigabytes of files larger than 100MB found in the originating repository.
* * `large_files_count` - the total number of files larger than 100MB found in the originating repository. To see a list of these files, make a "Get Large Files" request.
*
* FROM: <https://docs.github.com/rest/reference/migrations#get-an-import-status>
*
* **Parameters:**
*
* * `owner: &str`
* * `repo: &str`
*/
pub async fn get_import_status(
&self,
owner: &str,
repo: &str,
) -> ClientResult<crate::Response<crate::types::Import>> {
let url = self.client.url(
&format!(
"/repos/{}/{}/import",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Start an import.
*
* This function performs a `PUT` to the `/repos/{owner}/{repo}/import` endpoint.
*
* Start a source import to a GitHub repository using GitHub Importer.
*
* FROM: <https://docs.github.com/rest/reference/migrations#start-an-import>
*
* **Parameters:**
*
* * `owner: &str`
* * `repo: &str`
*/
pub async fn start_import(
&self,
owner: &str,
repo: &str,
body: &crate::types::MigrationsStartImportRequest,
) -> ClientResult<crate::Response<crate::types::Import>> {
let url = self.client.url(
&format!(
"/repos/{}/{}/import",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
),
None,
);
self.client
.put(
&url,
crate::Message {
body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
content_type: Some("application/json".to_string()),
},
)
.await
}
/**
* Cancel an import.
*
* This function performs a `DELETE` to the `/repos/{owner}/{repo}/import` endpoint.
*
* Stop an import for a repository.
*
* FROM: <https://docs.github.com/rest/reference/migrations#cancel-an-import>
*
* **Parameters:**
*
* * `owner: &str`
* * `repo: &str`
*/
pub async fn cancel_import(
&self,
owner: &str,
repo: &str,
) -> ClientResult<crate::Response<()>> {
let url = self.client.url(
&format!(
"/repos/{}/{}/import",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
),
None,
);
self.client
.delete(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Update an import.
*
* This function performs a `PATCH` to the `/repos/{owner}/{repo}/import` endpoint.
*
* An import can be updated with credentials or a project choice by passing in the appropriate parameters in this API
* request. If no parameters are provided, the import will be restarted.
*
* FROM: <https://docs.github.com/rest/reference/migrations#update-an-import>
*
* **Parameters:**
*
* * `owner: &str`
* * `repo: &str`
*/
pub async fn update_import(
&self,
owner: &str,
repo: &str,
body: &crate::types::MigrationsUpdateImportRequest,
) -> ClientResult<crate::Response<crate::types::Import>> {
let url = self.client.url(
&format!(
"/repos/{}/{}/import",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
),
None,
);
self.client
.patch(
&url,
crate::Message {
body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
content_type: Some("application/json".to_string()),
},
)
.await
}
/**
* Get commit authors.
*
* This function performs a `GET` to the `/repos/{owner}/{repo}/import/authors` endpoint.
*
* Each type of source control system represents authors in a different way. For example, a Git commit author has a display name and an email address, but a Subversion commit author just has a username. The GitHub Importer will make the author information valid, but the author might not be correct. For example, it will change the bare Subversion username `hubot` into something like `hubot <hubot@12341234-abab-fefe-8787-fedcba987654>`.
*
* This endpoint and the [Map a commit author](https://docs.github.com/rest/reference/migrations#map-a-commit-author) endpoint allow you to provide correct Git author information.
*
* FROM: <https://docs.github.com/rest/reference/migrations#get-commit-authors>
*
* **Parameters:**
*
* * `owner: &str`
* * `repo: &str`
* * `since: i64` -- A user ID. Only return users with an ID greater than this ID.
*/
pub async fn get_commit_authors(
&self,
owner: &str,
repo: &str,
since: i64,
) -> ClientResult<crate::Response<Vec<crate::types::PorterAuthor>>> {
let mut query_args: Vec<(String, String)> = Default::default();
if since > 0 {
query_args.push(("since".to_string(), since.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self.client.url(
&format!(
"/repos/{}/{}/import/authors?{}",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
query_
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Get commit authors.
*
* This function performs a `GET` to the `/repos/{owner}/{repo}/import/authors` endpoint.
*
* As opposed to `get_commit_authors`, this function returns all the pages of the request at once.
*
* Each type of source control system represents authors in a different way. For example, a Git commit author has a display name and an email address, but a Subversion commit author just has a username. The GitHub Importer will make the author information valid, but the author might not be correct. For example, it will change the bare Subversion username `hubot` into something like `hubot <hubot@12341234-abab-fefe-8787-fedcba987654>`.
*
* This endpoint and the [Map a commit author](https://docs.github.com/rest/reference/migrations#map-a-commit-author) endpoint allow you to provide correct Git author information.
*
* FROM: <https://docs.github.com/rest/reference/migrations#get-commit-authors>
*/
pub async fn get_all_commit_authors(
&self,
owner: &str,
repo: &str,
since: i64,
) -> ClientResult<crate::Response<Vec<crate::types::PorterAuthor>>> {
let mut query_args: Vec<(String, String)> = Default::default();
if since > 0 {
query_args.push(("since".to_string(), since.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self.client.url(
&format!(
"/repos/{}/{}/import/authors?{}",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
query_
),
None,
);
self.client
.get_all_pages(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Map a commit author.
*
* This function performs a `PATCH` to the `/repos/{owner}/{repo}/import/authors/{author_id}` endpoint.
*
* Update an author's identity for the import. Your application can continue updating authors any time before you push new commits to the repository.
*
* FROM: <https://docs.github.com/rest/reference/migrations#map-a-commit-author>
*
* **Parameters:**
*
* * `owner: &str`
* * `repo: &str`
* * `author_id: i64`
*/
pub async fn map_commit_author(
&self,
owner: &str,
repo: &str,
author_id: i64,
body: &crate::types::Author,
) -> ClientResult<crate::Response<crate::types::PorterAuthor>> {
let url = self.client.url(
&format!(
"/repos/{}/{}/import/authors/{}",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
crate::progenitor_support::encode_path(&author_id.to_string()),
),
None,
);
self.client
.patch(
&url,
crate::Message {
body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
content_type: Some("application/json".to_string()),
},
)
.await
}
/**
* Get large files.
*
* This function performs a `GET` to the `/repos/{owner}/{repo}/import/large_files` endpoint.
*
* List files larger than 100MB found during the import
*
* FROM: <https://docs.github.com/rest/reference/migrations#get-large-files>
*
* **Parameters:**
*
* * `owner: &str`
* * `repo: &str`
*/
pub async fn get_large_files(
&self,
owner: &str,
repo: &str,
) -> ClientResult<crate::Response<Vec<crate::types::PorterLargeFile>>> {
let url = self.client.url(
&format!(
"/repos/{}/{}/import/large_files",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Get large files.
*
* This function performs a `GET` to the `/repos/{owner}/{repo}/import/large_files` endpoint.
*
* As opposed to `get_large_files`, this function returns all the pages of the request at once.
*
* List files larger than 100MB found during the import
*
* FROM: <https://docs.github.com/rest/reference/migrations#get-large-files>
*/
pub async fn get_all_large_files(
&self,
owner: &str,
repo: &str,
) -> ClientResult<crate::Response<Vec<crate::types::PorterLargeFile>>> {
let url = self.client.url(
&format!(
"/repos/{}/{}/import/large_files",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
),
None,
);
self.client
.get_all_pages(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Update Git LFS preference.
*
* This function performs a `PATCH` to the `/repos/{owner}/{repo}/import/lfs` endpoint.
*
* You can import repositories from Subversion, Mercurial, and TFS that include files larger than 100MB. This ability is powered by [Git LFS](https://git-lfs.github.com). You can learn more about our LFS feature and working with large files [on our help site](https://help.github.com/articles/versioning-large-files/).
*
* FROM: <https://docs.github.com/rest/reference/migrations#update-git-lfs-preference>
*
* **Parameters:**
*
* * `owner: &str`
* * `repo: &str`
*/
pub async fn set_lfs_preference(
&self,
owner: &str,
repo: &str,
body: &crate::types::MigrationsSetLfsPreferenceRequest,
) -> ClientResult<crate::Response<crate::types::Import>> {
let url = self.client.url(
&format!(
"/repos/{}/{}/import/lfs",
crate::progenitor_support::encode_path(owner),
crate::progenitor_support::encode_path(repo),
),
None,
);
self.client
.patch(
&url,
crate::Message {
body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
content_type: Some("application/json".to_string()),
},
)
.await
}
/**
* List user migrations.
*
* This function performs a `GET` to the `/user/migrations` endpoint.
*
* Lists all migrations a user has started.
*
* FROM: <https://docs.github.com/rest/reference/migrations#list-user-migrations>
*
* **Parameters:**
*
* * `per_page: i64` -- Results per page (max 100).
* * `page: i64` -- Page number of the results to fetch.
*/
pub async fn list_for_authenticated_user(
&self,
per_page: i64,
page: i64,
) -> ClientResult<crate::Response<Vec<crate::types::Migration>>> {
let mut query_args: Vec<(String, String)> = Default::default();
if page > 0 {
query_args.push(("page".to_string(), page.to_string()));
}
if per_page > 0 {
query_args.push(("per_page".to_string(), per_page.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self
.client
.url(&format!("/user/migrations?{}", query_), None);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* List user migrations.
*
* This function performs a `GET` to the `/user/migrations` endpoint.
*
* As opposed to `list_for_authenticated_user`, this function returns all the pages of the request at once.
*
* Lists all migrations a user has started.
*
* FROM: <https://docs.github.com/rest/reference/migrations#list-user-migrations>
*/
pub async fn list_all_for_authenticated_user(
&self,
) -> ClientResult<crate::Response<Vec<crate::types::Migration>>> {
let url = self.client.url("/user/migrations", None);
self.client
.get_all_pages(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Start a user migration.
*
* This function performs a `POST` to the `/user/migrations` endpoint.
*
* Initiates the generation of a user migration archive.
*
* FROM: <https://docs.github.com/rest/reference/migrations#start-a-user-migration>
*/
pub async fn start_for_authenticated_user(
&self,
body: &crate::types::MigrationsStartRequest,
) -> ClientResult<crate::Response<crate::types::Migration>> {
let url = self.client.url("/user/migrations", None);
self.client
.post(
&url,
crate::Message {
body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
content_type: Some("application/json".to_string()),
},
)
.await
}
/**
* Get a user migration status.
*
* This function performs a `GET` to the `/user/migrations/{migration_id}` endpoint.
*
* Fetches a single user migration. The response includes the `state` of the migration, which can be one of the following values:
*
* * `pending` - the migration hasn't started yet.
* * `exporting` - the migration is in progress.
* * `exported` - the migration finished successfully.
* * `failed` - the migration failed.
*
* Once the migration has been `exported` you can [download the migration archive](https://docs.github.com/rest/reference/migrations#download-a-user-migration-archive).
*
* FROM: <https://docs.github.com/rest/reference/migrations#get-a-user-migration-status>
*
* **Parameters:**
*
* * `migration_id: i64` -- migration_id parameter.
* * `exclude: &[String]` -- The list of events for the GitHub app.
*/
pub async fn get_status_for_authenticated_user(
&self,
migration_id: i64,
exclude: &[String],
) -> ClientResult<crate::Response<crate::types::Migration>> {
let mut query_args: Vec<(String, String)> = Default::default();
if !exclude.is_empty() {
query_args.push(("exclude".to_string(), exclude.join(" ")));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self.client.url(
&format!(
"/user/migrations/{}?{}",
crate::progenitor_support::encode_path(&migration_id.to_string()),
query_
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Download a user migration archive.
*
* This function performs a `GET` to the `/user/migrations/{migration_id}/archive` endpoint.
*
* Fetches the URL to download the migration archive as a `tar.gz` file. Depending on the resources your repository uses, the migration archive can contain JSON files with data for these objects:
*
* * attachments
* * bases
* * commit\_comments
* * issue\_comments
* * issue\_events
* * issues
* * milestones
* * organizations
* * projects
* * protected\_branches
* * pull\_request\_reviews
* * pull\_requests
* * releases
* * repositories
* * review\_comments
* * schema
* * users
*
* The archive will also contain an `attachments` directory that includes all attachment files uploaded to GitHub.com and a `repositories` directory that contains the repository's Git data.
*
* FROM: <https://docs.github.com/rest/reference/migrations#download-a-user-migration-archive>
*
* **Parameters:**
*
* * `migration_id: i64` -- migration_id parameter.
*/
pub async fn get_archive_for_authenticated_user(
&self,
migration_id: i64,
) -> ClientResult<crate::Response<()>> {
let url = self.client.url(
&format!(
"/user/migrations/{}/archive",
crate::progenitor_support::encode_path(&migration_id.to_string()),
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Delete a user migration archive.
*
* This function performs a `DELETE` to the `/user/migrations/{migration_id}/archive` endpoint.
*
* Deletes a previous migration archive. Downloadable migration archives are automatically deleted after seven days. Migration metadata, which is returned in the [List user migrations](https://docs.github.com/rest/reference/migrations#list-user-migrations) and [Get a user migration status](https://docs.github.com/rest/reference/migrations#get-a-user-migration-status) endpoints, will continue to be available even after an archive is deleted.
*
* FROM: <https://docs.github.com/rest/reference/migrations#delete-a-user-migration-archive>
*
* **Parameters:**
*
* * `migration_id: i64` -- migration_id parameter.
*/
pub async fn delete_archive_for_authenticated_user(
&self,
migration_id: i64,
) -> ClientResult<crate::Response<()>> {
let url = self.client.url(
&format!(
"/user/migrations/{}/archive",
crate::progenitor_support::encode_path(&migration_id.to_string()),
),
None,
);
self.client
.delete(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* Unlock a user repository.
*
* This function performs a `DELETE` to the `/user/migrations/{migration_id}/repos/{repo_name}/lock` endpoint.
*
* Unlocks a repository. You can lock repositories when you [start a user migration](https://docs.github.com/rest/reference/migrations#start-a-user-migration). Once the migration is complete you can unlock each repository to begin using it again or [delete the repository](https://docs.github.com/rest/reference/repos#delete-a-repository) if you no longer need the source data. Returns a status of `404 Not Found` if the repository is not locked.
*
* FROM: <https://docs.github.com/rest/reference/migrations#unlock-a-user-repository>
*
* **Parameters:**
*
* * `migration_id: i64` -- migration_id parameter.
* * `repo_name: &str` -- repo_name parameter.
*/
pub async fn unlock_repo_for_authenticated_user(
&self,
migration_id: i64,
repo_name: &str,
) -> ClientResult<crate::Response<()>> {
let url = self.client.url(
&format!(
"/user/migrations/{}/repos/{}/lock",
crate::progenitor_support::encode_path(&migration_id.to_string()),
crate::progenitor_support::encode_path(repo_name),
),
None,
);
self.client
.delete(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* List repositories for a user migration.
*
* This function performs a `GET` to the `/user/migrations/{migration_id}/repositories` endpoint.
*
* Lists all the repositories for this user migration.
*
* FROM: <https://docs.github.com/rest/reference/migrations#list-repositories-for-a-user-migration>
*
* **Parameters:**
*
* * `migration_id: i64` -- migration_id parameter.
* * `per_page: i64` -- Results per page (max 100).
* * `page: i64` -- Page number of the results to fetch.
*/
pub async fn list_repos_for_user(
&self,
migration_id: i64,
per_page: i64,
page: i64,
) -> ClientResult<crate::Response<Vec<crate::types::MinimalRepository>>> {
let mut query_args: Vec<(String, String)> = Default::default();
if page > 0 {
query_args.push(("page".to_string(), page.to_string()));
}
if per_page > 0 {
query_args.push(("per_page".to_string(), per_page.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self.client.url(
&format!(
"/user/migrations/{}/repositories?{}",
crate::progenitor_support::encode_path(&migration_id.to_string()),
query_
),
None,
);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* List repositories for a user migration.
*
* This function performs a `GET` to the `/user/migrations/{migration_id}/repositories` endpoint.
*
* As opposed to `list_repos_for_user`, this function returns all the pages of the request at once.
*
* Lists all the repositories for this user migration.
*
* FROM: <https://docs.github.com/rest/reference/migrations#list-repositories-for-a-user-migration>
*/
pub async fn list_all_repos_for_user(
&self,
migration_id: i64,
) -> ClientResult<crate::Response<Vec<crate::types::MinimalRepository>>> {
let url = self.client.url(
&format!(
"/user/migrations/{}/repositories",
crate::progenitor_support::encode_path(&migration_id.to_string()),
),
None,
);
self.client
.get_all_pages(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
}