sylphx 0.3.6

The Sylphx SDK: one API, one key, every Sylphx service. Generated from the Sylphx schema registry.
Documentation
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
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
// @generated by sylphx-gen. Do not edit.
//! `sylphx.sandboxes.v1`.

#![allow(clippy::all)]

/// The request of AcquireLeaseControl.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct AcquireLeaseControlRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// HUMAN or AGENT.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub holder: Option<ControlHolder>,
    /// How long; default 10 minutes, capped at 30 minutes.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub ttl: String,
    /// A label for the holder, for example the person's user id; recorded in
    /// the audit events.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "holderLabel"
    )]
    pub holder_label: String,
    /// For HUMAN: take control from another human.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub preempt: bool,
}

/// The response of AcquireLeaseControl.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct AcquireLeaseControlResponse {
    /// The control now held.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub control: Option<ControlState>,
    /// For HUMAN: the controller stream bound to this epoch.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub stream: Option<StreamSession>,
}

/// The request of ActLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ActLeaseRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The actions, performed in order; at most 64. An empty list with
    /// `screenshot` set only takes a screenshot.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub actions: Vec<ComputerAction>,
    /// Take a screenshot after the last action and return it.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub screenshot: Option<ScreenshotOptions>,
    /// Refuse STALE_GENERATION unless the lease is at this generation; 0 skips
    /// the check.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "leaseGeneration"
    )]
    pub lease_generation: i64,
    /// Act under this AGENT control epoch; 0 acts only while nobody holds
    /// control.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "controlEpoch"
    )]
    pub control_epoch: i64,
}

/// The response of ActLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ActLeaseResponse {
    /// One result per action, in order.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub results: Vec<ActionResult>,
    /// The screenshot after the last action, when requested.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub screenshot: Option<Screenshot>,
    /// The lease generation the actions ran under.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "leaseGeneration"
    )]
    pub lease_generation: i64,
    /// The control the actions ran under.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub control: Option<ControlState>,
}

/// ActionResult is the outcome of one ComputerAction.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ActionResult {
    /// The pointer position after the action (and the answer of
    /// `cursor_position`).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cursor: Option<Point>,
    /// For `take_screenshot` and `zoom`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub image: Option<Screenshot>,
}

/// The request of ArchiveVolume.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ArchiveVolumeRequest {
    /// The workspace to archive. Its name and UID remain unchanged.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// Archive only if the current etag matches.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub etag: String,
    /// Check eligibility and retained-copy evidence without modifying the Volume,
    /// creating archive objects, or releasing its source claim.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// The result of ArchiveVolume. A pending archive can be retried safely; an
/// ambiguous response never authorizes attaching an empty replacement.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ArchiveVolumeResponse {
    /// The current workspace, including its unchanged resource identity.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub volume: Option<Volume>,
    /// Whether this attempt passed the eligibility and retained-copy checks.
    /// Validation is an observation; execution always checks current state again.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub reclaimable: bool,
    /// Requested PVC bytes that archival would release, not physical storage use.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "requestedBytes"
    )]
    pub requested_bytes: i64,
    /// True only after the source claim has disappeared and its archive is retained.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub archived: bool,
    /// A bounded decision reason, such as within_grace, attached,
    /// awaiting_offsite_coverage, coverage_unavailable, pending or archived.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub reason: String,
}

/// BrowserSpec configures the Chromium of a BROWSER lease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct BrowserSpec {
    /// Run headless instead of on the display. A headless browser has no stream
    /// and no computer actions; CDP only.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub headless: bool,
    /// The profile directory; put it on a volume to keep cookies and storage
    /// across leases. Default a fresh profile.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "userDataDir"
    )]
    pub user_data_dir: String,
    /// The page opened at start; default `about:blank`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "startUrl"
    )]
    pub start_url: String,
}

/// ButtonAction presses or releases one button.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ButtonAction {
    /// Where; unset acts at the current pointer position.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
    /// Default LEFT.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub button: Option<MouseButton>,
}

/// The request of CancelExecLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct CancelExecLeaseRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The execution key from the original ExecLease request.
    ///
    /// Field behavior: `required`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "idempotencyKey"
    )]
    pub idempotency_key: String,
}

/// ClickAction clicks a button one to three times.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ClickAction {
    /// Where; unset clicks at the current pointer position.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
    /// Default LEFT.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub button: Option<MouseButton>,
    /// 1 (default), 2 (double), or 3 (triple).
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub count: i32,
    /// Keys held during the click, xdotool names (`shift`, `ctrl`, `alt`,
    /// `super`).
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifiers: Vec<String>,
}

/// The request of CloseLeasePort.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct CloseLeasePortRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The guest port.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub port: i32,
}

/// ComputerAction is one input or observation. Coordinates are logical display
/// pixels (`status.display`), origin top-left.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ComputerAction {
    /// Capture the display (Anthropic `screenshot`, OpenAI `screenshot`).
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        alias = "takeScreenshot"
    )]
    pub take_screenshot: Option<ScreenshotAction>,
    /// Capture a region at full resolution (Anthropic `zoom`).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub zoom: Option<ZoomAction>,
    /// Move the pointer (Anthropic `mouse_move`, OpenAI `move`).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub r#move: Option<PointerMove>,
    /// Click (Anthropic `left_click`, `right_click`, `middle_click`,
    /// `double_click`, `triple_click`; OpenAI `click`, `double_click`; Android
    /// tap).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub click: Option<ClickAction>,
    /// Press a button without releasing it (Anthropic `left_mouse_down`).
    #[serde(default, skip_serializing_if = "Option::is_none", alias = "mouseDown")]
    pub mouse_down: Option<ButtonAction>,
    /// Release a button (Anthropic `left_mouse_up`).
    #[serde(default, skip_serializing_if = "Option::is_none", alias = "mouseUp")]
    pub mouse_up: Option<ButtonAction>,
    /// Press, move along a path, release (Anthropic `left_click_drag`, OpenAI
    /// `drag`; Android swipe).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub drag: Option<DragAction>,
    /// Scroll (Anthropic `scroll`, OpenAI `scroll`).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scroll: Option<ScrollAction>,
    /// Press a key combination (Anthropic `key`, OpenAI `keypress`; Android
    /// key events).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub key: Option<KeyAction>,
    /// Hold a key combination for a duration (Anthropic `hold_key`).
    #[serde(default, skip_serializing_if = "Option::is_none", alias = "holdKey")]
    pub hold_key: Option<HoldKeyAction>,
    /// Type text (Anthropic `type`, OpenAI `type`).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub r#type: Option<TypeAction>,
    /// Report the pointer position (Anthropic `cursor_position`).
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        alias = "cursorPosition"
    )]
    pub cursor_position: Option<CursorPositionAction>,
    /// Wait (Anthropic `wait`, OpenAI `wait`).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub wait: Option<WaitAction>,
}

/// ControlState says who holds input control of a lease's display. Control is
/// an exclusive lock with a hard time limit enforced in the Cell. While a
/// HUMAN holds it, agent actions are refused CONTROL_HELD_BY_HUMAN.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ControlState {
    /// Who holds control; UNSPECIFIED when nobody does (agent actions allowed).
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub holder: Option<ControlHolder>,
    /// Increases on every acquire; release names it.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64"
    )]
    pub epoch: i64,
    /// The Access principal that acquired control.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub principal: String,
    /// The caller's label for the person or agent, for example a user id.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "holderLabel"
    )]
    pub holder_label: String,
    /// When control was acquired.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "acquireTime"
    )]
    pub acquire_time: String,
    /// When control lapses unless re-acquired.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "expireTime"
    )]
    pub expire_time: String,
}

/// The request of CreateLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct CreateLeaseRequest {
    /// The parent to create in.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub parent: String,
    /// The lease to create; only spec and caller-writable metadata are read.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub lease: Option<Lease>,
    /// The id segment of the name; the server assigns one when unset.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "leaseId"
    )]
    pub lease_id: String,
    /// Validate and return the result without writing anything.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
    /// Return as soon as the machine is granted instead of when the guest is
    /// ready. Default false: wait for READY, at most 60 seconds.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "skipWaitReady"
    )]
    pub skip_wait_ready: bool,
}

/// The request of CreatePool.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct CreatePoolRequest {
    /// The parent to create in.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub parent: String,
    /// The pool to create; only spec and caller-writable metadata are read.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pool: Option<Pool>,
    /// The id segment of the name; the server assigns one when unset.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "poolId"
    )]
    pub pool_id: String,
    /// Validate and return the result without writing anything.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// The request of CreateSnapshot.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct CreateSnapshotRequest {
    /// The parent to create in.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub parent: String,
    /// The snapshot to create; only spec and caller-writable metadata are read.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub snapshot: Option<Snapshot>,
    /// The id segment of the name; the server assigns one when unset.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "snapshotId"
    )]
    pub snapshot_id: String,
    /// Validate and return the result without writing anything.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// The request of CreateVolume.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct CreateVolumeRequest {
    /// The parent to create in.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub parent: String,
    /// The volume to create; only spec and caller-writable metadata are read.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub volume: Option<Volume>,
    /// The id segment of the name; the server assigns one when unset.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "volumeId"
    )]
    pub volume_id: String,
    /// Validate and return the result without writing anything.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// CursorPositionAction reports the pointer position in its result.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct CursorPositionAction {}

/// The request of DeletePool.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct DeletePoolRequest {
    /// The name of the pool to delete.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// Delete only if the current etag matches.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub etag: String,
    /// Succeed when the Resource does not exist.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "allowMissing"
    )]
    pub allow_missing: bool,
    /// Validate without deleting anything.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// The request of DeleteSnapshot.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct DeleteSnapshotRequest {
    /// The name of the snapshot to delete.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// Delete only if the current etag matches.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub etag: String,
    /// Succeed when the Resource does not exist.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "allowMissing"
    )]
    pub allow_missing: bool,
    /// Validate without deleting anything.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// The request of DeleteVolume.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct DeleteVolumeRequest {
    /// The name of the volume to delete.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// Delete only if the current etag matches.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub etag: String,
    /// Succeed when the Resource does not exist.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "allowMissing"
    )]
    pub allow_missing: bool,
    /// Validate without deleting anything.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// DeviceSpec chooses the device of a device lease. An unknown model or OS
/// version is refused SHAPE_NOT_OFFERED.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct DeviceSpec {
    /// A model from the selected kind's catalog: an Android id such as
    /// `pixel_7`, or a Simulator device type such as
    /// `com.apple.CoreSimulator.SimDeviceType.iPhone-15-Plus`. Unset selects
    /// the kind's default model.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub model: String,
    /// The OS version, e.g. `14`; default the newest offered.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "osVersion"
    )]
    pub os_version: String,
    /// The required Simulator architecture; unset selects the offered architecture.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub architecture: String,
    /// Enable Vulkan on an Android emulator for native graphics tests. Default
    /// false: Chrome WebGL uses the OpenGL ES path. Refused on IOS leases.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "vulkanEnabled"
    )]
    pub vulkan_enabled: bool,
}

/// DisplayInfo is a lease's effective display.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct DisplayInfo {
    /// Logical width in pixels; action coordinates are in this space.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub width: i32,
    /// Logical height in pixels.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub height: i32,
    /// Dots per inch.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub dpi: i32,
}

/// DisplaySpec is a lease's requested display.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct DisplaySpec {
    /// Logical width in pixels; default 1280.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub width: i32,
    /// Logical height in pixels; default 800.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub height: i32,
    /// Dots per inch; default 96.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub dpi: i32,
}

