This repository has been archived by the owner on Dec 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
router.go
7000 lines (5068 loc) · 157 KB
/
router.go
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
package main
import (
"encoding/json"
"os"
"github.com/phrase/phraseapp-client/cli"
"github.com/phrase/phraseapp-go/phraseapp"
)
const (
RevisionDocs = "b33e5c3d0e590c6aed24f39a2c98731c6b2116d9"
RevisionGenerator = "HEAD/2020-04-02T173135/soenke"
)
func router(cfg *phraseapp.Config) (*cli.Router, error) {
r := cli.NewRouter()
r.Register("account/show", newAccountShow(cfg), "Get details on a single account.")
r.Register("accounts/list", newAccountsList(cfg), "List all accounts the current user has access to.")
if cmd, err := newAuthorizationCreate(cfg); err != nil {
return nil, err
} else {
r.Register("authorization/create", cmd, "Create a new authorization.")
}
r.Register("authorization/delete", newAuthorizationDelete(cfg), "Delete an existing authorization. API calls using that token will stop working.")
r.Register("authorization/show", newAuthorizationShow(cfg), "Get details on a single authorization.")
if cmd, err := newAuthorizationUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("authorization/update", cmd, "Update an existing authorization.")
}
r.Register("authorizations/list", newAuthorizationsList(cfg), "List all your authorizations.")
if cmd, err := newBitbucketSyncExport(cfg); err != nil {
return nil, err
} else {
r.Register("bitbucket_sync/export", cmd, "Export translations from Phrase to Bitbucket according to the .phraseapp.yml file within the Bitbucket Repository.")
}
if cmd, err := newBitbucketSyncImport(cfg); err != nil {
return nil, err
} else {
r.Register("bitbucket_sync/import", cmd, "Import translations from Bitbucket to Phrase according to the .phraseapp.yml file within the Bitbucket repository.")
}
if cmd, err := newBitbucketSyncsList(cfg); err != nil {
return nil, err
} else {
r.Register("bitbucket_syncs/list", cmd, "List all Bitbucket repositories for which synchronisation with Phrase is activated.")
}
if cmd, err := newBlacklistedKeyCreate(cfg); err != nil {
return nil, err
} else {
r.Register("blacklisted_key/create", cmd, "Create a new rule for blacklisting keys.")
}
r.Register("blacklisted_key/delete", newBlacklistedKeyDelete(cfg), "Delete an existing rule for blacklisting keys.")
r.Register("blacklisted_key/show", newBlacklistedKeyShow(cfg), "Get details on a single rule for blacklisting keys for a given project.")
if cmd, err := newBlacklistedKeyUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("blacklisted_key/update", cmd, "Update an existing rule for blacklisting keys.")
}
r.Register("blacklisted_keys/list", newBlacklistedKeysList(cfg), "List all rules for blacklisting keys for the given project.")
if cmd, err := newBranchCompare(cfg); err != nil {
return nil, err
} else {
r.Register("branch/compare", cmd, "Compare branch with main branch.")
}
if cmd, err := newBranchCreate(cfg); err != nil {
return nil, err
} else {
r.Register("branch/create", cmd, "Create a new branch.")
}
r.Register("branch/delete", newBranchDelete(cfg), "Delete an existing branch.")
if cmd, err := newBranchMerge(cfg); err != nil {
return nil, err
} else {
r.Register("branch/merge", cmd, "Merge an existing branch.")
}
r.Register("branch/show", newBranchShow(cfg), "Get details on a single branch for a given project.")
if cmd, err := newBranchUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("branch/update", cmd, "Update an existing branch.")
}
r.Register("branches/list", newBranchesList(cfg), "List all branches the of the current project.")
if cmd, err := newCommentCreate(cfg); err != nil {
return nil, err
} else {
r.Register("comment/create", cmd, "Create a new comment for a key.")
}
if cmd, err := newCommentDelete(cfg); err != nil {
return nil, err
} else {
r.Register("comment/delete", cmd, "Delete an existing comment.")
}
if cmd, err := newCommentMarkCheck(cfg); err != nil {
return nil, err
} else {
r.Register("comment/mark/check", cmd, "Check if comment was marked as read. Returns 204 if read, 404 if unread.")
}
if cmd, err := newCommentMarkRead(cfg); err != nil {
return nil, err
} else {
r.Register("comment/mark/read", cmd, "Mark a comment as read.")
}
if cmd, err := newCommentMarkUnread(cfg); err != nil {
return nil, err
} else {
r.Register("comment/mark/unread", cmd, "Mark a comment as unread.")
}
if cmd, err := newCommentShow(cfg); err != nil {
return nil, err
} else {
r.Register("comment/show", cmd, "Get details on a single comment.")
}
if cmd, err := newCommentUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("comment/update", cmd, "Update an existing comment.")
}
if cmd, err := newCommentsList(cfg); err != nil {
return nil, err
} else {
r.Register("comments/list", cmd, "List all comments for a key.")
}
if cmd, err := newDistributionCreate(cfg); err != nil {
return nil, err
} else {
r.Register("distribution/create", cmd, "Create a new distribution.")
}
r.Register("distribution/delete", newDistributionDelete(cfg), "Delete an existing distribution.")
r.Register("distribution/show", newDistributionShow(cfg), "Get details on a single distribution.")
if cmd, err := newDistributionUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("distribution/update", cmd, "Update an existing distribution.")
}
r.Register("distributions/list", newDistributionsList(cfg), "List all distributions for the given account.")
r.Register("formats/list", newFormatsList(cfg), "Get a handy list of all localization file formats supported in Phrase.")
r.Register("glossaries/list", newGlossariesList(cfg), "List all glossaries the current user has access to.")
if cmd, err := newGlossaryCreate(cfg); err != nil {
return nil, err
} else {
r.Register("glossary/create", cmd, "Create a new glossary.")
}
r.Register("glossary/delete", newGlossaryDelete(cfg), "Delete an existing glossary.")
r.Register("glossary/show", newGlossaryShow(cfg), "Get details on a single glossary.")
if cmd, err := newGlossaryUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("glossary/update", cmd, "Update an existing glossary.")
}
if cmd, err := newGlossaryTermCreate(cfg); err != nil {
return nil, err
} else {
r.Register("glossary_term/create", cmd, "Create a new glossary term.")
}
r.Register("glossary_term/delete", newGlossaryTermDelete(cfg), "Delete an existing glossary term.")
r.Register("glossary_term/show", newGlossaryTermShow(cfg), "Get details on a single glossary term.")
if cmd, err := newGlossaryTermUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("glossary_term/update", cmd, "Update an existing glossary term.")
}
if cmd, err := newGlossaryTermTranslationCreate(cfg); err != nil {
return nil, err
} else {
r.Register("glossary_term_translation/create", cmd, "Create a new glossary term translation.")
}
r.Register("glossary_term_translation/delete", newGlossaryTermTranslationDelete(cfg), "Delete an existing glossary term translation.")
if cmd, err := newGlossaryTermTranslationUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("glossary_term_translation/update", cmd, "Update an existing glossary term translation.")
}
r.Register("glossary_terms/list", newGlossaryTermsList(cfg), "List all glossary terms the current user has access to.")
if cmd, err := newInvitationCreate(cfg); err != nil {
return nil, err
} else {
r.Register("invitation/create", cmd, "Invite a person to an account. Developers and translators need <code>project_ids</code> and <code>locale_ids</code> assigned to access them. Access token scope must include <code>team.manage</code>.")
}
r.Register("invitation/delete", newInvitationDelete(cfg), "Delete an existing invitation (must not be accepted yet). Access token scope must include <code>team.manage</code>.")
r.Register("invitation/resend", newInvitationResend(cfg), "Resend the invitation email (must not be accepted yet). Access token scope must include <code>team.manage</code>.")
r.Register("invitation/show", newInvitationShow(cfg), "Get details on a single invitation. Access token scope must include <code>team.manage</code>.")
if cmd, err := newInvitationUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("invitation/update", cmd, "Update an existing invitation (must not be accepted yet). The <code>email</code> cannot be updated. Developers and translators need <code>project_ids</code> and <code>locale_ids</code> assigned to access them. Access token scope must include <code>team.manage</code>.")
}
r.Register("invitations/list", newInvitationsList(cfg), "List invitations for an account. It will also list the accessible resources like projects and locales the invited user has access to. In case nothing is shown the default access from the role is used. Access token scope must include <code>team.manage</code>.")
if cmd, err := newJobComplete(cfg); err != nil {
return nil, err
} else {
r.Register("job/complete", cmd, "Mark a job as completed.")
}
if cmd, err := newJobCreate(cfg); err != nil {
return nil, err
} else {
r.Register("job/create", cmd, "Create a new job.")
}
if cmd, err := newJobDelete(cfg); err != nil {
return nil, err
} else {
r.Register("job/delete", cmd, "Delete an existing job.")
}
if cmd, err := newJobKeysCreate(cfg); err != nil {
return nil, err
} else {
r.Register("job/keys/create", cmd, "Add multiple keys to a existing job.")
}
if cmd, err := newJobKeysDelete(cfg); err != nil {
return nil, err
} else {
r.Register("job/keys/delete", cmd, "Remove multiple keys from existing job.")
}
if cmd, err := newJobReopen(cfg); err != nil {
return nil, err
} else {
r.Register("job/reopen", cmd, "Mark a job as uncompleted.")
}
if cmd, err := newJobShow(cfg); err != nil {
return nil, err
} else {
r.Register("job/show", cmd, "Get details on a single job for a given project.")
}
if cmd, err := newJobStart(cfg); err != nil {
return nil, err
} else {
r.Register("job/start", cmd, "Starts an existing job in state draft.")
}
if cmd, err := newJobUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("job/update", cmd, "Update an existing job.")
}
if cmd, err := newJobLocaleComplete(cfg); err != nil {
return nil, err
} else {
r.Register("job_locale/complete", cmd, "Mark a job locale as completed.")
}
if cmd, err := newJobLocaleDelete(cfg); err != nil {
return nil, err
} else {
r.Register("job_locale/delete", cmd, "Delete an existing job locale.")
}
if cmd, err := newJobLocaleReopen(cfg); err != nil {
return nil, err
} else {
r.Register("job_locale/reopen", cmd, "Mark a job locale as uncompleted.")
}
if cmd, err := newJobLocaleShow(cfg); err != nil {
return nil, err
} else {
r.Register("job_locale/show", cmd, "Get a single job locale for a given job.")
}
if cmd, err := newJobLocaleUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("job_locale/update", cmd, "Update an existing job locale.")
}
if cmd, err := newJobLocalesCreate(cfg); err != nil {
return nil, err
} else {
r.Register("job_locales/create", cmd, "Create a new job locale.")
}
if cmd, err := newJobLocalesList(cfg); err != nil {
return nil, err
} else {
r.Register("job_locales/list", cmd, "List all job locales for a given job.")
}
if cmd, err := newJobsList(cfg); err != nil {
return nil, err
} else {
r.Register("jobs/list", cmd, "List all jobs for the given project.")
}
if cmd, err := newKeyCreate(cfg); err != nil {
return nil, err
} else {
r.Register("key/create", cmd, "Create a new key.")
}
if cmd, err := newKeyDelete(cfg); err != nil {
return nil, err
} else {
r.Register("key/delete", cmd, "Delete an existing key.")
}
if cmd, err := newKeyShow(cfg); err != nil {
return nil, err
} else {
r.Register("key/show", cmd, "Get details on a single key for a given project.")
}
if cmd, err := newKeyUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("key/update", cmd, "Update an existing key.")
}
if cmd, err := newKeysDelete(cfg); err != nil {
return nil, err
} else {
r.Register("keys/delete", cmd, "Delete all keys matching query. Same constraints as list. Please limit the number of affected keys to about 1,000 as you might experience timeouts otherwise.")
}
if cmd, err := newKeysList(cfg); err != nil {
return nil, err
} else {
r.Register("keys/list", cmd, "List all keys for the given project. Alternatively you can POST requests to /search.")
}
if cmd, err := newKeysSearch(cfg); err != nil {
return nil, err
} else {
r.Register("keys/search", cmd, "Search keys for the given project matching query.")
}
if cmd, err := newKeysTag(cfg); err != nil {
return nil, err
} else {
r.Register("keys/tag", cmd, "Tags all keys matching query. Same constraints as list.")
}
if cmd, err := newKeysUntag(cfg); err != nil {
return nil, err
} else {
r.Register("keys/untag", cmd, "Removes specified tags from keys matching query.")
}
if cmd, err := newLocaleCreate(cfg); err != nil {
return nil, err
} else {
r.Register("locale/create", cmd, "Create a new locale.")
}
if cmd, err := newLocaleDelete(cfg); err != nil {
return nil, err
} else {
r.Register("locale/delete", cmd, "Delete an existing locale.")
}
if cmd, err := newLocaleDownload(cfg); err != nil {
return nil, err
} else {
r.Register("locale/download", cmd, "Download a locale in a specific file format.")
}
if cmd, err := newLocaleShow(cfg); err != nil {
return nil, err
} else {
r.Register("locale/show", cmd, "Get details on a single locale for a given project.")
}
if cmd, err := newLocaleUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("locale/update", cmd, "Update an existing locale.")
}
if cmd, err := newLocalesList(cfg); err != nil {
return nil, err
} else {
r.Register("locales/list", cmd, "List all locales for the given project.")
}
r.Register("member/delete", newMemberDelete(cfg), "Remove a user from the account. The user will be removed from the account but not deleted from Phrase. Access token scope must include <code>team.manage</code>.")
r.Register("member/show", newMemberShow(cfg), "Get details on a single user in the account. Access token scope must include <code>team.manage</code>.")
if cmd, err := newMemberUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("member/update", cmd, "Update user permissions in the account. Developers and translators need <code>project_ids</code> and <code>locale_ids</code> assigned to access them. Access token scope must include <code>team.manage</code>.")
}
r.Register("members/list", newMembersList(cfg), "Get all users active in the account. It also lists resources like projects and locales the member has access to. In case nothing is shown the default access from the role is used. Access token scope must include <code>team.manage</code>.")
if cmd, err := newOrderConfirm(cfg); err != nil {
return nil, err
} else {
r.Register("order/confirm", cmd, "Confirm an existing order and send it to the provider for translation. Same constraints as for create.")
}
if cmd, err := newOrderCreate(cfg); err != nil {
return nil, err
} else {
r.Register("order/create", cmd, "Create a new order. Access token scope must include <code>orders.create</code>.")
}
if cmd, err := newOrderDelete(cfg); err != nil {
return nil, err
} else {
r.Register("order/delete", cmd, "Cancel an existing order. Must not yet be confirmed.")
}
if cmd, err := newOrderShow(cfg); err != nil {
return nil, err
} else {
r.Register("order/show", cmd, "Get details on a single order.")
}
if cmd, err := newOrdersList(cfg); err != nil {
return nil, err
} else {
r.Register("orders/list", cmd, "List all orders for the given project.")
}
if cmd, err := newProjectCreate(cfg); err != nil {
return nil, err
} else {
r.Register("project/create", cmd, "Create a new project.")
}
r.Register("project/delete", newProjectDelete(cfg), "Delete an existing project.")
r.Register("project/show", newProjectShow(cfg), "Get details on a single project.")
if cmd, err := newProjectUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("project/update", cmd, "Update an existing project.")
}
r.Register("projects/list", newProjectsList(cfg), "List all projects the current user has access to.")
if cmd, err := newReleaseCreate(cfg); err != nil {
return nil, err
} else {
r.Register("release/create", cmd, "Create a new release.")
}
r.Register("release/delete", newReleaseDelete(cfg), "Delete an existing release.")
r.Register("release/publish", newReleasePublish(cfg), "Publish a release for production.")
r.Register("release/show", newReleaseShow(cfg), "Get details on a single release.")
if cmd, err := newReleaseUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("release/update", cmd, "Update an existing release.")
}
r.Register("releases/list", newReleasesList(cfg), "List all releases for the given distribution.")
if cmd, err := newScreenshotCreate(cfg); err != nil {
return nil, err
} else {
r.Register("screenshot/create", cmd, "Create a new screenshot.")
}
r.Register("screenshot/delete", newScreenshotDelete(cfg), "Delete an existing screenshot.")
r.Register("screenshot/show", newScreenshotShow(cfg), "Get details on a single screenshot for a given project.")
if cmd, err := newScreenshotUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("screenshot/update", cmd, "Update an existing screenshot.")
}
if cmd, err := newScreenshotMarkerCreate(cfg); err != nil {
return nil, err
} else {
r.Register("screenshot_marker/create", cmd, "Create a new screenshot marker.")
}
r.Register("screenshot_marker/delete", newScreenshotMarkerDelete(cfg), "Delete an existing screenshot marker.")
r.Register("screenshot_marker/show", newScreenshotMarkerShow(cfg), "Get details on a single screenshot marker for a given project.")
if cmd, err := newScreenshotMarkerUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("screenshot_marker/update", cmd, "Update an existing screenshot marker.")
}
r.Register("screenshot_markers/list", newScreenshotMarkersList(cfg), "List all screenshot markers for the given project.")
r.Register("screenshots/list", newScreenshotsList(cfg), "List all screenshots for the given project.")
r.Register("show/user", newShowUser(cfg), "Show details for current User.")
if cmd, err := newSpaceCreate(cfg); err != nil {
return nil, err
} else {
r.Register("space/create", cmd, "Create a new Space.")
}
r.Register("space/delete", newSpaceDelete(cfg), "Delete the specified Space.")
r.Register("space/show", newSpaceShow(cfg), "Show the specified Space.")
if cmd, err := newSpaceUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("space/update", cmd, "Update the specified Space.")
}
r.Register("spaces/list", newSpacesList(cfg), "List all Spaces for the given account.")
if cmd, err := newSpacesProjectsCreate(cfg); err != nil {
return nil, err
} else {
r.Register("spaces/projects/create", cmd, "Adds an existing project to the space.")
}
r.Register("spaces/projects/delete", newSpacesProjectsDelete(cfg), "Removes a specified project from the specified space.")
r.Register("spaces/projects/list", newSpacesProjectsList(cfg), "List all projects for the specified Space.")
if cmd, err := newStyleguideCreate(cfg); err != nil {
return nil, err
} else {
r.Register("styleguide/create", cmd, "Create a new style guide.")
}
r.Register("styleguide/delete", newStyleguideDelete(cfg), "Delete an existing style guide.")
r.Register("styleguide/show", newStyleguideShow(cfg), "Get details on a single style guide.")
if cmd, err := newStyleguideUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("styleguide/update", cmd, "Update an existing style guide.")
}
r.Register("styleguides/list", newStyleguidesList(cfg), "List all styleguides for the given project.")
if cmd, err := newTagCreate(cfg); err != nil {
return nil, err
} else {
r.Register("tag/create", cmd, "Create a new tag.")
}
if cmd, err := newTagDelete(cfg); err != nil {
return nil, err
} else {
r.Register("tag/delete", cmd, "Delete an existing tag.")
}
if cmd, err := newTagShow(cfg); err != nil {
return nil, err
} else {
r.Register("tag/show", cmd, "Get details and progress information on a single tag for a given project.")
}
if cmd, err := newTagsList(cfg); err != nil {
return nil, err
} else {
r.Register("tags/list", cmd, "List all tags for the given project.")
}
if cmd, err := newTranslationCreate(cfg); err != nil {
return nil, err
} else {
r.Register("translation/create", cmd, "Create a translation.")
}
if cmd, err := newTranslationExclude(cfg); err != nil {
return nil, err
} else {
r.Register("translation/exclude", cmd, "Set exclude from export flag on an existing translation.")
}
if cmd, err := newTranslationInclude(cfg); err != nil {
return nil, err
} else {
r.Register("translation/include", cmd, "Remove exclude from export flag from an existing translation.")
}
if cmd, err := newTranslationReview(cfg); err != nil {
return nil, err
} else {
r.Register("translation/review", cmd, "Mark an existing translation as reviewed.")
}
if cmd, err := newTranslationShow(cfg); err != nil {
return nil, err
} else {
r.Register("translation/show", cmd, "Get details on a single translation.")
}
if cmd, err := newTranslationUnverify(cfg); err != nil {
return nil, err
} else {
r.Register("translation/unverify", cmd, "Mark an existing translation as unverified.")
}
if cmd, err := newTranslationUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("translation/update", cmd, "Update an existing translation.")
}
if cmd, err := newTranslationVerify(cfg); err != nil {
return nil, err
} else {
r.Register("translation/verify", cmd, "Verify an existing translation.")
}
if cmd, err := newTranslationsByKey(cfg); err != nil {
return nil, err
} else {
r.Register("translations/by_key", cmd, "List translations for a specific key.")
}
if cmd, err := newTranslationsByLocale(cfg); err != nil {
return nil, err
} else {
r.Register("translations/by_locale", cmd, "List translations for a specific locale. If you want to download all translations for one locale we recommend to use the <code>locales#download</code> endpoint.")
}
if cmd, err := newTranslationsExclude(cfg); err != nil {
return nil, err
} else {
r.Register("translations/exclude", cmd, "Exclude translations matching query from locale export.")
}
if cmd, err := newTranslationsInclude(cfg); err != nil {
return nil, err
} else {
r.Register("translations/include", cmd, "Include translations matching query in locale export.")
}
if cmd, err := newTranslationsList(cfg); err != nil {
return nil, err
} else {
r.Register("translations/list", cmd, "List translations for the given project. If you want to download all translations for one locale we recommend to use the <code>locales#download</code> endpoint.")
}
if cmd, err := newTranslationsReview(cfg); err != nil {
return nil, err
} else {
r.Register("translations/review", cmd, "Review translations matching query.")
}
if cmd, err := newTranslationsSearch(cfg); err != nil {
return nil, err
} else {
r.Register("translations/search", cmd, "Search translations for the given project. Provides the same search interface as <code>translations#index</code> but allows POST requests to avoid limitations imposed by GET requests. If you want to download all translations for one locale we recommend to use the <code>locales#download</code> endpoint.")
}
if cmd, err := newTranslationsUnverify(cfg); err != nil {
return nil, err
} else {
r.Register("translations/unverify", cmd, "Mark translations matching query as unverified.")
}
if cmd, err := newTranslationsVerify(cfg); err != nil {
return nil, err
} else {
r.Register("translations/verify", cmd, "Verify translations matching query.")
}
if cmd, err := newUploadCreate(cfg); err != nil {
return nil, err
} else {
r.Register("upload/create", cmd, "Upload a new language file. Creates necessary resources in your project.")
}
if cmd, err := newUploadShow(cfg); err != nil {
return nil, err
} else {
r.Register("upload/show", cmd, "View details and summary for a single upload.")
}
if cmd, err := newUploadsList(cfg); err != nil {
return nil, err
} else {
r.Register("uploads/list", cmd, "List all uploads for the given project.")
}
if cmd, err := newVersionShow(cfg); err != nil {
return nil, err
} else {
r.Register("version/show", cmd, "Get details on a single version.")
}
if cmd, err := newVersionsList(cfg); err != nil {
return nil, err
} else {
r.Register("versions/list", cmd, "List all versions for the given translation.")
}
if cmd, err := newWebhookCreate(cfg); err != nil {
return nil, err
} else {
r.Register("webhook/create", cmd, "Create a new webhook.")
}
r.Register("webhook/delete", newWebhookDelete(cfg), "Delete an existing webhook.")
r.Register("webhook/show", newWebhookShow(cfg), "Get details on a single webhook.")
r.Register("webhook/test", newWebhookTest(cfg), "Perform a test request for a webhook.")
if cmd, err := newWebhookUpdate(cfg); err != nil {
return nil, err
} else {
r.Register("webhook/update", cmd, "Update an existing webhook.")
}
r.Register("webhooks/list", newWebhooksList(cfg), "List all webhooks for the given project.")
ApplyNonRestRoutes(r, cfg)
return r, nil
}
type AccountShow struct {
phraseapp.Config
ID string `cli:"arg required"`
}
func newAccountShow(cfg *phraseapp.Config) *AccountShow {
actionAccountShow := &AccountShow{Config: *cfg}
return actionAccountShow
}
func (cmd *AccountShow) Run() error {
client, err := newClient(cmd.Config.Credentials, cmd.Config.Debug)
if err != nil {
return err
}
res, err := client.AccountShow(cmd.ID)
if err != nil {
return err
}
return json.NewEncoder(os.Stdout).Encode(&res)
}
type AccountsList struct {
phraseapp.Config
Page int `cli:"opt --page default=1"`
PerPage int `cli:"opt --per-page default=25"`
}
func newAccountsList(cfg *phraseapp.Config) *AccountsList {
actionAccountsList := &AccountsList{Config: *cfg}
if cfg.Page != nil {
actionAccountsList.Page = *cfg.Page
}
if cfg.PerPage != nil {
actionAccountsList.PerPage = *cfg.PerPage
}
return actionAccountsList
}
func (cmd *AccountsList) Run() error {
client, err := newClient(cmd.Config.Credentials, cmd.Config.Debug)
if err != nil {
return err
}
res, err := client.AccountsList(cmd.Page, cmd.PerPage)
if err != nil {
return err
}
return json.NewEncoder(os.Stdout).Encode(&res)
}
type AuthorizationCreate struct {
phraseapp.Config
phraseapp.AuthorizationParams
}
func newAuthorizationCreate(cfg *phraseapp.Config) (*AuthorizationCreate, error) {
actionAuthorizationCreate := &AuthorizationCreate{Config: *cfg}
val, defaultsPresent := actionAuthorizationCreate.Config.Defaults["authorization/create"]
if defaultsPresent {
if err := actionAuthorizationCreate.ApplyValuesFromMap(val); err != nil {
return nil, err
}
}
return actionAuthorizationCreate, nil
}
func (cmd *AuthorizationCreate) Run() error {
params := &cmd.AuthorizationParams
client, err := newClient(cmd.Config.Credentials, cmd.Config.Debug)
if err != nil {
return err
}
res, err := client.AuthorizationCreate(params)
if err != nil {
return err
}
return json.NewEncoder(os.Stdout).Encode(&res)
}
type AuthorizationDelete struct {
phraseapp.Config
ID string `cli:"arg required"`
}
func newAuthorizationDelete(cfg *phraseapp.Config) *AuthorizationDelete {
actionAuthorizationDelete := &AuthorizationDelete{Config: *cfg}
return actionAuthorizationDelete
}
func (cmd *AuthorizationDelete) Run() error {
client, err := newClient(cmd.Config.Credentials, cmd.Config.Debug)
if err != nil {
return err
}
err = client.AuthorizationDelete(cmd.ID)
if err != nil {
return err
}
return nil
}
type AuthorizationShow struct {
phraseapp.Config
ID string `cli:"arg required"`
}
func newAuthorizationShow(cfg *phraseapp.Config) *AuthorizationShow {
actionAuthorizationShow := &AuthorizationShow{Config: *cfg}
return actionAuthorizationShow
}
func (cmd *AuthorizationShow) Run() error {
client, err := newClient(cmd.Config.Credentials, cmd.Config.Debug)
if err != nil {
return err
}
res, err := client.AuthorizationShow(cmd.ID)
if err != nil {
return err
}
return json.NewEncoder(os.Stdout).Encode(&res)
}
type AuthorizationUpdate struct {
phraseapp.Config
phraseapp.AuthorizationParams
ID string `cli:"arg required"`
}
func newAuthorizationUpdate(cfg *phraseapp.Config) (*AuthorizationUpdate, error) {
actionAuthorizationUpdate := &AuthorizationUpdate{Config: *cfg}
val, defaultsPresent := actionAuthorizationUpdate.Config.Defaults["authorization/update"]
if defaultsPresent {
if err := actionAuthorizationUpdate.ApplyValuesFromMap(val); err != nil {
return nil, err
}
}
return actionAuthorizationUpdate, nil
}
func (cmd *AuthorizationUpdate) Run() error {
params := &cmd.AuthorizationParams
client, err := newClient(cmd.Config.Credentials, cmd.Config.Debug)
if err != nil {
return err
}
res, err := client.AuthorizationUpdate(cmd.ID, params)
if err != nil {
return err
}
return json.NewEncoder(os.Stdout).Encode(&res)
}
type AuthorizationsList struct {
phraseapp.Config
Page int `cli:"opt --page default=1"`
PerPage int `cli:"opt --per-page default=25"`
}
func newAuthorizationsList(cfg *phraseapp.Config) *AuthorizationsList {
actionAuthorizationsList := &AuthorizationsList{Config: *cfg}
if cfg.Page != nil {
actionAuthorizationsList.Page = *cfg.Page
}
if cfg.PerPage != nil {
actionAuthorizationsList.PerPage = *cfg.PerPage
}
return actionAuthorizationsList
}
func (cmd *AuthorizationsList) Run() error {