-
Notifications
You must be signed in to change notification settings - Fork 2
/
tidbcloud-oas.json
16546 lines (16546 loc) · 750 KB
/
tidbcloud-oas.json
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
{
"swagger": "2.0",
"info": {
"title": "TiDB Cloud API",
"description": "*TiDB Cloud API is in beta.*\n\n# Overview\n\nThe TiDB Cloud API is a [REST interface](https://en.wikipedia.org/wiki/Representational_state_transfer) that provides you with programmatic access to manage administrative objects within TiDB Cloud. Through this API, you can manage resources automatically and efficiently:\n\n* Projects\n* Clusters\n* Backups\n* Restores\n* Imports\n\nThe API has the following features:\n\n- **JSON entities.** All entities are expressed in JSON.\n- **HTTPS-only.** You can only access the API via HTTPS, ensuring all the data sent over the network is encrypted with TLS.\n- **Key-based access and digest authentication.** Before you access TiDB Cloud API, you must generate an API key. All requests are authenticated through [HTTP Digest Authentication](https://en.wikipedia.org/wiki/Digest_access_authentication), ensuring the API key is never sent over the network.\n\n# Get Started\n\nThis guide helps you make your first API call to TiDB Cloud API. You'll learn how to authenticate a request, build a request, and interpret the response. The [List all accessible projects](#tag/Project/operation/ListProjects) endpoint is used in this guide as an example.\n\n## Prerequisites\n\nTo complete this guide, you need to perform the following tasks:\n\n- Create a [TiDB Cloud account](https://tidbcloud.com/free-trial)\n- Install [curl](https://curl.se/)\n\n## Step 1. Create an API key\n\nTo create an API key, log in to your TiDB Cloud console. Navigate to the **Organization Settings** page, and create an API key.\n\nAn API key contains a public key and a private key. Copy and save them in a secure location. You will need to use the API key later in this guide.\n\nFor more details about creating API key, refer to [API Key Management](#section/Authentication/API-Key-Management).\n\n## Step 2. Make your first API call\n\n### Build an API call\n\nTiDB Cloud API call have the following components:\n\n- **A host.** The host for TiDB Cloud API is <https://api.tidbcloud.com>.\n- **An API Key**. The public key and the private key are required for authentication.\n- **A request.** When submitting data to a resource via `POST`, `PATCH`, or `PUT`, you must submit your payload in JSON.\n\nIn this guide, you call the [List all accessible projects](#tag/Project/operation/ListProjects) endpoint. For the detailed description of the endpoint, see the [API reference](#tag/Project/operation/ListProjects).\n\n### Call an API endpoint\n\nTo get all projects in your organization, run the following command in your terminal. Remember to change `YOUR_PUBLIC_KEY` to your public key and `YOUR_PRIVATE_KEY` to your private key.\n\n```shell\ncurl --digest \\\n --user 'YOUR_PUBLIC_KEY:YOUR_PRIVATE_KEY' \\\n --request GET \\\n --url https://api.tidbcloud.com/api/v1beta/projects\n```\n\n## Step 3. Check the response\n\nAfter making the API call, if the status code in response is `200` and you see details about all the projects in your organization, your request is successful. Here is an example of a successful response.\n\n```log\n{\n \"items\": [\n {\n \"id\": \"{project_id}\",\n \"org_id\": \"{org_id}\",\n \"name\": \"MyProject\",\n \"cluster_count\": 3,\n \"user_count\": 1,\n \"create_timestamp\": \"1652407748\"\n }\n ],\n \"total\": 1\n}\n```\n\nIf your API call is not successful, you will receive a status code other than `200` and the response looks similar to the following example. To troubleshoot the failed call, you can check the `message` in the response.\n\n```log\n{\n \"code\": 49900001,\n \"message\": \"public_key not found\",\n \"details\": []\n}\n```\n\n## Code samples\n\nThis section walks you through the quickest way to get started with TiDB Cloud API using programming languages. In these examples, you will learn how to use Python to create a cluster, backup and restore data, and scale out a cluster.\n\nYou can view the [full code examples](https://github.com/tidbcloud/tidbcloud-api-samples) of Python and Golang on GitHub or clone the repository to your local machine.\n\n```git\ngit clone https://github.com/tidbcloud/tidbcloud-api-samples.git\n```\n\n### Create and connect to a TiDB cluster\n\nThe following code examples show how to create a TiDB cluster and connect to the cluster. The whole process takes five steps:\n\n1. Get all projects.\n2. Get the cloud providers, regions and specifications.\n3. Create a cluster in your specified project.\n4. Get the new cluster information.\n5. Connect to the cluster using a MySQL client.\n\n#### Step 1: Get all projects\n\nBefore you create a cluster, you need to get the ID of the project that you want to create a cluster in.\n\nTo view the information of all available projects, you can use the [List all accessible projects](#tag/Project/operation/ListProjects) endpoint.\n\n```python\nimport requests\nfrom requests.auth import HTTPDigestAuth\n\nHOST = \"https://api.tidbcloud.com\"\n\n\ndef get_all_projects(public_key: str, private_key: str) -> dict:\n \"\"\"\n Get all projects\n :param public_key: Your public key\n :param private_key: Your private key\n :return: Projects detail\n \"\"\"\n url = f\"{HOST}/api/v1beta/projects\"\n resp = requests.get(url=url, auth=HTTPDigestAuth(public_key, private_key))\n if resp.status_code != 200:\n print(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n raise Exception(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n return resp.json()\n\n\nif __name__ == \"__main__\":\n # Replace YOUR_PUBLIC_KEY and YOUR_PRIVATE_KEY\n project = get_all_projects(\"{YOUR_PUBLIC_KEY}\", \"{YOUR_PRIVATE_KEY}\")\n print(project)\n```\n\nFor more details about the request and response, see [List all accessible projects](#tag/Project/operation/ListProjects).\n\n#### Step 2: Get the cloud providers, regions and specifications\n\nBefore you create a cluster, you need to get the list of available cloud providers, regions, and specifications.\n\n```python\nimport requests\nfrom requests.auth import HTTPDigestAuth\n\nHOST = \"https://api.tidbcloud.com\"\n\n\ndef get_provider_regions_specifications(public_key: str, private_key: str) -> dict:\n \"\"\"\n Get cloud providers, regions and available specifications.\n :param public_key: Your public key\n :param private_key: Your private key\n :return: List the cloud providers, regions and available specifications.\n \"\"\"\n url = f\"{HOST}/api/v1beta/clusters/provider/regions\"\n resp = requests.get(url=url, auth=HTTPDigestAuth(public_key, private_key))\n if resp.status_code != 200:\n print(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n raise Exception(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n return resp.json()\n\n\nif __name__ == \"__main__\":\n # Replace YOUR_PUBLIC_KEY and YOUR_PRIVATE_KEY\n provider_regions_specifications = get_provider_regions_specifications(\"{YOUR_PUBLIC_KEY}\", \"{YOUR_PRIVATE_KEY}\")\n print(provider_regions_specifications)\n```\n\nFor more details about the request and response, see [List the cloud providers, regions and available specifications](#tag/Cluster/operation/ListProviderRegions).\n\n#### Step 3: Create a cluster in your specified project and cloud provider\n\nThe following example uses the [Create a cluster](#tag/Cluster/operation/CreateCluster) endpoint to create a TiDB Dedicated cluster. A configuration example is provided in the code; you can replace the parameters using the information you get in the previous two steps.\n\n```python\nimport requests\nimport time\nimport json\nfrom requests.auth import HTTPDigestAuth\n\nHOST = \"https://api.tidbcloud.com\"\n\n\ndef create_dedicated_cluster(public_key: str, private_key: str, project_id: str) -> dict:\n \"\"\"\n Create a dedicated cluster in your specified project.\n `data_config` below is a demo. You should fill in the field according to\n your own situation\n :param public_key: Your public key\n :param private_key: Your private key\n :param project_id: The project id\n :return: Dedicated cluster id\n \"\"\"\n url = f\"{HOST}/api/v1beta/projects/{project_id}/clusters\"\n ts = int(time.time())\n data_config = \\\n {\n \"name\": f\"tidbcloud-sample-{ts}\",\n \"cluster_type\": \"DEDICATED\",\n \"cloud_provider\": \"AWS\",\n \"region\": \"us-west-2\",\n \"config\":\n {\n \"root_password\": \"input_your_password\",\n \"port\": 4000,\n \"components\":\n {\n \"tidb\":\n {\n \"node_size\": \"8C16G\",\n \"node_quantity\": 1\n },\n \"tikv\":\n {\"node_size\": \"8C32G\",\n \"storage_size_gib\": 500,\n \"node_quantity\": 3\n }\n },\n \"ip_access_list\":\n [\n {\n \"cidr\": \"0.0.0.0/0\",\n \"description\": \"Allow Access from Anywhere.\"\n }\n ]\n\n }\n }\n data_config_json = json.dumps(data_config)\n resp = requests.post(url=url,\n auth=HTTPDigestAuth(public_key, private_key),\n data=data_config_json)\n if resp.status_code != 200:\n print(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n raise Exception(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n return resp.json()\n\n\nif __name__ == \"__main__\":\n # Replace YOUR_PUBLIC_KEY, YOUR_PRIVATE_KEY and YOUR_PROJECT_ID\n cluster = create_dedicated_cluster(\"{YOUR_PUBLIC_KEY}\", \"{YOUR_PRIVATE_KEY}\", \"{YOUR_PROJECT_ID}\")\n print(cluster)\n```\n\nThis request returns the ID of the cluster that you just created. For more details about the request and response, see [Create a cluster](#tag/Cluster/operation/CreateCluster).\n\n#### Step 4: Get the new cluster information\n\nAfter you successfully create a cluster, you can use the [Get cluster by ID](#tag/Cluster/operation/GetCluster) endpoint to get the information of the cluster.\n\n```python\nimport requests\nfrom requests.auth import HTTPDigestAuth\n\nHOST = \"https://api.tidbcloud.com\"\n\n\ndef get_cluster_by_id(public_key: str, private_key: str, project_id: str, cluster_id: str) -> dict:\n \"\"\"\n Get the cluster detail.\n You will get `connection_strings` from the response after the cluster's status is`AVAILABLE`.\n Then, you can connect to TiDB using the default user, host, and port in `connection_strings`\n :param public_key: Your public key\n :param private_key: Your private key\n :param project_id: The project id\n :param cluster_id: The cluster id\n :return: The cluster detail\n \"\"\"\n url = f\"{HOST}/api/v1beta/projects/{project_id}/clusters/{cluster_id}\"\n resp = requests.get(url=url,\n auth=HTTPDigestAuth(public_key, private_key))\n if resp.status_code != 200:\n print(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n raise Exception(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n return resp.json()\n\n\nif __name__ == \"__main__\":\n # Replace YOUR_PUBLIC_KEY, YOUR_PRIVATE_KEY, YOUR_PROJECT_ID and YOUR_CLUSTER_ID\n cluster = get_cluster_by_id(\"{YOUR_PUBLIC_KEY}\", \"{YOUR_PRIVATE_KEY}\", \"{YOUR_PROJECT_ID}\",\n \"{YOUR_CLUSTER_ID}\")\n print(cluster)\n```\n\nIn the response, you can see the `connection_strings` field, which will be used later for connecting to the TiDB cluster. However, if your cluster status is `CREATING`, the `connection_strings` field might be empty. In such cases, you need to wait a while until the cluster status becomes `AVAILABLE` so that you can move on to the next step.\n\nFor more details about the request and response, see [Get a cluster by ID](#tag/Cluster/operation/GetCluster).\n\n#### Step 5: Connect to the cluster using a MySQL client\n\nAfter the cluster becomes `AVAILABLE`, you can get the connection strings. With the connection strings, you can connect to the cluster using a MySQL client.\n\nThe connection strings contain three fields:\n\n- `default_user`, the username you use to connect to TiDB.\n- `standard` connection string. In this guide, you'll use the `standard` connection.\n- `vpc_peering` connection string.\n\nThe `standard` connection string contains a `host` and a `port`. In the following command, replace `${default_user}` and `${host}` with the actual values in the connection strings. Run the command to connect to the TiDB cluster.\n\n```shell\nmysql --connect-timeout 15 -u ${default_user} -h ${host} -P 4000 -D test -p\n```\n\nFor more details on connection, see [Connect to TiDB Cluster](https://docs.pingcap.com/tidbcloud/connect-to-tidb-cluster).\n\n### Manage backups for your clusters\n\nThe following example shows how to create a manual backup and restore the last backup data to a new cluster.\n\n#### Step 1: Create a manual backup\n\nTo create a manual backup, you can use the [Create a backup for a cluster](#tag/Backup/operation/CreateBackup) endpoint.\n\n```python\nimport requests\nimport json\nimport datetime\nfrom requests.auth import HTTPDigestAuth\n\nHOST = \"https://api.tidbcloud.com\"\n\n\ndef create_manual_backup(public_key: str, private_key: str, project_id: str, cluster_id: str) -> dict:\n \"\"\"\n Create manual backup\n `data_for_backup` below is a demo. You should fill in the field according to\n your own situation\n :param public_key: Your public key\n :param private_key: Your private key\n :param project_id: The project id\n :param cluster_id: The dedicated cluster id\n :return: The backup id\n \"\"\"\n url = f\"{HOST}/api/v1beta/projects/{project_id}/clusters/{cluster_id}/backups\"\n cur_date = datetime.datetime.now().strftime(\"%Y-%m-%d\")\n data_for_backup = {\"name\": f\"tidbcloud-backup-{cur_date}\", \"description\": f\"tidbcloud-backup-{cur_date}\"}\n data_for_backup_json = json.dumps(data_for_backup)\n resp = requests.post(url=url,\n data=data_for_backup_json,\n auth=HTTPDigestAuth(public_key, private_key))\n if resp.status_code != 200:\n print(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n raise Exception(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n return resp.json()\n\n\nif __name__ == \"__main__\":\n # Replace YOUR_PUBLIC_KEY, YOUR_PRIVATE_KEY, YOUR_PROJECT_ID and YOUR_CLUSTER_ID\n backup = create_manual_backup(\"{YOUR_PUBLIC_KEY}\", \"{YOUR_PRIVATE_KEY}\", \"{YOUR_PROJECT_ID}\",\n \"{YOUR_CLUSTER_ID}\")\n print(backup)\n```\n\n#### Step 2: Restore the last backup data to a new cluster\n\nTo restore the last backup data to a new cluster, you can use the [Create a restore task](#tag/Restore/operation/CreateRestoreTask) endpoint.\n\n```python\nimport requests\nimport json\nimport datetime\nfrom requests.auth import HTTPDigestAuth\n\nHOST = \"https://api.tidbcloud.com\"\n\n\ndef create_restore_task(public_key: str, private_key: str, project_id: str, back_up_id: str) -> dict:\n \"\"\"\n Create restore task\n `data_for_restore` below is a demo. You should fill in the field according to\n your own situation\n :param private_key: Your public key\n :param public_key: Your private key\n :param project_id: The project id\n :param back_up_id: The backup id\n :return: The restore task id\n \"\"\"\n url = f\"{HOST}/api/v1beta/projects/{project_id}/restores\"\n cur_date = datetime.datetime.now().strftime(\"%Y-%m-%d\")\n data_for_restore = \\\n {\n \"backup_id\": f\"{back_up_id}\",\n \"name\": f\"tidbcloud-restore-{cur_date}\",\n \"config\":\n {\n \"root_password\": \"input_your_password\",\n \"port\": 4000,\n \"components\":\n {\n \"tidb\":\n {\n \"node_size\": \"8C16G\",\n \"node_quantity\": 1\n },\n \"tikv\":\n {\n \"node_size\": \"8C32G\",\n \"storage_size_gib\": 500,\n \"node_quantity\": 3\n }\n },\n \"ip_access_list\":\n [\n {\n \"cidr\": \"0.0.0.0/0\",\n \"description\": \"Allow Access from Anywhere.\"\n }\n ]\n\n }\n }\n data_for_restore_json = json.dumps(data_for_restore)\n resp = requests.post(url=url,\n auth=HTTPDigestAuth(public_key, private_key),\n data=data_for_restore_json)\n if resp.status_code != 200:\n print(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n raise Exception(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n return resp.json()\n\n\nif __name__ == \"__main__\":\n # Replace YOUR_PUBLIC_KEY, YOUR_PRIVATE_KEY, YOUR_PROJECT_ID and YOUR_BACKUP_ID\n restore = create_restore_task(\"{YOUR_PUBLIC_KEY}\", \"{YOUR_PRIVATE_KEY}\", \"{YOUR_PROJECT_ID}\",\n \"{YOUR_BACKUP_ID}\")\n print(restore)\n```\n\n#### Step 3: Get the restored cluster information\n\nTo get the information of the restored cluster, you can use the [Get a cluster by ID](#tag/Cluster/operation/GetCluster) endpoint.\n\n```python\nimport requests\nfrom requests.auth import HTTPDigestAuth\n\nHOST = \"https://api.tidbcloud.com\"\n\n\ndef get_cluster_by_id(public_key: str, private_key: str, project_id: str, cluster_id: str) -> dict:\n \"\"\"\n Get the cluster detail.\n You will get `connection_strings` from the response after the cluster's status is`AVAILABLE`.\n Then, you can connect to TiDB using the default user, host, and port in `connection_strings`\n :param public_key: Your public key\n :param private_key: Your private key\n :param project_id: The project id\n :param cluster_id: The cluster id\n :return: The cluster detail\n \"\"\"\n url = f\"{HOST}/api/v1beta/projects/{project_id}/clusters/{cluster_id}\"\n resp = requests.get(url=url,\n auth=HTTPDigestAuth(public_key, private_key))\n if resp.status_code != 200:\n print(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n raise Exception(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n return resp.json()\n\n\nif __name__ == \"__main__\":\n # Replace YOUR_PUBLIC_KEY, YOUR_PRIVATE_KEY, YOUR_PROJECT_ID and YOUR_CLUSTER_ID\n cluster = get_cluster_by_id(\"{YOUR_PUBLIC_KEY}\", \"{YOUR_PRIVATE_KEY}\", \"{YOUR_PROJECT_ID}\",\n \"{YOUR_CLUSTER_ID}\")\n print(cluster)\n```\n\n### Scale out one TiFlash node for an existing cluster\n\nThe following example shows how to scale out one TiFlash node for an existing cluster.\n\n#### Step 1: Add one TiFlash node for the specified cluster\n\nTo add a TiFlash node for the TiDB Dedicated cluster, you can use the [Modify a TiDB Dedicated cluster](#tag/Cluster/operation/UpdateCluster) endpoint.\n\n```python\nimport requests\nimport json\nfrom requests.auth import HTTPDigestAuth\n\nHOST = \"https://api.tidbcloud.com\"\n\n\ndef modify_cluster(public_key: str, private_key: str, project_id: str, cluster_id: str, tiflash_num: int) -> dict:\n \"\"\"\n Add one TiFlash node for specified cluster\n If the vCPUs of TiDB or TiKV component is 4, then the cluster does not support TiFlash.\n `data_add_tiflash` below is a demo. You should fill in the field according to\n your own situation\n :param public_key: Your public key\n :param private_key: Your private key\n :param project_id: The project id\n :param cluster_id: The cluster id\n :param tiflash_num: The tiflash num\n :return: If success, return None. Else, return message\n \"\"\"\n url = f\"{HOST}/api/v1beta/projects/{project_id}/clusters/{cluster_id}\"\n data_add_tiflash = \\\n {\n \"config\":\n {\n \"components\":\n {\n \"tidb\":\n {\n \"node_quantity\": 1\n },\n \"tikv\":\n {\n \"node_quantity\": 3\n },\n \"tiflash\":\n {\n \"node_quantity\": f\"{tiflash_num}\",\n \"node_size\": \"8C64G\",\n \"storage_size_gib\": 500\n }\n }\n }\n }\n data_add_tiflash_json = json.dumps(data_add_tiflash)\n resp = requests.patch(url=url,\n auth=HTTPDigestAuth(public_key, private_key),\n data=data_add_tiflash_json)\n if resp.status_code != 200:\n print(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n raise Exception(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n return resp.json()\n\n\nif __name__ == \"__main__\":\n # Replace YOUR_PUBLIC_KEY, YOUR_PRIVATE_KEY, YOUR_PROJECT_ID, YOUR_CLUSTER_ID and MODIFY_TIFLASH_NUM\n modify_cluster(\"{YOUR_PUBLIC_KEY}\", \"{YOUR_PRIVATE_KEY}\", \"{YOUR_PROJECT_ID}\",\n \"{YOUR_CLUSTER_ID}\", \"{MODIFY_TIFLASH_NUM}\")\n```\n\n#### Step 2: View the scale-out progress\n\nTo view the scale-out progress, you can use the [Get a cluster by ID](#tag/Cluster/operation/GetCluster) endpoint.\n\n```python\nimport requests\nfrom requests.auth import HTTPDigestAuth\n\nHOST = \"https://api.tidbcloud.com\"\n\n\ndef get_cluster_by_id(public_key: str, private_key: str, project_id: str, cluster_id: str) -> dict:\n \"\"\"\n Get the cluster detail.\n You will get `connection_strings` from the response after the cluster's status is`AVAILABLE`.\n Then, you can connect to TiDB using the default user, host, and port in `connection_strings`\n :param public_key: Your public key\n :param private_key: Your private key\n :param project_id: The project id\n :param cluster_id: The cluster id\n :return: The cluster detail\n \"\"\"\n url = f\"{HOST}/api/v1beta/projects/{project_id}/clusters/{cluster_id}\"\n resp = requests.get(url=url,\n auth=HTTPDigestAuth(public_key, private_key))\n if resp.status_code != 200:\n print(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n raise Exception(f\"request invalid, code : {resp.status_code}, message : {resp.text}\")\n return resp.json()\n\n\nif __name__ == \"__main__\":\n # Replace YOUR_PUBLIC_KEY, YOUR_PRIVATE_KEY, YOUR_PROJECT_ID and YOUR_CLUSTER_ID\n cluster = get_cluster_by_id(\"{YOUR_PUBLIC_KEY}\", \"{YOUR_PRIVATE_KEY}\", \"{YOUR_PROJECT_ID}\",\n \"{YOUR_CLUSTER_ID}\")\n print(cluster)\n```\n\n# Authentication\n\nThe TiDB Cloud API uses [HTTP Digest Authentication](https://en.wikipedia.org/wiki/Digest_access_authentication). It protects your private key from being sent over the network. For more details about HTTP Digest Authentication, refer to the [IETF RFC](https://datatracker.ietf.org/doc/html/rfc7616).\n\n## API key overview\n\n- The API key contains a public key and a private key, which act as the username and password required in the HTTP Digest Authentication. The private key only displays upon the key creation.\n- The API key belongs to your organization and acts as the `Owner` role. You can check [permissions of owner](https://docs.pingcap.com/tidbcloud/manage-user-access#configure-member-roles).\n- You must provide the correct API key in every request. Otherwise, the TiDB Cloud responds with a `401` error.\n\n## API key management\n\n### Create an API key\n\nOnly the **owner** of an organization can create an API key.\n\nTo create an API key in an organization, perform the following steps:\n\n1. Click <svg width=\"16\" height=\"16\" viewBox=\"0 -2 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 11H17.8C18.9201 11 19.4802 11 19.908 11.218C20.2843 11.4097 20.5903 11.7157 20.782 12.092C21 12.5198 21 13.0799 21 14.2V21M13 21V6.2C13 5.0799 13 4.51984 12.782 4.09202C12.5903 3.71569 12.2843 3.40973 11.908 3.21799C11.4802 3 10.9201 3 9.8 3H6.2C5.0799 3 4.51984 3 4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202C3 4.51984 3 5.0799 3 6.2V21M22 21H2M6.5 7H9.5M6.5 11H9.5M6.5 15H9.5\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></svg> **Organization** in the lower-left corner of the TiDB Cloud console.\n2. Click **Organization Settings**. The organization settings page is displayed.\n3. Click the **API Keys** tab and then click **Create API Key**.\n4. Enter a description for your API key. The role of the API key is always `Owner` currently.\n5. Click **Next**. Copy and save the public key and the private key.\n6. Make sure that you have copied and saved the private key in a secure location. The private key only displays upon the creation. After leaving this page, you will not be able to get the full private key again.\n7. Click **Done**.\n\n### View details of an API key\n\nTo view details of an API key, perform the following steps:\n\n1. Click <svg width=\"16\" height=\"16\" viewBox=\"0 -2 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 11H17.8C18.9201 11 19.4802 11 19.908 11.218C20.2843 11.4097 20.5903 11.7157 20.782 12.092C21 12.5198 21 13.0799 21 14.2V21M13 21V6.2C13 5.0799 13 4.51984 12.782 4.09202C12.5903 3.71569 12.2843 3.40973 11.908 3.21799C11.4802 3 10.9201 3 9.8 3H6.2C5.0799 3 4.51984 3 4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202C3 4.51984 3 5.0799 3 6.2V21M22 21H2M6.5 7H9.5M6.5 11H9.5M6.5 15H9.5\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></svg> **Organization** in the upper-right corner of the TiDB Cloud console.\n2. Click **Organization Settings**. The organization settings page is displayed.\n3. Click the **API Keys** tab.\n4. You can view the details of the API keys in the menu.\n\n### Edit an API key\n\nOnly the **owner** of an organization can modify an API key.\n\nTo edit an API key in an organization, perform the following steps:\n\n1. Click <svg width=\"16\" height=\"16\" viewBox=\"0 -2 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 11H17.8C18.9201 11 19.4802 11 19.908 11.218C20.2843 11.4097 20.5903 11.7157 20.782 12.092C21 12.5198 21 13.0799 21 14.2V21M13 21V6.2C13 5.0799 13 4.51984 12.782 4.09202C12.5903 3.71569 12.2843 3.40973 11.908 3.21799C11.4802 3 10.9201 3 9.8 3H6.2C5.0799 3 4.51984 3 4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202C3 4.51984 3 5.0799 3 6.2V21M22 21H2M6.5 7H9.5M6.5 11H9.5M6.5 15H9.5\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></svg> **Organization** in the upper-right corner of the TiDB Cloud console.\n2. Click **Organization Settings**. The organization settings page is displayed.\n3. Click the **API Keys** tab.\n4. Click **Edit** in the API key row that you want to change.\n4. You can update the API key description.\n5. Click **Done**.\n\n### Delete an API key\n\nOnly the **owner** of an organization can delete an API key.\n\nTo delete an API key in an organization, perform the following steps:\n\n1. Click <svg width=\"16\" height=\"16\" viewBox=\"0 -2 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 11H17.8C18.9201 11 19.4802 11 19.908 11.218C20.2843 11.4097 20.5903 11.7157 20.782 12.092C21 12.5198 21 13.0799 21 14.2V21M13 21V6.2C13 5.0799 13 4.51984 12.782 4.09202C12.5903 3.71569 12.2843 3.40973 11.908 3.21799C11.4802 3 10.9201 3 9.8 3H6.2C5.0799 3 4.51984 3 4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202C3 4.51984 3 5.0799 3 6.2V21M22 21H2M6.5 7H9.5M6.5 11H9.5M6.5 15H9.5\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"></path></svg> **Organization** in the upper-right corner of the TiDB Cloud console.\n2. Click **Organization Settings**. The organization settings page is displayed.\n3. Click the **API Keys** tab.\n4. Click **Delete** in the API key row that you want to delete.\n5. Click **I understand the consequences, delete this API Key.**\n\n# Rate Limiting\n\nThe TiDB Cloud API allows up to 100 requests per minute per API key. If you exceed the rate limit, the API returns a `429` error. For more quota, you can [submit a request](https://support.pingcap.com/hc/en-us/requests/new?ticket_form_id=7800003722519) to contact our support team.\n\nEach API request returns the following headers about the limit.\n\n- `X-Ratelimit-Limit-Minute`: The number of requests allowed per minute. It is 100 currently.\n- `X-Ratelimit-Remaining-Minute`: The number of remaining requests in the current minute. When it reaches `0`, the API returns a `429` error and indicates that you exceed the rate limit.\n- `X-Ratelimit-Reset`: The time in seconds at which the current rate limit resets.\n\nIf you exceed the rate limit, an error response returns like this.\n\n```\n> HTTP/2 429\n> date: Fri, 22 Jul 2022 05:28:37 GMT\n> content-type: application/json\n> content-length: 66\n> x-ratelimit-reset: 23\n> x-ratelimit-remaining-minute: 0\n> x-ratelimit-limit-minute: 100\n> x-kong-response-latency: 2\n> server: kong/2.8.1\n\n> {\"details\":[],\"code\":49900007,\"message\":\"The request exceeded the limit of 100 times per apikey per minute. For more quota, please contact us: https://support.pingcap.com/hc/en-us/requests/new?ticket_form_id=7800003722519\"}\n```\n\n# API Changelog\n\nThis changelog lists all changes to the TiDB Cloud API.\n\n<!-- In reverse chronological order -->\n\n## 20230905\n\n- Add six new endpoints for managing the private endpoint service and private endpoints:\n\n - [Create a private endpoint service for a cluster](#tag/Cluster/operation/CreatePrivateEndpointService)\n - [Retrieve the private endpoint service information for a cluster](#tag/Cluster/operation/GetPrivateEndpointService)\n - [Create a private endpoint for a cluster](#tag/Cluster/operation/CreatePrivateEndpoint)\n - [List all private endpoints for a cluster](#tag/Cluster/operation/ListPrivateEndpoints)\n - [List all private endpoints in a project](#tag/Cluster/operation/ListPrivateEndpointsOfProject)\n - [Delete a private endpoint for a cluster](#tag/Cluster/operation/DeletePrivateEndpoint)\n\n## 20230801\n\n- Add one cluster status: `\"PAUSING\"`.\n\n## 20230602\n\n- Rename the two tier options as follows:\n\n - \"Serverless Tier\" is renamed to \"TiDB Serverless\".\n - \"Dedicated Tier\" is renamed to \"TiDB Dedicated\".\n\n## 20230328\n\n- Add three new endpoints:\n\n - [Create a project](#tag/Project/operation/CreateProject)\n - [List AWS Customer-Managed Encryption Keys for a project](#tag/Cluster/operation/ListAwsCmek)\n - [Configure AWS Customer-Managed Encryption Keys for a project](#tag/Cluster/operation/CreateAwsCmek)\n\n## 20230321\n\n- Update three fields of the [Modify a Dedicated Tier cluster](#tag/Cluster/operation/UpdateCluster) endpoint. These fields now support decreasing the size of TiDB, TiKV, or TiFlash nodes.\n\n - `config.components.tidb.node_size`\n - `config.components.tikv.node_size`\n - `config.components.tiflash.node_size`\n\n## 20230228\n\n- Add the `imports` resource, including the following endpoints:\n\n - [List all import tasks for a cluster](#tag/Import/operation/ListImportTasks)\n - [Get an import task](#tag/Import/operation/GetImportTask)\n - [Create an import task](#tag/Import/operation/CreateImportTask)\n - [Update an import task](#tag/Import/operation/UpdateImportTask)\n - [Upload a local file for an import task](#tag/Import/operation/UploadLocalFile)\n - [Preview data before starting an import task](#tag/Import/operation/PreviewImportData)\n - [Retrieve the role information for import tasks on a cluster](#tag/Import/operation/GetImportTaskRoleInfo)\n\n## 20230214\n\n- Update two fields of the [Modify a Dedicated Tier cluster](#tag/Cluster/operation/UpdateCluster) endpoint. These fields now support decreasing TiKV or TiFlash nodes.\n\n - `config.components.tikv.node_quantity`\n - `config.components.tiflash.node_quantity`\n\n## 20230104\n\n- Add three fields to the [Modify a Dedicated Tier cluster](#tag/Cluster/operation/UpdateCluster) endpoint. These fields support scaling up node sizes, but not scaling down.\n\n - `config.components.tidb.node_size`\n - `config.components.tikv.node_size`\n - `config.components.tiflash.node_size`\n\n## 20221028\n\n- [Developer Tier is upgraded to Serverless Tier](https://docs.pingcap.com/tidbcloud/release-notes-2022#october-28-2022). Serverless Tier is still in beta and free to use.\n\n [Creating a cluster](#tag/Cluster/operation/CreateCluster) with the `cluster_type` field set to `DEVELOPER` creates a Serverless Tier cluster now.\n\n## 20220920\n\n- The API is now in public beta and available to all users.\n\n## 20220906\n\n- Add a `config.components.tikv.storage_size_gib` field to the [Modify a Dedicated Tier cluster](#tag/Cluster/operation/UpdateCluster) endpoint.\n- Modify the `config.components.tikv.node_quantity` and `config.components.tiflash.node_quantity` fields from `required` to `optional` for the [Modify a Dedicated Tier cluster](#tag/Cluster/operation/UpdateCluster) endpoint.\n- Remove the \"Can not modify `storage_size_gib` of an existing cluster\" limitation of the `config.components.tiflash.storage_size_gib` field for the [Create a cluster](#tag/Cluster/operation/CreateCluster) and [Modify a Dedicated Tier cluster](#tag/Cluster/operation/UpdateCluster) endpoints.\n\n## 20220823\n\n- Add a `config.paused` field to the [Modify a Dedicated Tier cluster](#tag/Cluster/operation/UpdateCluster) endpoint.\n- Add two cluster statuses: `\"IMPORTING\"` and `\"UNAVAILABLE\"`.\n\n## 20220809\n\n- Initial release of the TiDB Cloud API (v1beta) in private beta, including the following resources and endpoints:\n\n - Project:\n\n - [List all accessible projects](#tag/Project/operation/ListProjects)\n\n - Cluster:\n - [List the cloud providers, regions and available specifications](#tag/Cluster/operation/ListProviderRegions)\n - [List all clusters in a project](/#tag/Cluster/operation/ListClustersOfProject)\n - [Create a cluster](#tag/Cluster/operation/CreateCluster)\n - [Get a cluster by ID](#tag/Cluster/operation/GetCluster)\n - [Delete a cluster](#tag/Cluster/operation/DeleteCluster)\n - [Modify a Dedicated Tier cluster](#tag/Cluster/operation/UpdateCluster)\n - Backup:\n - [List all backups for a cluster](#tag/Backup/operation/ListBackUpOfCluster)\n - [Create a backup for a cluster](#tag/Backup/operation/CreateBackup)\n - [Get a backup for a cluster](#tag/Backup/operation/GetBackupOfCluster)\n - [Delete a backup for a cluster](#tag/Backup/operation/DeleteBackup)\n - Restore:\n - [List the restore tasks in a project](#tag/Restore/operation/ListRestoreTasks)\n - [Create a restore task](#tag/Restore/operation/CreateRestoreTask)\n - [Get a restore task](#tag/Restore/operation/GetRestoreTask)\n",
"version": "v1-beta",
"x-logo": {
"url": "https://download.pingcap.com/tidbcloud-logo-for-api-docs.png",
"altText": "TiDB Cloud Logo",
"href": "https://docs.pingcap.com/tidbcloud/"
}
},
"tags": [
{
"name": "Project",
"description": "List projects."
},
{
"name": "Cluster",
"description": "Create, get, modify, and delete TiDB clusters."
},
{
"name": "Backup",
"description": "Create, get, modify, and delete backups for TiDB clusters.\n\nFor TiDB Serverless clusters, you cannot create or manage backups via API. You can use [Dumpling](https://docs.pingcap.com/tidb/stable/dumpling-overview) to export your data as backups."
},
{
"name": "Import",
"description": "Create, get, update import tasks for TiDB clusters."
},
{
"name": "Restore",
"description": "Get and create restore tasks for TiDB clusters. You can only restore data to a new cluster.\n\nFor more information on restoration on TiDB Cloud, refer to [Restore](https://docs.pingcap.com/tidbcloud/backup-and-restore#restore).\n\nFor TiDB Serverless clusters, you cannot manage restore tasks via API."
}
],
"host": "api.tidbcloud.com",
"schemes": [
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/api/v1beta/clusters/provider/regions": {
"get": {
"summary": "List the cloud providers, regions and available specifications.",
"operationId": "ListProviderRegions",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"format": "array",
"example": [
{
"cluster_type": "DEDICATED",
"cloud_provider": "AWS",
"region": "us-west-2",
"tidb": [
{
"node_size": "8C16G",
"node_quantity_range": {
"min": 1,
"step": 1
}
}
],
"tikv": [
{
"node_size": "8C32G",
"node_quantity_range": {
"min": 3,
"step": 3
},
"storage_size_gib_range": {
"min": 500,
"max": 4096
}
}
],
"tiflash": [
{
"node_size": "8C64G",
"node_quantity_range": {
"min": 0,
"step": 1
},
"storage_size_gib_range": {
"min": 500,
"max": 2048
}
}
]
},
{
"cluster_type": "DEVELOPER",
"cloud_provider": "AWS",
"region": "us-west-2",
"tidb": [
{
"node_size": "Shared0",
"node_quantity_range": {
"min": 1,
"step": 1
}
}
],
"tikv": [
{
"node_size": "Shared0",
"node_quantity_range": {
"min": 1,
"step": 1
},
"storage_size_gib_range": {
"min": 1,
"max": 1
}
}
],
"tiflash": [
{
"node_size": "Shared0",
"node_quantity_range": {
"min": 1,
"step": 1
},
"storage_size_gib_range": {
"min": 1,
"max": 1
}
}
]
}
],
"items": {
"type": "object",
"properties": {
"cluster_type": {
"format": "enum",
"example": "DEDICATED",
"description": "The cluster type.\n- `\"DEVELOPER\"`: a [TiDB Serverless](https://docs.pingcap.com/tidbcloud/select-cluster-tier#tidb-serverless) cluster\n- `\"DEDICATED\"`: a [TiDB Dedicated](https://docs.pingcap.com/tidbcloud/select-cluster-tier#dedicated-tier) cluster\n\n**Warning:** `\"DEVELOPER\"` will soon be changed to `\"SERVERLESS\"` to represent TiDB Serverless clusters.",
"type": "string",
"enum": [
"DEDICATED",
"DEVELOPER"
]
},
"cloud_provider": {
"format": "string",
"example": "AWS",
"description": "The cloud provider on which your TiDB cluster is hosted.\n- `\"AWS\"`: the Amazon Web Services cloud provider\n- `\"GCP\"`: the Google Cloud cloud provider",
"type": "string",
"enum": [
"AWS",
"GCP"
]
},
"region": {
"type": "string",
"example": "us-west-2",
"description": "The region in which your TiDB cluster is hosted.\n\nFor the detailed information on each region, refer to the documentation of the corresponding cloud provider ([AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html) | [GCP](https://cloud.google.com/about/locations#americas)).\n\nFor example, `\"us-west-2\"` refers to Oregon for AWS."
},
"tidb": {
"type": "array",
"items": {
"type": "object",
"properties": {
"node_size": {
"type": "string",
"example": "8C16G",
"description": "The size of the TiDB component in the cluster."
},
"node_quantity_range": {
"description": "The range and step of node quantity of the TiDB component in the cluster.",
"type": "object",
"properties": {
"min": {
"type": "integer",
"format": "int32",
"description": "The minimum node quantity of the component in the cluster."
},
"step": {
"type": "integer",
"format": "int32",
"description": "The step of node quantity of the component in the cluster."
}
}
}
}
},
"description": "The list of TiDB specifications in the region."
},
"tikv": {
"type": "array",
"items": {
"type": "object",
"properties": {
"node_size": {
"type": "string",
"example": "8C32G",
"description": "The size of the TiKV component in the cluster."
},
"node_quantity_range": {
"description": "The range and step of node quantity of the TiKV component in the cluster.",
"type": "object",
"properties": {
"min": {
"type": "integer",
"format": "int32",
"description": "The minimum node quantity of the component in the cluster."
},
"step": {
"type": "integer",
"format": "int32",
"description": "The step of node quantity of the component in the cluster."
}
}
},
"storage_size_gib_range": {
"description": "The storage size range for each node of the TiKV component in the cluster.",
"type": "object",
"properties": {
"min": {
"type": "integer",
"format": "int32",
"description": "The minimum storage size for each node of the component in the cluster."
},
"max": {
"type": "integer",
"format": "int32",
"description": "The maximum storage size for each node of the component in the cluster."
}
}
}
}
},
"description": "The list of TiKV specifications in the region."
},
"tiflash": {
"type": "array",
"items": {
"type": "object",
"properties": {
"node_size": {
"type": "string",
"example": "8C64G",
"description": "The size of the TiFlash component in the cluster."
},
"node_quantity_range": {
"description": "The range and step of node quantity of the TiFlash component in the cluster.",
"type": "object",
"properties": {
"min": {
"type": "integer",
"format": "int32",
"description": "The minimum node quantity of the component in the cluster."
},
"step": {
"type": "integer",
"format": "int32",
"description": "The step of node quantity of the component in the cluster."
}
}
},
"storage_size_gib_range": {
"description": "The storage size range for each node of the TiFlash component in the cluster.",
"type": "object",
"properties": {
"min": {
"type": "integer",
"format": "int32",
"description": "The minimum storage size for each node of the component in the cluster."
},
"max": {
"type": "integer",
"format": "int32",
"description": "The maximum storage size for each node of the component in the cluster."
}
}
}
}
},
"description": "The list of TiFlash specifications in the region."
}
},
"description": "ListProviderRegionsItem is the item of provider regions.",
"title": "ListProviderRegionsItem"
},
"description": "Items of provider regions."
}
},
"description": "GetProviderRegionsResp is the response for getting provider regions.",
"title": "GetProviderRegionsResp"
}
},
"400": {
"description": "A request field is invalid.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"401": {
"description": "The API key cannot be authenticated.",
"schema": {}
},
"403": {
"description": "The API key does not have permission to access the resource.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"404": {
"description": "The requested resource does not exist.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"429": {
"description": "You have exceed the rate limit.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"500": {
"description": "Server error.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
}
}
}
}
}
},
"tags": [
"Cluster"
],
"x-code-samples": [
{
"lang": "curl",
"source": "curl --digest \\\n --user 'YOUR_PUBLIC_KEY:YOUR_PRIVATE_KEY' \\\n --request GET \\\n --url https://api.tidbcloud.com/api/v1beta/clusters/provider/regions"
}
]
}
},
"/api/v1beta/projects": {
"get": {
"summary": "List all accessible projects.",
"operationId": "ListProjects",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uint64",
"example": "1",
"description": "The ID of the project."
},
"org_id": {
"type": "string",
"format": "uint64",
"example": "1",
"description": "The ID of the TiDB Cloud organization to which the project belongs."
},
"name": {
"type": "string",
"example": "default_project",
"description": "The name of the project."
},
"cluster_count": {
"type": "integer",
"format": "int64",
"example": 4,
"description": "The number of TiDB Cloud clusters deployed in the project."
},
"user_count": {
"type": "integer",
"format": "int64",
"example": 10,
"description": "The number of users in the project."
},
"create_timestamp": {
"type": "string",
"format": "timestamp",
"example": "1656991448",
"description": "The creation time of the cluster in Unix timestamp seconds (epoch time)."
},
"aws_cmek_enabled": {
"type": "boolean",
"example": false,
"default": false,
"description": "Flag that indicates whether to enable AWS Customer-Managed Encryption Keys (CMEK). For more information, see [Encryption at Rest using CMEK](https://docs.pingcap.com/tidbcloud/tidb-cloud-encrypt-cmek).\n\n**Note:** Currently, this feature is only available upon request. If you need to try out this feature, contact [support](https://docs.pingcap.com/tidbcloud/tidb-cloud-support)."
}
},
"description": "ListProjectItem is the item of projects.",
"title": "ListProjectItem"
},
"description": "The items of accessible projects."
},
"total": {
"type": "integer",
"format": "int64",
"example": 1,
"description": "The total number of accessible projects."
}
},
"description": "GetProjectsResp is the response for getting accessible projects.",
"title": "GetProjectsResp",
"required": [
"total",
"items"
]
}
},
"400": {
"description": "A request field is invalid.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"401": {
"description": "The API key cannot be authenticated.",
"schema": {}
},
"403": {
"description": "The API key does not have permission to access the resource.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"404": {
"description": "The requested resource does not exist.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"429": {
"description": "You have exceed the rate limit.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"500": {
"description": "Server error.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
}
}
}
}
}
},
"parameters": [
{
"name": "page",
"description": "The number of pages.",
"in": "query",
"required": false,
"type": "integer",
"format": "int64",
"default": 1
},
{
"name": "page_size",
"description": "The size of a page.",
"in": "query",
"required": false,
"type": "integer",
"format": "int64",
"default": 10
}
],
"tags": [
"Project"
],
"x-code-samples": [
{
"lang": "curl",
"source": "curl --digest \\\n --user 'YOUR_PUBLIC_KEY:YOUR_PRIVATE_KEY' \\\n --request GET \\\n --url 'https://api.tidbcloud.com/api/v1beta/projects?page=1&page_size=10'"
}
]
},
"post": {
"summary": "Create a project.",
"operationId": "CreateProject",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uint64",
"example": "1",
"description": "The ID of the project."
}
},
"description": "CreateProjectResp is the response for creating project.",
"title": "CreateProjectResp",
"required": [
"id"
]
}
},
"400": {
"description": "A request field is invalid.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"401": {
"description": "The API key cannot be authenticated.",
"schema": {}
},
"403": {
"description": "The API key does not have permission to access the resource.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"404": {
"description": "The requested resource does not exist.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"429": {
"description": "You have exceed the rate limit.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"500": {
"description": "Server error.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "integer",
"description": "Error code returned with this error.",
"title": "code"
},
"message": {
"type": "string",
"description": "Error message returned with this error.",
"title": "message"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "Error details returned with this error.",
"title": "details"
}
}
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
}
}
}
}
}
},
"parameters": [
{
"name": "body",
"description": "CreateProjectReq is the request for creating project.",
"in": "body",
"required": true,
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"example": "Project0",
"description": "The name of the project."
},
"aws_cmek_enabled": {
"type": "boolean",
"x-nullable": true,
"example": false,
"default": false,
"description": "Flag that indicates whether to enable AWS Customer-Managed Encryption Keys.\n\nCurrently this feature is only available upon request. If you need to try out this feature, contact [support](https://docs.pingcap.com/tidbcloud/tidb-cloud-support)."
}
},
"description": "CreateProjectReq is the request for creating project.",
"title": "CreateProjectReq",
"required": [
"name"
]
}
}
],
"tags": [
"Project"
],
"x-code-samples": [
{
"lang": "curl",
"source": "curl --digest \\\n --user 'YOUR_PUBLIC_KEY:YOUR_PRIVATE_KEY' \\\n --request POST \\\n --url https://api.tidbcloud.com/api/v1beta/projects \\\n --header 'content-type: application/json' \\\n --data '{\"name\":\"Project0\",\"aws_cmek_enabled\":false}'"
}
]
}
},
"/api/v1beta/projects/{project_id}/aws-cmek": {
"get": {
"summary": "List AWS Customer-Managed Encryption Keys for a project.",
"description": "Customer-Managed Encryption Keys (CMEK) lets you protect your static data in a TiDB Dedicated cluster using a cryptographic key that is completely controlled by you. To create a project with CMEK enabled, use the [Create a project](#tag/Project/operation/CreateProject) endpoint and configure `aws_cmek_enabled` to `true`.\n\nFor more information, see [Encryption at Rest using CMEK](https://docs.pingcap.com/tidbcloud/tidb-cloud-encrypt-cmek).",
"operationId": "ListAwsCmek",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"format": "array",
"items": {
"type": "object",