/// DragAction presses at the first point, moves through the rest, and
/// releases at the last.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct DragAction {
    /// At least two points.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub path: Vec<Point>,
    /// Default LEFT.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub button: Option<MouseButton>,
    /// Keys held during the drag, xdotool names.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifiers: Vec<String>,
    /// Total time of the move; default 300 ms (Android swipe duration).
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub duration: String,
}

/// The request of ExecLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ExecLeaseRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The program and its arguments. Use `["bash", "-lc", "…"]` for a shell.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub command: Vec<String>,
    /// The working directory; default the user's home.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "workingDirectory"
    )]
    pub working_directory: String,
    /// Extra environment variables.
    #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")]
    pub env: std::collections::BTreeMap<String, String>,
    /// Bytes written to standard input.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub stdin: String,
    /// Kill the process after this long; default 60 seconds, at most 30
    /// minutes, and never past the lease's `expire_time`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub timeout: String,
    /// The guest user; default `user`. `root` is allowed: the whole machine
    /// belongs to the lessee.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub user: String,
    /// Stable execution identity, 1-255 printable ASCII characters. Required
    /// here or in the Idempotency-Key header (this field takes precedence).
    /// Persist it with the complete request before sending; use the same key
    /// and request to recover after any disconnect or caller restart.
    /// The first call claims the key before the command
    /// starts; a later call with the same key and request returns the recorded
    /// result (also after the lease ended), `IDEMPOTENCY_IN_PROGRESS` while the
    /// first still runs (the command continues after the call returns), and
    /// `EXEC_OUTCOME_UNKNOWN` when the outcome was lost after dispatch. The same
    /// key with another request is `IDEMPOTENCY_KEY_REUSED`. A refusal before
    /// the command started releases the key.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "idempotencyKey"
    )]
    pub idempotency_key: String,
}

/// The response of ExecLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ExecLeaseResponse {
    /// The confirmed process exit code (including a signal exit, such as 137).
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "exitCode"
    )]
    pub exit_code: i32,
    /// Standard output.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub stdout: String,
    /// Standard error.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub stderr: String,
    /// Whether either stream exceeded the cap.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub truncated: bool,
    /// Whether the process was killed at `timeout`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "timedOut"
    )]
    pub timed_out: bool,
    /// Whether an explicit cancellation was confirmed by process termination.
    /// A cancellation acknowledgement alone never sets this field.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub cancelled: bool,
    /// The stable key used to dispatch this command.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "idempotencyKey"
    )]
    pub idempotency_key: String,
    /// The one dispatch identity, unchanged on every terminal replay.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "executionId"
    )]
    pub execution_id: String,
}

/// FileEntry is one entry of a guest directory.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct FileEntry {
    /// The absolute path.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub path: String,
    /// Whether it is a directory.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub directory: bool,
    /// Size in bytes.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "sizeBytes"
    )]
    pub size_bytes: i64,
    /// The mode bits.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub mode: i32,
    /// When it last changed.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "modifyTime"
    )]
    pub modify_time: String,
}

/// The request of GetLeaseControl.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct GetLeaseControlRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
}

/// The request of GetLeaseEvent.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct GetLeaseEventRequest {
    /// The name of the event to get.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
}

/// The request of GetLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct GetLeaseRequest {
    /// The name of the lease to get.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
}

/// The request of GetPool.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct GetPoolRequest {
    /// The name of the pool to get.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
}

/// The request of GetShape.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct GetShapeRequest {
    /// The name of the shape to get.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
}

/// The request of GetSnapshot.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct GetSnapshotRequest {
    /// The name of the snapshot to get.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
}

/// The request of GetVolume.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct GetVolumeRequest {
    /// The name of the volume to get.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
}

/// HoldKeyAction holds a combination down, then releases it.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct HoldKeyAction {
    /// The combination, xdotool syntax.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub combo: String,
    /// How long; at most 10 seconds.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub duration: String,
}

/// IceServer is one RTCIceServer.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct IceServer {
    /// `stun:`, `turn:`, or `turns:` URLs.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub urls: Vec<String>,
    /// The TURN username.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub username: String,
    /// The TURN credential.
    ///
    /// Field behavior: `sensitive`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub credential: String,
}

/// The request of InstallLeaseApp.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct InstallLeaseAppRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// An Android APK uploaded to the lease. Exactly one app path is required.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "apkPath"
    )]
    pub apk_path: String,
    /// Grant every Android runtime permission the app declares.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "grantPermissions"
    )]
    pub grant_permissions: bool,
    /// A ZIP containing one Simulator .app, uploaded to an IOS lease.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "appPath"
    )]
    pub app_path: String,
    /// The exact ZIP SHA256; required for a Simulator install.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "artifactSha256"
    )]
    pub artifact_sha256: String,
    /// The caller's immutable source revision, returned in the install receipt.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "sourceRevision"
    )]
    pub source_revision: String,
}

/// The receipt of a successful app install or in-place update.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct InstallLeaseAppResponse {
    /// The Android package or iOS bundle identifier.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "packageName"
    )]
    pub package_name: String,
    /// The verified uploaded artifact SHA256.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "artifactSha256"
    )]
    pub artifact_sha256: String,
    /// The source revision supplied with this exact artifact.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "sourceRevision"
    )]
    pub source_revision: String,
    /// UTC time of the successful install.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "installTime"
    )]
    pub install_time: String,
}

/// KeyAction presses a key combination, xdotool syntax: `Return`, `ctrl+c`,
/// `ctrl+shift+t`, `super`, `F5`. On Android, `home`, `back`, `app_switch`,
/// `power`, `volume_up`, `volume_down`, `enter`, or `KEYCODE_*`.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct KeyAction {
    /// The combination.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub combo: String,
    /// Press it this many times; default 1.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub repeat: i32,
}

/// A Lease is one isolated machine of a shape, region, and image for a bounded
/// time. It is granted immediately from a warm or cold machine, or refused with
/// a typed reason; its end destroys the machine. Sandboxes is its only writer.
/// Put the caller's own correlation (agent id, work id) in `meta.labels`; List
/// filters on them.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Lease {
    /// `orgs/{org}/projects/{project}/envs/{env}/leases/{lease}`.
    ///
    /// Field behavior: `identifier`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// `sbx_<cell><ulid>`; never reused.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub uid: String,
    /// Resource metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub meta: Option<crate::common::ResourceMeta>,
    /// Desired state; omit it, or send it empty, for the zero-config lease: the
    /// platform resolves and records the shape and `ttl` (see `LeaseSpec`).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub spec: Option<LeaseSpec>,
    /// Observed state.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub status: Option<LeaseStatus>,
}

/// LeaseBudget bounds what one lease may consume. Reaching a bound ends the
/// lease with the matching EndReason; the Cell enforces it without the
/// control plane.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeaseBudget {
    /// End CPU_BUDGET after this many vCPU-seconds of guest CPU time.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "maxCpuSeconds"
    )]
    pub max_cpu_seconds: i64,
    /// End COST_BUDGET once the shape's list price times wall seconds reaches
    /// this many millionths of a US dollar.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "maxCostMicros"
    )]
    pub max_cost_micros: i64,
}

/// LeaseEndpoints are a lease's data-plane addresses. Each accepts an Access
/// key with `sandboxes:exec` or a lease token of the matching scope.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeaseEndpoints {
    /// The guest daemon: the E2B envd protocol (Connect-RPC `process.Process`,
    /// `filesystem.Filesystem`, HTTP `/files`), routed by the `E2b-Sandbox-Id`
    /// header, for streaming exec and PTYs.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "guestUri"
    )]
    pub guest_uri: String,
    /// The Chrome DevTools Protocol WebSocket of a BROWSER lease.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "cdpUri"
    )]
    pub cdp_uri: String,
    /// The E2B sandbox id this lease answers to on the E2B-compatible API.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "e2bSandboxId"
    )]
    pub e2b_sandbox_id: String,
}

/// A LeaseEvent is one immutable fact in a lease's life: grant, ready, end,
/// control changes, network changes. Events are listed in order and
/// long-polled with `wait`.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeaseEvent {
    /// `orgs/{org}/projects/{project}/envs/{env}/leases/{lease}/lease_events/{lease_event}`.
    ///
    /// Field behavior: `identifier`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// `lev_<cell><ulid>`; never reused.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub uid: String,
    /// Resource metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub meta: Option<crate::common::ResourceMeta>,
    /// What happened.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind: Option<LeaseEventKind>,
    /// The position in the lease's event sequence, from 1.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64"
    )]
    pub sequence: i64,
    /// When it happened.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "occurTime"
    )]
    pub occur_time: String,
    /// The lease generation after the event.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "leaseGeneration"
    )]
    pub lease_generation: i64,
    /// The lease state after the event.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub state: Option<LeaseState>,
    /// For LEASE_ENDED.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none", alias = "endReason")]
    pub end_reason: Option<EndReason>,
    /// For LEASE_ENDED: final usage.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub usage: Option<LeaseUsage>,
    /// For CONTROL_* events: the control after the event.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub control: Option<ControlState>,
    /// For CONTROL_RELEASED and CONTROL_EXPIRED: how long control was held.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "controlDuration"
    )]
    pub control_duration: String,
    /// The principal that caused it, when a caller did.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub principal: String,
}

/// LeaseNetwork is a lease's outbound policy. Link-local and cloud metadata
/// addresses (169.254.0.0/16, fd00:ec2::254), RFC 1918, CGNAT
/// (100.64.0.0/10), loopback, and the Cell's internal address ranges
/// are blocked under every policy and cannot be allowlisted.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeaseNetwork {
    /// Default ALLOW.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub egress: Option<EgressPolicy>,
    /// Hosts reachable when `egress` is ALLOWLIST: exact names or one leading
    /// `*.` wildcard label, for example `api.openai.com`, `*.github.com`.
    #[serde(
        default,
        skip_serializing_if = "Vec::is_empty",
        alias = "allowedDomains"
    )]
    pub allowed_domains: Vec<String>,
    /// Public CIDRs reachable when `egress` is ALLOWLIST.
    #[serde(default, skip_serializing_if = "Vec::is_empty", alias = "allowedCidrs")]
    pub allowed_cidrs: Vec<String>,
    /// The ranges blocked under every policy.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty", alias = "blockedCidrs")]
    pub blocked_cidrs: Vec<String>,
}

/// LeasePort is a guest port reachable through the lease's data plane.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeasePort {
    /// The guest port.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub port: i32,
    /// Default PRIVATE: a lease token or an Access key with `sandboxes:exec` is
    /// required.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub visibility: Option<PortVisibility>,
    /// The port's URL.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub uri: String,
}

/// LeaseSpec is the caller-writable state of a Lease. Every field is optional:
/// an empty spec (or no spec at all) is the zero-config lease — a GENERAL lease
/// of the `base` image on the `linux-s` shape for 300 seconds. Set `kind` for a
/// browser, desktop, or Android machine; set `shape`, `ttl`, or `region` only to
/// go beyond those defaults. The platform records the resolved shape and `ttl`
/// on the created lease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeaseSpec {
    /// The shape; when unset the platform resolves one from `kind` and the image:
    /// `linux-s` for a GENERAL lease, `linux-m` for BROWSER, `linux-l` for DESKTOP
    /// or ANDROID, and `build-standard` for the `template:build` image. An
    /// explicit shape must serve `kind`.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub shape: String,
    /// The image: an artifact in Sylphx Artifacts, by digest, or `template:<name>`
    /// (`base`, `desktop`, `browser`, `android`,
    /// `build`). Default the template of `kind`. Ignored when `source_snapshot` is
    /// set.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub image: String,
    /// What the machine serves; default GENERAL.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind: Option<LeaseKind>,
    /// Optional placement override. Unpinned ephemeral leases use eligible capacity;
    /// leases mounting volumes retain the home region unless explicitly pinned.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub region: String,
    /// The Pool to take a warm machine from; default the platform pool for the
    /// shape and image.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub pool: String,
    /// The maximum wall time from grant, bounded by the selected shape.
    /// Default 300 seconds (1800 for IOS); at least 60 seconds. The Simulator
    /// shape permits at most 3600 seconds. `:renew` stays within the shape's
    /// bound. Reaching it ends the lease EXPIRED.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub ttl: String,
    /// End the lease IDLE after no data-plane call, stream input, or exec for
    /// this long; unset never idles out.
    ///
    /// Field behavior: `immutable`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "idleTimeout"
    )]
    pub idle_timeout: String,
    /// The outbound policy. Change it on a running lease with `:setNetwork`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub network: Option<LeaseNetwork>,
    /// Guest ports to expose.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub ports: Vec<LeasePort>,
    /// Plain environment variables. Secrets bind through Sylphx Secrets, never
    /// here.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")]
    pub env: std::collections::BTreeMap<String, String>,
    /// Volumes attached at grant, each by name. A volume is attached to at most
    /// one lease at a time; a volume already attached refuses the lease with
    /// RESOURCE_IN_USE.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub volumes: Vec<VolumeMount>,
    /// Spend bounds beyond `ttl` and `idle_timeout`.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub budget: Option<LeaseBudget>,
    /// The display of a DESKTOP, BROWSER, or ANDROID lease.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub display: Option<DisplaySpec>,
    /// The browser of a BROWSER lease.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub browser: Option<BrowserSpec>,
    /// Boot from this Snapshot's disk and image instead of `image`.
    ///
    /// Field behavior: `immutable`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "sourceSnapshot"
    )]
    pub source_snapshot: String,
    /// Where lease events are delivered as signed webhooks, in addition to
    /// `leases/*/events`.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub webhook: Option<LeaseWebhook>,
    /// The device of an ANDROID or IOS lease: model and OS version
    /// (device-farm.md §2.1). The device sets the display; `display` is
    /// ignored.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub device: Option<DeviceSpec>,
}

/// LeaseStatus is the observed state of a Lease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeaseStatus {
    /// The generation this status was computed from.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "observedGeneration"
    )]
    pub observed_generation: i64,
    /// Ready, Reconciling, Stalled.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub conditions: Vec<crate::common::Condition>,
    /// The state machine.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub state: Option<LeaseState>,
    /// Increases on grant, pause, resume, and end; every token and platform
    /// command carries it, and a stale one is refused STALE_GENERATION.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "leaseGeneration"
    )]
    pub lease_generation: i64,
    /// Eight Crockford base32 characters naming the lease in data-plane routes.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "shortId"
    )]
    pub short_id: String,
    /// Data-plane addresses.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub endpoints: Option<LeaseEndpoints>,
    /// Why the lease was refused, when `state` is REFUSED.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub refusal: Option<LeaseRefusal>,
    /// Why the lease ended, once `state` is ENDING or ENDED.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none", alias = "endReason")]
    pub end_reason: Option<EndReason>,
    /// When a machine was assigned.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "grantTime"
    )]
    pub grant_time: String,
    /// When the guest became ready.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "readyTime"
    )]
    pub ready_time: String,
    /// When the lease ends unless renewed.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "expireTime"
    )]
    pub expire_time: String,
    /// When the lease ended.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "endTime"
    )]
    pub end_time: String,
    /// What the lease has consumed so far.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub usage: Option<LeaseUsage>,
    /// Who holds input control of the display.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub control: Option<ControlState>,
    /// The effective display, for kinds that have one.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub display: Option<DisplayInfo>,
    /// The effective outbound policy, including the ranges always blocked.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub network: Option<LeaseNetwork>,
}

/// LeaseUsage is what a lease has consumed, refreshed at least every 60
/// seconds while it runs and final once it ends.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeaseUsage {
    /// Wall seconds from grant.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "wallSeconds"
    )]
    pub wall_seconds: i64,
    /// Guest vCPU-seconds.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "cpuSeconds"
    )]
    pub cpu_seconds: i64,
    /// List-price cost so far, in millionths of a US dollar; 0 on classes that
    /// are not priced.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "costMicros"
    )]
    pub cost_micros: i64,
    /// When this usage was measured.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "measureTime"
    )]
    pub measure_time: String,
    /// Memory GiB-seconds (shape memory times wall seconds).
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "memoryGibSeconds"
    )]
    pub memory_gib_seconds: i64,
    /// Bytes sent to the internet.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "egressBytes"
    )]
    pub egress_bytes: i64,
    /// Seconds of live stream viewing, summed over viewers.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "streamSeconds"
    )]
    pub stream_seconds: i64,
}

/// LeaseWebhook delivers lease events as Standard Webhooks, signed Ed25519
/// (`webhook-signature: v1a,…`) with the key published at
/// `/.well-known/sandboxes-webhook-keys.json`.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct LeaseWebhook {
    /// The HTTPS URL that receives the POSTs.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub uri: String,
    /// Deliver only these kinds; default every kind.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub kinds: Vec<LeaseEventKind>,
}

/// The request of ListLeaseEvents.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListLeaseEventsRequest {
    /// The lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub parent: String,
    /// At most this many; default 50, clamped to 1000.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageSize"
    )]
    pub page_size: i32,
    /// `next_page_token` of the previous page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageToken"
    )]
    pub page_token: String,
    /// AIP-160 filter over `kind`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub filter: String,
    /// Block up to this long (at most 60 seconds) when there is no event after
    /// `page_token`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub wait: String,
}

/// The response of ListLeaseEvents.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListLeaseEventsResponse {
    /// The page, oldest first.
    #[serde(default, skip_serializing_if = "Vec::is_empty", alias = "leaseEvents")]
    pub lease_events: Vec<LeaseEvent>,
    /// Pass it back to continue after the last event; set on every page, so a
    /// caller can long-poll from it.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "nextPageToken"
    )]
    pub next_page_token: String,
}

/// The request of ListLeaseFiles.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListLeaseFilesRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The absolute directory path in the guest.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub path: String,
    /// Descend this many levels; default 1.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub depth: i32,
}

/// The response of ListLeaseFiles.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListLeaseFilesResponse {
    /// The entries.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub entries: Vec<FileEntry>,
}

/// The request of ListLeases.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListLeasesRequest {
    /// The parent to list in.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub parent: String,
    /// At most this many; default 50, clamped to 1000.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageSize"
    )]
    pub page_size: i32,
    /// `next_page_token` of the previous page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageToken"
    )]
    pub page_token: String,
    /// AIP-160 filter over labels, filterable fields, and Ready.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub filter: String,
    /// AIP-132 ordering over filterable fields.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "orderBy"
    )]
    pub order_by: String,
}

/// The response of ListLeases.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListLeasesResponse {
    /// The page.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub leases: Vec<Lease>,
    /// The token of the next page; empty on the last page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "nextPageToken"
    )]
    pub next_page_token: String,
}

/// The request of ListPools.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListPoolsRequest {
    /// The parent to list in.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub parent: String,
    /// At most this many; default 50, clamped to 1000.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageSize"
    )]
    pub page_size: i32,
    /// `next_page_token` of the previous page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageToken"
    )]
    pub page_token: String,
    /// AIP-160 filter over labels, filterable fields, and Ready.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub filter: String,
    /// AIP-132 ordering over filterable fields.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "orderBy"
    )]
    pub order_by: String,
}

/// The response of ListPools.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListPoolsResponse {
    /// The page.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub pools: Vec<Pool>,
    /// The token of the next page; empty on the last page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "nextPageToken"
    )]
    pub next_page_token: String,
}

/// The request of ListSandboxShapes.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListSandboxShapesRequest {
    /// At most this many; default 50, clamped to 1000.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageSize"
    )]
    pub page_size: i32,
    /// `next_page_token` of the previous page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageToken"
    )]
    pub page_token: String,
    /// AIP-160 filter over labels, filterable fields, and Ready.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub filter: String,
    /// AIP-132 ordering over filterable fields.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "orderBy"
    )]
    pub order_by: String,
}

/// The response of ListSandboxShapes.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListSandboxShapesResponse {
    /// The page.
    #[serde(
        default,
        skip_serializing_if = "Vec::is_empty",
        alias = "sandboxShapes"
    )]
    pub sandbox_shapes: Vec<Shape>,
    /// The token of the next page; empty on the last page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "nextPageToken"
    )]
    pub next_page_token: String,
}

/// The request of ListSnapshots.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListSnapshotsRequest {
    /// The parent to list in.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub parent: String,
    /// At most this many; default 50, clamped to 1000.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageSize"
    )]
    pub page_size: i32,
    /// `next_page_token` of the previous page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageToken"
    )]
    pub page_token: String,
    /// AIP-160 filter over labels, filterable fields, and Ready.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub filter: String,
    /// AIP-132 ordering over filterable fields.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "orderBy"
    )]
    pub order_by: String,
}

/// The response of ListSnapshots.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListSnapshotsResponse {
    /// The page.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub snapshots: Vec<Snapshot>,
    /// The token of the next page; empty on the last page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "nextPageToken"
    )]
    pub next_page_token: String,
}

/// The request of ListVolumes.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListVolumesRequest {
    /// The parent to list in.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub parent: String,
    /// At most this many; default 50, clamped to 1000.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageSize"
    )]
    pub page_size: i32,
    /// `next_page_token` of the previous page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "pageToken"
    )]
    pub page_token: String,
    /// AIP-160 filter over labels, filterable fields, and Ready.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub filter: String,
    /// AIP-132 ordering over filterable fields.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "orderBy"
    )]
    pub order_by: String,
}

/// The response of ListVolumes.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ListVolumesResponse {
    /// The page.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub volumes: Vec<Volume>,
    /// The token of the next page; empty on the last page.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "nextPageToken"
    )]
    pub next_page_token: String,
}

/// The request of MintLeaseToken.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct MintLeaseTokenRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// What the token admits.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub scopes: Vec<TokenScope>,
    /// At most 1 hour and never past the lease's `expire_time`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub ttl: String,
}

/// The response of MintLeaseToken.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct MintLeaseTokenResponse {
    /// The lease token; sent as a bearer token to the data plane.
    ///
    /// Field behavior: `sensitive`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub token: String,
    /// The lease generation the token is bound to.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64"
    )]
    pub generation: i64,
    /// When the token stops verifying.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "expireTime"
    )]
    pub expire_time: String,
}

/// The request of OpenLeasePort.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct OpenLeasePortRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The port to expose.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub port: Option<LeasePort>,
}

/// The request of OpenLeaseStream.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct OpenLeaseStreamRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// How long the token admits a new connection; at most and default 5
    /// minutes. A connected stream ends when the lease generation changes or the
    /// token is revoked.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub ttl: String,
}

/// The request of PauseLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct PauseLeaseRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// Act only if the current etag matches.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub etag: String,
    /// Validate without acting.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// Point is a position in logical display pixels.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Point {
    /// Pixels from the left edge.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub x: i32,
    /// Pixels from the top edge.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub y: i32,
}

/// PointerMove moves the pointer.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct PointerMove {
    /// Where to.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
}

/// A Pool keeps never-leased machines of one shape and image warm, so a lease
/// starts in seconds. An empty pool makes a lease slower, never different.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Pool {
    /// `orgs/{org}/projects/{project}/envs/{env}/pools/{pool}`.
    ///
    /// Field behavior: `identifier`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// `pol_<cell><ulid>`; never reused.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub uid: String,
    /// Resource metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub meta: Option<crate::common::ResourceMeta>,
    /// Desired state.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub spec: Option<PoolSpec>,
    /// Observed state.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub status: Option<PoolStatus>,
}

/// PoolSpec is the caller-writable state of a Pool.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct PoolSpec {
    /// The shape.
    ///
    /// Field behavior: `required`, `immutable`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub shape: String,
    /// The image: an artifact in Sylphx Artifacts, by digest, or `template:<name>`.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub image: String,
    /// Optional overrides over warm capacity sized automatically from recent lease demand.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub warm: Option<PoolWarm>,
    /// Warm machines older than this are recycled; 5 minutes to 2 hours.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "maxAge"
    )]
    pub max_age: String,
}

/// PoolStatus is the observed state of a Pool.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct PoolStatus {
    /// The generation this status was computed from.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "observedGeneration"
    )]
    pub observed_generation: i64,
    /// Ready, Reconciling, Stalled.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub conditions: Vec<crate::common::Condition>,
    /// Booted, never-leased machines ready now.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "warmMachines"
    )]
    pub warm_machines: i32,
    /// Machines booting into the pool.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "bootingMachines"
    )]
    pub booting_machines: i32,
}

/// PoolWarm bounds a Pool's warm machines.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct PoolWarm {
    /// Optional floor over automatic demand sizing; defaults to zero.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub min: i32,
    /// Optional ceiling over automatic demand sizing; zero uses the deployment limit.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub max: i32,
}

/// The request of ReadLeaseFile.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ReadLeaseFileRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The absolute path in the guest.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub path: String,
}

/// The response of ReadLeaseFile.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ReadLeaseFileResponse {
    /// The file's bytes.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub content: String,
    /// The file mode bits.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub mode: i32,
}

/// Region is a rectangle in logical display pixels.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Region {
    /// Left edge.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub x: i32,
    /// Top edge.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub y: i32,
    /// Width.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub width: i32,
    /// Height.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub height: i32,
}

/// The request of ReleaseLeaseControl.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ReleaseLeaseControlRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The epoch AcquireLeaseControl returned.
    ///
    /// Field behavior: `required`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64"
    )]
    pub epoch: i64,
}

/// The request of ReleaseLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ReleaseLeaseRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// Act only if the current etag matches.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub etag: String,
    /// Validate without acting.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// The request of RemoveLeaseFile.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct RemoveLeaseFileRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The absolute path in the guest.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub path: String,
}

/// The response of RemoveLeaseFile.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct RemoveLeaseFileResponse {}

/// The request of RenewLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct RenewLeaseRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The new time to live from now.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub ttl: String,
    /// Act only if the current etag matches.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub etag: String,
    /// Validate without acting.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// The request of ResumeLease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ResumeLeaseRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// Act only if the current etag matches.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub etag: String,
    /// Validate without acting.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// Screenshot is an encoded capture.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Screenshot {
    /// The encoded image.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub data: String,
    /// `image/png`, `image/jpeg`, or `image/webp`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "mediaType"
    )]
    pub media_type: String,
    /// Image width in pixels.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub width: i32,
    /// Image height in pixels.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub height: i32,
    /// The display's logical width; divide to map image pixels to action
    /// coordinates.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "displayWidth"
    )]
    pub display_width: i32,
    /// The display's logical height.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "displayHeight"
    )]
    pub display_height: i32,
    /// When it was captured.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "captureTime"
    )]
    pub capture_time: String,
}

/// ScreenshotAction captures the display into this action's result.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ScreenshotAction {
    /// How to encode it.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub options: Option<ScreenshotOptions>,
}

/// ScreenshotOptions says how a screenshot is encoded.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ScreenshotOptions {
    /// Default PNG.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub format: Option<ImageFormat>,
    /// JPEG and WebP quality 1 to 100; default 80.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub quality: i32,
    /// Downscale to at most this width, keeping the aspect ratio; 0 keeps the
    /// display size.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "maxWidth"
    )]
    pub max_width: i32,
    /// Wait this long after the last action before capturing, so the screen
    /// settles; default 300 ms, at most 5 seconds.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub settle: String,
}

/// ScrollAction scrolls at a position. Positive `delta_y` scrolls down,
/// positive `delta_x` right.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ScrollAction {
    /// Where; unset scrolls at the current pointer position.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub position: Option<Point>,
    /// Horizontal amount in `unit`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "deltaX"
    )]
    pub delta_x: i32,
    /// Vertical amount in `unit`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "deltaY"
    )]
    pub delta_y: i32,
    /// Default CLICKS (wheel notches, Anthropic `scroll_amount`); PIXELS (OpenAI
    /// `scroll_x`/`scroll_y`) are converted at 100 pixels per notch on desktops.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unit: Option<ScrollUnit>,
    /// Keys held during the scroll, xdotool names.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub modifiers: Vec<String>,
}

/// The request of SetLeaseNetwork.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct SetLeaseNetworkRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The new outbound policy; replaces the old one whole.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub network: Option<LeaseNetwork>,
}

/// A Shape is one entry of the platform's machine catalog: OS, size, the cell
/// capability it needs, and its lease bounds. The catalog is read-only; adding
/// a shape is a Release of the catalog.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Shape {
    /// `sandbox_shapes/{shape}`.
    ///
    /// Field behavior: `identifier`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// `shp_<cell><ulid>`; never reused.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub uid: String,
    /// Resource metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub meta: Option<crate::common::ResourceMeta>,
    /// The operating system.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub os: Option<ShapeOs>,
    /// vCPUs; for a whole host, its cores.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "vcpuCount"
    )]
    pub vcpu_count: i32,
    /// Memory in MiB.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "memoryMib"
    )]
    pub memory_mib: i32,
    /// Disk in GiB.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "diskGib"
    )]
    pub disk_gib: i32,
    /// The cell capability Placement matches, for example `kata` or `macos`.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub capability: String,
    /// The shortest lease; 24 hours for macOS.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "minLeaseDuration"
    )]
    pub min_lease_duration: String,
    /// The longest lease.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "maxLeaseDuration"
    )]
    pub max_lease_duration: String,
    /// Whether the shape is sold now. A lease of an unsold shape is refused
    /// SHAPE_NOT_OFFERED.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub offered: bool,
    /// The list price of one second of this shape, in millionths of a US
    /// dollar; 0 for a class that is not priced. `spec.budget.max_cost_micros` is
    /// measured against it; the invoice is Sylphx Billing's.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "priceMicrosPerSecond"
    )]
    pub price_micros_per_second: i64,
    /// The lease kinds this shape can serve.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub kinds: Vec<LeaseKind>,
    /// The offered Simulator toolchain; present only on an iOS shape.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub simulator: Option<SimulatorRuntime>,
}

/// A Simulator toolchain offered by an immutable macOS layer.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct SimulatorRuntime {
    /// Simulator runtime identifier, for example com.apple.CoreSimulator.SimRuntime.iOS-26-2.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "runtimeId"
    )]
    pub runtime_id: String,
    /// The installed iOS release.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "osVersion"
    )]
    pub os_version: String,
    /// The architecture an app must include, for example x86_64.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub architecture: String,
    /// The Xcode version and build that own this runtime.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "xcodeVersion"
    )]
    pub xcode_version: String,
    /// Offered CoreSimulator device type identifiers.
    #[serde(default, skip_serializing_if = "Vec::is_empty", alias = "deviceModels")]
    pub device_models: Vec<String>,
}

/// A Snapshot is a lease's disk and image captured at one moment. A lease
/// created with `source_snapshot` boots from it. Process memory is not
/// captured.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Snapshot {
    /// `orgs/{org}/projects/{project}/envs/{env}/snapshots/{snapshot}`.
    ///
    /// Field behavior: `identifier`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// `snp_<cell><ulid>`; never reused.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub uid: String,
    /// Resource metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub meta: Option<crate::common::ResourceMeta>,
    /// Desired state.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub spec: Option<SnapshotSpec>,
    /// Observed state.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub status: Option<SnapshotStatus>,
}

/// SnapshotSpec is the caller-writable state of a Snapshot.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct SnapshotSpec {
    /// The running lease to capture.
    ///
    /// Field behavior: `required`, `immutable`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "sourceLease"
    )]
    pub source_lease: String,
    /// Capture process memory too. Refused UNIMPLEMENTED until the microVM
    /// runtime exposes memory snapshots.
    ///
    /// Field behavior: `immutable`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "includeMemory"
    )]
    pub include_memory: bool,
    /// Delete the snapshot after this long; default 7 days, at most 30 days.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub retention: String,
}

/// SnapshotStatus is the observed state of a Snapshot.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct SnapshotStatus {
    /// The generation this status was computed from.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "observedGeneration"
    )]
    pub observed_generation: i64,
    /// Ready, Reconciling, Stalled.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub conditions: Vec<crate::common::Condition>,
    /// The state machine.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub state: Option<SnapshotState>,
    /// The source lease's shape.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub shape: String,
    /// The source lease's image, by digest.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub image: String,
    /// The source lease's kind.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind: Option<LeaseKind>,
    /// Captured bytes.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "sizeBytes"
    )]
    pub size_bytes: i64,
    /// When the snapshot is deleted.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "expireTime"
    )]
    pub expire_time: String,
}

/// StreamSession is how a browser or webview connects to a lease's display.
/// The token is short-lived, bound to the lease and its generation, and never
/// contains an Access key; stream traffic is never recorded or logged.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct StreamSession {
    /// VIEWER (frames) or CONTROLLER (frames and input).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub role: Option<StreamRole>,
    /// The stream token.
    ///
    /// Field behavior: `sensitive`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub token: String,
    /// An embeddable page (web, Telegram Mini App webview) that connects on
    /// load; the token rides in the URL fragment and never reaches a server log.
    ///
    /// Field behavior: `sensitive`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "viewerUri"
    )]
    pub viewer_uri: String,
    /// The WebRTC signaling WebSocket; send the token as the first message.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "signalingUri"
    )]
    pub signaling_uri: String,
    /// ICE servers, TURN credentials included, valid until `expire_time`.
    #[serde(default, skip_serializing_if = "Vec::is_empty", alias = "iceServers")]
    pub ice_servers: Vec<IceServer>,
    /// The noVNC/websockify fallback WebSocket for networks that block WebRTC.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "vncUri"
    )]
    pub vnc_uri: String,
    /// When the token stops admitting new connections.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "expireTime"
    )]
    pub expire_time: String,
    /// The lease generation the token is bound to.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "leaseGeneration"
    )]
    pub lease_generation: i64,
    /// For CONTROLLER: the control epoch the token is bound to.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "controlEpoch"
    )]
    pub control_epoch: i64,
    /// Revokes the token early: `POST` it with the token as bearer.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "revokeUri"
    )]
    pub revoke_uri: String,
}

/// TypeAction types Unicode text, including CJK and emoji.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct TypeAction {
    /// The text; at most 64 KiB.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub text: String,
    /// Delay between keystrokes; default 12 ms.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "keystrokeDelay"
    )]
    pub keystroke_delay: String,
}

/// The request of UpdatePool.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct UpdatePoolRequest {
    /// The pool to update; `name` identifies it.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pool: Option<Pool>,
    /// The fields to write; unset writes every populated field.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "updateMask"
    )]
    pub update_mask: String,
    /// Create the Resource when it does not exist (declarative upsert).
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "allowMissing"
    )]
    pub allow_missing: bool,
    /// Validate and return the result without writing anything.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// The request of UpdateVolume.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct UpdateVolumeRequest {
    /// The volume to update; `name` identifies it.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub volume: Option<Volume>,
    /// The fields to write; unset writes every populated field.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "updateMask"
    )]
    pub update_mask: String,
    /// Validate and return the result without writing anything.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "validateOnly"
    )]
    pub validate_only: bool,
}

/// A Volume is a persistent disk scoped to one environment, encrypted at rest
/// unless its class is `local`, attached by name when a lease is created. It has one writer: the lease it is
/// attached to, fenced by that lease's generation. It survives the lease's end
/// and is destroyed only by Delete.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct Volume {
    /// `orgs/{org}/projects/{project}/envs/{env}/volumes/{volume}`.
    ///
    /// Field behavior: `identifier`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// `vol_<cell><ulid>`; never reused.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub uid: String,
    /// Resource metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub meta: Option<crate::common::ResourceMeta>,
    /// Desired state.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub spec: Option<VolumeSpec>,
    /// Observed state.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub status: Option<VolumeStatus>,
}

/// VolumeMount attaches a Volume to a lease.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct VolumeMount {
    /// The volume.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub volume: String,
    /// The absolute guest path; default `/home/user/volumes/{volume id}`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "mountPath"
    )]
    pub mount_path: String,
    /// Mount read-only.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "readOnly"
    )]
    pub read_only: bool,
}

/// VolumeSpec is the caller-writable state of a Volume.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct VolumeSpec {
    /// Size in GiB, 1 to 1024; it may grow and never shrink. A `local` volume
    /// never grows.
    ///
    /// Field behavior: `required`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "sizeGib"
    )]
    pub size_gib: i32,
    /// The storage class; unset means `standard`.
    /// `standard`: replicated network storage, encrypted at rest with its own
    /// key, attachable on any node.
    /// `local`: fast node-local storage, not replicated, for warm build
    /// workspaces. The guest gets it as an ext4 filesystem it formats on first
    /// use. It pins every lease that attaches it to its node, is not encrypted at
    /// rest, cannot grow, cannot be mounted read-only, and is lost with its node:
    /// keep only caches on it.
    ///
    /// Field behavior: `immutable`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "storageClass"
    )]
    pub storage_class: String,
    /// The region whose Cell holds the volume; default the project's home
    /// region. A lease mounts the volume only in the same region.
    ///
    /// Field behavior: `immutable`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub region: String,
}

/// VolumeStatus is the observed state of a Volume.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct VolumeStatus {
    /// The generation this status was computed from.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "observedGeneration"
    )]
    pub observed_generation: i64,
    /// Ready, Reconciling, Stalled.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub conditions: Vec<crate::common::Condition>,
    /// The state machine.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub state: Option<VolumeState>,
    /// The lease the volume is attached to.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        alias = "attachedLease"
    )]
    pub attached_lease: String,
    /// The generation of `attached_lease` that holds the write fence.
    ///
    /// Field behavior: `output_only`.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "attachedGeneration"
    )]
    pub attached_generation: i64,
    /// Whether the volume is encrypted at rest with its own key: true for
    /// `standard`, false for `local`.
    ///
    /// Field behavior: `output_only`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub encrypted: bool,
}

/// WaitAction sleeps.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct WaitAction {
    /// How long; at most 30 seconds.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub duration: String,
}

/// The request of WriteLeaseFile.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct WriteLeaseFileRequest {
    /// The name of the lease.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub name: String,
    /// The absolute path in the guest.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub path: String,
    /// The file's bytes.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub content: String,
    /// The file mode bits; default 0644.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub mode: i32,
    /// Append `content` to the file (created when absent) instead of replacing
    /// it, so a file larger than one call uploads in chunks.
    #[serde(default, skip_serializing_if = "crate::runtime::is_default")]
    pub append: bool,
}

/// The response of WriteLeaseFile.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct WriteLeaseFileResponse {
    /// Bytes written.
    #[serde(
        default,
        skip_serializing_if = "crate::runtime::is_default",
        with = "crate::runtime::int64",
        alias = "sizeBytes"
    )]
    pub size_bytes: i64,
}

/// ZoomAction captures one region of the display.
#[derive(Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct ZoomAction {
    /// The region, in display pixels.
    ///
    /// Field behavior: `required`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub region: Option<Region>,
    /// How to encode it; the region is scaled to `options.max_width` when set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub options: Option<ScreenshotOptions>,
}

/// ControlHolder is who holds a lease's input control.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ControlHolder {
    /// An agent holds control; a human acquire preempts it.
    Agent,
    /// A human holds control; agent actions and screenshots are refused.
    Human,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl ControlHolder {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Agent => "agent",
            Self::Human => "human",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "agent" => Self::Agent,
            "human" => Self::Human,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for ControlHolder {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for ControlHolder {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for ControlHolder {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// EgressPolicy is a lease's outbound rule.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum EgressPolicy {
    /// Any public destination.
    Allow,
    /// No destination.
    Deny,
    /// Only `allowed_domains` and `allowed_cidrs`.
    Allowlist,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl EgressPolicy {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Allow => "allow",
            Self::Deny => "deny",
            Self::Allowlist => "allowlist",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "allow" => Self::Allow,
            "deny" => Self::Deny,
            "allowlist" => Self::Allowlist,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for EgressPolicy {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for EgressPolicy {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for EgressPolicy {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// EndReason is why a lease ended.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum EndReason {
    /// Released by a caller.
    Released,
    /// Reached `expire_time` (the wall-time budget).
    Expired,
    /// No activity for `idle_timeout`.
    Idle,
    /// Reached `budget.max_cpu_seconds`.
    CpuBudget,
    /// Reached `budget.max_cost_micros`.
    CostBudget,
    /// Terminated for mining or similar abuse.
    Abuse,
    /// The org exceeded its quota or spend limit.
    Quota,
    /// The org was deleted.
    OrgDeleted,
    /// The machine was lost.
    MachineLost,
    /// The machine failed to boot.
    BootFailed,
    /// Other work reclaimed the machine's room: a build shape runs only on idle
    /// capacity, so the run can simply start again.
    Preempted,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl EndReason {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Released => "released",
            Self::Expired => "expired",
            Self::Idle => "idle",
            Self::CpuBudget => "cpu_budget",
            Self::CostBudget => "cost_budget",
            Self::Abuse => "abuse",
            Self::Quota => "quota",
            Self::OrgDeleted => "org_deleted",
            Self::MachineLost => "machine_lost",
            Self::BootFailed => "boot_failed",
            Self::Preempted => "preempted",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "released" => Self::Released,
            "expired" => Self::Expired,
            "idle" => Self::Idle,
            "cpu_budget" => Self::CpuBudget,
            "cost_budget" => Self::CostBudget,
            "abuse" => Self::Abuse,
            "quota" => Self::Quota,
            "org_deleted" => Self::OrgDeleted,
            "machine_lost" => Self::MachineLost,
            "boot_failed" => Self::BootFailed,
            "preempted" => Self::Preempted,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for EndReason {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for EndReason {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for EndReason {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// ImageFormat is a screenshot encoding.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ImageFormat {
    /// PNG.
    Png,
    /// JPEG.
    Jpeg,
    /// WebP.
    Webp,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl ImageFormat {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Png => "png",
            Self::Jpeg => "jpeg",
            Self::Webp => "webp",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "png" => Self::Png,
            "jpeg" => Self::Jpeg,
            "webp" => Self::Webp,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for ImageFormat {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for ImageFormat {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for ImageFormat {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// LeaseEventKind is what a LeaseEvent records.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum LeaseEventKind {
    /// A machine was assigned.
    Granted,
    /// The guest became ready.
    Ready,
    /// The lease was refused.
    Refused,
    /// The lease ended; `end_reason` and final `usage` are set.
    Ended,
    /// `expire_time` moved.
    Renewed,
    /// The outbound policy changed.
    NetworkChanged,
    /// Control was acquired.
    ControlAcquired,
    /// Control was released by its holder.
    ControlReleased,
    /// Control reached its time limit in the Cell.
    ControlExpired,
    /// A budget reached 80 % of its bound.
    BudgetWarning,
    /// The lease was paused.
    Paused,
    /// The lease was resumed.
    Resumed,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl LeaseEventKind {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Granted => "granted",
            Self::Ready => "ready",
            Self::Refused => "refused",
            Self::Ended => "ended",
            Self::Renewed => "renewed",
            Self::NetworkChanged => "network_changed",
            Self::ControlAcquired => "control_acquired",
            Self::ControlReleased => "control_released",
            Self::ControlExpired => "control_expired",
            Self::BudgetWarning => "budget_warning",
            Self::Paused => "paused",
            Self::Resumed => "resumed",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "granted" => Self::Granted,
            "ready" => Self::Ready,
            "refused" => Self::Refused,
            "ended" => Self::Ended,
            "renewed" => Self::Renewed,
            "network_changed" => Self::NetworkChanged,
            "control_acquired" => Self::ControlAcquired,
            "control_released" => Self::ControlReleased,
            "control_expired" => Self::ControlExpired,
            "budget_warning" => Self::BudgetWarning,
            "paused" => Self::Paused,
            "resumed" => Self::Resumed,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for LeaseEventKind {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for LeaseEventKind {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for LeaseEventKind {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// LeaseKind is what a lease's machine serves.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum LeaseKind {
    /// Exec, files, and processes.
    General,
    /// A desktop with Chromium on it, over CDP and computer actions.
    Browser,
    /// A Linux desktop: computer actions, streams, and takeover.
    Desktop,
    /// An Android device: the same actions (tap is click, swipe is drag), adb,
    /// streams, and takeover.
    Android,
    /// An iOS Simulator in an isolated macOS VM, with simctl and XCTest.
    Ios,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl LeaseKind {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::General => "general",
            Self::Browser => "browser",
            Self::Desktop => "desktop",
            Self::Android => "android",
            Self::Ios => "ios",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "general" => Self::General,
            "browser" => Self::Browser,
            "desktop" => Self::Desktop,
            "android" => Self::Android,
            "ios" => Self::Ios,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for LeaseKind {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for LeaseKind {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for LeaseKind {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// LeaseRefusal is the typed reason a lease was not granted. There is no global
/// queue: a lease is granted now or refused.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum LeaseRefusal {
    /// No warm machine and no free cold-boot slot now; retry later.
    NoCapacity,
    /// No Cell offers the shape's capability in the region.
    NoMatchingCell,
    /// The shape is not sold, for example macOS before Apple hardware exists.
    ShapeNotOffered,
    /// The org's plan does not include the shape.
    ShapeNotEntitled,
    /// The image is not a known template or Kernel Artifact.
    ImageNotFound,
    /// The principal is held for abuse.
    AbuseHold,
    /// The Cell could not be reached or failed to answer; retry later. This is
    /// not evidence that its machine capacity is exhausted.
    Unavailable,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl LeaseRefusal {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::NoCapacity => "no_capacity",
            Self::NoMatchingCell => "no_matching_cell",
            Self::ShapeNotOffered => "shape_not_offered",
            Self::ShapeNotEntitled => "shape_not_entitled",
            Self::ImageNotFound => "image_not_found",
            Self::AbuseHold => "abuse_hold",
            Self::Unavailable => "unavailable",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "no_capacity" => Self::NoCapacity,
            "no_matching_cell" => Self::NoMatchingCell,
            "shape_not_offered" => Self::ShapeNotOffered,
            "shape_not_entitled" => Self::ShapeNotEntitled,
            "image_not_found" => Self::ImageNotFound,
            "abuse_hold" => Self::AbuseHold,
            "unavailable" => Self::Unavailable,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for LeaseRefusal {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for LeaseRefusal {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for LeaseRefusal {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// LeaseState is the lease state machine (sandboxes-e2b.md §5.4).
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum LeaseState {
    /// Accepted; not yet matched to a machine.
    Requested,
    /// A machine is assigned; the guest is not ready.
    Granted,
    /// The guest is ready.
    Ready,
    /// Paused; resuming grants a machine again.
    Paused,
    /// Ending: the machine is being destroyed.
    Ending,
    /// Ended; the machine is destroyed and never leased again.
    Ended,
    /// Refused at grant; see `refusal`.
    Refused,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl LeaseState {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Requested => "requested",
            Self::Granted => "granted",
            Self::Ready => "ready",
            Self::Paused => "paused",
            Self::Ending => "ending",
            Self::Ended => "ended",
            Self::Refused => "refused",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "requested" => Self::Requested,
            "granted" => Self::Granted,
            "ready" => Self::Ready,
            "paused" => Self::Paused,
            "ending" => Self::Ending,
            "ended" => Self::Ended,
            "refused" => Self::Refused,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for LeaseState {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for LeaseState {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for LeaseState {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// MouseButton is a pointer button.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum MouseButton {
    /// Left.
    Left,
    /// Right.
    Right,
    /// Middle (OpenAI `wheel`).
    Middle,
    /// Back.
    Back,
    /// Forward.
    Forward,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl MouseButton {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Left => "left",
            Self::Right => "right",
            Self::Middle => "middle",
            Self::Back => "back",
            Self::Forward => "forward",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "left" => Self::Left,
            "right" => Self::Right,
            "middle" => Self::Middle,
            "back" => Self::Back,
            "forward" => Self::Forward,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for MouseButton {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for MouseButton {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for MouseButton {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// PortVisibility is who can reach a lease port.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum PortVisibility {
    /// A lease token or an Access key with `sandboxes:exec`.
    Private,
    /// Anyone; rate limited and marked on the lease.
    Public,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl PortVisibility {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Private => "private",
            Self::Public => "public",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "private" => Self::Private,
            "public" => Self::Public,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for PortVisibility {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for PortVisibility {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for PortVisibility {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// ScrollUnit is the unit of a scroll amount.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ScrollUnit {
    /// Wheel notches.
    Clicks,
    /// Pixels.
    Pixels,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl ScrollUnit {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Clicks => "clicks",
            Self::Pixels => "pixels",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "clicks" => Self::Clicks,
            "pixels" => Self::Pixels,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for ScrollUnit {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for ScrollUnit {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for ScrollUnit {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// ShapeOs is the operating system of a shape.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ShapeOs {
    /// A Linux microVM in a `kata` cell.
    Linux,
    /// A whole Apple-hardware host in a `macos` cell.
    Macos,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl ShapeOs {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Linux => "linux",
            Self::Macos => "macos",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "linux" => Self::Linux,
            "macos" => Self::Macos,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for ShapeOs {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for ShapeOs {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for ShapeOs {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// SnapshotState is the snapshot state machine.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum SnapshotState {
    /// Being captured.
    Creating,
    /// Ready to boot a lease from.
    Ready,
    /// Capture failed.
    Failed,
    /// Being deleted.
    Deleting,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl SnapshotState {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Creating => "creating",
            Self::Ready => "ready",
            Self::Failed => "failed",
            Self::Deleting => "deleting",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "creating" => Self::Creating,
            "ready" => Self::Ready,
            "failed" => Self::Failed,
            "deleting" => Self::Deleting,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for SnapshotState {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for SnapshotState {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for SnapshotState {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// StreamRole is what a stream token admits.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum StreamRole {
    /// Frames only.
    Viewer,
    /// Frames and input; minted only by AcquireLeaseControl for the holder.
    Controller,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl StreamRole {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Viewer => "viewer",
            Self::Controller => "controller",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "viewer" => Self::Viewer,
            "controller" => Self::Controller,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for StreamRole {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for StreamRole {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for StreamRole {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// TokenScope is what a lease token admits.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum TokenScope {
    /// The guest daemon: exec, files, processes.
    Guest,
    /// Guest ports.
    Ports,
    /// The CDP endpoint.
    Cdp,
    /// Computer actions (subject to control).
    Computer,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl TokenScope {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Guest => "guest",
            Self::Ports => "ports",
            Self::Cdp => "cdp",
            Self::Computer => "computer",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "guest" => Self::Guest,
            "ports" => Self::Ports,
            "cdp" => Self::Cdp,
            "computer" => Self::Computer,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for TokenScope {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for TokenScope {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for TokenScope {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

/// VolumeState is the volume state machine.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum VolumeState {
    /// Being provisioned.
    Creating,
    /// Ready and not attached.
    Available,
    /// Attached to `attached_lease`.
    Attached,
    /// Being destroyed.
    Deleting,
    /// Provisioning failed.
    Failed,
    /// A value this SDK version does not know.
    Unknown(String),
}

impl VolumeState {
    /// The wire string.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Creating => "creating",
            Self::Available => "available",
            Self::Attached => "attached",
            Self::Deleting => "deleting",
            Self::Failed => "failed",
            Self::Unknown(s) => s.as_str(),
        }
    }

    /// Parses a wire string; unknown values are kept.
    pub fn from_wire(s: &str) -> Self {
        match s {
            "creating" => Self::Creating,
            "available" => Self::Available,
            "attached" => Self::Attached,
            "deleting" => Self::Deleting,
            "failed" => Self::Failed,
            other => Self::Unknown(other.to_string()),
        }
    }
}

impl serde::Serialize for VolumeState {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        s.serialize_str(self.as_str())
    }
}

impl<'de> serde::Deserialize<'de> for VolumeState {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        let s = <String as serde::Deserialize>::deserialize(d)?;
        Ok(Self::from_wire(&s))
    }
}

impl crate::runtime::QueryValue for VolumeState {
    fn query_value(&self) -> Option<String> {
        Some(self.as_str().to_string())
    }
}

impl<T: crate::runtime::Transport> crate::runtime::Client<T> {
    /// Sylphx Sandboxes (`preview`).
    pub fn sandboxes(&self) -> SandboxesApi<'_, T> {
        SandboxesApi { client: self }
    }
}

/// SandboxesService is Sylphx Sandboxes: isolated machines leased for a bounded
/// time, granted immediately or refused with a typed reason, and destroyed
/// before anyone else can touch them.
/// Every agent-computer surface is here: exec and files, computer actions that
/// map one-to-one onto the Anthropic computer tool and OpenAI computer-use
/// actions and return the post-action screenshot in the same call, CDP, live
/// streams, and human takeover. The streaming guest protocol (E2B envd) is
/// served at `status.endpoints.guest_uri`.
///
/// Namespace of Sylphx Sandboxes on the client.
pub struct SandboxesApi<'a, T> {
    client: &'a crate::runtime::Client<T>,
}

impl<'a, T: crate::runtime::Transport> SandboxesApi<'a, T> {
    /// The `sandbox_shapes` collection.
    pub fn sandbox_shapes(&self) -> SandboxShapesCollection<'a, T> {
        SandboxShapesCollection {
            client: self.client,
        }
    }

    /// The `pools` collection.
    pub fn pools(&self) -> PoolsCollection<'a, T> {
        PoolsCollection {
            client: self.client,
        }
    }

    /// The `leases` collection.
    pub fn leases(&self) -> LeasesCollection<'a, T> {
        LeasesCollection {
            client: self.client,
        }
    }

    /// The `lease_events` collection.
    pub fn lease_events(&self) -> LeaseEventsCollection<'a, T> {
        LeaseEventsCollection {
            client: self.client,
        }
    }

    /// The `volumes` collection.
    pub fn volumes(&self) -> VolumesCollection<'a, T> {
        VolumesCollection {
            client: self.client,
        }
    }

    /// The `snapshots` collection.
    pub fn snapshots(&self) -> SnapshotsCollection<'a, T> {
        SnapshotsCollection {
            client: self.client,
        }
    }
}

/// `sandbox_shapes` of Sylphx Sandboxes: Resource type `sandboxes.sylphx.com/Shape`.
pub struct SandboxShapesCollection<'a, T> {
    client: &'a crate::runtime::Client<T>,
}

impl<'a, T: crate::runtime::Transport> SandboxShapesCollection<'a, T> {
    /// Gets a shape.
    ///
    /// `GET /v1/{name=sandbox_shapes/*}` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
    pub async fn get(&self, request: GetShapeRequest) -> Result<Shape, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(&request.name, "sandbox_shapes/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Lists shapes.
    ///
    /// `GET /v1/sandbox_shapes` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
    pub async fn list(
        &self,
        request: ListSandboxShapesRequest,
    ) -> Result<ListSandboxShapesResponse, crate::runtime::Error> {
        let path = "/v1/sandbox_shapes".to_string();
        let mut query = crate::runtime::Query::default();
        query.push("page_size", &request.page_size);
        query.push("page_token", &request.page_token);
        query.push("filter", &request.filter);
        query.push("order_by", &request.order_by);
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Every page of [`Self::list`], collected.
    pub async fn list_all(
        &self,
        mut request: ListSandboxShapesRequest,
    ) -> Result<Vec<Shape>, crate::runtime::Error> {
        let mut items = Vec::new();
        loop {
            let page = self.list(request.clone()).await?;
            items.extend(page.sandbox_shapes);
            if page.next_page_token.is_empty() {
                return Ok(items);
            }
            request.page_token = page.next_page_token;
        }
    }
}

/// `pools` of Sylphx Sandboxes: Resource type `sandboxes.sylphx.com/Pool`.
pub struct PoolsCollection<'a, T> {
    client: &'a crate::runtime::Client<T>,
}

impl<'a, T: crate::runtime::Transport> PoolsCollection<'a, T> {
    /// Gets a pool.
    ///
    /// `GET /v1/{name=orgs/*/projects/*/envs/*/pools/*}` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
    pub async fn get(&self, request: GetPoolRequest) -> Result<Pool, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/pools/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Lists pools in a environment.
    ///
    /// `GET /v1/{parent=orgs/*/projects/*/envs/*}/pools` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
    pub async fn list(
        &self,
        request: ListPoolsRequest,
    ) -> Result<ListPoolsResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/pools",
            crate::runtime::path_param(&request.parent, "orgs/*/projects/*/envs/*", "parent")?
        );
        let mut query = crate::runtime::Query::default();
        query.push("page_size", &request.page_size);
        query.push("page_token", &request.page_token);
        query.push("filter", &request.filter);
        query.push("order_by", &request.order_by);
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Every page of [`Self::list`], collected.
    pub async fn list_all(
        &self,
        mut request: ListPoolsRequest,
    ) -> Result<Vec<Pool>, crate::runtime::Error> {
        let mut items = Vec::new();
        loop {
            let page = self.list(request.clone()).await?;
            items.extend(page.pools);
            if page.next_page_token.is_empty() {
                return Ok(items);
            }
            request.page_token = page.next_page_token;
        }
    }

    /// Creates a pool. The Operation is done when the controller settles it.
    ///
    /// `POST /v1/{parent=orgs/*/projects/*/envs/*}/pools` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `RESOURCE_ALREADY_EXISTS`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `PLAN_LIMIT_REACHED`, `SPEND_LIMIT_REACHED`.
    pub async fn create(
        &self,
        request: CreatePoolRequest,
    ) -> Result<crate::runtime::Operation<'a, T, Pool>, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/pools",
            crate::runtime::path_param(&request.parent, "orgs/*/projects/*/envs/*", "parent")?
        );
        let mut query = crate::runtime::Query::default();
        query.push("pool_id", &request.pool_id);
        query.push("validate_only", &request.validate_only);
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body(&request.pool)?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        let operation = self.client.call(http).await?;
        Ok(crate::runtime::Operation::new(self.client, operation))
    }

    /// Updates a pool.
    ///
    /// `PATCH /v1/{pool.name=orgs/*/projects/*/envs/*/pools/*}` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `ETAG_MISMATCH`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn update(
        &self,
        request: UpdatePoolRequest,
    ) -> Result<crate::runtime::Operation<'a, T, Pool>, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(
                request.pool.as_ref().map(|v| v.name.as_str()).unwrap_or(""),
                "orgs/*/projects/*/envs/*/pools/*",
                "pool.name"
            )?
        );
        let mut query = crate::runtime::Query::default();
        query.push("update_mask", &request.update_mask);
        query.push("allow_missing", &request.allow_missing);
        query.push("validate_only", &request.validate_only);
        let http = crate::runtime::HttpRequest {
            method: "PATCH",
            path,
            query: query.0,
            body: Some(crate::runtime::body(&request.pool)?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        let operation = self.client.call(http).await?;
        Ok(crate::runtime::Operation::new(self.client, operation))
    }

    /// Deletes a pool.
    ///
    /// `DELETE /v1/{name=orgs/*/projects/*/envs/*/pools/*}` · permission `sandboxes:write` · effect `destructive`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn delete(
        &self,
        request: DeletePoolRequest,
    ) -> Result<crate::runtime::Operation<'a, T, crate::runtime::Empty>, crate::runtime::Error>
    {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/pools/*", "name")?
        );
        let mut query = crate::runtime::Query::default();
        query.push("etag", &request.etag);
        query.push("allow_missing", &request.allow_missing);
        query.push("validate_only", &request.validate_only);
        let http = crate::runtime::HttpRequest {
            method: "DELETE",
            path,
            query: query.0,
            body: None,
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        let operation = self.client.call(http).await?;
        Ok(crate::runtime::Operation::new(self.client, operation))
    }
}

/// `leases` of Sylphx Sandboxes: Resource type `sandboxes.sylphx.com/Lease`.
pub struct LeasesCollection<'a, T> {
    client: &'a crate::runtime::Client<T>,
}

impl<'a, T: crate::runtime::Transport> LeasesCollection<'a, T> {
    /// Gets a lease.
    ///
    /// `GET /v1/{name=orgs/*/projects/*/envs/*/leases/*}` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
    pub async fn get(&self, request: GetLeaseRequest) -> Result<Lease, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Lists leases in a environment. Filter on `meta.labels` (for example
    /// `labels.agent = "a_123"`), `status.state`, and `spec.kind`.
    ///
    /// `GET /v1/{parent=orgs/*/projects/*/envs/*}/leases` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
    pub async fn list(
        &self,
        request: ListLeasesRequest,
    ) -> Result<ListLeasesResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/leases",
            crate::runtime::path_param(&request.parent, "orgs/*/projects/*/envs/*", "parent")?
        );
        let mut query = crate::runtime::Query::default();
        query.push("page_size", &request.page_size);
        query.push("page_token", &request.page_token);
        query.push("filter", &request.filter);
        query.push("order_by", &request.order_by);
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Every page of [`Self::list`], collected.
    pub async fn list_all(
        &self,
        mut request: ListLeasesRequest,
    ) -> Result<Vec<Lease>, crate::runtime::Error> {
        let mut items = Vec::new();
        loop {
            let page = self.list(request.clone()).await?;
            items.extend(page.leases);
            if page.next_page_token.is_empty() {
                return Ok(items);
            }
            request.page_token = page.next_page_token;
        }
    }

    /// Creates a lease: granted now and returned READY (or GRANTED when
    /// `wait_ready` is false), or refused with a typed error. There is no queue.
    ///
    /// `POST /v1/{parent=orgs/*/projects/*/envs/*}/leases` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `RESOURCE_ALREADY_EXISTS`, `RESOURCE_NOT_FOUND`, `RESOURCE_IN_USE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `NO_CAPACITY`, `UNAVAILABLE`, `SHAPE_NOT_OFFERED`, `PLAN_LIMIT_REACHED`, `SPEND_LIMIT_REACHED`.
    pub async fn create(
        &self,
        request: CreateLeaseRequest,
    ) -> Result<Lease, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/leases",
            crate::runtime::path_param(&request.parent, "orgs/*/projects/*/envs/*", "parent")?
        );
        let mut query = crate::runtime::Query::default();
        query.push("lease_id", &request.lease_id);
        query.push("validate_only", &request.validate_only);
        query.push("skip_wait_ready", &request.skip_wait_ready);
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body(&request.lease)?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Extends `expire_time`, never past the shape's longest lease. Does not
    /// change the generation.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:renew` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn renew(&self, request: RenewLeaseRequest) -> Result<Lease, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:renew",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Ends a lease with END_REASON_RELEASED; the machine is destroyed and never
    /// leased again, and attached volumes are detached.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:release` · permission `sandboxes:write` · effect `destructive`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn release(
        &self,
        request: ReleaseLeaseRequest,
    ) -> Result<Lease, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:release",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Pauses a lease: its disk is kept and its machine destroyed; the
    /// generation increases. Process memory is not kept.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:pause` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `UNIMPLEMENTED`.
    pub async fn pause(&self, request: PauseLeaseRequest) -> Result<Lease, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:pause",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Resumes a paused lease on a machine granted now, or refuses it; the
    /// generation increases.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:resume` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `NO_CAPACITY`, `UNIMPLEMENTED`.
    pub async fn resume(
        &self,
        request: ResumeLeaseRequest,
    ) -> Result<Lease, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:resume",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Replaces a running lease's outbound policy. The generation does not
    /// change; the new policy applies before the call returns.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:setNetwork` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_FIELD`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn set_network(
        &self,
        request: SetLeaseNetworkRequest,
    ) -> Result<Lease, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:setNetwork",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Mints a lease token for the data plane, bound to the current generation.
    /// Hand it to a process that must not hold the Access key.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:mintToken` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn mint_token(
        &self,
        request: MintLeaseTokenRequest,
    ) -> Result<MintLeaseTokenResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:mintToken",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Dispatches one command at most once per lease and execution key. Each
    /// HTTP response waits at most 20 seconds: repeat the exact request and key
    /// after IDEMPOTENCY_IN_PROGRESS, honoring Retry-After, until the recorded
    /// result or a terminal error arrives. Pending observations do not consume
    /// the client's transient-error retry budget. Disconnect only stops waiting.
    /// Results (capped at 1 MiB per stream) remain replayable after lease expiry.
    /// An unknown outcome is never dispatched again. Interactive processes use
    /// the guest protocol at `status.endpoints.guest_uri`.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:exec` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_STATE`, `STALE_GENERATION`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `EXEC_OUTCOME_UNKNOWN`.
    pub async fn exec(
        &self,
        request: ExecLeaseRequest,
    ) -> Result<ExecLeaseResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:exec",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Requests cancellation of the existing execution key. This acknowledgement
    /// means the request was recorded, not that the process has stopped. Observe
    /// the exact original ExecLease request for its confirmed terminal result.
    /// An already completed result wins; an unknown outcome remains unknown.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:cancelExec` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `STALE_GENERATION`.
    pub async fn cancel_exec(
        &self,
        request: CancelExecLeaseRequest,
    ) -> Result<crate::runtime::Empty, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:cancelExec",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Reads one file from the lease, at most 16 MiB; larger files use the
    /// guest's `/files`.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:readFile` · permission `sandboxes:exec` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `NOT_FOUND`, `INVALID_STATE`.
    pub async fn read_file(
        &self,
        request: ReadLeaseFileRequest,
    ) -> Result<ReadLeaseFileResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:readFile",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Writes one file in the lease, at most 16 MiB, creating parent directories.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:writeFile` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn write_file(
        &self,
        request: WriteLeaseFileRequest,
    ) -> Result<WriteLeaseFileResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:writeFile",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Lists one directory in the lease.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:listFiles` · permission `sandboxes:exec` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `NOT_FOUND`, `INVALID_STATE`.
    pub async fn list_files(
        &self,
        request: ListLeaseFilesRequest,
    ) -> Result<ListLeaseFilesResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:listFiles",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Removes one file or directory tree in the lease.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:removeFile` · permission `sandboxes:exec` · effect `destructive`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn remove_file(
        &self,
        request: RemoveLeaseFileRequest,
    ) -> Result<RemoveLeaseFileResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:removeFile",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Exposes a guest port.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:openPort` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `UNIMPLEMENTED`.
    pub async fn open_port(
        &self,
        request: OpenLeasePortRequest,
    ) -> Result<Lease, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:openPort",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Stops exposing a guest port.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:closePort` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_STATE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `UNIMPLEMENTED`.
    pub async fn close_port(
        &self,
        request: CloseLeasePortRequest,
    ) -> Result<Lease, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:closePort",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Performs computer actions on a DESKTOP, BROWSER, or ANDROID lease, in
    /// order, and returns each action's result and, when `screenshot` is set,
    /// the screenshot taken after the last action. The actions are the Anthropic
    /// computer tool's and OpenAI computer use's, one-to-one
    /// (docs/services/sandboxes/computer-use.md). Refused CONTROL_HELD_BY_HUMAN
    /// while a human holds control.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:act` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_FIELD`, `INVALID_STATE`, `STALE_GENERATION`, `CONTROL_HELD`, `CONTROL_HELD_BY_HUMAN`.
    pub async fn act(
        &self,
        request: ActLeaseRequest,
    ) -> Result<ActLeaseResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:act",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Opens a read-only live view of a lease's display: a short-lived viewer
    /// token bound to the lease and its generation, an embeddable URL, and the
    /// WebRTC signaling endpoint with ICE servers. Input needs control
    /// (AcquireLeaseControl).
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:openStream` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_STATE`.
    pub async fn open_stream(
        &self,
        request: OpenLeaseStreamRequest,
    ) -> Result<StreamSession, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:openStream",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Takes exclusive input control of a lease's display. A HUMAN acquire
    /// preempts an AGENT holder and returns a controller stream; an AGENT acquire
    /// is refused CONTROL_HELD_BY_HUMAN while a human holds control. Control
    /// lapses at `ttl`, which the platform caps at 30 minutes.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:acquireControl` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_FIELD`, `INVALID_STATE`, `CONTROL_HELD`, `CONTROL_HELD_BY_HUMAN`.
    pub async fn acquire_control(
        &self,
        request: AcquireLeaseControlRequest,
    ) -> Result<AcquireLeaseControlResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:acquireControl",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Releases control held under `epoch`; its controller tokens stop working.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:releaseControl` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `STALE_GENERATION`.
    pub async fn release_control(
        &self,
        request: ReleaseLeaseControlRequest,
    ) -> Result<ControlState, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:releaseControl",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Gets who holds control of a lease's display.
    ///
    /// `GET /v1/{name=orgs/*/projects/*/envs/*/leases/*}:getControl` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
    pub async fn get_control(
        &self,
        request: GetLeaseControlRequest,
    ) -> Result<ControlState, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:getControl",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Installs an Android app (APK) on an ANDROID lease.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/leases/*}:installApp` · permission `sandboxes:exec` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_STATE`, `NOT_FOUND`, `UNIMPLEMENTED`.
    pub async fn install_app(
        &self,
        request: InstallLeaseAppRequest,
    ) -> Result<InstallLeaseAppResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:installApp",
            crate::runtime::path_param(&request.name, "orgs/*/projects/*/envs/*/leases/*", "name")?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }
}

/// `lease_events` of Sylphx Sandboxes: Resource type `sandboxes.sylphx.com/LeaseEvent`.
pub struct LeaseEventsCollection<'a, T> {
    client: &'a crate::runtime::Client<T>,
}

impl<'a, T: crate::runtime::Transport> LeaseEventsCollection<'a, T> {
    /// Gets one lease event.
    ///
    /// `GET /v1/{name=orgs/*/projects/*/envs/*/leases/*/lease_events/*}` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
    pub async fn get(
        &self,
        request: GetLeaseEventRequest,
    ) -> Result<LeaseEvent, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(
                &request.name,
                "orgs/*/projects/*/envs/*/leases/*/lease_events/*",
                "name"
            )?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Lists a lease's events in order. With `wait`, blocks up to that long
    /// for an event after `page_token` (long poll).
    ///
    /// `GET /v1/{parent=orgs/*/projects/*/envs/*/leases/*}/lease_events` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
    pub async fn list(
        &self,
        request: ListLeaseEventsRequest,
    ) -> Result<ListLeaseEventsResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/lease_events",
            crate::runtime::path_param(
                &request.parent,
                "orgs/*/projects/*/envs/*/leases/*",
                "parent"
            )?
        );
        let mut query = crate::runtime::Query::default();
        query.push("page_size", &request.page_size);
        query.push("page_token", &request.page_token);
        query.push("filter", &request.filter);
        query.push("wait", &request.wait);
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Every page of [`Self::list`], collected.
    pub async fn list_all(
        &self,
        mut request: ListLeaseEventsRequest,
    ) -> Result<Vec<LeaseEvent>, crate::runtime::Error> {
        let mut items = Vec::new();
        loop {
            let page = self.list(request.clone()).await?;
            items.extend(page.lease_events);
            if page.next_page_token.is_empty() {
                return Ok(items);
            }
            request.page_token = page.next_page_token;
        }
    }
}

/// `volumes` of Sylphx Sandboxes: Resource type `sandboxes.sylphx.com/Volume`.
pub struct VolumesCollection<'a, T> {
    client: &'a crate::runtime::Client<T>,
}

impl<'a, T: crate::runtime::Transport> VolumesCollection<'a, T> {
    /// Gets a volume.
    ///
    /// `GET /v1/{name=orgs/*/projects/*/envs/*/volumes/*}` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
    pub async fn get(&self, request: GetVolumeRequest) -> Result<Volume, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(
                &request.name,
                "orgs/*/projects/*/envs/*/volumes/*",
                "name"
            )?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Lists volumes in a environment.
    ///
    /// `GET /v1/{parent=orgs/*/projects/*/envs/*}/volumes` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
    pub async fn list(
        &self,
        request: ListVolumesRequest,
    ) -> Result<ListVolumesResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/volumes",
            crate::runtime::path_param(&request.parent, "orgs/*/projects/*/envs/*", "parent")?
        );
        let mut query = crate::runtime::Query::default();
        query.push("page_size", &request.page_size);
        query.push("page_token", &request.page_token);
        query.push("filter", &request.filter);
        query.push("order_by", &request.order_by);
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Every page of [`Self::list`], collected.
    pub async fn list_all(
        &self,
        mut request: ListVolumesRequest,
    ) -> Result<Vec<Volume>, crate::runtime::Error> {
        let mut items = Vec::new();
        loop {
            let page = self.list(request.clone()).await?;
            items.extend(page.volumes);
            if page.next_page_token.is_empty() {
                return Ok(items);
            }
            request.page_token = page.next_page_token;
        }
    }

    /// Creates a volume.
    ///
    /// `POST /v1/{parent=orgs/*/projects/*/envs/*}/volumes` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `RESOURCE_ALREADY_EXISTS`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `PLAN_LIMIT_REACHED`.
    pub async fn create(
        &self,
        request: CreateVolumeRequest,
    ) -> Result<Volume, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/volumes",
            crate::runtime::path_param(&request.parent, "orgs/*/projects/*/envs/*", "parent")?
        );
        let mut query = crate::runtime::Query::default();
        query.push("volume_id", &request.volume_id);
        query.push("validate_only", &request.validate_only);
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body(&request.volume)?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Updates a volume: grows `spec.size_gib` and edits metadata.
    ///
    /// `PATCH /v1/{volume.name=orgs/*/projects/*/envs/*/volumes/*}` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `ETAG_MISMATCH`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn update(
        &self,
        request: UpdateVolumeRequest,
    ) -> Result<Volume, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(
                request
                    .volume
                    .as_ref()
                    .map(|v| v.name.as_str())
                    .unwrap_or(""),
                "orgs/*/projects/*/envs/*/volumes/*",
                "volume.name"
            )?
        );
        let mut query = crate::runtime::Query::default();
        query.push("update_mask", &request.update_mask);
        query.push("validate_only", &request.validate_only);
        let http = crate::runtime::HttpRequest {
            method: "PATCH",
            path,
            query: query.0,
            body: Some(crate::runtime::body(&request.volume)?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Archives an idle standard workspace without changing its identity or
    /// destroying its files. Ordinary attachment restores the retained copy.
    /// Validation reports eligibility and copy coverage without changing state.
    ///
    /// `POST /v1/{name=orgs/*/projects/*/envs/*/volumes/*}:archive` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `INVALID_STATE`, `ETAG_MISMATCH`.
    pub async fn archive(
        &self,
        request: ArchiveVolumeRequest,
    ) -> Result<ArchiveVolumeResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}:archive",
            crate::runtime::path_param(
                &request.name,
                "orgs/*/projects/*/envs/*/volumes/*",
                "name"
            )?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body_without(&request, &["name"])?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Deletes a volume and destroys its data. Refused RESOURCE_IN_USE while it
    /// is attached.
    ///
    /// `DELETE /v1/{name=orgs/*/projects/*/envs/*/volumes/*}` · permission `sandboxes:write` · effect `destructive`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `RESOURCE_IN_USE`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn delete(
        &self,
        request: DeleteVolumeRequest,
    ) -> Result<Volume, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(
                &request.name,
                "orgs/*/projects/*/envs/*/volumes/*",
                "name"
            )?
        );
        let mut query = crate::runtime::Query::default();
        query.push("etag", &request.etag);
        query.push("allow_missing", &request.allow_missing);
        query.push("validate_only", &request.validate_only);
        let http = crate::runtime::HttpRequest {
            method: "DELETE",
            path,
            query: query.0,
            body: None,
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }
}

/// `snapshots` of Sylphx Sandboxes: Resource type `sandboxes.sylphx.com/Snapshot`.
pub struct SnapshotsCollection<'a, T> {
    client: &'a crate::runtime::Client<T>,
}

impl<'a, T: crate::runtime::Transport> SnapshotsCollection<'a, T> {
    /// Gets a snapshot.
    ///
    /// `GET /v1/{name=orgs/*/projects/*/envs/*/snapshots/*}` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`.
    pub async fn get(
        &self,
        request: GetSnapshotRequest,
    ) -> Result<Snapshot, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(
                &request.name,
                "orgs/*/projects/*/envs/*/snapshots/*",
                "name"
            )?
        );
        let query = crate::runtime::Query::default();
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Lists snapshots in a environment.
    ///
    /// `GET /v1/{parent=orgs/*/projects/*/envs/*}/snapshots` · permission `sandboxes:read` · effect `read`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `INVALID_FIELD`, `PAGE_TOKEN_MISMATCH`.
    pub async fn list(
        &self,
        request: ListSnapshotsRequest,
    ) -> Result<ListSnapshotsResponse, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/snapshots",
            crate::runtime::path_param(&request.parent, "orgs/*/projects/*/envs/*", "parent")?
        );
        let mut query = crate::runtime::Query::default();
        query.push("page_size", &request.page_size);
        query.push("page_token", &request.page_token);
        query.push("filter", &request.filter);
        query.push("order_by", &request.order_by);
        let http = crate::runtime::HttpRequest {
            method: "GET",
            path,
            query: query.0,
            body: None,
            mutation: false,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Every page of [`Self::list`], collected.
    pub async fn list_all(
        &self,
        mut request: ListSnapshotsRequest,
    ) -> Result<Vec<Snapshot>, crate::runtime::Error> {
        let mut items = Vec::new();
        loop {
            let page = self.list(request.clone()).await?;
            items.extend(page.snapshots);
            if page.next_page_token.is_empty() {
                return Ok(items);
            }
            request.page_token = page.next_page_token;
        }
    }

    /// Captures a running lease's disk as a snapshot.
    ///
    /// `POST /v1/{parent=orgs/*/projects/*/envs/*}/snapshots` · permission `sandboxes:write` · effect `write`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `UNKNOWN_FIELD`, `INVALID_FIELD`, `INVALID_STATE`, `RESOURCE_ALREADY_EXISTS`, `RESOURCE_NOT_FOUND`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`, `PLAN_LIMIT_REACHED`, `UNIMPLEMENTED`.
    pub async fn create(
        &self,
        request: CreateSnapshotRequest,
    ) -> Result<Snapshot, crate::runtime::Error> {
        let path = format!(
            "/v1/{}/snapshots",
            crate::runtime::path_param(&request.parent, "orgs/*/projects/*/envs/*", "parent")?
        );
        let mut query = crate::runtime::Query::default();
        query.push("snapshot_id", &request.snapshot_id);
        query.push("validate_only", &request.validate_only);
        let http = crate::runtime::HttpRequest {
            method: "POST",
            path,
            query: query.0,
            body: Some(crate::runtime::body(&request.snapshot)?),
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }

    /// Deletes a snapshot.
    ///
    /// `DELETE /v1/{name=orgs/*/projects/*/envs/*/snapshots/*}` · permission `sandboxes:write` · effect `destructive`
    ///
    /// Errors: `UNAUTHENTICATED`, `PERMISSION_DENIED`, `RESOURCE_NOT_FOUND`, `ETAG_MISMATCH`, `IDEMPOTENCY_KEY_REUSED`, `IDEMPOTENCY_IN_PROGRESS`.
    pub async fn delete(
        &self,
        request: DeleteSnapshotRequest,
    ) -> Result<Snapshot, crate::runtime::Error> {
        let path = format!(
            "/v1/{}",
            crate::runtime::path_param(
                &request.name,
                "orgs/*/projects/*/envs/*/snapshots/*",
                "name"
            )?
        );
        let mut query = crate::runtime::Query::default();
        query.push("etag", &request.etag);
        query.push("allow_missing", &request.allow_missing);
        query.push("validate_only", &request.validate_only);
        let http = crate::runtime::HttpRequest {
            method: "DELETE",
            path,
            query: query.0,
            body: None,
            mutation: true,
            origin: None,
            effect_ids: false,
        };
        self.client.call(http).await
    }
}

/// Hand-written (not generated): see `sandboxes/stream.rs`.
#[cfg(feature = "stream")]
pub mod stream;

/// Hand-written (not generated): see `sandboxes/stream_mock.rs`.
#[cfg(feature = "stream")]
pub mod stream_mock;