Skip to content

PixelClientAsync

pixel_client

PixelClientAsync

Asynchronous client for interacting with the Pixel API.

This client provides methods for working with projects, data collections, images, rasters, and other resources in the Pixel system. It handles authentication, request management, and provides high-level operations for common tasks.

Source code in src/pixel_client/_base.py
 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
class PixelClientAsync:
    """
    Asynchronous client for interacting with the Pixel API.

    This client provides methods for working with projects, data collections, images,
    rasters, and other resources in the Pixel system. It handles authentication,
    request management, and provides high-level operations for common tasks.
    """

    def __init__(
        self,
        url: str,
        keycloak_server_url: str | None = None,
        realm: str | None = None,
        client_id: str | None = None,
        username: str | None = None,
        password: str | None = None,
        api_key: str | None = None,
        timeout_pixel: httpx.Timeout = DEFAULT_PIXEL_TIMEOUT,
        timeout_upload: httpx.Timeout = DEFAULT_UPLOAD_TIMEOUT,
        upload_num_retries: int = DEFAULT_UPLOAD_RETRIES,
        upload_max_concurrency: int = DEFAULT_MAX_CONCURRENCY,
    ):
        """
        Initialize a new Pixel API client.

        The client authenticates either with Keycloak credentials
        (`keycloak_server_url`, `realm`, `client_id`, `username`, `password`) or
        with a Pixel api key (`api_key`). Provide one or the other, not both.

        Args:
            url: Base URL of the Pixel API.
            keycloak_server_url: URL of the Keycloak authentication server.
            realm: Keycloak realm name.
            client_id: Keycloak client ID.
            username: Username for authentication.
            password: Password for authentication.
            api_key: A Pixel api key, used instead of the Keycloak credentials.
            timeout_pixel: Optional timeout configuration for Pixel API requests.
            timeout_upload: Optional timeout configuration for file uploads. If not provided, defaults to the same as `timeout_pixel`.

        Raises:
            ValueError: If both an api key and Keycloak credentials are given, or if neither is.
        """
        self.url: str = url
        self._timeout_pixel = timeout_pixel
        self._timeout_upload = timeout_upload
        self.auth: httpx.Auth = self._build_auth(
            keycloak_server_url=keycloak_server_url,
            realm=realm,
            client_id=client_id,
            username=username,
            password=password,
            api_key=api_key,
        )
        self.pixel_client = httpx.AsyncClient(
            base_url=self.url, auth=self.auth, timeout=self._timeout_pixel
        )
        self._internal_client = httpx.AsyncClient(
            timeout=self._timeout_upload,  # Use a separate client for uploads
        )  # For s3 uploads
        self._semaphore: asyncio.Semaphore = asyncio.Semaphore(upload_max_concurrency)

        self._retry_policy = tenacity.AsyncRetrying(
            stop=tenacity.stop_after_attempt(upload_num_retries),
            wait=tenacity.wait_random_exponential(),
            before=tenacity.before_log(logger, logging.DEBUG),
            after=tenacity.after_log(logger, logging.DEBUG),
        )
        self._internal_client.request = self._retry_policy.wraps(
            self._internal_client.request
        )

    @staticmethod
    def _build_auth(
        keycloak_server_url: str | None,
        realm: str | None,
        client_id: str | None,
        username: str | None,
        password: str | None,
        api_key: str | None,
    ) -> httpx.Auth:
        """Pick the auth scheme from the credentials given.

        Returns:
            httpx.Auth: An ApiKeyAuth if an api key was given, otherwise a KeyCloakAuth.

        Raises:
            ValueError: If both an api key and Keycloak credentials are given, or if neither is.
        """
        keycloak_args = {
            "keycloak_server_url": keycloak_server_url,
            "realm": realm,
            "client_id": client_id,
            "username": username,
            "password": password,
        }
        given = [name for name, value in keycloak_args.items() if value is not None]
        if api_key is not None:
            if given:
                raise ValueError(
                    "Got both api_key and Keycloak credentials "
                    f"({', '.join(given)}). Provide one or the other."
                )
            return ApiKeyAuth(api_key)
        missing = [name for name, value in keycloak_args.items() if value is None]
        if missing:
            raise ValueError(
                "No api_key given, so Keycloak credentials are required. "
                f"Missing: {', '.join(missing)}."
            )
        return KeyCloakAuth(
            keycloak_server_url,  # type: ignore[arg-type]
            realm,  # type: ignore[arg-type]
            client_id,  # type: ignore[arg-type]
            username,  # type: ignore[arg-type]
            password,  # type: ignore[arg-type]
        )

    @classmethod
    def from_settings(
        cls, settings: PixelApiSettings, **kwargs: Unpack[PixelClientKwargs]
    ) -> Self:
        """
        Instantiate the client from settings.

        Args:
            settings: PixelApiSettings object containing API configuration.
            **kwargs: Additional keyword arguments to pass to the client constructor.

        Returns:
            PixelClientAsync: A new client instance configured with the provided settings.
        """
        if settings.PIXEL_API_KEY is not None:
            return cls(
                url=settings.PIXEL_API_URL,
                api_key=settings.PIXEL_API_KEY.get_secret_value(),
                **kwargs,
            )
        return cls(
            url=settings.PIXEL_API_URL,
            keycloak_server_url=settings.PIXEL_AUTH_SERVER_URL,
            client_id=settings.PIXEL_CLIENT_ID,
            username=settings.PIXEL_USERNAME,
            password=settings.PIXEL_PASSWORD.get_secret_value(),  # type: ignore[union-attr]
            realm=settings.PIXEL_REALM,
            **kwargs,
        )

    async def __aenter__(self):
        await self.pixel_client.__aenter__()
        await self._internal_client.__aenter__()
        return self

    async def __aexit__(self, exc_type, exc_value, traceback):
        await self.pixel_client.__aexit__(exc_type, exc_value, traceback)
        await self._internal_client.__aexit__(exc_type, exc_value, traceback)

    async def _make_request(self, method: str, url: str, **kwargs) -> httpx.Response:
        """
        Make an HTTP request to the Pixel API with error handling.

        Args:
            method: The HTTP method to use (GET, POST, PUT, DELETE).
            url: The URL to request, relative to the base URL.
            **kwargs: Additional arguments to pass to the request method.

        Returns:
            httpx.Response: The HTTP response object.

        Raises:
            PixelBadRequestError: If the server returns a 4xx client error with JSON response.
            httpx.HTTPStatusError: For other HTTP errors.
        """
        sensitive_content = kwargs.pop("sensitive_content", False)
        headers = kwargs.pop("headers", {})
        if "X-Request-ID" not in headers:
            headers["X-Request-ID"] = str(uuid4())
        kwargs["headers"] = headers
        response = await self.pixel_client.request(method, url, **kwargs)
        try:
            response.raise_for_status()
        except httpx.HTTPStatusError as e:
            logger.error(f"Error in request {method} {url}: {e}")
            if e.response.is_client_error:
                try:
                    response_json = e.response.json()
                except json.JSONDecodeError:
                    raise e  # If the response is not JSON, raise the original exception
                raise PixelBadRequestError(
                    response_json=response_json,
                    status_code=e.response.status_code,
                    method=method,
                    url=str(e.request.url),
                    request_id=e.response.headers.get("X-Request-ID"),
                    body=e.request.content.decode() if not sensitive_content else None,
                ) from e
            raise e
        return response

    async def _get(self, url: str, **kwargs) -> httpx.Response:
        """
        Make a GET request to the Pixel API.

        Args:
            url: The URL to request, relative to the base URL.
            **kwargs: Additional arguments to pass to the request method.

        Returns:
            httpx.Response: The HTTP response object.
        """
        return await self._make_request("GET", url, **kwargs)

    async def _post(self, url: str, **kwargs) -> httpx.Response:
        """
        Make a POST request to the Pixel API.

        Args:
            url: The URL to request, relative to the base URL.
            **kwargs: Additional arguments to pass to the request method.

        Returns:
            httpx.Response: The HTTP response object.
        """
        return await self._make_request("POST", url, **kwargs)

    async def _put(self, url: str, **kwargs) -> httpx.Response:
        """Make a PUT request to the Pixel API.

        Args:
            url: The URL to request, relative to the base URL.
            **kwargs: Additional arguments to pass to the request method.

        Returns:
            httpx.Response: The HTTP response object.
        """
        return await self._make_request("PUT", url, **kwargs)

    async def _patch(self, url: str, **kwargs) -> httpx.Response:
        """Make a PATCH request to the Pixel API.

        Args:
            url: The URL to request, relative to the base URL.
            **kwargs: Additional arguments to pass to the request method.

        Returns:
            httpx.Response: The HTTP response object.
        """
        return await self._make_request("PATCH", url, **kwargs)

    async def _delete(self, url: str, **kwargs) -> httpx.Response:
        """
        Make a DELETE request to the Pixel API.

        Args:
            url: The URL to request, relative to the base URL.
            **kwargs: Additional arguments to pass to the request method.

        Returns:
            httpx.Response: The HTTP response object.
        """
        return await self._make_request("DELETE", url, **kwargs)

    async def _paginate(
        self,
        url: str,
        page_size: int,
        method: str = "GET",
        use_body: bool = False,
        results_parser: Callable[[dict], list[dict]] | None = None,
        **kwargs,
    ) -> AsyncGenerator[dict, None]:
        """
        Internal helper function for paginating through API results.

        Args:
            url: The API endpoint URL to paginate through.
            page_size: Number of items to fetch per page.
            method: HTTP method to use for the request (default is "GET").
            use_body: Whether to use the request body for pagination parameters instead of query parameters.
            **kwargs: Additional parameters to pass to the _make_request method.
        Yields:
            dict: Individual items from the paginated results, one at a time.
        """
        params: dict = kwargs.pop("params", {})
        body: dict = kwargs.pop("json", {})
        offset: int = params.get("offset", 0) if not use_body else body.get("offset", 0)
        limit = page_size
        while True:
            new_body = {**body, "offset": offset, "limit": limit} if use_body else body
            new_params = (
                {**params, "offset": offset, "limit": limit} if not use_body else params
            )
            response = await self._make_request(
                method, url, params=new_params, json=new_body, **kwargs
            )
            data = response.json()
            if results_parser and isinstance(data, dict):
                data = results_parser(data)
            for item in data:
                yield item
            if (
                len(data) < page_size
            ):  # If the number of items is less than the page size, we are done
                break
            offset += limit

    async def me(self, extended: bool = False) -> dict:
        """
        Get information about the authenticated user.

        Args:
            extended: If True, also returns the projects you can access with your effective
                permissions on each, and your organisation-wide grants and permissions.

        Returns:
            dict: User information including username, email, and other profile details.

        Note:
            Cannot be called with an api key.
        """
        response = await self._get("/users/me", params={"extended": extended})
        return response.json()

    async def get_plugins(self) -> list[dict]:
        """
        Retrieve a list of available plugins for the pixel tenant.

        Possible plugins include:

        * `optimized_raster` - Optimize Raster capability
        * `image_service` - Image Service capability, dependent on the 'optimize_raster' plugin.

        Returns:
            list[dict]: A list of plugin objects with their details.
        """
        response = await self._get("/plugins/")
        return response.json()

    async def create_project(
        self,
        name: str,
        description: str,
        area_of_interest: Polygon,
        parent_project_id: int | None = None,
        tags: list[str] | None = None,
        groups: dict[int, RoleType] | None = None,
    ) -> dict:
        """
        Create a new project in the Pixel system.

        Args:
            name: The name of the project.
            description: A description of the project.
            area_of_interest: A GeoJSON polygon defining the project's geographic area of interest.
            parent_project_id: Optional ID of a parent project. If provided, this project will be created as a child of that project.
            tags: Optional list of tags to associate with the project.
            groups: Optional mapping of group ID to the role each group gets on the new project,
                e.g. `{3: "editor"}`. Written together with the project: either all succeed or
                nothing is created. You must be a group admin of every group listed.

        Returns:
            dict: The created project object.
        """
        body = {
            "name": name,
            "description": description,
            "area_of_interest": area_of_interest.__geo_interface__,
        }
        if parent_project_id:
            body["parent_project_id"] = parent_project_id
        if tags:
            body["tags"] = tags
        if groups:
            body["groups"] = [
                {"group_id": group_id, "role": role} for group_id, role in groups.items()
            ]
        response = await self._post("/projects/", json=body)
        return response.json()

    async def list_projects(
        self, params: ListParams | None = None, **kwargs
    ) -> list[dict]:
        """
        List projects with optional filtering.

        Args:
            params: Optional ListParams object containing filtering parameters such as offset, limit, search, etc.
            **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

        Returns:
            list[dict]: A list of project objects matching the filter criteria.
        """
        if params and kwargs:
            logger.warning("Ignoring kwargs when params is provided")
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else ListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get("/projects/", params=params_dict)
        return response.json()

    async def list_deleted_projects(
        self, params: ListParams | None = None, **kwargs
    ) -> list[dict]:
        """
        List deleted projects in the Pixel system.

        Args:
            params: Optional ListParams object containing filtering parameters such as offset, limit, search, etc.
            **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

        Returns:
            list[dict]: A list of deleted project objects.
        """
        if params and kwargs:
            logger.warning("Ignoring kwargs when params is provided")
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else ListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get("/projects/deleted", params=params_dict)
        return response.json()

    async def get_project(self, project_id: int, extended: bool = False) -> dict:
        """
        Retrieve a project by its ID.

        Args:
            project_id: The ID of the project to retrieve.
            extended: If True, returns extended project information including child projects and data collections.

        Returns:
            dict: The project object with its details.
        """
        response = await self._get(
            f"/projects/{project_id}", params={"extended": extended}
        )
        return response.json()

    async def update_project(
        self,
        project_id: int,
        name: str | None = None,
        description: str | None = None,
        area_of_interest: Polygon | None = None,
        add_tags: list[str] | None = None,
        remove_tags: list[str] | None = None,
    ) -> dict:
        """
        Update an existing project with new values.

        Args:
            project_id: The ID of the project to update.
            name: Optional new name for the project.
            description: Optional new description for the project.
            area_of_interest: Optional new GeoJSON polygon defining the project's geographic area of interest.
            add_tags: Optional list of tags to add to the project.
            remove_tags: Optional list of tags to remove from the project.

        Returns:
            dict: The updated project object.

        Raises:
            ValueError: If no update parameters are provided.
        """
        body = {}
        for param_name, value in {
            "name": name,
            "description": description,
            "area_of_interest": area_of_interest.__geo_interface__
            if area_of_interest
            else None,
            "add_tags": add_tags,
            "remove_tags": remove_tags,
        }.items():
            if value is not None:
                body[param_name] = value
        if not body:
            raise ValueError("No update parameters provided")
        response = await self._put(f"/projects/{project_id}", json=body)
        return response.json()

    async def delete_project(self, project_id: int) -> dict:
        """
        Delete a project by its ID.

        Args:
            project_id: The ID of the project to delete.

        Returns:
            dict: The response confirming deletion.
        """
        response = await self._delete(f"/projects/{project_id}")
        return response.json()

    async def restore_project(self, project_id: int) -> dict:
        """
        Restore a deleted project by its ID.

        Args:
            project_id: The ID of the project to restore.

        Returns:
            dict: The restored project object.
        """
        response = await self._post(f"/projects/{project_id}/restore")
        return response.json()

    async def move_project(
        self, project_id: int, new_parent_project_id: int | None = None
    ) -> dict:
        """
        Move a project to a new parent project or to the root level.

        Args:
            project_id: The ID of the project to move.
            new_parent_project_id: Optional ID of the new parent project. If None, the project will be moved to the root level.

        Returns:
            dict: The updated project object.
        """
        # If None is provided, set to -1 to move to root
        new_parent_project_id = new_parent_project_id or -1
        response = await self._put(
            f"/projects/{project_id}/move",
            params={"new_parent_id": new_parent_project_id},
        )
        return response.json()

    async def create_data_collection(
        self,
        project_id: int,
        name: str,
        description: str,
        data_collection_type: DataCollectionType,
        tags: list[str] | None = None,
        raster_info: RasterInfo | None = None,
    ) -> dict:
        """
        Create a new data collection within a project.

        Args:
            project_id: The ID of the project to create the data collection in.
            name: The name of the data collection.
            description: A description of the data collection.
            data_collection_type: The type of data collection (e.g., "image", "raster", "RGB", "DTM", "DSM").
            tags: Optional list of tags to associate with the data collection.
            raster_info: Optional RasterInfo object containing raster-specific configuration.

        Returns:
            dict: The created data collection object.
        """
        body: dict[str, Any] = {
            "name": name,
            "description": description,
            "data_collection_type": data_collection_type,
        }
        if tags:
            body["tags"] = tags
        if raster_info:
            body["raster_info"] = raster_info.model_dump(exclude_none=True, mode="json")
        response = await self._post(
            f"/projects/{project_id}/data_collections/", json=body
        )
        return response.json()

    async def list_data_collections(
        self, project_id: int, params: DataCollectionListParams | None = None, **kwargs
    ) -> list[dict]:
        """
        List data collections within a project with optional filtering.

        Args:
            project_id: The ID of the project to list data collections from.
            params: Optional DataCollectionListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

        Returns:
            list[dict]: A list of data collection objects matching the filter criteria.
        """
        if params and kwargs:
            logger.warning("Ignoring kwargs when params is provided")
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else DataCollectionListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get(
            f"/projects/{project_id}/data_collections/", params=params_dict
        )
        return response.json()

    async def list_deleted_data_collections(
        self, project_id: int, params: DataCollectionListParams | None = None, **kwargs
    ) -> list[dict]:
        """
        List deleted data collections within a project.

        Args:
            project_id: The ID of the project to list deleted data collections from.

        Returns:
            list[dict]: A list of deleted data collection objects.
        """
        if params and kwargs:
            logger.warning("Ignoring kwargs when params is provided")
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else DataCollectionListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get(
            f"/projects/{project_id}/data_collections/deleted", params=params_dict
        )
        return response.json()

    async def get_data_collection(
        self, project_id: int, data_collection_id: int
    ) -> dict:
        """
        Retrieve a data collection by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to retrieve.

        Returns:
            dict: The data collection object with its details.
        """
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}"
        )
        return response.json()

    async def update_data_collection(
        self,
        project_id: int,
        data_collection_id: int,
        name: str | None = None,
        description: str | None = None,
        add_tags: list[str] | None = None,
        remove_tags: list[str] | None = None,
    ) -> dict:
        """
        Update an existing data collection with new values.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to update.
            name: Optional new name for the data collection.
            description: Optional new description for the data collection.
            add_tags: Optional list of tags to add to the data collection.
            remove_tags: Optional list of tags to remove from the data collection.

        Returns:
            dict: The updated data collection object.

        Raises:
            ValueError: If no update parameters are provided.
        """
        body = {}
        for param_name, value in {
            "name": name,
            "description": description,
            "add_tags": add_tags,
            "remove_tags": remove_tags,
        }.items():
            if value is not None:
                body[param_name] = value
        if not body:
            raise ValueError("No update parameters provided")
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}", json=body
        )
        return response.json()

    async def move_data_collection(
        self, project_id: int, data_collection_id: int, new_project_id: int
    ) -> dict:
        """
        Move a data collection to a different project.

        Args:
            project_id: The ID of the project currently containing the data collection.
            data_collection_id: The ID of the data collection to move.
            new_project_id: The ID of the project to move the data collection to.

        Returns:
            dict: The updated data collection object.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/move",
            params={"new_project_id": new_project_id},
        )
        return response.json()

    async def delete_data_collection(
        self, project_id: int, data_collection_id: int
    ) -> dict:
        """
        Delete a data collection by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to delete.

        Returns:
            dict: The response confirming deletion.
        """
        response = await self._delete(
            f"/projects/{project_id}/data_collections/{data_collection_id}"
        )
        return response.json()

    async def restore_data_collection(
        self, project_id: int, data_collection_id: int
    ) -> dict:
        """
        Restore a deleted data collection by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to restore.

        Returns:
            dict: The restored data collection object.
        """
        response = await self._post(
            f"/projects/{project_id}/data_collections/{data_collection_id}/restore"
        )
        return response.json()

    async def get_images(
        self,
        project_id: int,
        data_collection_id: int,
        params: ListParams | None = None,
        **kwargs,
    ) -> list[dict]:
        """
        Retrieve images from a data collection with optional filtering.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the images.
            params: Optional ListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters.

        Returns:
            list[dict]: A list of image objects matching the filter criteria.
        """
        params_dict = (
            params.model_dump(exclude_none=True, mode="json") if params else {}
        )
        params_dict.update(kwargs)
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/images/",
            params=params_dict,
        )
        return response.json()

    async def paginate_images(
        self,
        project_id: int,
        data_collection_id: int,
        page_size: int,
        params: ListParams | None = None,
        **kwargs,
    ) -> AsyncGenerator[dict, None]:
        """
        Paginate through images in a data collection with optional filtering.
        This method returns an async generator that yields images one at a time,
        automatically handling pagination in the background.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the images.
            page_size: The number of images to fetch per page.
            params: Optional ListParams object containing filtering parameters (excluding offset and limit).
            **kwargs: Alternative way to provide filtering parameters.

        Yields:
            dict: Image objects matching the filter criteria, one at a time.
        """
        params_dict = (
            params.model_dump(
                exclude_none=True, exclude={"offset", "limit"}, mode="json"
            )
            if params
            else {}
        )
        params_dict.update(kwargs)
        url = f"/projects/{project_id}/data_collections/{data_collection_id}/images/"
        async for item in self._paginate(url, page_size, params=params_dict):
            yield item

    async def get_image(
        self,
        project_id: int,
        data_collection_id: int,
        image_id: int,
    ) -> dict:
        """
        Retrieve a specific image by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the image.
            image_id: The ID of the image to retrieve.

        Returns:
            dict: The image object with its details.
        """
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}"
        )
        return response.json()

    async def get_image_metadata(
        self, project_id: int, data_collection_id: int, image_id: int
    ) -> dict:
        """
        Retrieve metadata for a specific image by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the image.
            image_id: The ID of the image to retrieve metadata for.

        Returns:
            dict: The image metadata object with its details.
        """
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}/metadata"
        )
        return response.json()

    async def update_image(
        self,
        project_id: int,
        data_collection_id: int,
        image_id: int,
        update_input: ImageUpdateInput,
    ) -> dict:
        """
        Update an existing image with new values.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the image.
            image_id: The ID of the image to update.
            update_input: ImageUpdateInput object containing the fields to update.

        Returns:
            dict: The updated image object.
        """

        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}",
            json=update_input.model_dump(mode="json", exclude_none=True),
        )
        return response.json()

    async def move_image(
        self,
        project_id: int,
        data_collection_id: int,
        image_id: int,
        new_project_id: int,
        new_data_collection_id: int,
    ) -> dict:
        """
        Move an image to a different data collection within a project.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the image.
            image_id: The ID of the image to move.
            new_project_id: The ID of the project to move the image to.
            new_data_collection_id: The ID of the data collection to move the image to.
        Returns:
            dict: The updated image object.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}/move",
            params={
                "new_project_id": new_project_id,
                "new_data_collection_id": new_data_collection_id,
            },
        )
        return response.json()

    async def delete_image(
        self,
        project_id: int,
        data_collection_id: int,
        image_id: int,
    ) -> dict:
        """
        Delete a specific image by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the image.
            image_id: The ID of the image to delete.

        Returns:
            dict: The response confirming deletion.
        """
        response = await self._delete(
            f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}"
        )
        return response.json()

    async def get_rasters(
        self,
        project_id: int,
        data_collection_id: int,
        params: RasterListParams | None = None,
        **kwargs,
    ) -> list[dict]:
        """
        Retrieve rasters from a data collection with optional filtering.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the rasters.
            params: Optional ListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters.

        Returns:
            dict: A list of raster objects matching the filter criteria.
        """
        params_dict = (
            params.model_dump(exclude_none=True, mode="json") if params else {}
        )
        params_dict.update(kwargs)
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/",
            params=params_dict,
        )
        return response.json()

    async def paginate_rasters(
        self,
        project_id: int,
        data_collection_id: int,
        page_size: int,
        params: ListParams | None = None,
        **kwargs,
    ) -> AsyncGenerator[dict, None]:
        """
        Paginate through rasters in a data collection with optional filtering.
        This method returns an async generator that yields rasters one at a time,
        automatically handling pagination in the background.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the rasters.
            page_size: The number of rasters to fetch per page.
            params: Optional ListParams object containing filtering parameters (excluding offset and limit).
            **kwargs: Alternative way to provide filtering parameters.

        Yields:
            dict: Raster objects matching the filter criteria, one at a time.
        """
        params_dict = (
            params.model_dump(exclude_none=True, exclude={"offset", "limit"})
            if params
            else {}
        )
        params_dict.update(kwargs)
        url = f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/"
        async for item in self._paginate(url, page_size, params=params_dict):
            yield item

    async def get_raster(
        self,
        project_id: int,
        data_collection_id: int,
        raster_id: int,
    ) -> dict:
        """
        Retrieve a specific raster by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the raster.
            raster_id: The ID of the raster to retrieve.

        Returns:
            dict: The raster object with its details.
        """
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}"
        )
        return response.json()

    async def update_raster(
        self,
        project_id: int,
        data_collection_id: int,
        raster_id: int,
        update_input: RasterUpdateInput,
    ) -> dict:
        """
        Update an existing raster with new values.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the raster.
            raster_id: The ID of the raster to update.
            update_input: RasterUpdateInput object containing the fields to update.

        Returns:
            dict: The updated raster object.

        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}",
            json=update_input.model_dump(mode="json", exclude_none=True),
        )
        return response.json()

    async def move_raster(
        self,
        project_id: int,
        data_collection_id: int,
        raster_id: int,
        new_project_id: int,
        new_data_collection_id: int,
    ) -> dict:
        """
        Move a raster to a different data collection within a project.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the raster.
            raster_id: The ID of the raster to move.
            new_project_id: The ID of the project to move the raster to.
            new_data_collection_id: The ID of the data collection to move the raster to.
        Returns:
            dict: The updated raster object.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}/move",
            params={
                "new_project_id": new_project_id,
                "new_data_collection_id": new_data_collection_id,
            },
        )
        return response.json()

    async def delete_raster(
        self,
        project_id: int,
        data_collection_id: int,
        raster_id: int,
    ) -> dict:
        """
        Delete a specific raster by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the raster.
            raster_id: The ID of the raster to delete.

        Returns:
            dict: The response confirming deletion.
        """
        response = await self._delete(
            f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}"
        )
        return response.json()

    async def get_upload_jobs(
        self,
        project_id: int,
        data_collection_id: int,
        params: ListParams | None = None,
        **kwargs,
    ) -> list[dict]:
        """
        Retrieve upload jobs for a data collection with optional filtering.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to list upload jobs for.
            params: Optional ListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

        Returns:
            list[dict]: A list of upload job objects matching the filter criteria.
        """
        if params and kwargs:
            logger.warning("Ignoring kwargs when params is provided")
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else ListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/upload_jobs/",
            params=params_dict,
        )
        return response.json()

    async def _create_upload_jobs(
        self,
        project_id: int,
        data_collection_id: int,
        multipart: bool,
        files: list[dict],
    ) -> list[dict]:
        """
        Internal helper to create upload job objects in the API.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to create upload jobs for.
            multipart: If True, create multipart upload jobs for large files.
            files: List of file objects containing metadata for the upload jobs.

        Returns:
            list[dict]: The created upload job objects.
        """
        url = (
            f"/projects/{project_id}/data_collections/{data_collection_id}/upload_jobs/"
        )
        if multipart:
            url += "multipart"
        body = {"files": files}
        response = await self._post(url, json=body)
        return response.json()

    def _create_support_file_file(
        self,
        file_path: Path,
    ) -> dict:
        """
        Create a file object for a support file to be included in an upload job.

        Args:
            file_path: Path to the support file.

        Returns:
            dict: A file object containing the file name and MD5 hash.

        Raises:
            FileNotFoundError: If the file does not exist.
        """
        if not file_path.exists():
            raise FileNotFoundError(f"File {file_path} not found")
        return {
            "name": file_path.name,
            "md5": calculate_md5_base64_from_file(file_path),
        }

    def _create_single_part_upload_job_from_file(
        self,
        file_path: Path,
        support_files: list[Path] | None = None,
        metadata: dict | None = None,
    ) -> dict:
        """
        Create a file object for a single-part upload job.

        Args:
            file_path: Path to the file to upload.
            support_files: Optional list of support file paths to include with the upload.
            metadata: Optional metadata to associate with the file.

        Returns:
            dict: A file object containing the file name, MD5 hash, and optional metadata and support files.
        """
        body: dict[str, Any] = {
            "name": file_path.name,
            "md5": calculate_md5_base64_from_file(file_path),
        }
        if metadata:
            body["metadata"] = metadata
        if support_files:
            body["support_files"] = [
                self._create_support_file_file(f) for f in support_files
            ]
        return body

    def _create_multipart_upload_job_from_file(
        self,
        file_path: Path,
        part_size: int,
        support_files: list[Path] | None = None,
        metadata: dict | None = None,
    ) -> dict:
        """
        Create a file object for a multipart upload job.

        Args:
            file_path: Path to the file to upload.
            part_size: Size of each part in bytes.
            support_files: Optional list of support file paths to include with the upload.
            metadata: Optional metadata to associate with the file.

        Returns:
            dict: A file object containing the file name, parts information, and optional metadata and support files.
        """
        parts = []
        for part_number, (content_length, md5, _) in enumerate(
            iter_file_parts(file_path, part_size), start=1
        ):
            parts.append(
                {
                    "part_number": part_number,
                    "md5": md5,
                    "content_length": content_length,
                }
            )
        file_body = {
            "name": file_path.name,
            "parts": parts,
        }
        if metadata:
            file_body["metadata"] = metadata
        if support_files:
            file_body["support_files"] = [
                self._create_support_file_file(f) for f in support_files
            ]
        return file_body

    async def _upload_singlepart_to_s3(
        self,
        upload_job: dict,
        file_path: Path,
    ):
        """
        Upload a file to S3 using a single part upload.

        Args:
            upload_job: Upload job object containing the S3 URL and upload fields.
            file_path: Path to the file to upload.

        Returns:
            None: This method returns None on success.

        Raises:
            httpx.HTTPStatusError: If the upload fails.
        """
        async with self._semaphore:
            response = await self._internal_client.post(
                upload_job["url"],
                files={"file": file_path.read_bytes()},
                data=upload_job["upload_fields"],
            )
            response.raise_for_status()
        return None

    async def _upload_multipart_to_s3(
        self, upload_job: dict, file_path: Path, multipart_part_size: int
    ):
        parts = sorted(upload_job["upload_parts"], key=lambda p: p["part_number"])

        async def read_and_upload_single_part(part_index, part):
            async with self._semaphore:
                with open(file_path, "rb") as f:
                    f.seek(part_index * multipart_part_size)
                    part_data = f.read(multipart_part_size)

                response = await self._internal_client.put(
                    part["url"], content=part_data, headers=part["headers"]
                )
                response.raise_for_status()

        tasks = [read_and_upload_single_part(i, part) for i, part in enumerate(parts)]

        with silence_logger(logging.getLogger("httpx")):
            await tqdm_asyncio.gather(
                *tasks, total=len(tasks), desc=f"Uploading {file_path.name} to Pixel"
            )

        return None

    async def _upload_to_s3(
        self,
        file: Path,
        support_files: list[Path] | None,
        upload_job: dict,
        multipart: bool,
        multipart_part_size: int | None,
    ):
        """
        Upload a file and its support files to S3.

        Args:
            file: Path to the main file to upload.
            support_files: Optional list of support file paths to upload with the main file.
            upload_job: Upload job object containing the upload information.
            multipart: If True, use multipart upload for the main file.
            multipart_part_size: Required size of each part in bytes when using multipart upload.

        Returns:
            None: This method returns None on success.

        Raises:
            AssertionError: If multipart is True but multipart_part_size is not provided,
                           or if support_files are required but not provided.
        """
        logger.info(f"Uploading {file} to S3 with upload job {upload_job['id']}")
        if multipart:
            assert multipart_part_size, (
                "multipart_part_size must be provided for multipart upload"
            )
            await self._upload_multipart_to_s3(upload_job, file, multipart_part_size)
        else:
            await self._upload_singlepart_to_s3(upload_job, file)
        if upload_job.get("support_files"):
            assert support_files, "Support files must be provided for upload job"
            # Sort the support file by name
            support_files = sorted(support_files, key=lambda f: f.name)
            upload_job_support_files = sorted(
                upload_job["support_files"], key=lambda f: f["name"]
            )
            await asyncio.gather(
                *[
                    self._upload_singlepart_to_s3(uj_sp, sp_path)
                    for uj_sp, sp_path in zip(upload_job_support_files, support_files)
                ]
            )
        logger.info(f"Upload job {upload_job['id']} with {file} completed upload")
        return None

    async def _upload_file_finished(
        self,
        project_id: int,
        data_collection_id: int,
        upload_job_id: int,
    ) -> dict:
        """
        Signal to the API that a file upload has completed.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the upload job.
            upload_job_id: The ID of the upload job to mark as finished.

        Returns:
            dict: The response containing job information for the validation process.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/upload_jobs/{upload_job_id}/uploadFinished"
        )
        return response.json()

    async def _multiple_upload_file_finished(
        self,
        project_id: int,
        data_collection_id: int,
        upload_job_ids: list[int],
    ) -> dict:
        """
        Signal to the API that multiple file uploads have completed.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the upload jobs.
            upload_job_ids: List of upload job IDs to mark as finished.

        Returns:
            dict: The response containing group job information and updated upload jobs.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/upload_jobs/multiple_uploadFinished",
            json={"job_ids": upload_job_ids},
        )
        return response.json()

    async def _wait_for_multiple_upload_jobs(
        self,
        project_id: int,
        data_collection_id: int,
        group_job_id: int,
        upload_job_ids: list[int],
    ) -> tuple[list[dict], list[PixelUploadJobError]]:
        """
        Wait for multiple upload jobs to complete validation and processing.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the upload jobs.
            group_job_id: The ID of the group job managing the upload jobs.
            upload_job_ids: List of upload job IDs to wait for.

        Returns:
            tuple: A tuple containing:
                - list[dict]: List of successfully completed upload jobs.
                - list[PixelUploadJobError]: List of errors for failed upload jobs.
        """
        _ = await self.wait_for_group_job(group_job_id=group_job_id)
        upload_jobs = await self.get_upload_jobs(
            project_id,
            data_collection_id,
            ids=upload_job_ids,
            limit=len(upload_job_ids),
        )
        while any(
            uj["status"] in ("lobby", "validating", "submitted", "validated")
            for uj in upload_jobs
        ):
            upload_jobs = await self.get_upload_jobs(
                project_id,
                data_collection_id,
                ids=upload_job_ids,
                limit=len(upload_job_ids),
            )
            await asyncio.sleep(1)
        # Collect any errors
        errors = []
        finished_upload_jobs = []
        for uj in upload_jobs:
            try:
                if uj["status"] != "validated_and_moved":
                    raise PixelUploadJobError(
                        job_id=uj["id"], status=uj["status"], detail=uj["detail"]
                    )
            except PixelUploadJobError as e:
                errors.append(e)
            else:
                finished_upload_jobs.append(uj)
        return finished_upload_jobs, errors

    async def _wait_for_upload_job(
        self, project_id: int, data_collection_id: int, upload_job_id: int, job_id: int
    ) -> dict:
        """
        Wait for a single upload job to complete validation and processing.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the upload job.
            upload_job_id: The ID of the upload job to wait for.
            job_id: The ID of the job managing the upload job validation.

        Returns:
            dict: The completed upload job object.

        Raises:
            PixelUploadJobError: If the upload job fails validation or processing.
        """
        await self.wait_for_job(job_id)
        upload_jobs = await self.get_upload_jobs(
            project_id, data_collection_id, ids=[upload_job_id], limit=1
        )
        upload_job = upload_jobs[0]
        if upload_job["status"] == "validated_and_moved":
            return upload_job
        if upload_job["status"] != "validated_and_moved":
            raise PixelUploadJobError(
                job_id=upload_job_id,
                status=upload_job["status"],
                detail=upload_job["detail"],
            )
        return upload_job

    def _get_resource_func(
        self, resource_name: ResourceTypeName
    ) -> Callable[..., Awaitable[dict]]:
        """
        Helper method to get the appropriate resource retrieval function based on resource name.
        """
        return {
            "image": self.get_image,
            "raster": self.get_raster,
            "point_cloud": self.get_point_cloud,
        }[resource_name]

    def _list_resource_func(
        self, resource_name: ResourceTypeName
    ) -> Callable[..., Awaitable[list[dict]]]:
        """
        Helper method to get the appropriate resource listing function based on resource name.
        """
        return {
            "image": self.get_images,
            "raster": self.get_rasters,
            "point_cloud": self.get_point_clouds,
        }[resource_name]

    async def _resources_from_upload_jobs(
        self, project_id: int, data_collection_id: int, upload_jobs: list[dict]
    ) -> list[dict]:
        """
        Retrieve the created resources (images, rasters or point_clouds) from completed upload jobs.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the resources.
            upload_jobs: List of completed upload job objects.

        Returns:
            list[dict]: List of resource objects (images, rasters or point_clouds) created from the upload jobs.
        """
        resource_ids: defaultdict[ResourceTypeName, list[int]] = defaultdict(list)
        resources: defaultdict[ResourceTypeName, list[dict]] = defaultdict(list)
        # Chunk up the resources ids
        chunk_size = 50
        for upload_job in upload_jobs:
            resource_ids[upload_job["result"]["resource_name"]].append(
                upload_job["result"]["resource_id"]
            )
        for resource_name, ids in resource_ids.items():
            for chunk in chunks(ids, chunk_size):
                resources[resource_name].extend(
                    await self._list_resource_func(resource_name)(
                        project_id,
                        data_collection_id,
                        ids=",".join(map(str, chunk)),
                        limit=len(chunk),
                    )
                )
        all_resources = list(itertools.chain.from_iterable(resources.values()))
        return all_resources

    async def _resource_from_upload_job(
        self, project_id: int, data_collection_id: int, upload_job: dict
    ) -> dict:
        """
        Retrieve the created resource (image, raster or point_cloud) from a completed upload job.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the resource.
            upload_job: The completed upload job object.

        Returns:
            dict: The resource object (image, raster or point_cloud) created from the upload job.

        Raises:
            ValueError: If the resource type in the upload job result is unknown.
        """
        return await self._get_resource_func(upload_job["result"]["resource_name"])(
            project_id,
            data_collection_id,
            upload_job["result"]["resource_id"],
        )

    async def _upload_multiple_files(
        self,
        project_id: int,
        data_collection_id: int,
        files: list[PixelUploadFile],
        multipart: bool,
        multipart_part_size: int | None,
        raise_on_error: bool = False,
    ) -> tuple[list[dict], list[PixelUploadJobError]]:
        """
        Upload multiple files to a data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to upload to.
            files: List of PixelUploadFile objects containing the files to upload.
            multipart: If True, use multipart upload for large files.
            multipart_part_size: Required size of each part in bytes when using multipart upload.
            raise_on_error: If True, raise a PixelMultipleUploadJobError if any uploads fail.

        Returns:
            tuple: A tuple containing:
                - list[dict]: List of created resource objects (image, raster or point_cloud).
                - list[PixelUploadJobError]: List of errors for failed uploads.

        Raises:
            ValueError: If any files have duplicate names.
            PixelMultipleUploadJobError: If raise_on_error is True and any uploads fail.
        """

        # Chunk the operation into 200 files at a time (maximum for API)
        all_resources: list[dict] = []
        all_errors: list[PixelUploadJobError] = []

        create_body_func = (
            partial(
                self._create_multipart_upload_job_from_file,
                part_size=multipart_part_size,  # type: ignore
            )
            if multipart
            else self._create_single_part_upload_job_from_file
        )
        # Assert unique file names
        file_names = [f.file.name for f in files]
        if len(file_names) != len(set(file_names)):
            raise ValueError("All files must have unique names")
        for files_chunk in chunks(files, 200):
            logger.info("Uploading chunk of %d files", len(files_chunk))
            file_bodies = [
                create_body_func(
                    file.file,
                    support_files=file.support_files,
                    metadata=file.metadata.model_dump(mode="json", exclude_none=True)
                    if file.metadata
                    else None,
                )
                for file in files_chunk
            ]
            upload_jobs = await self._create_upload_jobs(
                project_id, data_collection_id, multipart, file_bodies
            )
            # sort the upload jobs by the file name
            upload_jobs = sorted(upload_jobs, key=lambda uj: uj["name"])
            files = sorted(files, key=lambda f: f.file.name)
            await asyncio.gather(
                *[
                    self._upload_to_s3(
                        file.file,
                        file.support_files,
                        upload_job,
                        multipart,
                        multipart_part_size,
                    )
                    for upload_job, file in zip(upload_jobs, files)
                ]
            )
            upload_finished = await self._multiple_upload_file_finished(
                project_id, data_collection_id, [uj["id"] for uj in upload_jobs]
            )
            group_job = upload_finished["group_job"]
            upload_jobs = upload_finished["upload_jobs"]
            upload_jobs, errors = await self._wait_for_multiple_upload_jobs(
                project_id,
                data_collection_id,
                group_job["group_id"],
                [uj["id"] for uj in upload_jobs],
            )
            resources = await self._resources_from_upload_jobs(
                project_id, data_collection_id, upload_jobs
            )
            all_resources.extend(resources)
            all_errors.extend(errors)

        if raise_on_error and all_errors:
            raise PixelMultipleUploadJobError(errors)
        return all_resources, all_errors

    async def _upload_file(
        self,
        project_id: int,
        data_collection_id: int,
        file_path: Path,
        support_files: list[Path] | None = None,
        metadata: dict | None = None,
        multipart: bool = False,
        multipart_part_size: int | None = None,
    ) -> dict:
        """
        Upload a single file to a data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to upload to.
            file_path: Path to the file to upload.
            support_files: Optional list of support file paths to upload with the file.
            metadata: Optional dictionary of metadata to associate with the file.
            multipart: If True, use multipart upload for large files.
            multipart_part_size: Required size of each part in bytes when using multipart upload.

        Returns:
            dict: The created resource object (image, raster or point_cloud).

        Raises:
            FileNotFoundError: If the file does not exist.
            ValueError: If multipart is True but multipart_part_size is not provided.
            PixelUploadJobError: If the upload job fails validation or processing.
        """
        if not file_path.exists():
            raise FileNotFoundError(f"File {file_path} not found")
        if multipart and not multipart_part_size:
            raise ValueError(
                "multipart_part_size must be provided for multipart upload"
            )
        if multipart:
            assert multipart_part_size
            file_body = self._create_multipart_upload_job_from_file(
                file_path,
                multipart_part_size,
                support_files=support_files,
                metadata=metadata,
            )
        else:
            file_body = self._create_single_part_upload_job_from_file(
                file_path,
                support_files=support_files,
                metadata=metadata,
            )
        upload_jobs = await self._create_upload_jobs(
            project_id, data_collection_id, multipart, [file_body]
        )
        upload_job = upload_jobs[0]
        await self._upload_to_s3(
            file_path,
            support_files,
            upload_job,
            multipart,
            multipart_part_size,
        )
        upload_job_finished = await self._upload_file_finished(
            project_id, data_collection_id, upload_job["id"]
        )
        job = upload_job_finished["job"]
        upload_job = await self._wait_for_upload_job(
            project_id, data_collection_id, upload_job["id"], job["job_id"]
        )
        return await self._resource_from_upload_job(
            project_id, data_collection_id, upload_job
        )

    async def upload_image(
        self,
        project_id: int,
        data_collection_id: int,
        file_path: Path,
        metadata: dict | None = None,
        support_files: list[Path] | None = None,
        multipart: bool = False,
        multipart_part_size: int | None = None,
    ) -> dict:
        """
        Upload an image file to an image data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the image data collection to upload to.
            file_path: Path to the image file to upload.
            metadata: Optional dictionary of metadata to associate with the image.
            support_files: Optional list of support file paths to upload with the image.
            multipart: If True, use multipart upload for large files.
            multipart_part_size: Required size of each part in bytes when using multipart upload.

        Returns:
            dict: The created image object.

        Raises:
            ValueError: If the data collection is not an image data collection.
            FileNotFoundError: If the file does not exist.
            ValueError: If multipart is True but multipart_part_size is not provided.
        """
        dc = await self.get_data_collection(project_id, data_collection_id)
        if dc["data_collection_type"] != "image":
            raise ValueError("Data collection is not an image data collection")
        return await self._upload_file(
            project_id,
            data_collection_id,
            file_path,
            support_files=support_files,
            metadata=metadata,
            multipart=multipart,
            multipart_part_size=multipart_part_size,
        )

    async def upload_multiple_images(
        self,
        project_id: int,
        data_collection_id: int,
        files: list[PixelUploadFile],
        multipart: bool = False,
        multipart_part_size: int | None = None,
    ) -> tuple[list[dict], list[PixelUploadJobError]]:
        """
        Upload multiple image files to an image data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the image data collection to upload to.
            files: List of PixelUploadFile objects containing the files to upload.
            multipart: If True, use multipart upload for large files.
            multipart_part_size: Required size of each part in bytes when using multipart upload.

        Returns:
            tuple: A tuple containing:
                - list[dict]: List of created image objects.
                - list[PixelUploadJobError]: List of errors that occurred during upload.

        Raises:
            ValueError: If the data collection is not an image data collection.
            ValueError: If any files have duplicate names.
            ValueError: If multipart is True but multipart_part_size is not provided.
        """
        dc = await self.get_data_collection(project_id, data_collection_id)
        if dc["data_collection_type"] != "image":
            raise ValueError("Data collection is not an image data collection")
        return await self._upload_multiple_files(
            project_id,
            data_collection_id,
            files,
            multipart,
            multipart_part_size,
        )

    async def upload_multiple_rasters(
        self,
        project_id: int,
        data_collection_id: int,
        files: list[PixelUploadFile],
        multipart: bool = False,
        multipart_part_size: int | None = None,
    ) -> tuple[list[dict], list[PixelUploadJobError]]:
        """
        Upload multiple raster files to a raster data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the raster data collection to upload to.
            files: List of PixelUploadFile objects containing the files to upload.
            multipart: If True, use multipart upload for large files.
            multipart_part_size: Required size of each part in bytes when using multipart upload.

        Returns:
            tuple: A tuple containing:
                - list[dict]: List of created raster objects.
                - list[PixelUploadJobError]: List of errors that occurred during upload.

        Raises:
            ValueError: If the data collection is not a raster data collection.
            ValueError: If any files have duplicate names.
            ValueError: If multipart is True but multipart_part_size is not provided.
        """
        dc = await self.get_data_collection(project_id, data_collection_id)
        if dc["data_collection_type"] not in ("raster", "RGB", "DTM", "DSM"):
            raise ValueError("Data collection is not a raster data collection")
        return await self._upload_multiple_files(
            project_id,
            data_collection_id,
            files,
            multipart,
            multipart_part_size,
        )

    async def upload_raster(
        self,
        project_id: int,
        data_collection_id: int,
        file_path: Path,
        support_files: list[Path] | None = None,
        metadata: dict | None = None,
        multipart: bool = False,
        multipart_part_size: int | None = None,
    ) -> dict:
        """
        Upload a raster file to a raster data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the raster data collection to upload to.
            file_path: Path to the raster file to upload.
            support_files: Optional list of support file paths to upload with the raster.
            metadata: Optional dictionary of metadata to associate with the raster.
            multipart: If True, use multipart upload for large files.
            multipart_part_size: Required size of each part in bytes when using multipart upload.

        Returns:
            dict: The created raster object.

        Raises:
            ValueError: If the data collection is not a raster data collection.
            FileNotFoundError: If the file does not exist.
            ValueError: If multipart is True but multipart_part_size is not provided.
        """
        dc = await self.get_data_collection(project_id, data_collection_id)
        if dc["data_collection_type"] not in ("raster", "RGB", "DTM", "DSM"):
            raise ValueError("Data collection is not a raster data collection")
        return await self._upload_file(
            project_id,
            data_collection_id,
            file_path,
            support_files=support_files,
            metadata=metadata,
            multipart=multipart,
            multipart_part_size=multipart_part_size,
        )

    async def upload_multiple_point_clouds(
        self,
        project_id: int,
        data_collection_id: int,
        files: list[PixelUploadFile],
        multipart: bool = False,
        multipart_part_size: int | None = None,
    ) -> tuple[list[dict], list[PixelUploadJobError]]:
        """
        Upload multiple point cloud files to a point cloud data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the point cloud data collection to upload to.
            files: List of PixelUploadFile objects containing the files to upload.
            multipart: If True, use multipart upload for large files.
            multipart_part_size: Required size of each part in bytes when using multipart upload.

        Returns:
            tuple: A tuple containing:
                - list[dict]: List of created point cloud objects.
                - list[PixelUploadJobError]: List of errors that occurred during upload.

        Raises:
            ValueError: If the data collection is not a point cloud data collection.
            ValueError: If any files have duplicate names.
            ValueError: If multipart is True but multipart_part_size is not provided.
        """
        dc = await self.get_data_collection(project_id, data_collection_id)
        if dc["data_collection_type"] != "point_cloud":
            raise ValueError("Data collection is not a point cloud data collection")
        return await self._upload_multiple_files(
            project_id,
            data_collection_id,
            files,
            multipart,
            multipart_part_size,
        )

    async def upload_point_cloud(
        self,
        project_id: int,
        data_collection_id: int,
        file_path: Path,
        metadata: dict | None = None,
        multipart: bool = False,
        multipart_part_size: int | None = None,
    ) -> dict:
        """
        Upload a point cloud file to a point cloud data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the point cloud data collection to upload to.
            file_path: Path to the point cloud file to upload.
            metadata: Optional dictionary of metadata to associate with the point cloud.
            multipart: If True, use multipart upload for large files.
            multipart_part_size: Required size of each part in bytes when using multipart upload.

        Returns:
            dict: The created point cloud object.

        Raises:
            ValueError: If the data collection is not a point cloud data collection.
            FileNotFoundError: If the file does not exist.
            ValueError: If multipart is True but multipart_part_size is not provided.
        """
        dc = await self.get_data_collection(project_id, data_collection_id)
        if dc["data_collection_type"] != "point_cloud":
            raise ValueError("Data collection is not a point cloud data collection")
        return await self._upload_file(
            project_id,
            data_collection_id,
            file_path,
            metadata=metadata,
            multipart=multipart,
            multipart_part_size=multipart_part_size,
        )

    async def create_optimized_rasters(
        self,
        project_id: int,
        data_collection_id: int,
        raster_ids: list[int] | None,
        profile: str | None = None,
        nearblack: NearblackOptions | None = None,
        overview_resampling: OverviewResampling = "average",
    ) -> list[dict]:
        """
        Create optimized raster objects in the database.
        This function creates optimized raster objects but does not run the actual optimization process.
        To run the optimization, use the run_optimize_rasters function with the returned optimized raster IDs.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the rasters.
            raster_ids: Optional list of raster IDs to optimize. If None, all rasters in the collection will be optimized.
            profile: Optional profile name to use for optimization.
            nearblack: Optional NearblackOptions object for configuring the nearblack process.
            overview_resampling: The resampling method to use for creating overviews. Default is "average".

        Returns:
            list[dict]: List of created optimized raster objects.
        """
        body: dict = {
            "creation_options": {
                "nearblack_options": nearblack.model_dump(
                    exclude_none=True, mode="json"
                )
                if nearblack
                else NearblackOptions(enabled=False).model_dump(
                    exclude_none=True, mode="json"
                ),
                "overview_resampling": overview_resampling,
            }
        }
        if raster_ids:
            body["raster_ids"] = raster_ids
        if profile:
            body["profile"] = profile
        response = await self._post(
            f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/optimized/",
            json=body,
        )
        return response.json()

    async def run_optimize_rasters(
        self,
        project_id: int,
        data_collection_id: int,
        optimize_raster_ids: list[int] | None,
        retry_failed: bool = False,
    ) -> dict:
        """
        Run the optimization process on optimized raster objects.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the optimized rasters.
            optimize_raster_ids: Optional list of optimized raster IDs to process. If None, all optimized rasters in the collection will be processed.
            retry_failed: If True, retry previously failed optimization jobs.

        Returns:
            dict: The group job object representing the optimization process.
        """
        body: dict = {"retry_failed": retry_failed}
        if optimize_raster_ids:
            body["optimized_raster_ids"] = optimize_raster_ids
        response = await self._post(
            f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/optimized/run",
            json=body,
        )
        response_json = response.json()

        job = await self.wait_for_group_job(response_json["group_job"]["group_id"])
        return job

    async def create_optimized_point_clouds(
        self,
        project_id: int,
        data_collection_id: int,
        point_cloud_ids: list[int] | None,
    ) -> list[dict]:
        """
        Create optimized point cloud objects in the database.

        This function creates optimized point clouds (copc format) but does not run the actual optimization process.
        Run the optimization using the `run_optimize_point_clouds` function with the returned same point cloud IDs.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the point clouds.
            point_cloud_ids: Optional list of point cloud IDs to optimize. If None, all point clouds in the collection will be optimized.
        Returns:
            list[dict]: List of created optimized point cloud objects.
        """
        body: dict = {}
        if point_cloud_ids:
            body["point_cloud_ids"] = point_cloud_ids
        response = await self._post(
            f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/optimized/",
            json=body,
        )
        return response.json()

    async def run_optimize_point_clouds(
        self,
        project_id: int,
        data_collection_id: int,
        point_cloud_ids: list[int] | None,
        retry_failed: bool = False,
    ) -> dict:
        """
        Run the optimization process on optimized point cloud objects.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the optimized point clouds.
            point_cloud_ids: Optional list of optimized point cloud IDs to process. If None, all optimized point clouds in the collection will be processed.
        Returns:
            dict: The group job object representing the optimization process.
        """
        body: dict = {"retry_failed": retry_failed}
        if point_cloud_ids:
            body["point_cloud_ids"] = point_cloud_ids
        response = await self._post(
            f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/optimized/run",
            json=body,
        )
        response_json = response.json()
        # Wait for the group job to complete
        job = await self.wait_for_group_job(response_json["group_job"]["group_id"])
        return job

    async def get_job(
        self,
        job_id: int,
    ) -> dict:
        """
        Retrieve information about a specific job.

        Args:
            job_id: The ID of the job to retrieve.

        Returns:
            dict: The job object with its details.
        """
        response = await self._get(f"/jobs/{job_id}")
        return response.json()

    async def get_job_group(
        self,
        job_id: int,
    ) -> dict:
        """
        Retrieve information about a specific job group.

        Args:
            job_id: The ID of the job group to retrieve.

        Returns:
            dict: The job group object with its details.
        """
        response = await self._get(f"/jobs/groups/{job_id}")
        return response.json()

    async def wait_for_job(
        self,
        job_id: int,
        timeout: int = 600,
    ) -> dict:
        """
        Wait for a job to complete, polling its status at regular intervals.

        Args:
            job_id: The ID of the job to wait for.
            timeout: Maximum time to wait in seconds before raising a TimeoutError. Default is 600 seconds (10 minutes).

        Returns:
            dict: The completed job object.

        Raises:
            TimeoutError: If the job does not complete within the specified timeout period.
        """
        job = await self.get_job(job_id)
        with silence_logger(logging.getLogger("httpx")):
            while not job["completed"]:
                job = await self.get_job(job_id)
                job_name = job["name"] or "unnamed"
                logger.info(f"Job {job_name} {job_id} status: {job['status']}")
                await asyncio.sleep(3)
                timeout -= 5
                if timeout <= 0:
                    raise TimeoutError("Timed out waiting for job")
        logger.info(f"Job {job_id} finished with status {job['status']}")
        return job

    async def wait_for_group_job(
        self,
        group_job_id: int,
        timeout: int = 1200,
    ) -> dict:
        """
        Wait for a group job to complete, polling its status at regular intervals.
        A group job consists of multiple individual jobs. This method displays a progress bar
        showing the completion status of all jobs in the group.

        Args:
            group_job_id: The ID of the group job to wait for.
            timeout: Maximum time to wait in seconds before raising a TimeoutError. Default is 1200 seconds (20 minutes).

        Returns:
            dict: The completed group job object.

        Raises:
            TimeoutError: If the group job does not complete within the specified timeout period.
        """
        job = await self.get_job_group(group_job_id)
        num_jobs = job["total_jobs"]
        with (
            silence_logger(logging.getLogger("httpx")),
            tqdm.tqdm(total=num_jobs, desc=f"Running group job {group_job_id}") as pbar,
        ):
            while not job["completed"]:
                job = await self.get_job_group(group_job_id)
                num_failed = job["failed_count"]
                num_success = job["success_count"]
                num_finished = num_failed + num_success
                pbar.n = num_finished
                pbar.refresh()
                await asyncio.sleep(3)
                timeout -= 5
                if timeout <= 0:
                    raise TimeoutError("Timed out waiting for optimize rasters job")
        logger.info(
            f"Group job {group_job_id} finished {job['total_jobs']} jobs, with {num_failed} failures and {num_success} successes"
        )
        return job

    async def get_optimized_rasters(
        self,
        project_id: int,
        data_collection_id: int,
        params: ListParams | None = None,
        **kwargs,
    ) -> list[dict]:
        """
        Retrieve optimized rasters from a data collection with optional filtering.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the optimized rasters.
            params: Optional ListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters.

        Returns:
            list[dict]: A list of optimized raster objects matching the filter criteria.
        """
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else ListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/optimized/",
            params=params_dict,
        )
        return response.json()

    async def delete_optimized_rasters(
        self,
        project_id: int,
        data_collection_id: int,
        raster_id: int,
        profile: str | None = None,
    ) -> list[dict]:
        """
        Delete optimized rasters associated with a specific raster.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the raster.
            raster_id: The ID of the raster whose optimized versions should be deleted.
            profile: Optional profile name to filter which optimized rasters to delete.
                    If None, all optimized versions of the raster will be deleted.

        Returns:
            list[dict]: A list of the deleted optimized raster objects.
        """
        params = {}
        if profile:
            params["profile"] = profile
        response = await self._delete(
            f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}/optimized",
            params=params,
        )
        return response.json()

    async def optimize_rasters(
        self,
        project_id: int,
        data_collection_id: int,
        raster_ids: list[int] | None = None,
        profile: str | None = None,
        nearblack: NearblackOptions | None = None,
        overview_resampling: OverviewResampling = "average",
    ) -> list[dict]:
        """
        Create and run optimization on rasters in a data collection.
        This is a convenience method that combines create_optimized_rasters and run_optimize_rasters
        into a single operation.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the rasters.
            raster_ids: Optional list of raster IDs to optimize. If None, all rasters in the collection will be optimized.
            profile: Optional profile name to use for optimization.
            nearblack: Optional NearblackOptions object for configuring the nearblack process.
            overview_resampling: The resampling method to use for creating overviews. Default is "average".

        Returns:
            list[dict]: List of optimized raster objects after the optimization process has completed.
        """
        optimized_rasters = await self.create_optimized_rasters(
            project_id,
            data_collection_id,
            raster_ids,
            profile,
            nearblack=nearblack,
            overview_resampling=overview_resampling,
        )
        await self.run_optimize_rasters(
            project_id, data_collection_id, [r["id"] for r in optimized_rasters]
        )
        optimized_rasters = await self.get_optimized_rasters(
            project_id,
            data_collection_id,
            params=ListParams(
                ids=[r["id"] for r in optimized_rasters], limit=len(optimized_rasters)
            ),
        )
        return optimized_rasters

    async def get_point_clouds(
        self,
        project_id: int,
        data_collection_id: int,
        params: PointCloudListParams | None = None,
        **kwargs,
    ) -> list[dict]:
        """
        Retrieve point clouds from a data collection with optional filtering.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the point clouds.
            params: Optional PointCloudListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters.
        Returns:
            list[dict]: A list of point cloud objects matching the filter criteria.
        """
        params_dict = (
            params.model_dump(exclude_none=True, mode="json") if params else {}
        )
        params_dict.update(kwargs)
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/",
            params=params_dict,
        )
        return response.json()

    async def paginate_point_clouds(
        self,
        project_id: int,
        data_collection_id: int,
        page_size: int,
        params: PointCloudListParams | None = None,
        **kwargs,
    ) -> AsyncGenerator[dict, None]:
        """
        Paginate through point clouds in a data collection with optional filtering.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the point clouds.
            page_size: The number of point clouds to retrieve per page.
            params: Optional PointCloudListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters.
        Yields:
            dict: Point cloud objects matching the filter criteria, one at a time.
        """
        params_dict = (
            params.model_dump(
                exclude_none=True, exclude={"offset", "limit"}, mode="json"
            )
            if params
            else {}
        )
        params_dict.update(kwargs)
        url = f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/"
        async for point_cloud in self._paginate(
            url=url,
            page_size=page_size,
            params=params_dict,
        ):
            yield point_cloud

    async def get_point_cloud(
        self,
        project_id: int,
        data_collection_id: int,
        point_cloud_id: int,
    ) -> dict:
        """
        Retrieve a specific point cloud by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the point cloud.
            point_cloud_id: The ID of the point cloud to retrieve.
        Returns:
            dict: The point cloud object with its details.
        """
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}"
        )
        return response.json()

    async def update_point_cloud(
        self,
        project_id: int,
        data_collection_id: int,
        point_cloud_id: int,
        update_input: PointCloudUpdateInput,
    ) -> dict:
        """
        Update an existing point cloud with new values.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the point cloud.
            point_cloud_id: The ID of the point cloud to update.
            update_input: PointCloudUpdateInput object containing the fields to update.
        Returns:
            dict: The updated point cloud object.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}",
            json=update_input.model_dump(mode="json", exclude_none=True),
        )
        return response.json()

    async def move_point_cloud(
        self,
        project_id: int,
        data_collection_id: int,
        point_cloud_id: int,
        new_data_collection_id: int,
        new_project_id: int | None = None,
    ) -> dict:
        """
        Move a point cloud to a different data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the current data collection containing the point cloud.
            point_cloud_id: The ID of the point cloud to move.
            new_data_collection_id: The ID of the target data collection to move the point cloud to.
            new_project_id: The ID of the project containing the target data collection. Defaults to `project_id`.
        Returns:
            dict: The moved point cloud object.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}/move",
            params={
                "new_project_id": new_project_id or project_id,
                "new_data_collection_id": new_data_collection_id,
            },
        )
        return response.json()

    async def delete_point_cloud(
        self,
        project_id: int,
        data_collection_id: int,
        point_cloud_id: int,
    ) -> dict:
        """
        Delete a specific point cloud by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the point cloud.
            point_cloud_id: The ID of the point cloud to delete.
        Returns:
            dict: The response confirming deletion.
        """
        response = await self._delete(
            f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}"
        )
        return response.json()

    async def get_optimized_point_clouds(
        self,
        project_id: int,
        data_collection_id: int,
        params: OptimizedPointCloudListParams | None = None,
        **kwargs,
    ) -> list[dict]:
        """
        Retrieve optimized point clouds from a data collection with optional filtering.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the optimized point clouds.
            params: Optional PointCloudListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters.
        Returns:
            list[dict]: A list of optimized point cloud objects matching the filter criteria.
        """
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else OptimizedPointCloudListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/optimized/",
            params=params_dict,
        )
        return response.json()

    async def delete_optimized_point_cloud(
        self,
        project_id: int,
        data_collection_id: int,
        point_cloud_id: int,
    ) -> dict:
        """
        Delete optimized point cloud associated with a specific point cloud.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the point cloud.
            point_cloud_id: The ID of the point cloud whose optimized versions should be deleted.

        Returns:
            dict: The response confirming deletion.
        """
        response = await self._delete(
            f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}/optimized"
        )
        return response.json()

    async def optimize_point_clouds(
        self,
        project_id: int,
        data_collection_id: int,
        point_cloud_ids: list[int] | None = None,
    ) -> list[dict]:
        """
        Create and run optimization on point clouds in a data collection.

        This is a convenience method that combines create_optimized_point_clouds and run_optimize_point_clouds
        into a single operation.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the rasters.
            point_cloud_ids: Optional list of raster IDs to optimize. If None, all rasters in the collection will be optimized.
        Returns:
            list[dict]: List of optimized point_cloud objects after the optimization process has completed.
        """
        optimized_point_clouds = await self.create_optimized_point_clouds(
            project_id,
            data_collection_id,
            point_cloud_ids,
        )
        await self.run_optimize_point_clouds(
            project_id,
            data_collection_id,
            [pc["id"] for pc in optimized_point_clouds],
        )
        optimized_point_clouds = await self.get_optimized_point_clouds(
            project_id,
            data_collection_id,
            params=OptimizedPointCloudListParams(
                ids=[pc["id"] for pc in optimized_point_clouds],
                limit=len(optimized_point_clouds),
            ),
        )
        return optimized_point_clouds

    async def list_gdo_users(self) -> list[str]:
        """Retrieve a list of GDO (GeoData Online) users.

        Returns:
            list[dict]: A list of GDO user names.
        """
        response = await self._get("/arcgis_services/gdo-users")
        return response.json()

    async def create_arcgis_service(
        self,
        service_type: Literal["Feature", "Image"],
        create_input: ArcgisServiceCreateInput,
    ) -> dict:
        """Create a new ArcGIS service.

        Args:
            service_type: The type of service to create, either "Feature" or "Image".
            create_input: ArcgisServiceCreateInput object containing the service configuration.

        Returns:
            dict: The created ArcGIS service object.

        Raises:
            AssertionError: If the create_input does not contain the appropriate service options for the specified service_type.
        """
        assert (
            getattr(
                create_input.options, f"{service_type.lower()}_service_options", None
            )
            is not None
        ), (
            f"Service options for {service_type} service must be provided in the create input"
        )
        response = await self._post(
            f"/arcgis_services/{service_type}/",
            json=create_input.model_dump(mode="json", exclude_none=True),
        )
        return response.json()

    async def list_arcgis_services(
        self,
        service_type: Literal["Feature", "Image"],
        params: ListParams | None = None,
        **kwargs,
    ) -> list[dict]:
        """List ArcGIS services of a specific type with optional filtering.

        Args:
            service_type: The type of services to list, either "Feature" or "Image".
            params: Optional ListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters.

        Returns:
            list[dict]: A list of ArcGIS service objects matching the filter criteria.
        """
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else ListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get(
            f"/arcgis_services/{service_type}/", params=params_dict
        )
        return response.json()

    async def get_arcgis_service(
        self, service_type: Literal["Feature", "Image"], service_id: int
    ) -> dict:
        """Retrieve a specific ArcGIS service by its ID.

        Args:
            service_type: The type of service, either "Feature" or "Image".
            service_id: The ID of the service to retrieve.

        Returns:
            dict: The ArcGIS service object with its details.
        """
        response = await self._get(f"/arcgis_services/{service_type}/{service_id}")
        return response.json()

    async def delete_arcgis_service(
        self, service_type: Literal["Feature", "Image"], service_id: int
    ) -> dict:
        """Delete a specific ArcGIS service by its ID.

        Args:
            service_type: The type of service, either "Feature" or "Image".
            service_id: The ID of the service to delete.

        Returns:
            dict: The response confirming deletion.
        """
        response = await self._delete(f"/arcgis_services/{service_type}/{service_id}")
        return response.json()

    async def update_arcgis_service(
        self,
        service_type: Literal["Feature", "Image"],
        service_id: int,
        update_input: ArcgisServiceUpdateInput,
    ) -> dict:
        """Update an existing ArcGIS service with new values.

        Args:
            service_type: The type of service, either "Feature" or "Image".
            service_id: The ID of the service to update.
            update_input: ArcgisServiceUpdateInput object containing the fields to update.

        Returns:
            dict: The updated ArcGIS service object.
        """
        response = await self._put(
            f"/arcgis_services/{service_type}/{service_id}",
            json=update_input.model_dump(mode="json", exclude_none=True),
        )
        return response.json()

    async def start_arcgis_service(
        self,
        service_type: Literal["Feature", "Image"],
        service_id: int,
        wait: bool = True,
    ) -> dict:
        """Start a specific ArcGIS service.

        Args:
            service_type: The type of service, either "Feature" or "Image".
            service_id: The ID of the service to start.
            wait: If True, wait for the start operation to complete before returning.
                 If False, return immediately after initiating the start operation.

        Returns:
            dict: A response object containing job information and, if wait is True,
                 the updated service object after starting.
        """
        response = await self._put(
            f"/arcgis_services/{service_type}/{service_id}/start"
        )
        resp = response.json()
        job = resp["job"]
        if wait and job:
            job = await self.wait_for_job(job["job_id"], timeout=1000)
            resp["job"] = job
            resp["arcgis_service"] = await self.get_arcgis_service(
                service_type, service_id
            )
        return resp

    async def stop_arcgis_service(
        self,
        service_type: Literal["Feature", "Image"],
        service_id: int,
        wait: bool = True,
    ) -> dict:
        """Stop a specific ArcGIS service.

        Args:
            service_type: The type of service, either "Feature" or "Image".
            service_id: The ID of the service to stop.
            wait: If True, wait for the stop operation to complete before returning.
                 If False, return immediately after initiating the stop operation.

        Returns:
            dict: A response object containing job information and, if wait is True,
                 the updated service object after stopping.
        """
        response = await self._put(f"/arcgis_services/{service_type}/{service_id}/stop")
        resp = response.json()
        job = resp["job"]
        if wait and job:
            job = await self.wait_for_job(job["job_id"], timeout=1000)
            resp["job"] = job
            resp["arcgis_service"] = await self.get_arcgis_service(
                service_type, service_id
            )
        return resp

    async def refresh_arcgis_service(
        self,
        service_type: Literal["Feature", "Image"],
        service_id: int,
        refresh_data: bool = False,
        wait: bool = True,
    ) -> dict:
        """Refresh a specific ArcGIS service, optionally refreshing its data.

        Args:
            service_type: The type of service, either "Feature" or "Image".
            service_id: The ID of the service to refresh.
            refresh_data: If True, also refresh the data used by the service.
            wait: If True, wait for the refresh operation to complete before returning.
                 If False, return immediately after initiating the refresh operation.

        Returns:
            dict: A response object containing job information and, if wait is True,
                 the updated service object after refreshing.
        """
        response = await self._put(
            f"/arcgis_services/{service_type}/{service_id}/refresh",
            params={"refresh_data": refresh_data},
        )
        resp = response.json()
        job = resp["job"]
        if wait and job:
            job = await self.wait_for_job(job["job_id"], timeout=1000)
            resp["job"] = job
            resp["arcgis_service"] = await self.get_arcgis_service(
                service_type, service_id
            )
        return resp

    async def create_harvest_service(
        self,
        project_id: int,
        data_collection_id: int,
        create_input: HarvestServiceCreateInput,
    ) -> dict:
        """Create a new harvest service for a data collection.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to create the harvest service for.
            create_input: HarvestServiceCreateInput object containing the service configuration.

        Returns:
            dict: The created harvest service object.
        """
        response = await self._post(
            f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/",
            json=create_input.model_dump(mode="json", exclude_none=True),
            sensitive_content=True,
        )
        return response.json()

    async def list_harvest_services(
        self,
        project_id: int,
        data_collection_id: int,
        params: ListParams | None = None,
        **kwargs,
    ) -> list[dict]:
        """List harvest services for a data collection with optional filtering.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection to list harvest services for.
            params: Optional ListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

        Returns:
            list[dict]: A list of harvest service objects matching the filter criteria.
        """
        if params and kwargs:
            logger.warning("Ignoring kwargs when params is provided")
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else ListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/",
            params=params_dict,
        )
        return response.json()

    async def get_harvest_service(
        self, project_id: int, data_collection_id: int, service_id: int
    ) -> dict:
        """Retrieve a specific harvest service by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the harvest service.
            service_id: The ID of the harvest service to retrieve.

        Returns:
            dict: The harvest service object with its details.
        """
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}"
        )
        return response.json()

    async def update_harvest_service(
        self,
        project_id: int,
        data_collection_id: int,
        service_id: int,
        update_input: HarvestServiceUpdateInput,
    ) -> dict:
        """Update an existing harvest service with new values.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the harvest service.
            service_id: The ID of the harvest service to update.
            update_input: HarvestServiceUpdateInput object containing the fields to update.

        Returns:
            dict: The updated harvest service object.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}",
            json=update_input.model_dump(mode="json", exclude_none=True),
            sensitive_content=True,
        )
        return response.json()

    async def delete_harvest_service(
        self, project_id: int, data_collection_id: int, service_id: int
    ) -> dict:
        """Delete a specific harvest service by its ID.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the harvest service.
            service_id: The ID of the harvest service to delete.

        Returns:
            dict: The response confirming deletion.
        """
        response = await self._delete(
            f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}"
        )
        return response.json()

    async def get_harvest_service_tasks(
        self,
        project_id: int,
        data_collection_id: int,
        service_id: int,
        params: HarvestTaskListParams,
        **kwargs,
    ) -> list[dict]:
        """Retrieve tasks for a specific harvest service with optional filtering.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the harvest service.
            service_id: The ID of the harvest service to retrieve tasks for.
            params: HarvestTaskListParams object containing filtering parameters.
            **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

        Returns:
            list[dict]: A list of harvest task objects matching the filter criteria.
        """
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else ListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get(
            f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}/",
            params=params_dict,
        )
        return response.json()

    async def start_harvest_service(
        self, project_id: int, data_collection_id: int, service_id: int
    ) -> dict:
        """Start a specific harvest service.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the harvest service.
            service_id: The ID of the harvest service to start.

        Returns:
            dict: The response confirming the service has been started.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}/start"
        )
        return response.json()

    async def stop_harvest_service(
        self, project_id: int, data_collection_id: int, service_id: int
    ) -> dict:
        """Stop a specific harvest service.

        Args:
            project_id: The ID of the project containing the data collection.
            data_collection_id: The ID of the data collection containing the harvest service.
            service_id: The ID of the harvest service to stop.

        Returns:
            dict: The response confirming the service has been stopped.
        """
        response = await self._put(
            f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}/stop"
        )
        return response.json()

    async def create_oidc_user(self, create_input: OIDCUserCreateInput) -> dict:
        """Create a new OIDC user in the system.

        Deprecated:
            Use [`create_user`][pixel_client.PixelClientAsync.create_user] instead.

        Args:
            create_input: OIDCUserCreateInput object containing the user information.

        Returns:
            dict: The created user object.
        """
        warnings.warn(
            "create_oidc_user is deprecated, use create_user instead",
            DeprecationWarning,
            stacklevel=2,
        )
        return await self._create_user(create_input)

    async def update_oidc_user(
        self, email: str, update_input: OIDCUserUpdateInput
    ) -> dict:
        """
        Update an existing OIDC user with new values.

        Deprecated:
            Use [`update_user`][pixel_client.PixelClientAsync.update_user] instead,
            which also keeps the user's active status unchanged.

        Args:
            email: The email address of the user to update.
            update_input: OIDCUserUpdateInput object containing the fields to update.

        Returns:
            dict: The updated user object.
        """
        warnings.warn(
            "update_oidc_user is deprecated, use update_user instead",
            DeprecationWarning,
            stacklevel=2,
        )
        return await self._update_user(email, update_input)

    async def _upload_attachment_to_s3(
        self,
        resource_type: AttachmentResourceType,
        resource_id: int,
        attachment: dict,
        file_path: Path,
    ) -> dict:
        """
        Upload an attachment file to S3 and mark it as completed.

        Args:
            resource_type: The type of resource the attachment belongs to.
            resource_id: The ID of the resource the attachment belongs to.
            attachment: The attachment object containing upload parameters.
            file_path: Path to the attachment file to upload.

        Returns:
            dict: The updated attachment object.

        Raises:
            AssertionError: If the attachment status is not "Pending".
            httpx.HTTPStatusError: If the upload fails.
        """
        assert attachment["status"] == "Pending", "Attachment status must be pending"
        response = await self._internal_client.post(
            attachment["upload_file_params"]["url"],
            files={"file": file_path.read_bytes()},
            data=attachment["upload_file_params"]["fields"],
        )
        response.raise_for_status()
        # Update the status to completed
        resp = await self._put(
            "/attachments/update",
            params={
                "resource_type": resource_type,
                "resource_id": resource_id,
                "attachment_id": attachment["id"],
                "status": "Completed",
            },
        )
        return resp.json()

    async def list_attachments(
        self,
        resource_type: AttachmentResourceType,
        resource_id: int,
        status: Literal["Pending", "Completed"] | None = None,
    ) -> list[dict]:
        """
        List attachments for a specific resource with optional status filtering.

        Args:
            resource_type: The type of resource the attachments belong to.
            resource_id: The ID of the resource to list attachments for.
            status: Optional filter for attachment status, either "Pending" or "Completed".

        Returns:
            list[dict]: A list of attachment objects matching the filter criteria.
        """
        params = {"resource_type": resource_type, "resource_id": resource_id}
        if status:
            params["status"] = status
        response = await self._get(
            "/attachments/",
            params=params,
        )
        return response.json()

    async def add_attachments(
        self,
        resource_type: AttachmentResourceType,
        resource_id: int,
        files: list[PixelAttachmentUpload | Path]
        | list[Path]
        | list[PixelAttachmentUpload],
    ) -> list[dict]:
        """
        Add one or more file attachments to a resource.

        Args:
            resource_type: The type of resource to attach files to.
            resource_id: The ID of the resource to attach files to.
            files: List of files to attach, which can be Path objects or PixelAttachmentUpload objects.

        Returns:
            list[dict]: A list of the created attachment objects.

        Raises:
            AssertionError: If any attachment names are not unique.
        """
        pixel_attachments = [
            PixelAttachmentUpload(
                file=f,
            )
            if isinstance(f, Path)
            else f
            for f in files
        ]
        assert len(set(pa.name for pa in pixel_attachments)) == len(
            pixel_attachments
        ), "Attachment names must be unique"
        response = await self._post(
            "/attachments/",
            params={"resource_type": resource_type, "resource_id": resource_id},
            json={
                "files": [
                    pa.model_dump(mode="json", exclude_none=True)
                    for pa in pixel_attachments
                ]
            },
        )
        attachments = response.json()
        sorted_attachments = sorted(attachments, key=lambda a: a["name"])
        sorted_files = sorted(pixel_attachments, key=lambda f: f.name)
        attachments = await asyncio.gather(
            *[
                self._upload_attachment_to_s3(resource_type, resource_id, a, pa.file)
                for a, pa in zip(sorted_attachments, sorted_files)
            ]
        )
        return attachments

    async def move_attachment(
        self,
        resource_type: AttachmentResourceType,
        resource_id: int,
        attachment_id: int,
        new_resource_type: AttachmentResourceType,
        new_resource_id: int,
    ) -> dict:
        """
        Move an attachment from one resource to another.

        Args:
            resource_type: The current resource type of the attachment.
            resource_id: The current resource ID the attachment belongs to.
            attachment_id: The ID of the attachment to move.
            new_resource_type: The target resource type to move the attachment to.
            new_resource_id: The target resource ID to move the attachment to.

        Returns:
            dict: The updated attachment object.
        """
        resp = await self._put(
            "/attachments/move",
            params={
                "resource_type": resource_type,
                "resource_id": resource_id,
                "attachment_id": attachment_id,
                "new_resource_type": new_resource_type,
                "new_resource_id": new_resource_id,
            },
        )
        return resp.json()

    async def delete_attachment(
        self,
        resource_type: AttachmentResourceType,
        resource_id: int,
        attachment_id: int,
    ) -> dict:
        """
        Delete a specific attachment from a resource.

        Args:
            resource_type: The resource type the attachment belongs to.
            resource_id: The resource ID the attachment belongs to.
            attachment_id: The ID of the attachment to delete.

        Returns:
            dict: The response confirming deletion.
        """
        resp = await self._delete(
            "/attachments/",
            params={
                "resource_type": resource_type,
                "resource_id": resource_id,
                "attachment_id": attachment_id,
            },
        )
        return resp.json()

    async def search_info(self, on: SearchOn):
        """
        Retrieve search metadata for a specific resource type.

        Args:
            on: The resource type to retrieve search metadata for.
        Returns:
            dict: A dictionary containing output fields, filterable fields and search capabilities.
        """
        response = await self._get(
            "/search/info",
            params={"on": on},
        )
        return response.json()

    async def search(
        self,
        search_query: dict | SearchQuery,
    ) -> SearchResults:
        """
        Perform a search across various resources.

        Args:
            search_query: SearchQuery object or dict containing the search parameters.
        Returns:
            SearchResults: The search results dictionary.
        """
        search_model = (
            SearchQuery.model_validate(search_query)
            if isinstance(search_query, dict)
            else search_query
        )
        response = await self._post(
            "/search/",
            json=search_model.model_dump(mode="json", exclude_none=True),
        )
        return response.json()

    async def paginate_search(
        self, search_query: dict | SearchQuery, page_size: int
    ) -> AsyncGenerator[dict, None]:
        """
        Perform a paginated search across various resources.

        Args:
            search_query: SearchQuery object or dict containing the search parameters.
            page_size: Number of results to retrieve per page.

        Yields:
            dict: Individual search result items.
        """
        search_model = (
            SearchQuery.model_validate(search_query)
            if isinstance(search_query, dict)
            else search_query
        )
        search_query_body = search_model.model_dump(
            mode="json", exclude_none=True, exclude={"limit", "offset"}
        )
        async for item in self._paginate(
            "/search/",
            method="POST",
            page_size=page_size,
            use_body=True,
            # The return of the search endpoint is in the "results" field
            results_parser=lambda resp: resp.get("results", []),
            json=search_query_body,
        ):
            yield item


    async def list_analysis_modules(self) -> list[dict]:
            """
            Retrieve a list of available analysis modules.

            Returns:
                list[dict]: A list of analysis module objects.
            """
            response = await self._get("/analysis/modules/")
            return response.json()

    async def list_analysis_services(self, params: AnalysisServiceListParams | None = None, **kwargs) -> list[dict]:
            """
            Retrieve a list of available analysis services.

            Returns:
                list[dict]: A list of analysis service objects.
            """
            if params and kwargs:
                logger.warning("Ignoring kwargs when params is provided")
            params_dict = (
                params.model_dump(exclude_none=True, mode="json")
                if params
                else AnalysisServiceListParams.model_validate(kwargs).model_dump(
                    exclude_none=True, mode="json"
                )
            )
            response = await self._get("/analysis/services/", params=params_dict)
            return response.json()

    async def create_analysis_service(self, create_input: AnalysisServiceCreateUpdateInput | None = None, **kwargs) -> dict:
            """
            Create a new analysis service.

            Returns:
                dict: The created analysis service object.
            """
            if create_input and kwargs:
                logger.warning("Ignoring kwargs when create_input is provided")
            input_dict = (
                create_input.model_dump(mode="json", exclude_none=True)
                if create_input
                else AnalysisServiceCreateUpdateInput.model_validate(kwargs).model_dump(
                    exclude_none=True, mode="json"
                )
            )
            response = await self._post(
                "/analysis/services/", json=input_dict
            )
            return response.json()

    async def patch_analysis_service(
        self,
        service_id: int,
        patch_input: AnalysisServicePatchInput | None = None,
        **kwargs,
    ) -> dict:
            """
            Partially update an analysis service.

            Only fields explicitly set on `patch_input` (or passed as kwargs)
            are sent. Backend deep-merges `config`; omitted fields are kept
            as-is. `module_name` cannot be changed.

            Returns:
                dict: The updated analysis service object.
            """
            if patch_input and kwargs:
                logger.warning("Ignoring kwargs when patch_input is provided")
            model = patch_input or AnalysisServicePatchInput.model_validate(kwargs)
            input_dict = model.model_dump(exclude_unset=True, mode="json")
            response = await self._patch(
                f"/analysis/services/{service_id}", json=input_dict
            )
            return response.json()

    async def delete_analysis_service(self, service_id: int) -> bool:
            """
            Delete an existing analysis service.

            Returns:
                dict: The response confirming deletion.
            """
            _ = await self._delete(f"/analysis/services/{service_id}")
            return True

    async def list_analysis_tasks(self, service_id: int, list_input: AnalysisTaskListParams | None = None, **kwargs) -> list[dict]:
            """
            Retrieve a list of analysis tasks.

            Returns:
                list[dict]: A list of analysis task objects.
            """
            if list_input and kwargs:
                logger.warning("Ignoring kwargs when list_input is provided")
            params_dict = (
                list_input.model_dump(exclude_none=True, mode="json")
                if list_input
                else AnalysisTaskListParams.model_validate(kwargs).model_dump(
                    exclude_none=True, mode="json"
                )
            )
            response = await self._get(f"/analysis/services/{service_id}/tasks/", params=params_dict)
            return response.json()

    async def create_analysis_task(self, service_id: int, params: AnalysisTaskCreateInput | None = None, **kwargs) -> dict:
            """
            Create a new analysis task.

            Returns:
                dict: The created analysis task object.
            """
            if params and kwargs:
                logger.warning("Ignoring kwargs when params is provided")
            input_dict = (
                params.model_dump(mode="json", exclude_none=True)
                if params
                else AnalysisTaskCreateInput.model_validate(kwargs).model_dump(
                    exclude_none=True, mode="json"
                )
            )


            response = await self._post(
                f"/analysis/services/{service_id}/tasks/", json=input_dict
            )
            return response.json()

    async def delete_analysis_task(self, service_id: int, task_id: int) -> bool:
            """
            Delete an existing analysis task.

            Returns:
                dict: The response confirming deletion.
            """
            _ = await self._delete(f"/analysis/services/{service_id}/tasks/{task_id}")
            return True

    async def run_analysis_task(self, service_id: int, task_id: int) -> dict:
            """
            Run an existing analysis task.

            Returns:
                dict: The response confirming the task has been started.
            """
            response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/run")
            return response.json()

    async def revoke_analysis_task(self, service_id: int, task_id: int) -> dict:
            """
            Revoke an existing analysis task.

            Returns:
                dict: The response confirming the task has been revoked.
            """
            response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/revoke")
            return response.json()

    async def pause_analysis_task(self, service_id: int, task_id: int) -> dict:
            """
            Pause a running analysis task. Only modules with `pausable` set support this.

            The task moves to `PAUSING`, then to `PAUSED` at the next step boundary.

            Returns:
                dict: The task ID and its new status.
            """
            response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/pause")
            return response.json()

    async def resume_analysis_task(self, service_id: int, task_id: int) -> dict:
            """
            Resume a paused analysis task.

            Returns:
                dict: The task ID and its new status.
            """
            response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/resume")
            return response.json()

    async def list_analysis_service_field_options(
        self, service_id: int, field: str
    ) -> list[dict]:
            """
            List the allowed values for a field of an analysis service's config or task parameters.

            Args:
                service_id: The ID of the analysis service.
                field: The name of the config or params field to list options for.

            Returns:
                list[dict]: Options with `value`, `label` and an optional `description`.
            """
            response = await self._get(f"/analysis/services/{service_id}/options/{field}")
            return response.json()

    async def list_roles(self) -> list[dict]:
        """List the roles that can be granted, with the permissions each one bundles.

        Returns:
            list[dict]: Role objects with `name`, `is_system` and `permissions`
                (each a `kind` and `verb`).
        """
        response = await self._get("/roles/")
        return response.json()

    async def get_role(self, name: str) -> dict:
        """Retrieve a single role and the permissions it bundles.

        Args:
            name: The role name, e.g. `"editor"`.

        Returns:
            dict: The role object.
        """
        response = await self._get(f"/roles/{name}")
        return response.json()

    async def list_permissions(self) -> list[dict]:
        """List every permission that exists, independent of which roles bundle it.

        Returns:
            list[dict]: Permission objects with a `kind` (e.g. `"project"`) and a `verb` (e.g. `"read"`).
        """
        response = await self._get("/permissions/")
        return response.json()

    async def paginate_grants(
        self,
        page_size: int,
        project_ids: list[int] | None = None,
        principal_kind: Literal["user", "group"] | None = None,
        principal_ids: list[int] | None = None,
        include_root: bool = False,
    ) -> AsyncGenerator[dict, None]:
        """Iterate over the user and group grants on the projects you administer, page by page.

        See [`list_grants`][pixel_client.PixelClientAsync.list_grants] for the filters.

        Args:
            page_size: Number of grants to fetch per request.

        Yields:
            dict: Individual grant objects.
        """
        params: dict[str, Any] = {"include_root": include_root}
        if project_ids:
            params["project_id"] = list(project_ids)
        if principal_kind:
            params["principal_kind"] = principal_kind
        if principal_ids:
            params["principal_id"] = list(principal_ids)
        offset = 0
        while True:
            response = await self._get(
                "/access/grants",
                params={**params, "offset": offset, "limit": page_size},
            )
            page = response.json()
            for item in page["items"]:
                yield item
            offset += len(page["items"])
            if not page["items"] or offset >= page["total"]:
                break

    async def list_grants(
        self,
        project_ids: list[int] | None = None,
        principal_kind: Literal["user", "group"] | None = None,
        principal_ids: list[int] | None = None,
        include_root: bool = False,
    ) -> list[dict]:
        """List the user and group grants on the projects you administer.

        Each grant says who holds which role, where it is held, and the project
        it is listed on. A grant held on a project above the ones you administer
        is listed on the highest of your projects it reaches, with `held_on`
        set to `"above"`. Group grants include the group's member ids in
        `member_ids`, so access people get through a group can be worked out.
        Fetches every page.

        Args:
            project_ids: Only grants listed on these projects.
            principal_kind: Only grants held by users, or only by groups.
            principal_ids: Only grants held by these users or groups.
            include_root: Also include organisation-wide grants.

        Returns:
            list[dict]: Grant objects.

        Note:
            Cannot be called with an api key.
        """
        return [
            grant
            async for grant in self.paginate_grants(
                GRANTS_PAGE_SIZE, project_ids, principal_kind, principal_ids, include_root
            )
        ]

    async def get_user_access(self, user: UserRef) -> dict:
        """What a user can do, and why.

        Returns the user's organisation-wide grants and every project they reach,
        each with their effective role and permissions and the grants behind
        them (direct, inherited from a parent project, or through a group).
        For another user you need to be able to list users, and you only see
        projects you administer.

        Args:
            user: The user's ID or email address.

        Returns:
            dict: The user's access, with `root` and `projects`.

        Note:
            Cannot be called with an api key.
        """
        user_id = await self._resolve_user_id(user)
        response = await self._get(f"/users/{user_id}/access")
        return response.json()

    async def get_group_access(self, group_id: int) -> dict:
        """What a group can do: its own grants, and every project it reaches with
        the effective permissions there. Only projects you can read are listed.

        Args:
            group_id: The ID of the group.

        Returns:
            dict: The group's access, with `root`, `projects` and `member_count`.

        Note:
            Cannot be called with an api key.
        """
        response = await self._get(f"/groups/{group_id}/access")
        return response.json()

    async def _resolve_user_id(self, user: UserRef) -> int:
        """Return the ID of a user given by ID or email address."""
        if isinstance(user, int):
            return user
        try:
            response = await self._get(f"/users/{user}/info")
        except PixelBadRequestError as e:
            if e.status_code == 404:
                raise ValueError(f"No user with email address {user!r}.") from e
            raise
        return response.json()["id"]

    async def _resolve_user_ids(self, users: list[UserRef] | None) -> list[int]:
        return [await self._resolve_user_id(user) for user in users or []]

    async def _resolve_user_email(self, user: UserRef) -> str:
        """Return the email address of a user given by ID or email address."""
        if isinstance(user, str):
            return user
        found = await self.list_users(ids=[user])
        if not found:
            raise ValueError(f"No user with ID {user}.")
        return found[0]["email"]

    async def _resolve_geo_service_user_ids(
        self, geo_service_users: list[GeoServiceUserRef] | None
    ) -> list[int]:
        """Return the IDs of geo service users given by ID or username."""
        refs = list(geo_service_users or [])
        if all(isinstance(ref, int) for ref in refs):
            return refs  # type: ignore[return-value]
        by_username = {u["username"]: u["id"] for u in await self.list_geo_service_users()}
        ids = []
        for ref in refs:
            if isinstance(ref, int):
                ids.append(ref)
            elif ref in by_username:
                ids.append(by_username[ref])
            else:
                raise ValueError(f"No geo service user with username {ref!r}.")
        return ids

    async def grant_access_on(
        self,
        resources: Resource | list[Resource],
        role: str | None = None,
        *,
        users: list[UserRef] | None = None,
        groups: list[int] | None = None,
        geo_service_users: list[GeoServiceUserRef] | None = None,
    ) -> list[dict]:
        """Give users, groups or geo service users a role on one or more resources.

        Everyone listed gets the same role; to give different roles, call again.
        A principal that already holds a role directly on the resource is moved
        to the requested role, also when that lowers it, so running the same
        call twice gives the same result. Access inherited from a parent project
        or through a group is not changed, and still applies.

        Which principals and roles a resource accepts depends on its type:

        - [`ProjectResource`][pixel_client.models.ProjectResource]: users and
          groups, with role `"viewer"`, `"editor"` or `"admin"`. You need the
          admin role on the project, can only give roles you hold there, and
          must be a member of each group.
        - [`ArcgisServiceResource`][pixel_client.models.ArcgisServiceResource]:
          geo service users only; the role can be omitted.

        Args:
            resources: The resource, or a list of resources, to give access on.
            role: The role to give.
            users: Users, by ID or email address.
            groups: Groups, by ID.
            geo_service_users: Geo service users, by ID or username.

        Returns:
            list[dict]: One entry per principal and resource, with `resource`,
                `principal_kind`, `principal_id`, `role` and `action`
                (`"granted"`, `"updated"` or `"unchanged"`).

        Raises:
            ValueError: If the resource does not accept these principals or this
                role, or a user or geo service user cannot be found. Raised before
                any change is made.
            PixelAccessUpdateError: If some changes failed. All other changes
                were still applied.
        """
        resources, principals = await self._prepare_access_change(
            resources, users, groups, geo_service_users, role=role, granting=True
        )
        outcome = Outcome()
        for resource in resources:
            handler = handler_for(resource)
            await handler.grant(
                self, resource, handler.check_role(resource, role), principals, outcome
            )
        if outcome.failed:
            raise PixelAccessUpdateError(outcome.succeeded, outcome.failed)
        return outcome.succeeded

    async def revoke_access_on(
        self,
        resources: Resource | list[Resource],
        *,
        users: list[UserRef] | None = None,
        groups: list[int] | None = None,
        geo_service_users: list[GeoServiceUserRef] | None = None,
    ) -> list[dict]:
        """Remove the access users, groups or geo service users hold directly on
        one or more resources.

        Principals without a direct grant on a resource are skipped. Access
        inherited from a parent project or through a group is not changed.

        Args:
            resources: The resource, or a list of resources, to remove access on.
            users: Users, by ID or email address.
            groups: Groups, by ID.
            geo_service_users: Geo service users, by ID or username.

        Returns:
            list[dict]: One entry per principal and resource, with `action`
                `"revoked"` or `"unchanged"`.

        Raises:
            ValueError: If the resource does not accept these principals, or a
                user or geo service user cannot be found.
            PixelAccessUpdateError: If some changes failed. All other changes
                were still applied.
        """
        resources, principals = await self._prepare_access_change(
            resources, users, groups, geo_service_users, role=None, granting=False
        )
        outcome = Outcome()
        for resource in resources:
            await handler_for(resource).revoke(self, resource, principals, outcome)
        if outcome.failed:
            raise PixelAccessUpdateError(outcome.succeeded, outcome.failed)
        return outcome.succeeded

    async def _prepare_access_change(
        self,
        resources: Resource | list[Resource],
        users: list[UserRef] | None,
        groups: list[int] | None,
        geo_service_users: list[GeoServiceUserRef] | None,
        role: str | None,
        granting: bool,
    ) -> tuple[list[Resource], Principals]:
        """Validate an access change and resolve its principals to IDs, before any write."""
        resources = [resources] if isinstance(resources, Resource) else list(resources)
        if not resources:
            raise ValueError("Give at least one resource to change access on.")
        given: dict[str, list] = {
            "user": list(users or []),
            "group": list(groups or []),
            "geo_service_user": list(geo_service_users or []),
        }
        if not any(given.values()):
            raise ValueError(
                "Give at least one principal: users, groups or geo_service_users."
            )
        for resource in resources:
            handler = handler_for(resource)
            handler.check(resource, given)  # type: ignore[arg-type]
            if granting:
                handler.check_role(resource, role)
        principals: Principals = {
            "user": await self._resolve_user_ids(given["user"]),
            "group": given["group"],
            "geo_service_user": await self._resolve_geo_service_user_ids(
                given["geo_service_user"]
            ),
        }
        return resources, principals

    async def grant_project_access(
        self,
        projects: int | list[int],
        role: RoleType,
        *,
        users: list[UserRef] | None = None,
        groups: list[int] | None = None,
    ) -> list[dict]:
        """Give users and groups a role on one or more projects (and their subprojects).

        Everyone listed gets the same role. Anyone who already has a role
        directly on a project is moved to `role`, also when that lowers it.
        Access inherited from a parent project or through a group still applies.

        You need the admin role on each project, can only give roles you hold
        there yourself, and must be a member of each group.

        Args:
            projects: The project ID, or a list of project IDs.
            role: `"viewer"`, `"editor"` or `"admin"`.
            users: Users, by ID or email address.
            groups: Groups, by ID.

        Returns:
            list[dict]: One entry per principal and project, with `action`
                `"granted"`, `"updated"` or `"unchanged"`.

        Raises:
            ValueError: If the role is not a project role or a user cannot be found.
            PixelAccessUpdateError: If some changes failed. All other changes
                were still applied.
        """
        return await self.grant_access_on(
            self._project_resources(projects), role, users=users, groups=groups
        )

    async def revoke_project_access(
        self,
        projects: int | list[int],
        *,
        users: list[UserRef] | None = None,
        groups: list[int] | None = None,
    ) -> list[dict]:
        """Remove the access users and groups hold directly on one or more projects.

        Access inherited from a parent project or through a group still applies.
        Admins of the project can remove anyone; group admins can also remove
        their group.

        Args:
            projects: The project ID, or a list of project IDs.
            users: Users, by ID or email address.
            groups: Groups, by ID.

        Returns:
            list[dict]: One entry per principal and project, with `action`
                `"revoked"` or `"unchanged"`.
        """
        return await self.revoke_access_on(
            self._project_resources(projects), users=users, groups=groups
        )

    @staticmethod
    def _project_resources(projects: int | list[int]) -> list[Resource]:
        project_ids = [projects] if isinstance(projects, int) else projects
        return [ProjectResource(project_id) for project_id in project_ids]

    async def list_project_users(self, project_id: int) -> list[dict]:
        """List the users with a role directly on a project.

        Users who reach the project through a parent project or a group are not
        included; see [`list_grants`][pixel_client.PixelClientAsync.list_grants].

        Args:
            project_id: The ID of the project.

        Returns:
            list[dict]: User objects, each with their `role` on the project.
        """
        response = await self._get(f"/projects/{project_id}/users")
        return response.json()

    async def list_project_groups(self, project_id: int) -> list[dict]:
        """List the groups with a role directly on a project.

        Args:
            project_id: The ID of the project.

        Returns:
            list[dict]: Group objects, each with their `role` on the project.
        """
        response = await self._get(f"/projects/{project_id}/groups")
        return response.json()

    async def _grant_projects_by_role(
        self,
        projects: dict[int, RoleType],
        result: dict,
        **principals: list,
    ) -> None:
        """Grant each project its role, then raise one error for anything that failed."""
        by_role: dict[RoleType, list[int]] = defaultdict(list)
        for project_id, role in projects.items():
            by_role[role].append(project_id)
        succeeded: list[dict] = []
        failed: list[tuple[dict, Exception]] = []
        for role, project_ids in by_role.items():
            try:
                succeeded += await self.grant_project_access(project_ids, role, **principals)
            except PixelAccessUpdateError as e:
                succeeded += e.succeeded
                failed += e.failed
        if failed:
            raise PixelAccessUpdateError(succeeded, failed, result=result)

    async def create_user(
        self,
        email: str,
        first_name: str,
        last_name: str,
        password: str | SecretStr,
        user_type: UserType = "viewer",
        *,
        groups: list[int] | None = None,
        projects: dict[int, RoleType] | None = None,
    ) -> dict:
        """Create a user, optionally adding them to groups and giving them project roles.

        A new user sees nothing until they are given access, directly or
        through a group. Superusers only.

        Args:
            email: The user's email address, used to sign in.
            first_name: The user's first name.
            last_name: The user's last name.
            password: A temporary password. The user chooses their own the first
                time they sign in, so share it securely.
            user_type: The account type. `"viewer"` sees only what they are given
                access to; `"creator"` can also create top-level projects, groups
                and api keys, and list users; `"superuser"` can see and change
                everything in the organisation.
            groups: Groups to add the user to, by ID. You must be a group admin
                of each.
            projects: Mapping of project ID to the role the user gets there,
                e.g. `{42: "editor"}`.

        Returns:
            dict: The created user.

        Raises:
            PixelAccessUpdateError: If the user was created but some project
                roles could not be given. The user is in `result`.

        Note:
            Cannot be called with an api key.
        """
        create_input = OIDCUserCreateInput(
            email=email,
            first_name=first_name,
            last_name=last_name,
            password=password,  # type: ignore[arg-type]
            user_type=user_type,
            groups=[GroupMembershipInput(group_id=group_id) for group_id in groups or []],
        )
        user = await self._create_user(create_input)
        if projects:
            await self._grant_projects_by_role(projects, result=user, users=[user["id"]])
        return user

    async def _create_user(self, create_input: OIDCUserCreateInput) -> dict:
        response = await self._post(
            "/users/",
            json=create_input.model_dump(exclude_none=True, mode="json"),
            sensitive_content=True,
        )
        return response.json()

    async def update_user(
        self,
        user: UserRef,
        *,
        first_name: str | None = None,
        last_name: str | None = None,
        password: str | SecretStr | None = None,
        user_type: UserType | None = None,
    ) -> dict:
        """Change a user's name, account type or password. Superusers only.

        Fields left out are not changed. The user's active status is kept.

        Args:
            user: The user's ID or email address.
            first_name: New first name.
            last_name: New last name.
            password: A new temporary password. The user chooses their own the
                next time they sign in.
            user_type: New account type: `"viewer"`, `"creator"` or `"superuser"`.

        Returns:
            dict: The updated user.

        Note:
            Cannot be called with an api key.
        """
        email = await self._resolve_user_email(user)
        current = await self.get_user(email)
        update_input = OIDCUserUpdateInput(
            first_name=first_name,
            last_name=last_name,
            password=password,  # type: ignore[arg-type]
            user_type=user_type,
            enabled=current["is_active"],
        )
        return await self._update_user(email, update_input)

    async def _update_user(self, email: str, update_input: OIDCUserUpdateInput) -> dict:
        response = await self._put(
            f"/users/{email}",
            json=update_input.model_dump(mode="json", exclude_none=True),
            sensitive_content=True,
        )
        return response.json()

    async def get_user(self, user: UserRef) -> dict:
        """Retrieve a user.

        Args:
            user: The user's ID or email address.

        Returns:
            dict: The user, including `id`, `email`, `is_active` and `user_type`.
        """
        email = await self._resolve_user_email(user)
        response = await self._get(f"/users/{email}/info")
        return response.json()

    async def list_users(
        self, params: UserListParams | None = None, **kwargs
    ) -> list[dict]:
        """List the users in the organisation, including deactivated ones.

        Needs the creator or superuser account type.

        Args:
            params: Optional UserListParams object with `name`, `ids`, `offset` and `limit`.
            **kwargs: Alternative way to provide the filtering parameters.

        Returns:
            list[dict]: User objects.
        """
        params = params or UserListParams.model_validate(kwargs)
        response = await self._get(
            "/users/", params=params.model_dump(exclude_none=True, mode="json")
        )
        return response.json()

    async def paginate_users(
        self, page_size: int, params: UserListParams | None = None, **kwargs
    ) -> AsyncGenerator[dict, None]:
        """Iterate over the users in the organisation, page by page.

        Args:
            page_size: Number of users to fetch per request.
            params: Optional UserListParams object with filtering parameters.
            **kwargs: Alternative way to provide the filtering parameters.

        Yields:
            dict: Individual user objects.
        """
        params = params or UserListParams.model_validate(kwargs)
        async for user in self._paginate(
            "/users/",
            page_size=page_size,
            params=params.model_dump(exclude_none=True, mode="json", exclude={"offset", "limit"}),
        ):
            yield user

    async def create_group(
        self,
        name: str,
        description: str = "",
        *,
        members: list[UserRef] | None = None,
        projects: dict[int, RoleType] | None = None,
    ) -> dict:
        """Create a group, optionally with members and project roles.

        You become the group's first member and admin. Members get the group's
        access on its projects.

        Args:
            name: The name of the group.
            description: A description of the group.
            members: Users to add, by ID or email address.
            projects: Mapping of project ID to the role the group gets there,
                e.g. `{42: "editor"}`. You need the admin role on each project.

        Returns:
            dict: The created group.

        Raises:
            ValueError: If a member cannot be found. Raised before the group is created.
            PixelAccessUpdateError: If the group was created but some members or
                project roles could not be added. The group is in `result`.
        """
        user_ids = await self._resolve_user_ids(members)
        response = await self._post(
            "/groups/",
            json=GroupCreateInput(name=name, description=description).model_dump(mode="json"),
        )
        group = response.json()
        succeeded: list[dict] = []
        failed: list[tuple[dict, Exception]] = []
        if user_ids:
            changes = [
                {
                    "resource": {"kind": "group", "id": group["id"]},
                    "principal_kind": "user",
                    "principal_id": user_id,
                    "role": None,
                    "action": "added",
                }
                for user_id in user_ids
            ]
            try:
                await self._add_group_members(group["id"], user_ids, admin=False)
            except (PixelBadRequestError, httpx.HTTPError) as e:
                failed += [(c, e) for c in changes]
            else:
                succeeded += changes
        if projects:
            try:
                await self._grant_projects_by_role(projects, result=group, groups=[group["id"]])
            except PixelAccessUpdateError as e:
                succeeded += e.succeeded
                failed += e.failed
        if failed:
            raise PixelAccessUpdateError(succeeded, failed, result=group)
        return group

    async def list_groups(
        self, params: GroupListParams | None = None, **kwargs
    ) -> list[dict]:
        """List the groups you are a member of. Superusers see every group.

        Args:
            params: Optional GroupListParams object with `name`, `ids`, `offset` and `limit`.
            **kwargs: Alternative way to provide the filtering parameters.

        Returns:
            list[dict]: Group objects.
        """
        params = params or GroupListParams.model_validate(kwargs)
        response = await self._get(
            "/groups/", params=params.model_dump(exclude_none=True, mode="json")
        )
        return response.json()

    async def get_group(self, group_id: int) -> dict:
        """Retrieve a group with its members and the projects it has a role on.

        Visible to members of the group and to superusers.

        Args:
            group_id: The ID of the group.

        Returns:
            dict: The group, with `members` (each with `is_admin`) and `projects`
                (each with the group's `role`).
        """
        response = await self._get(f"/groups/{group_id}")
        return response.json()

    async def update_group(
        self,
        group_id: int,
        *,
        name: str | None = None,
        description: str | None = None,
    ) -> dict:
        """Rename a group or change its description. Group admins only.

        Members and access are not changed.

        Args:
            group_id: The ID of the group.
            name: New name.
            description: New description.

        Returns:
            dict: The updated group.
        """
        update_input = GroupUpdateInput(name=name, description=description)
        response = await self._patch(
            f"/groups/{group_id}",
            json=update_input.model_dump(mode="json", exclude_none=True),
        )
        return response.json()

    async def delete_group(self, group_id: int) -> dict:
        """Delete a group. Group admins only.

        Every member, and every api key that follows the group, loses the access
        it had through the group. This cannot be undone.

        Args:
            group_id: The ID of the group.

        Returns:
            dict: The response confirming deletion.
        """
        response = await self._delete(f"/groups/{group_id}")
        return response.json()

    async def add_group_members(
        self, group_id: int, users: list[UserRef], *, admin: bool = False
    ) -> list[dict]:
        """Add users to a group. They get the group's access. Group admins only.

        Args:
            group_id: The ID of the group.
            users: Users to add, by ID or email address.
            admin: Also make them group admins. Admins can rename and delete the
                group and manage its members; it gives no access to data.

        Returns:
            list[dict]: The added members.
        """
        return await self._add_group_members(
            group_id, await self._resolve_user_ids(users), admin=admin
        )

    async def _add_group_members(
        self, group_id: int, user_ids: list[int], admin: bool
    ) -> list[dict]:
        response = await self._post(
            f"/groups/{group_id}/users",
            json={
                "users": [
                    GroupMemberInput(user_id=user_id, is_admin=admin).model_dump(mode="json")
                    for user_id in user_ids
                ]
            },
        )
        return response.json()

    async def remove_group_member(self, group_id: int, user: UserRef) -> dict:
        """Remove a member from a group. They lose the access the group gave them.

        Group admins can remove anyone; any member can remove themselves to
        leave the group. The last admin cannot be removed.

        Args:
            group_id: The ID of the group.
            user: The member, by ID or email address.

        Returns:
            dict: The response confirming removal.
        """
        user_id = await self._resolve_user_id(user)
        response = await self._delete(f"/groups/{group_id}/users/{user_id}")
        return response.json()

    async def set_group_admin(
        self, group_id: int, user: UserRef, admin: bool = True
    ) -> dict:
        """Make a member a group admin, or remove their admin status. Group admins only.

        Only members can be admins, and a group always keeps at least one.

        Args:
            group_id: The ID of the group.
            user: The member, by ID or email address.
            admin: `True` to make them admin, `False` to remove admin status.

        Returns:
            dict: The updated member.
        """
        user_id = await self._resolve_user_id(user)
        response = await self._put(
            f"/groups/{group_id}/users/{user_id}/admin", params={"is_admin": admin}
        )
        return response.json()

    async def create_api_key(
        self,
        name: str,
        *,
        projects: dict[int, RoleType] | None = None,
        groups: list[int] | None = None,
        base_role: BaseRoleType | None = None,
        expires_in_days: int = 90,
        expires_at: datetime.datetime | None = None,
    ) -> dict:
        """Create an api key for scripts and integrations.

        A key can never do more than you can: its access is always limited to
        your own current access, so it loses access when you do. The scope
        cannot be changed later; use
        [`replace_api_key`][pixel_client.PixelClientAsync.replace_api_key] to
        get a key with a different scope.

        Args:
            name: A name to recognise the key by.
            projects: Mapping of project ID to the role the key gets there,
                e.g. `{42: "editor"}`.
            groups: Groups the key follows, by ID. The key gets whatever each
                group can reach, even as that changes. You must be a member.
            base_role: An organisation-wide role: `"viewer"` reads all projects,
                `"creator"` can create projects and groups, `"superuser"` can do
                everything. You can only give a role you hold yourself.
            expires_in_days: Days until the key expires. Ignored if `expires_at` is given.
            expires_at: When the key expires.

        Returns:
            dict: The key's details under `api_key`, and the secret under `token`.

        Warning:
            The `token` is returned only this once and can never be retrieved
            again. Store it somewhere safe.

        Raises:
            ValueError: If none of `projects`, `groups` or `base_role` is given.

        Note:
            Cannot be called with an api key.
        """
        grants = self._api_key_grants(projects, groups, base_role)
        if not grants:
            raise ValueError(
                "An api key needs at least one of projects, groups or base_role."
            )
        return await self._create_api_key(
            ApiKeyCreateInput(
                name=name,
                expires_at=self._api_key_expiry(expires_in_days, expires_at),
                grants=grants,
            )
        )

    @staticmethod
    def _api_key_grants(
        projects: dict[int, RoleType] | None,
        groups: list[int] | None,
        base_role: BaseRoleType | None,
    ) -> list[ApiKeyGrant]:
        grants: list[ApiKeyGrant] = [
            ApiKeyProjectGrant(project_id=project_id, role=role)
            for project_id, role in (projects or {}).items()
        ]
        grants += [ApiKeyGroupGrant(group_id=group_id) for group_id in groups or []]
        if base_role is not None:
            grants.append(ApiKeyRootGrant(role=base_role))
        return grants

    @staticmethod
    def _api_key_expiry(
        expires_in_days: int, expires_at: datetime.datetime | None
    ) -> datetime.datetime:
        return expires_at or datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(
            days=expires_in_days
        )

    async def _create_api_key(self, create_input: ApiKeyCreateInput) -> dict:
        response = await self._post(
            "/api_keys/", json=create_input.model_dump(mode="json")
        )
        return response.json()

    async def list_api_keys(self, all: bool = False) -> list[dict]:
        """List your api keys. Never includes the secret.

        Each key has a `status` (`"active"`, `"expired"`, `"revoked"` or
        `"owner_inactive"`) and is `weakened` when its owner has lost some of the
        access it was given.

        Args:
            all: Superusers only. List every key in the organisation.

        Returns:
            list[dict]: Api key objects, with their `grants`.

        Note:
            Cannot be called with an api key.
        """
        response = await self._get("/api_keys/", params={"all": all})
        return response.json()

    async def rename_api_key(self, api_key_id: str | UUID, name: str) -> dict:
        """Rename an api key. Only the name can change. Owner only.

        Args:
            api_key_id: The ID of the api key.
            name: The new name.

        Returns:
            dict: The updated api key.

        Note:
            Cannot be called with an api key.
        """
        response = await self._patch(f"/api_keys/{api_key_id}", json={"name": name})
        return response.json()

    async def revoke_api_key(self, api_key_id: str | UUID) -> dict:
        """Revoke an api key. Scripts using it stop working within minutes.

        The owner or a superuser can revoke a key. Revoking twice is harmless.

        Args:
            api_key_id: The ID of the api key.

        Returns:
            dict: The response confirming revocation.

        Note:
            Cannot be called with an api key.
        """
        response = await self._delete(f"/api_keys/{api_key_id}")
        return response.json()

    async def replace_api_key(
        self,
        api_key_id: str | UUID,
        *,
        name: str | None = None,
        projects: dict[int, RoleType] | None = None,
        groups: list[int] | None = None,
        base_role: BaseRoleType | None = None,
        expires_in_days: int = 90,
        expires_at: datetime.datetime | None = None,
        take_over: bool = False,
    ) -> dict:
        """Create a new api key with the same scope as an existing one, then revoke the old one.

        Use it to rotate a key, renew an expired one, or change a key's scope:
        each of `projects`, `groups` and `base_role` that you give replaces that
        part of the copied scope. An expired or revoked key is not revoked again.

        Args:
            api_key_id: The ID of the key to replace.
            name: Name of the new key. Defaults to the old name with " (new)" added.
            projects: Replaces the old key's project roles.
            groups: Replaces the groups the old key follows.
            base_role: Replaces the old key's organisation-wide role.
            expires_in_days: Days until the new key expires. Ignored if `expires_at` is given.
            expires_at: When the new key expires.
            take_over: Superusers only. Allow replacing someone else's key. The
                new key belongs to you and is limited to your access, and the
                owner's key is revoked, so their scripts stop working.

        Returns:
            dict: The new key's details under `api_key`, and the secret under `token`.

        Warning:
            The `token` is returned only this once and can never be retrieved again.

        Raises:
            ValueError: If the key is not found, or belongs to someone else and
                `take_over` is not set.

        Note:
            Cannot be called with an api key.
        """
        key = await self._find_api_key(str(api_key_id), take_over)
        copied = [self._api_key_grant_from_response(g) for g in key["grants"]]
        grants: list[ApiKeyGrant] = (
            self._api_key_grants(projects, None, None)
            if projects is not None
            else [g for g in copied if isinstance(g, ApiKeyProjectGrant)]
        )
        grants += (
            self._api_key_grants(None, groups, None)
            if groups is not None
            else [g for g in copied if isinstance(g, ApiKeyGroupGrant)]
        )
        grants += (
            self._api_key_grants(None, None, base_role)
            if base_role is not None
            else [g for g in copied if isinstance(g, ApiKeyRootGrant)]
        )
        new_key = await self._create_api_key(
            ApiKeyCreateInput(
                name=name or f"{key['name']} (new)",
                expires_at=self._api_key_expiry(expires_in_days, expires_at),
                grants=grants,
            )
        )
        if key["status"] not in ("revoked", "expired"):
            await self.revoke_api_key(key["id"])
        return new_key

    async def _find_api_key(self, api_key_id: str, take_over: bool) -> dict:
        for key in await self.list_api_keys():
            if str(key["id"]) == api_key_id:
                return key
        others: list[dict] = []
        try:
            others = await self.list_api_keys(all=True)
        except PixelBadRequestError:
            pass
        for key in others:
            if str(key["id"]) == api_key_id:
                if not take_over:
                    raise ValueError(
                        f"Api key {api_key_id!r} belongs to someone else. Pass "
                        "take_over=True to replace it with a key of your own."
                    )
                return key
        raise ValueError(f"No api key with ID {api_key_id!r}.")

    @staticmethod
    def _api_key_grant_from_response(grant: dict) -> ApiKeyGrant:
        if grant["kind"] == "project":
            return ApiKeyProjectGrant(project_id=grant["project_id"], role=grant["role"])
        if grant["kind"] == "group":
            return ApiKeyGroupGrant(group_id=grant["group_id"])
        return ApiKeyRootGrant(role=grant["role"])

    async def create_geo_service_user(
        self,
        username: str,
        description: str = "",
        password: str | SecretStr | None = None,
    ) -> dict:
        """Create a geo service user: a username and password ArcGIS clients use
        to sign in to the map services.

        A geo service user can only reach the services it is given access to
        (see [`grant_arcgis_service_access`][pixel_client.PixelClientAsync.grant_arcgis_service_access]),
        starts with access to none, and can never sign in to Pixel itself. Only
        works on ArcGIS Server v2. Superusers only.

        Args:
            username: 3-64 characters: lowercase letters, digits, `_`, `.` and
                `-`, starting with a letter or digit. Cannot be changed later.
            description: What the user is for.
            password: Leave out to have a strong password generated. A password
                you choose (12-128 characters) is never shown again.

        Returns:
            dict: The user under `geo_service_user`, and under `password` the
                generated password, or `None` if you chose one.

        Warning:
            A generated password is returned only this once. Store it somewhere safe.

        Note:
            Cannot be called with an api key.
        """
        create_input = GeoServiceUserCreateInput(
            username=username,
            description=description,
            password=password,  # type: ignore[arg-type]
        )
        response = await self._post(
            "/geo_service_users/",
            json=create_input.model_dump(mode="json", exclude_none=True),
            sensitive_content=True,
        )
        return response.json()

    async def list_geo_service_users(self) -> list[dict]:
        """List the geo service users, with the services each can access.

        Returns:
            list[dict]: Geo service user objects, with their `grants`.
        """
        response = await self._get("/geo_service_users/")
        return response.json()

    async def _geo_service_user_id(self, geo_service_user: GeoServiceUserRef) -> int:
        return (await self._resolve_geo_service_user_ids([geo_service_user]))[0]

    async def get_geo_service_user(self, geo_service_user: GeoServiceUserRef) -> dict:
        """Retrieve a geo service user.

        Args:
            geo_service_user: The geo service user's ID or username.

        Returns:
            dict: The geo service user, with the services it can access.
        """
        user_id = await self._geo_service_user_id(geo_service_user)
        response = await self._get(f"/geo_service_users/{user_id}")
        return response.json()

    async def update_geo_service_user(
        self, geo_service_user: GeoServiceUserRef, *, description: str | None = None
    ) -> dict:
        """Change a geo service user's description. Superusers only.

        Args:
            geo_service_user: The geo service user's ID or username.
            description: The new description.

        Returns:
            dict: The updated geo service user.

        Note:
            Cannot be called with an api key.
        """
        return await self._patch_geo_service_user(
            geo_service_user, {"description": description}
        )

    async def disable_geo_service_user(self, geo_service_user: GeoServiceUserRef) -> dict:
        """Stop a geo service user from signing in. Its service access is kept
        and comes back when it is enabled again. Superusers only.

        Args:
            geo_service_user: The geo service user's ID or username.

        Returns:
            dict: The updated geo service user.

        Note:
            Cannot be called with an api key.
        """
        return await self._patch_geo_service_user(geo_service_user, {"disabled": True})

    async def enable_geo_service_user(self, geo_service_user: GeoServiceUserRef) -> dict:
        """Let a disabled geo service user sign in again, with the access it had.
        Superusers only.

        Args:
            geo_service_user: The geo service user's ID or username.

        Returns:
            dict: The updated geo service user.

        Note:
            Cannot be called with an api key.
        """
        return await self._patch_geo_service_user(geo_service_user, {"disabled": False})

    async def _patch_geo_service_user(
        self, geo_service_user: GeoServiceUserRef, fields: dict
    ) -> dict:
        user_id = await self._geo_service_user_id(geo_service_user)
        response = await self._patch(
            f"/geo_service_users/{user_id}",
            json={k: v for k, v in fields.items() if v is not None},
        )
        return response.json()

    async def rotate_geo_service_user_password(
        self,
        geo_service_user: GeoServiceUserRef,
        password: str | SecretStr | None = None,
    ) -> dict:
        """Replace a geo service user's password. The old one stops working
        immediately. Superusers only.

        Args:
            geo_service_user: The geo service user's ID or username.
            password: Leave out to have a strong password generated. A password
                you choose (12-128 characters) is never shown again.

        Returns:
            dict: The user under `geo_service_user`, and under `password` the
                generated password, or `None` if you chose one.

        Warning:
            A generated password is returned only this once. Store it somewhere safe.

        Note:
            Cannot be called with an api key.
        """
        user_id = await self._geo_service_user_id(geo_service_user)
        if isinstance(password, SecretStr):
            password = password.get_secret_value()
        response = await self._post(
            f"/geo_service_users/{user_id}/rotate",
            json={"password": password} if password else {},
            sensitive_content=True,
        )
        return response.json()

    async def delete_geo_service_user(self, geo_service_user: GeoServiceUserRef) -> dict:
        """Delete a geo service user and all its service access. This cannot be
        undone; use [`disable_geo_service_user`][pixel_client.PixelClientAsync.disable_geo_service_user]
        to stop it temporarily. Superusers only.

        Args:
            geo_service_user: The geo service user's ID or username.

        Returns:
            dict: The response confirming deletion.

        Note:
            Cannot be called with an api key.
        """
        user_id = await self._geo_service_user_id(geo_service_user)
        response = await self._delete(f"/geo_service_users/{user_id}")
        return response.json()

    async def grant_arcgis_service_access(
        self,
        service_type: Literal["Feature", "Image"],
        service_id: int,
        geo_service_users: list[GeoServiceUserRef],
    ) -> list[dict]:
        """Give geo service users access to an ArcGIS service. Superusers only.

        Changes reach the map services within a few minutes.

        Args:
            service_type: `"Feature"` or `"Image"`.
            service_id: The ID of the ArcGIS service.
            geo_service_users: Geo service users, by ID or username.

        Returns:
            list[dict]: One entry per geo service user, with `action`
                `"granted"` or `"unchanged"`.
        """
        return await self.grant_access_on(
            ArcgisServiceResource(service_type, service_id),
            geo_service_users=geo_service_users,
        )

    async def revoke_arcgis_service_access(
        self,
        service_type: Literal["Feature", "Image"],
        service_id: int,
        geo_service_users: list[GeoServiceUserRef],
    ) -> list[dict]:
        """Remove geo service users' access to an ArcGIS service. Superusers only.

        Args:
            service_type: `"Feature"` or `"Image"`.
            service_id: The ID of the ArcGIS service.
            geo_service_users: Geo service users, by ID or username.

        Returns:
            list[dict]: One entry per geo service user, with `action`
                `"revoked"` or `"unchanged"`.
        """
        return await self.revoke_access_on(
            ArcgisServiceResource(service_type, service_id),
            geo_service_users=geo_service_users,
        )

    async def list_arcgis_service_access(
        self, service_type: Literal["Feature", "Image"], service_id: int
    ) -> list[dict]:
        """List the geo service users with access to an ArcGIS service.

        Args:
            service_type: `"Feature"` or `"Image"`.
            service_id: The ID of the ArcGIS service.

        Returns:
            list[dict]: Geo service user objects.
        """
        response = await self._get(
            f"/arcgis_services/{service_type}/{service_id}/access"
        )
        return response.json()

url instance-attribute

url: str = url

auth instance-attribute

auth: httpx.Auth = self._build_auth(
    keycloak_server_url=keycloak_server_url,
    realm=realm,
    client_id=client_id,
    username=username,
    password=password,
    api_key=api_key,
)

pixel_client instance-attribute

pixel_client = httpx.AsyncClient(
    base_url=self.url,
    auth=self.auth,
    timeout=self._timeout_pixel,
)

__init__

__init__(
    url: str,
    keycloak_server_url: str | None = None,
    realm: str | None = None,
    client_id: str | None = None,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    timeout_pixel: httpx.Timeout = DEFAULT_PIXEL_TIMEOUT,
    timeout_upload: httpx.Timeout = DEFAULT_UPLOAD_TIMEOUT,
    upload_num_retries: int = DEFAULT_UPLOAD_RETRIES,
    upload_max_concurrency: int = DEFAULT_MAX_CONCURRENCY,
)

The client authenticates either with Keycloak credentials (keycloak_server_url, realm, client_id, username, password) or with a Pixel api key (api_key). Provide one or the other, not both.

Parameters:

Name Type Description Default
url str

Base URL of the Pixel API.

required
keycloak_server_url str | None

URL of the Keycloak authentication server.

None
realm str | None

Keycloak realm name.

None
client_id str | None

Keycloak client ID.

None
username str | None

Username for authentication.

None
password str | None

Password for authentication.

None
api_key str | None

A Pixel api key, used instead of the Keycloak credentials.

None
timeout_pixel httpx.Timeout

Optional timeout configuration for Pixel API requests.

DEFAULT_PIXEL_TIMEOUT
timeout_upload httpx.Timeout

Optional timeout configuration for file uploads. If not provided, defaults to the same as timeout_pixel.

DEFAULT_UPLOAD_TIMEOUT

Raises:

Type Description
ValueError

If both an api key and Keycloak credentials are given, or if neither is.

Source code in src/pixel_client/_base.py
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
def __init__(
    self,
    url: str,
    keycloak_server_url: str | None = None,
    realm: str | None = None,
    client_id: str | None = None,
    username: str | None = None,
    password: str | None = None,
    api_key: str | None = None,
    timeout_pixel: httpx.Timeout = DEFAULT_PIXEL_TIMEOUT,
    timeout_upload: httpx.Timeout = DEFAULT_UPLOAD_TIMEOUT,
    upload_num_retries: int = DEFAULT_UPLOAD_RETRIES,
    upload_max_concurrency: int = DEFAULT_MAX_CONCURRENCY,
):
    """
    Initialize a new Pixel API client.

    The client authenticates either with Keycloak credentials
    (`keycloak_server_url`, `realm`, `client_id`, `username`, `password`) or
    with a Pixel api key (`api_key`). Provide one or the other, not both.

    Args:
        url: Base URL of the Pixel API.
        keycloak_server_url: URL of the Keycloak authentication server.
        realm: Keycloak realm name.
        client_id: Keycloak client ID.
        username: Username for authentication.
        password: Password for authentication.
        api_key: A Pixel api key, used instead of the Keycloak credentials.
        timeout_pixel: Optional timeout configuration for Pixel API requests.
        timeout_upload: Optional timeout configuration for file uploads. If not provided, defaults to the same as `timeout_pixel`.

    Raises:
        ValueError: If both an api key and Keycloak credentials are given, or if neither is.
    """
    self.url: str = url
    self._timeout_pixel = timeout_pixel
    self._timeout_upload = timeout_upload
    self.auth: httpx.Auth = self._build_auth(
        keycloak_server_url=keycloak_server_url,
        realm=realm,
        client_id=client_id,
        username=username,
        password=password,
        api_key=api_key,
    )
    self.pixel_client = httpx.AsyncClient(
        base_url=self.url, auth=self.auth, timeout=self._timeout_pixel
    )
    self._internal_client = httpx.AsyncClient(
        timeout=self._timeout_upload,  # Use a separate client for uploads
    )  # For s3 uploads
    self._semaphore: asyncio.Semaphore = asyncio.Semaphore(upload_max_concurrency)

    self._retry_policy = tenacity.AsyncRetrying(
        stop=tenacity.stop_after_attempt(upload_num_retries),
        wait=tenacity.wait_random_exponential(),
        before=tenacity.before_log(logger, logging.DEBUG),
        after=tenacity.after_log(logger, logging.DEBUG),
    )
    self._internal_client.request = self._retry_policy.wraps(
        self._internal_client.request
    )

from_settings classmethod

from_settings(
    settings: PixelApiSettings,
    **kwargs: Unpack[PixelClientKwargs],
) -> Self

Instantiate the client from settings.

Parameters:

Name Type Description Default
settings PixelApiSettings

PixelApiSettings object containing API configuration.

required
**kwargs Unpack[PixelClientKwargs]

Additional keyword arguments to pass to the client constructor.

{}

Returns:

Name Type Description
PixelClientAsync Self

A new client instance configured with the provided settings.

Source code in src/pixel_client/_base.py
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
@classmethod
def from_settings(
    cls, settings: PixelApiSettings, **kwargs: Unpack[PixelClientKwargs]
) -> Self:
    """
    Instantiate the client from settings.

    Args:
        settings: PixelApiSettings object containing API configuration.
        **kwargs: Additional keyword arguments to pass to the client constructor.

    Returns:
        PixelClientAsync: A new client instance configured with the provided settings.
    """
    if settings.PIXEL_API_KEY is not None:
        return cls(
            url=settings.PIXEL_API_URL,
            api_key=settings.PIXEL_API_KEY.get_secret_value(),
            **kwargs,
        )
    return cls(
        url=settings.PIXEL_API_URL,
        keycloak_server_url=settings.PIXEL_AUTH_SERVER_URL,
        client_id=settings.PIXEL_CLIENT_ID,
        username=settings.PIXEL_USERNAME,
        password=settings.PIXEL_PASSWORD.get_secret_value(),  # type: ignore[union-attr]
        realm=settings.PIXEL_REALM,
        **kwargs,
    )

me async

me(extended: bool = False) -> dict

Get information about the authenticated user.

Parameters:

Name Type Description Default
extended bool

If True, also returns the projects you can access with your effective permissions on each, and your organisation-wide grants and permissions.

False

Returns:

Name Type Description
dict dict

User information including username, email, and other profile details.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
async def me(self, extended: bool = False) -> dict:
    """
    Get information about the authenticated user.

    Args:
        extended: If True, also returns the projects you can access with your effective
            permissions on each, and your organisation-wide grants and permissions.

    Returns:
        dict: User information including username, email, and other profile details.

    Note:
        Cannot be called with an api key.
    """
    response = await self._get("/users/me", params={"extended": extended})
    return response.json()

get_plugins async

get_plugins() -> list[dict]

Retrieve a list of available plugins for the pixel tenant.

Possible plugins include:

  • optimized_raster - Optimize Raster capability
  • image_service - Image Service capability, dependent on the 'optimize_raster' plugin.

Returns:

Type Description
list[dict]

list[dict]: A list of plugin objects with their details.

Source code in src/pixel_client/_base.py
466
467
468
469
470
471
472
473
474
475
476
477
478
479
async def get_plugins(self) -> list[dict]:
    """
    Retrieve a list of available plugins for the pixel tenant.

    Possible plugins include:

    * `optimized_raster` - Optimize Raster capability
    * `image_service` - Image Service capability, dependent on the 'optimize_raster' plugin.

    Returns:
        list[dict]: A list of plugin objects with their details.
    """
    response = await self._get("/plugins/")
    return response.json()

create_project async

create_project(
    name: str,
    description: str,
    area_of_interest: Polygon,
    parent_project_id: int | None = None,
    tags: list[str] | None = None,
    groups: dict[int, RoleType] | None = None,
) -> dict

Create a new project in the Pixel system.

Parameters:

Name Type Description Default
name str

The name of the project.

required
description str

A description of the project.

required
area_of_interest Polygon

A GeoJSON polygon defining the project's geographic area of interest.

required
parent_project_id int | None

Optional ID of a parent project. If provided, this project will be created as a child of that project.

None
tags list[str] | None

Optional list of tags to associate with the project.

None
groups dict[int, RoleType] | None

Optional mapping of group ID to the role each group gets on the new project, e.g. {3: "editor"}. Written together with the project: either all succeed or nothing is created. You must be a group admin of every group listed.

None

Returns:

Name Type Description
dict dict

The created project object.

Source code in src/pixel_client/_base.py
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
async def create_project(
    self,
    name: str,
    description: str,
    area_of_interest: Polygon,
    parent_project_id: int | None = None,
    tags: list[str] | None = None,
    groups: dict[int, RoleType] | None = None,
) -> dict:
    """
    Create a new project in the Pixel system.

    Args:
        name: The name of the project.
        description: A description of the project.
        area_of_interest: A GeoJSON polygon defining the project's geographic area of interest.
        parent_project_id: Optional ID of a parent project. If provided, this project will be created as a child of that project.
        tags: Optional list of tags to associate with the project.
        groups: Optional mapping of group ID to the role each group gets on the new project,
            e.g. `{3: "editor"}`. Written together with the project: either all succeed or
            nothing is created. You must be a group admin of every group listed.

    Returns:
        dict: The created project object.
    """
    body = {
        "name": name,
        "description": description,
        "area_of_interest": area_of_interest.__geo_interface__,
    }
    if parent_project_id:
        body["parent_project_id"] = parent_project_id
    if tags:
        body["tags"] = tags
    if groups:
        body["groups"] = [
            {"group_id": group_id, "role": role} for group_id, role in groups.items()
        ]
    response = await self._post("/projects/", json=body)
    return response.json()

list_projects async

list_projects(
    params: ListParams | None = None, **kwargs
) -> list[dict]

List projects with optional filtering.

Parameters:

Name Type Description Default
params ListParams | None

Optional ListParams object containing filtering parameters such as offset, limit, search, etc.

None
**kwargs

Alternative way to provide filtering parameters. Ignored if params is provided.

{}

Returns:

Type Description
list[dict]

list[dict]: A list of project objects matching the filter criteria.

Source code in src/pixel_client/_base.py
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
async def list_projects(
    self, params: ListParams | None = None, **kwargs
) -> list[dict]:
    """
    List projects with optional filtering.

    Args:
        params: Optional ListParams object containing filtering parameters such as offset, limit, search, etc.
        **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

    Returns:
        list[dict]: A list of project objects matching the filter criteria.
    """
    if params and kwargs:
        logger.warning("Ignoring kwargs when params is provided")
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else ListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get("/projects/", params=params_dict)
    return response.json()

list_deleted_projects async

list_deleted_projects(
    params: ListParams | None = None, **kwargs
) -> list[dict]

List deleted projects in the Pixel system.

Parameters:

Name Type Description Default
params ListParams | None

Optional ListParams object containing filtering parameters such as offset, limit, search, etc.

None
**kwargs

Alternative way to provide filtering parameters. Ignored if params is provided.

{}

Returns:

Type Description
list[dict]

list[dict]: A list of deleted project objects.

Source code in src/pixel_client/_base.py
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
async def list_deleted_projects(
    self, params: ListParams | None = None, **kwargs
) -> list[dict]:
    """
    List deleted projects in the Pixel system.

    Args:
        params: Optional ListParams object containing filtering parameters such as offset, limit, search, etc.
        **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

    Returns:
        list[dict]: A list of deleted project objects.
    """
    if params and kwargs:
        logger.warning("Ignoring kwargs when params is provided")
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else ListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get("/projects/deleted", params=params_dict)
    return response.json()

get_project async

get_project(
    project_id: int, extended: bool = False
) -> dict

Retrieve a project by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project to retrieve.

required
extended bool

If True, returns extended project information including child projects and data collections.

False

Returns:

Name Type Description
dict dict

The project object with its details.

Source code in src/pixel_client/_base.py
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
async def get_project(self, project_id: int, extended: bool = False) -> dict:
    """
    Retrieve a project by its ID.

    Args:
        project_id: The ID of the project to retrieve.
        extended: If True, returns extended project information including child projects and data collections.

    Returns:
        dict: The project object with its details.
    """
    response = await self._get(
        f"/projects/{project_id}", params={"extended": extended}
    )
    return response.json()

update_project async

update_project(
    project_id: int,
    name: str | None = None,
    description: str | None = None,
    area_of_interest: Polygon | None = None,
    add_tags: list[str] | None = None,
    remove_tags: list[str] | None = None,
) -> dict

Update an existing project with new values.

Parameters:

Name Type Description Default
project_id int

The ID of the project to update.

required
name str | None

Optional new name for the project.

None
description str | None

Optional new description for the project.

None
area_of_interest Polygon | None

Optional new GeoJSON polygon defining the project's geographic area of interest.

None
add_tags list[str] | None

Optional list of tags to add to the project.

None
remove_tags list[str] | None

Optional list of tags to remove from the project.

None

Returns:

Name Type Description
dict dict

The updated project object.

Raises:

Type Description
ValueError

If no update parameters are provided.

Source code in src/pixel_client/_base.py
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
async def update_project(
    self,
    project_id: int,
    name: str | None = None,
    description: str | None = None,
    area_of_interest: Polygon | None = None,
    add_tags: list[str] | None = None,
    remove_tags: list[str] | None = None,
) -> dict:
    """
    Update an existing project with new values.

    Args:
        project_id: The ID of the project to update.
        name: Optional new name for the project.
        description: Optional new description for the project.
        area_of_interest: Optional new GeoJSON polygon defining the project's geographic area of interest.
        add_tags: Optional list of tags to add to the project.
        remove_tags: Optional list of tags to remove from the project.

    Returns:
        dict: The updated project object.

    Raises:
        ValueError: If no update parameters are provided.
    """
    body = {}
    for param_name, value in {
        "name": name,
        "description": description,
        "area_of_interest": area_of_interest.__geo_interface__
        if area_of_interest
        else None,
        "add_tags": add_tags,
        "remove_tags": remove_tags,
    }.items():
        if value is not None:
            body[param_name] = value
    if not body:
        raise ValueError("No update parameters provided")
    response = await self._put(f"/projects/{project_id}", json=body)
    return response.json()

delete_project async

delete_project(project_id: int) -> dict

Delete a project by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project to delete.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Source code in src/pixel_client/_base.py
631
632
633
634
635
636
637
638
639
640
641
642
async def delete_project(self, project_id: int) -> dict:
    """
    Delete a project by its ID.

    Args:
        project_id: The ID of the project to delete.

    Returns:
        dict: The response confirming deletion.
    """
    response = await self._delete(f"/projects/{project_id}")
    return response.json()

restore_project async

restore_project(project_id: int) -> dict

Restore a deleted project by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project to restore.

required

Returns:

Name Type Description
dict dict

The restored project object.

Source code in src/pixel_client/_base.py
644
645
646
647
648
649
650
651
652
653
654
655
async def restore_project(self, project_id: int) -> dict:
    """
    Restore a deleted project by its ID.

    Args:
        project_id: The ID of the project to restore.

    Returns:
        dict: The restored project object.
    """
    response = await self._post(f"/projects/{project_id}/restore")
    return response.json()

move_project async

move_project(
    project_id: int,
    new_parent_project_id: int | None = None,
) -> dict

Move a project to a new parent project or to the root level.

Parameters:

Name Type Description Default
project_id int

The ID of the project to move.

required
new_parent_project_id int | None

Optional ID of the new parent project. If None, the project will be moved to the root level.

None

Returns:

Name Type Description
dict dict

The updated project object.

Source code in src/pixel_client/_base.py
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
async def move_project(
    self, project_id: int, new_parent_project_id: int | None = None
) -> dict:
    """
    Move a project to a new parent project or to the root level.

    Args:
        project_id: The ID of the project to move.
        new_parent_project_id: Optional ID of the new parent project. If None, the project will be moved to the root level.

    Returns:
        dict: The updated project object.
    """
    # If None is provided, set to -1 to move to root
    new_parent_project_id = new_parent_project_id or -1
    response = await self._put(
        f"/projects/{project_id}/move",
        params={"new_parent_id": new_parent_project_id},
    )
    return response.json()

create_data_collection async

create_data_collection(
    project_id: int,
    name: str,
    description: str,
    data_collection_type: DataCollectionType,
    tags: list[str] | None = None,
    raster_info: RasterInfo | None = None,
) -> dict

Create a new data collection within a project.

Parameters:

Name Type Description Default
project_id int

The ID of the project to create the data collection in.

required
name str

The name of the data collection.

required
description str

A description of the data collection.

required
data_collection_type DataCollectionType

The type of data collection (e.g., "image", "raster", "RGB", "DTM", "DSM").

required
tags list[str] | None

Optional list of tags to associate with the data collection.

None
raster_info RasterInfo | None

Optional RasterInfo object containing raster-specific configuration.

None

Returns:

Name Type Description
dict dict

The created data collection object.

Source code in src/pixel_client/_base.py
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
async def create_data_collection(
    self,
    project_id: int,
    name: str,
    description: str,
    data_collection_type: DataCollectionType,
    tags: list[str] | None = None,
    raster_info: RasterInfo | None = None,
) -> dict:
    """
    Create a new data collection within a project.

    Args:
        project_id: The ID of the project to create the data collection in.
        name: The name of the data collection.
        description: A description of the data collection.
        data_collection_type: The type of data collection (e.g., "image", "raster", "RGB", "DTM", "DSM").
        tags: Optional list of tags to associate with the data collection.
        raster_info: Optional RasterInfo object containing raster-specific configuration.

    Returns:
        dict: The created data collection object.
    """
    body: dict[str, Any] = {
        "name": name,
        "description": description,
        "data_collection_type": data_collection_type,
    }
    if tags:
        body["tags"] = tags
    if raster_info:
        body["raster_info"] = raster_info.model_dump(exclude_none=True, mode="json")
    response = await self._post(
        f"/projects/{project_id}/data_collections/", json=body
    )
    return response.json()

list_data_collections async

list_data_collections(
    project_id: int,
    params: DataCollectionListParams | None = None,
    **kwargs,
) -> list[dict]

List data collections within a project with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project to list data collections from.

required
params DataCollectionListParams | None

Optional DataCollectionListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters. Ignored if params is provided.

{}

Returns:

Type Description
list[dict]

list[dict]: A list of data collection objects matching the filter criteria.

Source code in src/pixel_client/_base.py
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
async def list_data_collections(
    self, project_id: int, params: DataCollectionListParams | None = None, **kwargs
) -> list[dict]:
    """
    List data collections within a project with optional filtering.

    Args:
        project_id: The ID of the project to list data collections from.
        params: Optional DataCollectionListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

    Returns:
        list[dict]: A list of data collection objects matching the filter criteria.
    """
    if params and kwargs:
        logger.warning("Ignoring kwargs when params is provided")
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else DataCollectionListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get(
        f"/projects/{project_id}/data_collections/", params=params_dict
    )
    return response.json()

list_deleted_data_collections async

list_deleted_data_collections(
    project_id: int,
    params: DataCollectionListParams | None = None,
    **kwargs,
) -> list[dict]

List deleted data collections within a project.

Parameters:

Name Type Description Default
project_id int

The ID of the project to list deleted data collections from.

required

Returns:

Type Description
list[dict]

list[dict]: A list of deleted data collection objects.

Source code in src/pixel_client/_base.py
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
async def list_deleted_data_collections(
    self, project_id: int, params: DataCollectionListParams | None = None, **kwargs
) -> list[dict]:
    """
    List deleted data collections within a project.

    Args:
        project_id: The ID of the project to list deleted data collections from.

    Returns:
        list[dict]: A list of deleted data collection objects.
    """
    if params and kwargs:
        logger.warning("Ignoring kwargs when params is provided")
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else DataCollectionListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get(
        f"/projects/{project_id}/data_collections/deleted", params=params_dict
    )
    return response.json()

get_data_collection async

get_data_collection(
    project_id: int, data_collection_id: int
) -> dict

Retrieve a data collection by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection to retrieve.

required

Returns:

Name Type Description
dict dict

The data collection object with its details.

Source code in src/pixel_client/_base.py
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
async def get_data_collection(
    self, project_id: int, data_collection_id: int
) -> dict:
    """
    Retrieve a data collection by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection to retrieve.

    Returns:
        dict: The data collection object with its details.
    """
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}"
    )
    return response.json()

update_data_collection async

update_data_collection(
    project_id: int,
    data_collection_id: int,
    name: str | None = None,
    description: str | None = None,
    add_tags: list[str] | None = None,
    remove_tags: list[str] | None = None,
) -> dict

Update an existing data collection with new values.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection to update.

required
name str | None

Optional new name for the data collection.

None
description str | None

Optional new description for the data collection.

None
add_tags list[str] | None

Optional list of tags to add to the data collection.

None
remove_tags list[str] | None

Optional list of tags to remove from the data collection.

None

Returns:

Name Type Description
dict dict

The updated data collection object.

Raises:

Type Description
ValueError

If no update parameters are provided.

Source code in src/pixel_client/_base.py
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
async def update_data_collection(
    self,
    project_id: int,
    data_collection_id: int,
    name: str | None = None,
    description: str | None = None,
    add_tags: list[str] | None = None,
    remove_tags: list[str] | None = None,
) -> dict:
    """
    Update an existing data collection with new values.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection to update.
        name: Optional new name for the data collection.
        description: Optional new description for the data collection.
        add_tags: Optional list of tags to add to the data collection.
        remove_tags: Optional list of tags to remove from the data collection.

    Returns:
        dict: The updated data collection object.

    Raises:
        ValueError: If no update parameters are provided.
    """
    body = {}
    for param_name, value in {
        "name": name,
        "description": description,
        "add_tags": add_tags,
        "remove_tags": remove_tags,
    }.items():
        if value is not None:
            body[param_name] = value
    if not body:
        raise ValueError("No update parameters provided")
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}", json=body
    )
    return response.json()

move_data_collection async

move_data_collection(
    project_id: int,
    data_collection_id: int,
    new_project_id: int,
) -> dict

Move a data collection to a different project.

Parameters:

Name Type Description Default
project_id int

The ID of the project currently containing the data collection.

required
data_collection_id int

The ID of the data collection to move.

required
new_project_id int

The ID of the project to move the data collection to.

required

Returns:

Name Type Description
dict dict

The updated data collection object.

Source code in src/pixel_client/_base.py
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
async def move_data_collection(
    self, project_id: int, data_collection_id: int, new_project_id: int
) -> dict:
    """
    Move a data collection to a different project.

    Args:
        project_id: The ID of the project currently containing the data collection.
        data_collection_id: The ID of the data collection to move.
        new_project_id: The ID of the project to move the data collection to.

    Returns:
        dict: The updated data collection object.
    """
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/move",
        params={"new_project_id": new_project_id},
    )
    return response.json()

delete_data_collection async

delete_data_collection(
    project_id: int, data_collection_id: int
) -> dict

Delete a data collection by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection to delete.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Source code in src/pixel_client/_base.py
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
async def delete_data_collection(
    self, project_id: int, data_collection_id: int
) -> dict:
    """
    Delete a data collection by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection to delete.

    Returns:
        dict: The response confirming deletion.
    """
    response = await self._delete(
        f"/projects/{project_id}/data_collections/{data_collection_id}"
    )
    return response.json()

restore_data_collection async

restore_data_collection(
    project_id: int, data_collection_id: int
) -> dict

Restore a deleted data collection by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection to restore.

required

Returns:

Name Type Description
dict dict

The restored data collection object.

Source code in src/pixel_client/_base.py
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
async def restore_data_collection(
    self, project_id: int, data_collection_id: int
) -> dict:
    """
    Restore a deleted data collection by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection to restore.

    Returns:
        dict: The restored data collection object.
    """
    response = await self._post(
        f"/projects/{project_id}/data_collections/{data_collection_id}/restore"
    )
    return response.json()

get_images async

get_images(
    project_id: int,
    data_collection_id: int,
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]

Retrieve images from a data collection with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the images.

required
params ListParams | None

Optional ListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters.

{}

Returns:

Type Description
list[dict]

list[dict]: A list of image objects matching the filter criteria.

Source code in src/pixel_client/_base.py
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
async def get_images(
    self,
    project_id: int,
    data_collection_id: int,
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]:
    """
    Retrieve images from a data collection with optional filtering.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the images.
        params: Optional ListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters.

    Returns:
        list[dict]: A list of image objects matching the filter criteria.
    """
    params_dict = (
        params.model_dump(exclude_none=True, mode="json") if params else {}
    )
    params_dict.update(kwargs)
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/images/",
        params=params_dict,
    )
    return response.json()

paginate_images async

paginate_images(
    project_id: int,
    data_collection_id: int,
    page_size: int,
    params: ListParams | None = None,
    **kwargs,
) -> AsyncGenerator[dict, None]

Paginate through images in a data collection with optional filtering. This method returns an async generator that yields images one at a time, automatically handling pagination in the background.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the images.

required
page_size int

The number of images to fetch per page.

required
params ListParams | None

Optional ListParams object containing filtering parameters (excluding offset and limit).

None
**kwargs

Alternative way to provide filtering parameters.

{}

Yields:

Name Type Description
dict AsyncGenerator[dict, None]

Image objects matching the filter criteria, one at a time.

Source code in src/pixel_client/_base.py
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
async def paginate_images(
    self,
    project_id: int,
    data_collection_id: int,
    page_size: int,
    params: ListParams | None = None,
    **kwargs,
) -> AsyncGenerator[dict, None]:
    """
    Paginate through images in a data collection with optional filtering.
    This method returns an async generator that yields images one at a time,
    automatically handling pagination in the background.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the images.
        page_size: The number of images to fetch per page.
        params: Optional ListParams object containing filtering parameters (excluding offset and limit).
        **kwargs: Alternative way to provide filtering parameters.

    Yields:
        dict: Image objects matching the filter criteria, one at a time.
    """
    params_dict = (
        params.model_dump(
            exclude_none=True, exclude={"offset", "limit"}, mode="json"
        )
        if params
        else {}
    )
    params_dict.update(kwargs)
    url = f"/projects/{project_id}/data_collections/{data_collection_id}/images/"
    async for item in self._paginate(url, page_size, params=params_dict):
        yield item

get_image async

get_image(
    project_id: int, data_collection_id: int, image_id: int
) -> dict

Retrieve a specific image by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the image.

required
image_id int

The ID of the image to retrieve.

required

Returns:

Name Type Description
dict dict

The image object with its details.

Source code in src/pixel_client/_base.py
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
async def get_image(
    self,
    project_id: int,
    data_collection_id: int,
    image_id: int,
) -> dict:
    """
    Retrieve a specific image by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the image.
        image_id: The ID of the image to retrieve.

    Returns:
        dict: The image object with its details.
    """
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}"
    )
    return response.json()

get_image_metadata async

get_image_metadata(
    project_id: int, data_collection_id: int, image_id: int
) -> dict

Retrieve metadata for a specific image by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the image.

required
image_id int

The ID of the image to retrieve metadata for.

required

Returns:

Name Type Description
dict dict

The image metadata object with its details.

Source code in src/pixel_client/_base.py
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
async def get_image_metadata(
    self, project_id: int, data_collection_id: int, image_id: int
) -> dict:
    """
    Retrieve metadata for a specific image by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the image.
        image_id: The ID of the image to retrieve metadata for.

    Returns:
        dict: The image metadata object with its details.
    """
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}/metadata"
    )
    return response.json()

update_image async

update_image(
    project_id: int,
    data_collection_id: int,
    image_id: int,
    update_input: ImageUpdateInput,
) -> dict

Update an existing image with new values.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the image.

required
image_id int

The ID of the image to update.

required
update_input ImageUpdateInput

ImageUpdateInput object containing the fields to update.

required

Returns:

Name Type Description
dict dict

The updated image object.

Source code in src/pixel_client/_base.py
 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
async def update_image(
    self,
    project_id: int,
    data_collection_id: int,
    image_id: int,
    update_input: ImageUpdateInput,
) -> dict:
    """
    Update an existing image with new values.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the image.
        image_id: The ID of the image to update.
        update_input: ImageUpdateInput object containing the fields to update.

    Returns:
        dict: The updated image object.
    """

    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}",
        json=update_input.model_dump(mode="json", exclude_none=True),
    )
    return response.json()

move_image async

move_image(
    project_id: int,
    data_collection_id: int,
    image_id: int,
    new_project_id: int,
    new_data_collection_id: int,
) -> dict

Move an image to a different data collection within a project.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the image.

required
image_id int

The ID of the image to move.

required
new_project_id int

The ID of the project to move the image to.

required
new_data_collection_id int

The ID of the data collection to move the image to.

required
Source code in src/pixel_client/_base.py
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
async def move_image(
    self,
    project_id: int,
    data_collection_id: int,
    image_id: int,
    new_project_id: int,
    new_data_collection_id: int,
) -> dict:
    """
    Move an image to a different data collection within a project.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the image.
        image_id: The ID of the image to move.
        new_project_id: The ID of the project to move the image to.
        new_data_collection_id: The ID of the data collection to move the image to.
    Returns:
        dict: The updated image object.
    """
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}/move",
        params={
            "new_project_id": new_project_id,
            "new_data_collection_id": new_data_collection_id,
        },
    )
    return response.json()

delete_image async

delete_image(
    project_id: int, data_collection_id: int, image_id: int
) -> dict

Delete a specific image by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the image.

required
image_id int

The ID of the image to delete.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Source code in src/pixel_client/_base.py
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
async def delete_image(
    self,
    project_id: int,
    data_collection_id: int,
    image_id: int,
) -> dict:
    """
    Delete a specific image by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the image.
        image_id: The ID of the image to delete.

    Returns:
        dict: The response confirming deletion.
    """
    response = await self._delete(
        f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}"
    )
    return response.json()

get_rasters async

get_rasters(
    project_id: int,
    data_collection_id: int,
    params: RasterListParams | None = None,
    **kwargs,
) -> list[dict]

Retrieve rasters from a data collection with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the rasters.

required
params RasterListParams | None

Optional ListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters.

{}

Returns:

Name Type Description
dict list[dict]

A list of raster objects matching the filter criteria.

Source code in src/pixel_client/_base.py
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
async def get_rasters(
    self,
    project_id: int,
    data_collection_id: int,
    params: RasterListParams | None = None,
    **kwargs,
) -> list[dict]:
    """
    Retrieve rasters from a data collection with optional filtering.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the rasters.
        params: Optional ListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters.

    Returns:
        dict: A list of raster objects matching the filter criteria.
    """
    params_dict = (
        params.model_dump(exclude_none=True, mode="json") if params else {}
    )
    params_dict.update(kwargs)
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/",
        params=params_dict,
    )
    return response.json()

paginate_rasters async

paginate_rasters(
    project_id: int,
    data_collection_id: int,
    page_size: int,
    params: ListParams | None = None,
    **kwargs,
) -> AsyncGenerator[dict, None]

Paginate through rasters in a data collection with optional filtering. This method returns an async generator that yields rasters one at a time, automatically handling pagination in the background.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the rasters.

required
page_size int

The number of rasters to fetch per page.

required
params ListParams | None

Optional ListParams object containing filtering parameters (excluding offset and limit).

None
**kwargs

Alternative way to provide filtering parameters.

{}

Yields:

Name Type Description
dict AsyncGenerator[dict, None]

Raster objects matching the filter criteria, one at a time.

Source code in src/pixel_client/_base.py
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
async def paginate_rasters(
    self,
    project_id: int,
    data_collection_id: int,
    page_size: int,
    params: ListParams | None = None,
    **kwargs,
) -> AsyncGenerator[dict, None]:
    """
    Paginate through rasters in a data collection with optional filtering.
    This method returns an async generator that yields rasters one at a time,
    automatically handling pagination in the background.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the rasters.
        page_size: The number of rasters to fetch per page.
        params: Optional ListParams object containing filtering parameters (excluding offset and limit).
        **kwargs: Alternative way to provide filtering parameters.

    Yields:
        dict: Raster objects matching the filter criteria, one at a time.
    """
    params_dict = (
        params.model_dump(exclude_none=True, exclude={"offset", "limit"})
        if params
        else {}
    )
    params_dict.update(kwargs)
    url = f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/"
    async for item in self._paginate(url, page_size, params=params_dict):
        yield item

get_raster async

get_raster(
    project_id: int, data_collection_id: int, raster_id: int
) -> dict

Retrieve a specific raster by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the raster.

required
raster_id int

The ID of the raster to retrieve.

required

Returns:

Name Type Description
dict dict

The raster object with its details.

Source code in src/pixel_client/_base.py
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
async def get_raster(
    self,
    project_id: int,
    data_collection_id: int,
    raster_id: int,
) -> dict:
    """
    Retrieve a specific raster by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the raster.
        raster_id: The ID of the raster to retrieve.

    Returns:
        dict: The raster object with its details.
    """
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}"
    )
    return response.json()

update_raster async

update_raster(
    project_id: int,
    data_collection_id: int,
    raster_id: int,
    update_input: RasterUpdateInput,
) -> dict

Update an existing raster with new values.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the raster.

required
raster_id int

The ID of the raster to update.

required
update_input RasterUpdateInput

RasterUpdateInput object containing the fields to update.

required

Returns:

Name Type Description
dict dict

The updated raster object.

Source code in src/pixel_client/_base.py
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
async def update_raster(
    self,
    project_id: int,
    data_collection_id: int,
    raster_id: int,
    update_input: RasterUpdateInput,
) -> dict:
    """
    Update an existing raster with new values.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the raster.
        raster_id: The ID of the raster to update.
        update_input: RasterUpdateInput object containing the fields to update.

    Returns:
        dict: The updated raster object.

    """
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}",
        json=update_input.model_dump(mode="json", exclude_none=True),
    )
    return response.json()

move_raster async

move_raster(
    project_id: int,
    data_collection_id: int,
    raster_id: int,
    new_project_id: int,
    new_data_collection_id: int,
) -> dict

Move a raster to a different data collection within a project.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the raster.

required
raster_id int

The ID of the raster to move.

required
new_project_id int

The ID of the project to move the raster to.

required
new_data_collection_id int

The ID of the data collection to move the raster to.

required
Source code in src/pixel_client/_base.py
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
async def move_raster(
    self,
    project_id: int,
    data_collection_id: int,
    raster_id: int,
    new_project_id: int,
    new_data_collection_id: int,
) -> dict:
    """
    Move a raster to a different data collection within a project.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the raster.
        raster_id: The ID of the raster to move.
        new_project_id: The ID of the project to move the raster to.
        new_data_collection_id: The ID of the data collection to move the raster to.
    Returns:
        dict: The updated raster object.
    """
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}/move",
        params={
            "new_project_id": new_project_id,
            "new_data_collection_id": new_data_collection_id,
        },
    )
    return response.json()

delete_raster async

delete_raster(
    project_id: int, data_collection_id: int, raster_id: int
) -> dict

Delete a specific raster by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the raster.

required
raster_id int

The ID of the raster to delete.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Source code in src/pixel_client/_base.py
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
async def delete_raster(
    self,
    project_id: int,
    data_collection_id: int,
    raster_id: int,
) -> dict:
    """
    Delete a specific raster by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the raster.
        raster_id: The ID of the raster to delete.

    Returns:
        dict: The response confirming deletion.
    """
    response = await self._delete(
        f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}"
    )
    return response.json()

get_upload_jobs async

get_upload_jobs(
    project_id: int,
    data_collection_id: int,
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]

Retrieve upload jobs for a data collection with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection to list upload jobs for.

required
params ListParams | None

Optional ListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters. Ignored if params is provided.

{}

Returns:

Type Description
list[dict]

list[dict]: A list of upload job objects matching the filter criteria.

Source code in src/pixel_client/_base.py
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
async def get_upload_jobs(
    self,
    project_id: int,
    data_collection_id: int,
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]:
    """
    Retrieve upload jobs for a data collection with optional filtering.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection to list upload jobs for.
        params: Optional ListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

    Returns:
        list[dict]: A list of upload job objects matching the filter criteria.
    """
    if params and kwargs:
        logger.warning("Ignoring kwargs when params is provided")
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else ListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/upload_jobs/",
        params=params_dict,
    )
    return response.json()

upload_image async

upload_image(
    project_id: int,
    data_collection_id: int,
    file_path: Path,
    metadata: dict | None = None,
    support_files: list[Path] | None = None,
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> dict

Upload an image file to an image data collection.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the image data collection to upload to.

required
file_path Path

Path to the image file to upload.

required
metadata dict | None

Optional dictionary of metadata to associate with the image.

None
support_files list[Path] | None

Optional list of support file paths to upload with the image.

None
multipart bool

If True, use multipart upload for large files.

False
multipart_part_size int | None

Required size of each part in bytes when using multipart upload.

None

Returns:

Name Type Description
dict dict

The created image object.

Raises:

Type Description
ValueError

If the data collection is not an image data collection.

FileNotFoundError

If the file does not exist.

ValueError

If multipart is True but multipart_part_size is not provided.

Source code in src/pixel_client/_base.py
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
async def upload_image(
    self,
    project_id: int,
    data_collection_id: int,
    file_path: Path,
    metadata: dict | None = None,
    support_files: list[Path] | None = None,
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> dict:
    """
    Upload an image file to an image data collection.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the image data collection to upload to.
        file_path: Path to the image file to upload.
        metadata: Optional dictionary of metadata to associate with the image.
        support_files: Optional list of support file paths to upload with the image.
        multipart: If True, use multipart upload for large files.
        multipart_part_size: Required size of each part in bytes when using multipart upload.

    Returns:
        dict: The created image object.

    Raises:
        ValueError: If the data collection is not an image data collection.
        FileNotFoundError: If the file does not exist.
        ValueError: If multipart is True but multipart_part_size is not provided.
    """
    dc = await self.get_data_collection(project_id, data_collection_id)
    if dc["data_collection_type"] != "image":
        raise ValueError("Data collection is not an image data collection")
    return await self._upload_file(
        project_id,
        data_collection_id,
        file_path,
        support_files=support_files,
        metadata=metadata,
        multipart=multipart,
        multipart_part_size=multipart_part_size,
    )

upload_multiple_images async

upload_multiple_images(
    project_id: int,
    data_collection_id: int,
    files: list[PixelUploadFile],
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> tuple[list[dict], list[PixelUploadJobError]]

Upload multiple image files to an image data collection.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the image data collection to upload to.

required
files list[PixelUploadFile]

List of PixelUploadFile objects containing the files to upload.

required
multipart bool

If True, use multipart upload for large files.

False
multipart_part_size int | None

Required size of each part in bytes when using multipart upload.

None

Returns:

Name Type Description
tuple tuple[list[dict], list[PixelUploadJobError]]

A tuple containing: - list[dict]: List of created image objects. - list[PixelUploadJobError]: List of errors that occurred during upload.

Raises:

Type Description
ValueError

If the data collection is not an image data collection.

ValueError

If any files have duplicate names.

ValueError

If multipart is True but multipart_part_size is not provided.

Source code in src/pixel_client/_base.py
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
async def upload_multiple_images(
    self,
    project_id: int,
    data_collection_id: int,
    files: list[PixelUploadFile],
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> tuple[list[dict], list[PixelUploadJobError]]:
    """
    Upload multiple image files to an image data collection.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the image data collection to upload to.
        files: List of PixelUploadFile objects containing the files to upload.
        multipart: If True, use multipart upload for large files.
        multipart_part_size: Required size of each part in bytes when using multipart upload.

    Returns:
        tuple: A tuple containing:
            - list[dict]: List of created image objects.
            - list[PixelUploadJobError]: List of errors that occurred during upload.

    Raises:
        ValueError: If the data collection is not an image data collection.
        ValueError: If any files have duplicate names.
        ValueError: If multipart is True but multipart_part_size is not provided.
    """
    dc = await self.get_data_collection(project_id, data_collection_id)
    if dc["data_collection_type"] != "image":
        raise ValueError("Data collection is not an image data collection")
    return await self._upload_multiple_files(
        project_id,
        data_collection_id,
        files,
        multipart,
        multipart_part_size,
    )

upload_multiple_rasters async

upload_multiple_rasters(
    project_id: int,
    data_collection_id: int,
    files: list[PixelUploadFile],
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> tuple[list[dict], list[PixelUploadJobError]]

Upload multiple raster files to a raster data collection.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the raster data collection to upload to.

required
files list[PixelUploadFile]

List of PixelUploadFile objects containing the files to upload.

required
multipart bool

If True, use multipart upload for large files.

False
multipart_part_size int | None

Required size of each part in bytes when using multipart upload.

None

Returns:

Name Type Description
tuple tuple[list[dict], list[PixelUploadJobError]]

A tuple containing: - list[dict]: List of created raster objects. - list[PixelUploadJobError]: List of errors that occurred during upload.

Raises:

Type Description
ValueError

If the data collection is not a raster data collection.

ValueError

If any files have duplicate names.

ValueError

If multipart is True but multipart_part_size is not provided.

Source code in src/pixel_client/_base.py
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
async def upload_multiple_rasters(
    self,
    project_id: int,
    data_collection_id: int,
    files: list[PixelUploadFile],
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> tuple[list[dict], list[PixelUploadJobError]]:
    """
    Upload multiple raster files to a raster data collection.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the raster data collection to upload to.
        files: List of PixelUploadFile objects containing the files to upload.
        multipart: If True, use multipart upload for large files.
        multipart_part_size: Required size of each part in bytes when using multipart upload.

    Returns:
        tuple: A tuple containing:
            - list[dict]: List of created raster objects.
            - list[PixelUploadJobError]: List of errors that occurred during upload.

    Raises:
        ValueError: If the data collection is not a raster data collection.
        ValueError: If any files have duplicate names.
        ValueError: If multipart is True but multipart_part_size is not provided.
    """
    dc = await self.get_data_collection(project_id, data_collection_id)
    if dc["data_collection_type"] not in ("raster", "RGB", "DTM", "DSM"):
        raise ValueError("Data collection is not a raster data collection")
    return await self._upload_multiple_files(
        project_id,
        data_collection_id,
        files,
        multipart,
        multipart_part_size,
    )

upload_raster async

upload_raster(
    project_id: int,
    data_collection_id: int,
    file_path: Path,
    support_files: list[Path] | None = None,
    metadata: dict | None = None,
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> dict

Upload a raster file to a raster data collection.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the raster data collection to upload to.

required
file_path Path

Path to the raster file to upload.

required
support_files list[Path] | None

Optional list of support file paths to upload with the raster.

None
metadata dict | None

Optional dictionary of metadata to associate with the raster.

None
multipart bool

If True, use multipart upload for large files.

False
multipart_part_size int | None

Required size of each part in bytes when using multipart upload.

None

Returns:

Name Type Description
dict dict

The created raster object.

Raises:

Type Description
ValueError

If the data collection is not a raster data collection.

FileNotFoundError

If the file does not exist.

ValueError

If multipart is True but multipart_part_size is not provided.

Source code in src/pixel_client/_base.py
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
async def upload_raster(
    self,
    project_id: int,
    data_collection_id: int,
    file_path: Path,
    support_files: list[Path] | None = None,
    metadata: dict | None = None,
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> dict:
    """
    Upload a raster file to a raster data collection.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the raster data collection to upload to.
        file_path: Path to the raster file to upload.
        support_files: Optional list of support file paths to upload with the raster.
        metadata: Optional dictionary of metadata to associate with the raster.
        multipart: If True, use multipart upload for large files.
        multipart_part_size: Required size of each part in bytes when using multipart upload.

    Returns:
        dict: The created raster object.

    Raises:
        ValueError: If the data collection is not a raster data collection.
        FileNotFoundError: If the file does not exist.
        ValueError: If multipart is True but multipart_part_size is not provided.
    """
    dc = await self.get_data_collection(project_id, data_collection_id)
    if dc["data_collection_type"] not in ("raster", "RGB", "DTM", "DSM"):
        raise ValueError("Data collection is not a raster data collection")
    return await self._upload_file(
        project_id,
        data_collection_id,
        file_path,
        support_files=support_files,
        metadata=metadata,
        multipart=multipart,
        multipart_part_size=multipart_part_size,
    )

upload_multiple_point_clouds async

upload_multiple_point_clouds(
    project_id: int,
    data_collection_id: int,
    files: list[PixelUploadFile],
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> tuple[list[dict], list[PixelUploadJobError]]

Upload multiple point cloud files to a point cloud data collection.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the point cloud data collection to upload to.

required
files list[PixelUploadFile]

List of PixelUploadFile objects containing the files to upload.

required
multipart bool

If True, use multipart upload for large files.

False
multipart_part_size int | None

Required size of each part in bytes when using multipart upload.

None

Returns:

Name Type Description
tuple tuple[list[dict], list[PixelUploadJobError]]

A tuple containing: - list[dict]: List of created point cloud objects. - list[PixelUploadJobError]: List of errors that occurred during upload.

Raises:

Type Description
ValueError

If the data collection is not a point cloud data collection.

ValueError

If any files have duplicate names.

ValueError

If multipart is True but multipart_part_size is not provided.

Source code in src/pixel_client/_base.py
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
async def upload_multiple_point_clouds(
    self,
    project_id: int,
    data_collection_id: int,
    files: list[PixelUploadFile],
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> tuple[list[dict], list[PixelUploadJobError]]:
    """
    Upload multiple point cloud files to a point cloud data collection.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the point cloud data collection to upload to.
        files: List of PixelUploadFile objects containing the files to upload.
        multipart: If True, use multipart upload for large files.
        multipart_part_size: Required size of each part in bytes when using multipart upload.

    Returns:
        tuple: A tuple containing:
            - list[dict]: List of created point cloud objects.
            - list[PixelUploadJobError]: List of errors that occurred during upload.

    Raises:
        ValueError: If the data collection is not a point cloud data collection.
        ValueError: If any files have duplicate names.
        ValueError: If multipart is True but multipart_part_size is not provided.
    """
    dc = await self.get_data_collection(project_id, data_collection_id)
    if dc["data_collection_type"] != "point_cloud":
        raise ValueError("Data collection is not a point cloud data collection")
    return await self._upload_multiple_files(
        project_id,
        data_collection_id,
        files,
        multipart,
        multipart_part_size,
    )

upload_point_cloud async

upload_point_cloud(
    project_id: int,
    data_collection_id: int,
    file_path: Path,
    metadata: dict | None = None,
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> dict

Upload a point cloud file to a point cloud data collection.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the point cloud data collection to upload to.

required
file_path Path

Path to the point cloud file to upload.

required
metadata dict | None

Optional dictionary of metadata to associate with the point cloud.

None
multipart bool

If True, use multipart upload for large files.

False
multipart_part_size int | None

Required size of each part in bytes when using multipart upload.

None

Returns:

Name Type Description
dict dict

The created point cloud object.

Raises:

Type Description
ValueError

If the data collection is not a point cloud data collection.

FileNotFoundError

If the file does not exist.

ValueError

If multipart is True but multipart_part_size is not provided.

Source code in src/pixel_client/_base.py
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
async def upload_point_cloud(
    self,
    project_id: int,
    data_collection_id: int,
    file_path: Path,
    metadata: dict | None = None,
    multipart: bool = False,
    multipart_part_size: int | None = None,
) -> dict:
    """
    Upload a point cloud file to a point cloud data collection.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the point cloud data collection to upload to.
        file_path: Path to the point cloud file to upload.
        metadata: Optional dictionary of metadata to associate with the point cloud.
        multipart: If True, use multipart upload for large files.
        multipart_part_size: Required size of each part in bytes when using multipart upload.

    Returns:
        dict: The created point cloud object.

    Raises:
        ValueError: If the data collection is not a point cloud data collection.
        FileNotFoundError: If the file does not exist.
        ValueError: If multipart is True but multipart_part_size is not provided.
    """
    dc = await self.get_data_collection(project_id, data_collection_id)
    if dc["data_collection_type"] != "point_cloud":
        raise ValueError("Data collection is not a point cloud data collection")
    return await self._upload_file(
        project_id,
        data_collection_id,
        file_path,
        metadata=metadata,
        multipart=multipart,
        multipart_part_size=multipart_part_size,
    )

create_optimized_rasters async

create_optimized_rasters(
    project_id: int,
    data_collection_id: int,
    raster_ids: list[int] | None,
    profile: str | None = None,
    nearblack: NearblackOptions | None = None,
    overview_resampling: OverviewResampling = "average",
) -> list[dict]

Create optimized raster objects in the database. This function creates optimized raster objects but does not run the actual optimization process. To run the optimization, use the run_optimize_rasters function with the returned optimized raster IDs.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the rasters.

required
raster_ids list[int] | None

Optional list of raster IDs to optimize. If None, all rasters in the collection will be optimized.

required
profile str | None

Optional profile name to use for optimization.

None
nearblack NearblackOptions | None

Optional NearblackOptions object for configuring the nearblack process.

None
overview_resampling OverviewResampling

The resampling method to use for creating overviews. Default is "average".

'average'

Returns:

Type Description
list[dict]

list[dict]: List of created optimized raster objects.

Source code in src/pixel_client/_base.py
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
async def create_optimized_rasters(
    self,
    project_id: int,
    data_collection_id: int,
    raster_ids: list[int] | None,
    profile: str | None = None,
    nearblack: NearblackOptions | None = None,
    overview_resampling: OverviewResampling = "average",
) -> list[dict]:
    """
    Create optimized raster objects in the database.
    This function creates optimized raster objects but does not run the actual optimization process.
    To run the optimization, use the run_optimize_rasters function with the returned optimized raster IDs.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the rasters.
        raster_ids: Optional list of raster IDs to optimize. If None, all rasters in the collection will be optimized.
        profile: Optional profile name to use for optimization.
        nearblack: Optional NearblackOptions object for configuring the nearblack process.
        overview_resampling: The resampling method to use for creating overviews. Default is "average".

    Returns:
        list[dict]: List of created optimized raster objects.
    """
    body: dict = {
        "creation_options": {
            "nearblack_options": nearblack.model_dump(
                exclude_none=True, mode="json"
            )
            if nearblack
            else NearblackOptions(enabled=False).model_dump(
                exclude_none=True, mode="json"
            ),
            "overview_resampling": overview_resampling,
        }
    }
    if raster_ids:
        body["raster_ids"] = raster_ids
    if profile:
        body["profile"] = profile
    response = await self._post(
        f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/optimized/",
        json=body,
    )
    return response.json()

run_optimize_rasters async

run_optimize_rasters(
    project_id: int,
    data_collection_id: int,
    optimize_raster_ids: list[int] | None,
    retry_failed: bool = False,
) -> dict

Run the optimization process on optimized raster objects.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the optimized rasters.

required
optimize_raster_ids list[int] | None

Optional list of optimized raster IDs to process. If None, all optimized rasters in the collection will be processed.

required
retry_failed bool

If True, retry previously failed optimization jobs.

False

Returns:

Name Type Description
dict dict

The group job object representing the optimization process.

Source code in src/pixel_client/_base.py
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
async def run_optimize_rasters(
    self,
    project_id: int,
    data_collection_id: int,
    optimize_raster_ids: list[int] | None,
    retry_failed: bool = False,
) -> dict:
    """
    Run the optimization process on optimized raster objects.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the optimized rasters.
        optimize_raster_ids: Optional list of optimized raster IDs to process. If None, all optimized rasters in the collection will be processed.
        retry_failed: If True, retry previously failed optimization jobs.

    Returns:
        dict: The group job object representing the optimization process.
    """
    body: dict = {"retry_failed": retry_failed}
    if optimize_raster_ids:
        body["optimized_raster_ids"] = optimize_raster_ids
    response = await self._post(
        f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/optimized/run",
        json=body,
    )
    response_json = response.json()

    job = await self.wait_for_group_job(response_json["group_job"]["group_id"])
    return job

create_optimized_point_clouds async

create_optimized_point_clouds(
    project_id: int,
    data_collection_id: int,
    point_cloud_ids: list[int] | None,
) -> list[dict]

Create optimized point cloud objects in the database.

This function creates optimized point clouds (copc format) but does not run the actual optimization process. Run the optimization using the run_optimize_point_clouds function with the returned same point cloud IDs.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the point clouds.

required
point_cloud_ids list[int] | None

Optional list of point cloud IDs to optimize. If None, all point clouds in the collection will be optimized.

required
Source code in src/pixel_client/_base.py
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
async def create_optimized_point_clouds(
    self,
    project_id: int,
    data_collection_id: int,
    point_cloud_ids: list[int] | None,
) -> list[dict]:
    """
    Create optimized point cloud objects in the database.

    This function creates optimized point clouds (copc format) but does not run the actual optimization process.
    Run the optimization using the `run_optimize_point_clouds` function with the returned same point cloud IDs.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the point clouds.
        point_cloud_ids: Optional list of point cloud IDs to optimize. If None, all point clouds in the collection will be optimized.
    Returns:
        list[dict]: List of created optimized point cloud objects.
    """
    body: dict = {}
    if point_cloud_ids:
        body["point_cloud_ids"] = point_cloud_ids
    response = await self._post(
        f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/optimized/",
        json=body,
    )
    return response.json()

run_optimize_point_clouds async

run_optimize_point_clouds(
    project_id: int,
    data_collection_id: int,
    point_cloud_ids: list[int] | None,
    retry_failed: bool = False,
) -> dict

Run the optimization process on optimized point cloud objects.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the optimized point clouds.

required
point_cloud_ids list[int] | None

Optional list of optimized point cloud IDs to process. If None, all optimized point clouds in the collection will be processed.

required
Source code in src/pixel_client/_base.py
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
async def run_optimize_point_clouds(
    self,
    project_id: int,
    data_collection_id: int,
    point_cloud_ids: list[int] | None,
    retry_failed: bool = False,
) -> dict:
    """
    Run the optimization process on optimized point cloud objects.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the optimized point clouds.
        point_cloud_ids: Optional list of optimized point cloud IDs to process. If None, all optimized point clouds in the collection will be processed.
    Returns:
        dict: The group job object representing the optimization process.
    """
    body: dict = {"retry_failed": retry_failed}
    if point_cloud_ids:
        body["point_cloud_ids"] = point_cloud_ids
    response = await self._post(
        f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/optimized/run",
        json=body,
    )
    response_json = response.json()
    # Wait for the group job to complete
    job = await self.wait_for_group_job(response_json["group_job"]["group_id"])
    return job

get_job async

get_job(job_id: int) -> dict

Retrieve information about a specific job.

Parameters:

Name Type Description Default
job_id int

The ID of the job to retrieve.

required

Returns:

Name Type Description
dict dict

The job object with its details.

Source code in src/pixel_client/_base.py
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
async def get_job(
    self,
    job_id: int,
) -> dict:
    """
    Retrieve information about a specific job.

    Args:
        job_id: The ID of the job to retrieve.

    Returns:
        dict: The job object with its details.
    """
    response = await self._get(f"/jobs/{job_id}")
    return response.json()

get_job_group async

get_job_group(job_id: int) -> dict

Retrieve information about a specific job group.

Parameters:

Name Type Description Default
job_id int

The ID of the job group to retrieve.

required

Returns:

Name Type Description
dict dict

The job group object with its details.

Source code in src/pixel_client/_base.py
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
async def get_job_group(
    self,
    job_id: int,
) -> dict:
    """
    Retrieve information about a specific job group.

    Args:
        job_id: The ID of the job group to retrieve.

    Returns:
        dict: The job group object with its details.
    """
    response = await self._get(f"/jobs/groups/{job_id}")
    return response.json()

wait_for_job async

wait_for_job(job_id: int, timeout: int = 600) -> dict

Wait for a job to complete, polling its status at regular intervals.

Parameters:

Name Type Description Default
job_id int

The ID of the job to wait for.

required
timeout int

Maximum time to wait in seconds before raising a TimeoutError. Default is 600 seconds (10 minutes).

600

Returns:

Name Type Description
dict dict

The completed job object.

Raises:

Type Description
TimeoutError

If the job does not complete within the specified timeout period.

Source code in src/pixel_client/_base.py
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
async def wait_for_job(
    self,
    job_id: int,
    timeout: int = 600,
) -> dict:
    """
    Wait for a job to complete, polling its status at regular intervals.

    Args:
        job_id: The ID of the job to wait for.
        timeout: Maximum time to wait in seconds before raising a TimeoutError. Default is 600 seconds (10 minutes).

    Returns:
        dict: The completed job object.

    Raises:
        TimeoutError: If the job does not complete within the specified timeout period.
    """
    job = await self.get_job(job_id)
    with silence_logger(logging.getLogger("httpx")):
        while not job["completed"]:
            job = await self.get_job(job_id)
            job_name = job["name"] or "unnamed"
            logger.info(f"Job {job_name} {job_id} status: {job['status']}")
            await asyncio.sleep(3)
            timeout -= 5
            if timeout <= 0:
                raise TimeoutError("Timed out waiting for job")
    logger.info(f"Job {job_id} finished with status {job['status']}")
    return job

wait_for_group_job async

wait_for_group_job(
    group_job_id: int, timeout: int = 1200
) -> dict

Wait for a group job to complete, polling its status at regular intervals. A group job consists of multiple individual jobs. This method displays a progress bar showing the completion status of all jobs in the group.

Parameters:

Name Type Description Default
group_job_id int

The ID of the group job to wait for.

required
timeout int

Maximum time to wait in seconds before raising a TimeoutError. Default is 1200 seconds (20 minutes).

1200

Returns:

Name Type Description
dict dict

The completed group job object.

Raises:

Type Description
TimeoutError

If the group job does not complete within the specified timeout period.

Source code in src/pixel_client/_base.py
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
async def wait_for_group_job(
    self,
    group_job_id: int,
    timeout: int = 1200,
) -> dict:
    """
    Wait for a group job to complete, polling its status at regular intervals.
    A group job consists of multiple individual jobs. This method displays a progress bar
    showing the completion status of all jobs in the group.

    Args:
        group_job_id: The ID of the group job to wait for.
        timeout: Maximum time to wait in seconds before raising a TimeoutError. Default is 1200 seconds (20 minutes).

    Returns:
        dict: The completed group job object.

    Raises:
        TimeoutError: If the group job does not complete within the specified timeout period.
    """
    job = await self.get_job_group(group_job_id)
    num_jobs = job["total_jobs"]
    with (
        silence_logger(logging.getLogger("httpx")),
        tqdm.tqdm(total=num_jobs, desc=f"Running group job {group_job_id}") as pbar,
    ):
        while not job["completed"]:
            job = await self.get_job_group(group_job_id)
            num_failed = job["failed_count"]
            num_success = job["success_count"]
            num_finished = num_failed + num_success
            pbar.n = num_finished
            pbar.refresh()
            await asyncio.sleep(3)
            timeout -= 5
            if timeout <= 0:
                raise TimeoutError("Timed out waiting for optimize rasters job")
    logger.info(
        f"Group job {group_job_id} finished {job['total_jobs']} jobs, with {num_failed} failures and {num_success} successes"
    )
    return job

get_optimized_rasters async

get_optimized_rasters(
    project_id: int,
    data_collection_id: int,
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]

Retrieve optimized rasters from a data collection with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the optimized rasters.

required
params ListParams | None

Optional ListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters.

{}

Returns:

Type Description
list[dict]

list[dict]: A list of optimized raster objects matching the filter criteria.

Source code in src/pixel_client/_base.py
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
async def get_optimized_rasters(
    self,
    project_id: int,
    data_collection_id: int,
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]:
    """
    Retrieve optimized rasters from a data collection with optional filtering.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the optimized rasters.
        params: Optional ListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters.

    Returns:
        list[dict]: A list of optimized raster objects matching the filter criteria.
    """
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else ListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/optimized/",
        params=params_dict,
    )
    return response.json()

delete_optimized_rasters async

delete_optimized_rasters(
    project_id: int,
    data_collection_id: int,
    raster_id: int,
    profile: str | None = None,
) -> list[dict]

Delete optimized rasters associated with a specific raster.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the raster.

required
raster_id int

The ID of the raster whose optimized versions should be deleted.

required
profile str | None

Optional profile name to filter which optimized rasters to delete. If None, all optimized versions of the raster will be deleted.

None

Returns:

Type Description
list[dict]

list[dict]: A list of the deleted optimized raster objects.

Source code in src/pixel_client/_base.py
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
async def delete_optimized_rasters(
    self,
    project_id: int,
    data_collection_id: int,
    raster_id: int,
    profile: str | None = None,
) -> list[dict]:
    """
    Delete optimized rasters associated with a specific raster.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the raster.
        raster_id: The ID of the raster whose optimized versions should be deleted.
        profile: Optional profile name to filter which optimized rasters to delete.
                If None, all optimized versions of the raster will be deleted.

    Returns:
        list[dict]: A list of the deleted optimized raster objects.
    """
    params = {}
    if profile:
        params["profile"] = profile
    response = await self._delete(
        f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}/optimized",
        params=params,
    )
    return response.json()

optimize_rasters async

optimize_rasters(
    project_id: int,
    data_collection_id: int,
    raster_ids: list[int] | None = None,
    profile: str | None = None,
    nearblack: NearblackOptions | None = None,
    overview_resampling: OverviewResampling = "average",
) -> list[dict]

Create and run optimization on rasters in a data collection. This is a convenience method that combines create_optimized_rasters and run_optimize_rasters into a single operation.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the rasters.

required
raster_ids list[int] | None

Optional list of raster IDs to optimize. If None, all rasters in the collection will be optimized.

None
profile str | None

Optional profile name to use for optimization.

None
nearblack NearblackOptions | None

Optional NearblackOptions object for configuring the nearblack process.

None
overview_resampling OverviewResampling

The resampling method to use for creating overviews. Default is "average".

'average'

Returns:

Type Description
list[dict]

list[dict]: List of optimized raster objects after the optimization process has completed.

Source code in src/pixel_client/_base.py
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
async def optimize_rasters(
    self,
    project_id: int,
    data_collection_id: int,
    raster_ids: list[int] | None = None,
    profile: str | None = None,
    nearblack: NearblackOptions | None = None,
    overview_resampling: OverviewResampling = "average",
) -> list[dict]:
    """
    Create and run optimization on rasters in a data collection.
    This is a convenience method that combines create_optimized_rasters and run_optimize_rasters
    into a single operation.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the rasters.
        raster_ids: Optional list of raster IDs to optimize. If None, all rasters in the collection will be optimized.
        profile: Optional profile name to use for optimization.
        nearblack: Optional NearblackOptions object for configuring the nearblack process.
        overview_resampling: The resampling method to use for creating overviews. Default is "average".

    Returns:
        list[dict]: List of optimized raster objects after the optimization process has completed.
    """
    optimized_rasters = await self.create_optimized_rasters(
        project_id,
        data_collection_id,
        raster_ids,
        profile,
        nearblack=nearblack,
        overview_resampling=overview_resampling,
    )
    await self.run_optimize_rasters(
        project_id, data_collection_id, [r["id"] for r in optimized_rasters]
    )
    optimized_rasters = await self.get_optimized_rasters(
        project_id,
        data_collection_id,
        params=ListParams(
            ids=[r["id"] for r in optimized_rasters], limit=len(optimized_rasters)
        ),
    )
    return optimized_rasters

get_point_clouds async

get_point_clouds(
    project_id: int,
    data_collection_id: int,
    params: PointCloudListParams | None = None,
    **kwargs,
) -> list[dict]

Retrieve point clouds from a data collection with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the point clouds.

required
params PointCloudListParams | None

Optional PointCloudListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters.

{}
Source code in src/pixel_client/_base.py
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
async def get_point_clouds(
    self,
    project_id: int,
    data_collection_id: int,
    params: PointCloudListParams | None = None,
    **kwargs,
) -> list[dict]:
    """
    Retrieve point clouds from a data collection with optional filtering.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the point clouds.
        params: Optional PointCloudListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters.
    Returns:
        list[dict]: A list of point cloud objects matching the filter criteria.
    """
    params_dict = (
        params.model_dump(exclude_none=True, mode="json") if params else {}
    )
    params_dict.update(kwargs)
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/",
        params=params_dict,
    )
    return response.json()

paginate_point_clouds async

paginate_point_clouds(
    project_id: int,
    data_collection_id: int,
    page_size: int,
    params: PointCloudListParams | None = None,
    **kwargs,
) -> AsyncGenerator[dict, None]

Paginate through point clouds in a data collection with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the point clouds.

required
page_size int

The number of point clouds to retrieve per page.

required
params PointCloudListParams | None

Optional PointCloudListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters.

{}
Source code in src/pixel_client/_base.py
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
async def paginate_point_clouds(
    self,
    project_id: int,
    data_collection_id: int,
    page_size: int,
    params: PointCloudListParams | None = None,
    **kwargs,
) -> AsyncGenerator[dict, None]:
    """
    Paginate through point clouds in a data collection with optional filtering.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the point clouds.
        page_size: The number of point clouds to retrieve per page.
        params: Optional PointCloudListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters.
    Yields:
        dict: Point cloud objects matching the filter criteria, one at a time.
    """
    params_dict = (
        params.model_dump(
            exclude_none=True, exclude={"offset", "limit"}, mode="json"
        )
        if params
        else {}
    )
    params_dict.update(kwargs)
    url = f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/"
    async for point_cloud in self._paginate(
        url=url,
        page_size=page_size,
        params=params_dict,
    ):
        yield point_cloud

get_point_cloud async

get_point_cloud(
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
) -> dict

Retrieve a specific point cloud by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the point cloud.

required
point_cloud_id int

The ID of the point cloud to retrieve.

required
Source code in src/pixel_client/_base.py
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
async def get_point_cloud(
    self,
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
) -> dict:
    """
    Retrieve a specific point cloud by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the point cloud.
        point_cloud_id: The ID of the point cloud to retrieve.
    Returns:
        dict: The point cloud object with its details.
    """
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}"
    )
    return response.json()

update_point_cloud async

update_point_cloud(
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
    update_input: PointCloudUpdateInput,
) -> dict

Update an existing point cloud with new values.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the point cloud.

required
point_cloud_id int

The ID of the point cloud to update.

required
update_input PointCloudUpdateInput

PointCloudUpdateInput object containing the fields to update.

required
Source code in src/pixel_client/_base.py
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
async def update_point_cloud(
    self,
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
    update_input: PointCloudUpdateInput,
) -> dict:
    """
    Update an existing point cloud with new values.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the point cloud.
        point_cloud_id: The ID of the point cloud to update.
        update_input: PointCloudUpdateInput object containing the fields to update.
    Returns:
        dict: The updated point cloud object.
    """
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}",
        json=update_input.model_dump(mode="json", exclude_none=True),
    )
    return response.json()

move_point_cloud async

move_point_cloud(
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
    new_data_collection_id: int,
    new_project_id: int | None = None,
) -> dict

Move a point cloud to a different data collection.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the current data collection containing the point cloud.

required
point_cloud_id int

The ID of the point cloud to move.

required
new_data_collection_id int

The ID of the target data collection to move the point cloud to.

required
new_project_id int | None

The ID of the project containing the target data collection. Defaults to project_id.

None
Source code in src/pixel_client/_base.py
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
async def move_point_cloud(
    self,
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
    new_data_collection_id: int,
    new_project_id: int | None = None,
) -> dict:
    """
    Move a point cloud to a different data collection.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the current data collection containing the point cloud.
        point_cloud_id: The ID of the point cloud to move.
        new_data_collection_id: The ID of the target data collection to move the point cloud to.
        new_project_id: The ID of the project containing the target data collection. Defaults to `project_id`.
    Returns:
        dict: The moved point cloud object.
    """
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}/move",
        params={
            "new_project_id": new_project_id or project_id,
            "new_data_collection_id": new_data_collection_id,
        },
    )
    return response.json()

delete_point_cloud async

delete_point_cloud(
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
) -> dict

Delete a specific point cloud by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the point cloud.

required
point_cloud_id int

The ID of the point cloud to delete.

required
Source code in src/pixel_client/_base.py
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
async def delete_point_cloud(
    self,
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
) -> dict:
    """
    Delete a specific point cloud by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the point cloud.
        point_cloud_id: The ID of the point cloud to delete.
    Returns:
        dict: The response confirming deletion.
    """
    response = await self._delete(
        f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}"
    )
    return response.json()

get_optimized_point_clouds async

get_optimized_point_clouds(
    project_id: int,
    data_collection_id: int,
    params: OptimizedPointCloudListParams | None = None,
    **kwargs,
) -> list[dict]

Retrieve optimized point clouds from a data collection with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the optimized point clouds.

required
params OptimizedPointCloudListParams | None

Optional PointCloudListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters.

{}
Source code in src/pixel_client/_base.py
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
async def get_optimized_point_clouds(
    self,
    project_id: int,
    data_collection_id: int,
    params: OptimizedPointCloudListParams | None = None,
    **kwargs,
) -> list[dict]:
    """
    Retrieve optimized point clouds from a data collection with optional filtering.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the optimized point clouds.
        params: Optional PointCloudListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters.
    Returns:
        list[dict]: A list of optimized point cloud objects matching the filter criteria.
    """
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else OptimizedPointCloudListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/optimized/",
        params=params_dict,
    )
    return response.json()

delete_optimized_point_cloud async

delete_optimized_point_cloud(
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
) -> dict

Delete optimized point cloud associated with a specific point cloud.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the point cloud.

required
point_cloud_id int

The ID of the point cloud whose optimized versions should be deleted.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Source code in src/pixel_client/_base.py
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
async def delete_optimized_point_cloud(
    self,
    project_id: int,
    data_collection_id: int,
    point_cloud_id: int,
) -> dict:
    """
    Delete optimized point cloud associated with a specific point cloud.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the point cloud.
        point_cloud_id: The ID of the point cloud whose optimized versions should be deleted.

    Returns:
        dict: The response confirming deletion.
    """
    response = await self._delete(
        f"/projects/{project_id}/data_collections/{data_collection_id}/point_clouds/{point_cloud_id}/optimized"
    )
    return response.json()

optimize_point_clouds async

optimize_point_clouds(
    project_id: int,
    data_collection_id: int,
    point_cloud_ids: list[int] | None = None,
) -> list[dict]

Create and run optimization on point clouds in a data collection.

This is a convenience method that combines create_optimized_point_clouds and run_optimize_point_clouds into a single operation.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the rasters.

required
point_cloud_ids list[int] | None

Optional list of raster IDs to optimize. If None, all rasters in the collection will be optimized.

None
Source code in src/pixel_client/_base.py
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
async def optimize_point_clouds(
    self,
    project_id: int,
    data_collection_id: int,
    point_cloud_ids: list[int] | None = None,
) -> list[dict]:
    """
    Create and run optimization on point clouds in a data collection.

    This is a convenience method that combines create_optimized_point_clouds and run_optimize_point_clouds
    into a single operation.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the rasters.
        point_cloud_ids: Optional list of raster IDs to optimize. If None, all rasters in the collection will be optimized.
    Returns:
        list[dict]: List of optimized point_cloud objects after the optimization process has completed.
    """
    optimized_point_clouds = await self.create_optimized_point_clouds(
        project_id,
        data_collection_id,
        point_cloud_ids,
    )
    await self.run_optimize_point_clouds(
        project_id,
        data_collection_id,
        [pc["id"] for pc in optimized_point_clouds],
    )
    optimized_point_clouds = await self.get_optimized_point_clouds(
        project_id,
        data_collection_id,
        params=OptimizedPointCloudListParams(
            ids=[pc["id"] for pc in optimized_point_clouds],
            limit=len(optimized_point_clouds),
        ),
    )
    return optimized_point_clouds

list_gdo_users async

list_gdo_users() -> list[str]

Retrieve a list of GDO (GeoData Online) users.

Returns:

Type Description
list[str]

list[dict]: A list of GDO user names.

Source code in src/pixel_client/_base.py
2708
2709
2710
2711
2712
2713
2714
2715
async def list_gdo_users(self) -> list[str]:
    """Retrieve a list of GDO (GeoData Online) users.

    Returns:
        list[dict]: A list of GDO user names.
    """
    response = await self._get("/arcgis_services/gdo-users")
    return response.json()

create_arcgis_service async

create_arcgis_service(
    service_type: Literal["Feature", "Image"],
    create_input: ArcgisServiceCreateInput,
) -> dict

Create a new ArcGIS service.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

The type of service to create, either "Feature" or "Image".

required
create_input ArcgisServiceCreateInput

ArcgisServiceCreateInput object containing the service configuration.

required

Returns:

Name Type Description
dict dict

The created ArcGIS service object.

Raises:

Type Description
AssertionError

If the create_input does not contain the appropriate service options for the specified service_type.

Source code in src/pixel_client/_base.py
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
async def create_arcgis_service(
    self,
    service_type: Literal["Feature", "Image"],
    create_input: ArcgisServiceCreateInput,
) -> dict:
    """Create a new ArcGIS service.

    Args:
        service_type: The type of service to create, either "Feature" or "Image".
        create_input: ArcgisServiceCreateInput object containing the service configuration.

    Returns:
        dict: The created ArcGIS service object.

    Raises:
        AssertionError: If the create_input does not contain the appropriate service options for the specified service_type.
    """
    assert (
        getattr(
            create_input.options, f"{service_type.lower()}_service_options", None
        )
        is not None
    ), (
        f"Service options for {service_type} service must be provided in the create input"
    )
    response = await self._post(
        f"/arcgis_services/{service_type}/",
        json=create_input.model_dump(mode="json", exclude_none=True),
    )
    return response.json()

list_arcgis_services async

list_arcgis_services(
    service_type: Literal["Feature", "Image"],
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]

List ArcGIS services of a specific type with optional filtering.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

The type of services to list, either "Feature" or "Image".

required
params ListParams | None

Optional ListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters.

{}

Returns:

Type Description
list[dict]

list[dict]: A list of ArcGIS service objects matching the filter criteria.

Source code in src/pixel_client/_base.py
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
async def list_arcgis_services(
    self,
    service_type: Literal["Feature", "Image"],
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]:
    """List ArcGIS services of a specific type with optional filtering.

    Args:
        service_type: The type of services to list, either "Feature" or "Image".
        params: Optional ListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters.

    Returns:
        list[dict]: A list of ArcGIS service objects matching the filter criteria.
    """
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else ListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get(
        f"/arcgis_services/{service_type}/", params=params_dict
    )
    return response.json()

get_arcgis_service async

get_arcgis_service(
    service_type: Literal["Feature", "Image"],
    service_id: int,
) -> dict

Retrieve a specific ArcGIS service by its ID.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

The type of service, either "Feature" or "Image".

required
service_id int

The ID of the service to retrieve.

required

Returns:

Name Type Description
dict dict

The ArcGIS service object with its details.

Source code in src/pixel_client/_base.py
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
async def get_arcgis_service(
    self, service_type: Literal["Feature", "Image"], service_id: int
) -> dict:
    """Retrieve a specific ArcGIS service by its ID.

    Args:
        service_type: The type of service, either "Feature" or "Image".
        service_id: The ID of the service to retrieve.

    Returns:
        dict: The ArcGIS service object with its details.
    """
    response = await self._get(f"/arcgis_services/{service_type}/{service_id}")
    return response.json()

delete_arcgis_service async

delete_arcgis_service(
    service_type: Literal["Feature", "Image"],
    service_id: int,
) -> dict

Delete a specific ArcGIS service by its ID.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

The type of service, either "Feature" or "Image".

required
service_id int

The ID of the service to delete.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Source code in src/pixel_client/_base.py
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
async def delete_arcgis_service(
    self, service_type: Literal["Feature", "Image"], service_id: int
) -> dict:
    """Delete a specific ArcGIS service by its ID.

    Args:
        service_type: The type of service, either "Feature" or "Image".
        service_id: The ID of the service to delete.

    Returns:
        dict: The response confirming deletion.
    """
    response = await self._delete(f"/arcgis_services/{service_type}/{service_id}")
    return response.json()

update_arcgis_service async

update_arcgis_service(
    service_type: Literal["Feature", "Image"],
    service_id: int,
    update_input: ArcgisServiceUpdateInput,
) -> dict

Update an existing ArcGIS service with new values.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

The type of service, either "Feature" or "Image".

required
service_id int

The ID of the service to update.

required
update_input ArcgisServiceUpdateInput

ArcgisServiceUpdateInput object containing the fields to update.

required

Returns:

Name Type Description
dict dict

The updated ArcGIS service object.

Source code in src/pixel_client/_base.py
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
async def update_arcgis_service(
    self,
    service_type: Literal["Feature", "Image"],
    service_id: int,
    update_input: ArcgisServiceUpdateInput,
) -> dict:
    """Update an existing ArcGIS service with new values.

    Args:
        service_type: The type of service, either "Feature" or "Image".
        service_id: The ID of the service to update.
        update_input: ArcgisServiceUpdateInput object containing the fields to update.

    Returns:
        dict: The updated ArcGIS service object.
    """
    response = await self._put(
        f"/arcgis_services/{service_type}/{service_id}",
        json=update_input.model_dump(mode="json", exclude_none=True),
    )
    return response.json()

start_arcgis_service async

start_arcgis_service(
    service_type: Literal["Feature", "Image"],
    service_id: int,
    wait: bool = True,
) -> dict

Start a specific ArcGIS service.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

The type of service, either "Feature" or "Image".

required
service_id int

The ID of the service to start.

required
wait bool

If True, wait for the start operation to complete before returning. If False, return immediately after initiating the start operation.

True

Returns:

Name Type Description
dict dict

A response object containing job information and, if wait is True, the updated service object after starting.

Source code in src/pixel_client/_base.py
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
async def start_arcgis_service(
    self,
    service_type: Literal["Feature", "Image"],
    service_id: int,
    wait: bool = True,
) -> dict:
    """Start a specific ArcGIS service.

    Args:
        service_type: The type of service, either "Feature" or "Image".
        service_id: The ID of the service to start.
        wait: If True, wait for the start operation to complete before returning.
             If False, return immediately after initiating the start operation.

    Returns:
        dict: A response object containing job information and, if wait is True,
             the updated service object after starting.
    """
    response = await self._put(
        f"/arcgis_services/{service_type}/{service_id}/start"
    )
    resp = response.json()
    job = resp["job"]
    if wait and job:
        job = await self.wait_for_job(job["job_id"], timeout=1000)
        resp["job"] = job
        resp["arcgis_service"] = await self.get_arcgis_service(
            service_type, service_id
        )
    return resp

stop_arcgis_service async

stop_arcgis_service(
    service_type: Literal["Feature", "Image"],
    service_id: int,
    wait: bool = True,
) -> dict

Stop a specific ArcGIS service.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

The type of service, either "Feature" or "Image".

required
service_id int

The ID of the service to stop.

required
wait bool

If True, wait for the stop operation to complete before returning. If False, return immediately after initiating the stop operation.

True

Returns:

Name Type Description
dict dict

A response object containing job information and, if wait is True, the updated service object after stopping.

Source code in src/pixel_client/_base.py
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
async def stop_arcgis_service(
    self,
    service_type: Literal["Feature", "Image"],
    service_id: int,
    wait: bool = True,
) -> dict:
    """Stop a specific ArcGIS service.

    Args:
        service_type: The type of service, either "Feature" or "Image".
        service_id: The ID of the service to stop.
        wait: If True, wait for the stop operation to complete before returning.
             If False, return immediately after initiating the stop operation.

    Returns:
        dict: A response object containing job information and, if wait is True,
             the updated service object after stopping.
    """
    response = await self._put(f"/arcgis_services/{service_type}/{service_id}/stop")
    resp = response.json()
    job = resp["job"]
    if wait and job:
        job = await self.wait_for_job(job["job_id"], timeout=1000)
        resp["job"] = job
        resp["arcgis_service"] = await self.get_arcgis_service(
            service_type, service_id
        )
    return resp

refresh_arcgis_service async

refresh_arcgis_service(
    service_type: Literal["Feature", "Image"],
    service_id: int,
    refresh_data: bool = False,
    wait: bool = True,
) -> dict

Refresh a specific ArcGIS service, optionally refreshing its data.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

The type of service, either "Feature" or "Image".

required
service_id int

The ID of the service to refresh.

required
refresh_data bool

If True, also refresh the data used by the service.

False
wait bool

If True, wait for the refresh operation to complete before returning. If False, return immediately after initiating the refresh operation.

True

Returns:

Name Type Description
dict dict

A response object containing job information and, if wait is True, the updated service object after refreshing.

Source code in src/pixel_client/_base.py
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
async def refresh_arcgis_service(
    self,
    service_type: Literal["Feature", "Image"],
    service_id: int,
    refresh_data: bool = False,
    wait: bool = True,
) -> dict:
    """Refresh a specific ArcGIS service, optionally refreshing its data.

    Args:
        service_type: The type of service, either "Feature" or "Image".
        service_id: The ID of the service to refresh.
        refresh_data: If True, also refresh the data used by the service.
        wait: If True, wait for the refresh operation to complete before returning.
             If False, return immediately after initiating the refresh operation.

    Returns:
        dict: A response object containing job information and, if wait is True,
             the updated service object after refreshing.
    """
    response = await self._put(
        f"/arcgis_services/{service_type}/{service_id}/refresh",
        params={"refresh_data": refresh_data},
    )
    resp = response.json()
    job = resp["job"]
    if wait and job:
        job = await self.wait_for_job(job["job_id"], timeout=1000)
        resp["job"] = job
        resp["arcgis_service"] = await self.get_arcgis_service(
            service_type, service_id
        )
    return resp

create_harvest_service async

create_harvest_service(
    project_id: int,
    data_collection_id: int,
    create_input: HarvestServiceCreateInput,
) -> dict

Create a new harvest service for a data collection.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection to create the harvest service for.

required
create_input HarvestServiceCreateInput

HarvestServiceCreateInput object containing the service configuration.

required

Returns:

Name Type Description
dict dict

The created harvest service object.

Source code in src/pixel_client/_base.py
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
async def create_harvest_service(
    self,
    project_id: int,
    data_collection_id: int,
    create_input: HarvestServiceCreateInput,
) -> dict:
    """Create a new harvest service for a data collection.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection to create the harvest service for.
        create_input: HarvestServiceCreateInput object containing the service configuration.

    Returns:
        dict: The created harvest service object.
    """
    response = await self._post(
        f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/",
        json=create_input.model_dump(mode="json", exclude_none=True),
        sensitive_content=True,
    )
    return response.json()

list_harvest_services async

list_harvest_services(
    project_id: int,
    data_collection_id: int,
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]

List harvest services for a data collection with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection to list harvest services for.

required
params ListParams | None

Optional ListParams object containing filtering parameters.

None
**kwargs

Alternative way to provide filtering parameters. Ignored if params is provided.

{}

Returns:

Type Description
list[dict]

list[dict]: A list of harvest service objects matching the filter criteria.

Source code in src/pixel_client/_base.py
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
async def list_harvest_services(
    self,
    project_id: int,
    data_collection_id: int,
    params: ListParams | None = None,
    **kwargs,
) -> list[dict]:
    """List harvest services for a data collection with optional filtering.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection to list harvest services for.
        params: Optional ListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

    Returns:
        list[dict]: A list of harvest service objects matching the filter criteria.
    """
    if params and kwargs:
        logger.warning("Ignoring kwargs when params is provided")
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else ListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/",
        params=params_dict,
    )
    return response.json()

get_harvest_service async

get_harvest_service(
    project_id: int,
    data_collection_id: int,
    service_id: int,
) -> dict

Retrieve a specific harvest service by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the harvest service.

required
service_id int

The ID of the harvest service to retrieve.

required

Returns:

Name Type Description
dict dict

The harvest service object with its details.

Source code in src/pixel_client/_base.py
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
async def get_harvest_service(
    self, project_id: int, data_collection_id: int, service_id: int
) -> dict:
    """Retrieve a specific harvest service by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the harvest service.
        service_id: The ID of the harvest service to retrieve.

    Returns:
        dict: The harvest service object with its details.
    """
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}"
    )
    return response.json()

update_harvest_service async

update_harvest_service(
    project_id: int,
    data_collection_id: int,
    service_id: int,
    update_input: HarvestServiceUpdateInput,
) -> dict

Update an existing harvest service with new values.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the harvest service.

required
service_id int

The ID of the harvest service to update.

required
update_input HarvestServiceUpdateInput

HarvestServiceUpdateInput object containing the fields to update.

required

Returns:

Name Type Description
dict dict

The updated harvest service object.

Source code in src/pixel_client/_base.py
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
async def update_harvest_service(
    self,
    project_id: int,
    data_collection_id: int,
    service_id: int,
    update_input: HarvestServiceUpdateInput,
) -> dict:
    """Update an existing harvest service with new values.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the harvest service.
        service_id: The ID of the harvest service to update.
        update_input: HarvestServiceUpdateInput object containing the fields to update.

    Returns:
        dict: The updated harvest service object.
    """
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}",
        json=update_input.model_dump(mode="json", exclude_none=True),
        sensitive_content=True,
    )
    return response.json()

delete_harvest_service async

delete_harvest_service(
    project_id: int,
    data_collection_id: int,
    service_id: int,
) -> dict

Delete a specific harvest service by its ID.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the harvest service.

required
service_id int

The ID of the harvest service to delete.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Source code in src/pixel_client/_base.py
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
async def delete_harvest_service(
    self, project_id: int, data_collection_id: int, service_id: int
) -> dict:
    """Delete a specific harvest service by its ID.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the harvest service.
        service_id: The ID of the harvest service to delete.

    Returns:
        dict: The response confirming deletion.
    """
    response = await self._delete(
        f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}"
    )
    return response.json()

get_harvest_service_tasks async

get_harvest_service_tasks(
    project_id: int,
    data_collection_id: int,
    service_id: int,
    params: HarvestTaskListParams,
    **kwargs,
) -> list[dict]

Retrieve tasks for a specific harvest service with optional filtering.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the harvest service.

required
service_id int

The ID of the harvest service to retrieve tasks for.

required
params HarvestTaskListParams

HarvestTaskListParams object containing filtering parameters.

required
**kwargs

Alternative way to provide filtering parameters. Ignored if params is provided.

{}

Returns:

Type Description
list[dict]

list[dict]: A list of harvest task objects matching the filter criteria.

Source code in src/pixel_client/_base.py
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
async def get_harvest_service_tasks(
    self,
    project_id: int,
    data_collection_id: int,
    service_id: int,
    params: HarvestTaskListParams,
    **kwargs,
) -> list[dict]:
    """Retrieve tasks for a specific harvest service with optional filtering.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the harvest service.
        service_id: The ID of the harvest service to retrieve tasks for.
        params: HarvestTaskListParams object containing filtering parameters.
        **kwargs: Alternative way to provide filtering parameters. Ignored if params is provided.

    Returns:
        list[dict]: A list of harvest task objects matching the filter criteria.
    """
    params_dict = (
        params.model_dump(exclude_none=True, mode="json")
        if params
        else ListParams.model_validate(kwargs).model_dump(
            exclude_none=True, mode="json"
        )
    )
    response = await self._get(
        f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}/",
        params=params_dict,
    )
    return response.json()

start_harvest_service async

start_harvest_service(
    project_id: int,
    data_collection_id: int,
    service_id: int,
) -> dict

Start a specific harvest service.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the harvest service.

required
service_id int

The ID of the harvest service to start.

required

Returns:

Name Type Description
dict dict

The response confirming the service has been started.

Source code in src/pixel_client/_base.py
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
async def start_harvest_service(
    self, project_id: int, data_collection_id: int, service_id: int
) -> dict:
    """Start a specific harvest service.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the harvest service.
        service_id: The ID of the harvest service to start.

    Returns:
        dict: The response confirming the service has been started.
    """
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}/start"
    )
    return response.json()

stop_harvest_service async

stop_harvest_service(
    project_id: int,
    data_collection_id: int,
    service_id: int,
) -> dict

Stop a specific harvest service.

Parameters:

Name Type Description Default
project_id int

The ID of the project containing the data collection.

required
data_collection_id int

The ID of the data collection containing the harvest service.

required
service_id int

The ID of the harvest service to stop.

required

Returns:

Name Type Description
dict dict

The response confirming the service has been stopped.

Source code in src/pixel_client/_base.py
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
async def stop_harvest_service(
    self, project_id: int, data_collection_id: int, service_id: int
) -> dict:
    """Stop a specific harvest service.

    Args:
        project_id: The ID of the project containing the data collection.
        data_collection_id: The ID of the data collection containing the harvest service.
        service_id: The ID of the harvest service to stop.

    Returns:
        dict: The response confirming the service has been stopped.
    """
    response = await self._put(
        f"/projects/{project_id}/data_collections/{data_collection_id}/harvest_services/{service_id}/stop"
    )
    return response.json()

create_oidc_user async

create_oidc_user(create_input: OIDCUserCreateInput) -> dict

Create a new OIDC user in the system.

Deprecated

Use create_user instead.

Parameters:

Name Type Description Default
create_input OIDCUserCreateInput

OIDCUserCreateInput object containing the user information.

required

Returns:

Name Type Description
dict dict

The created user object.

Source code in src/pixel_client/_base.py
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
async def create_oidc_user(self, create_input: OIDCUserCreateInput) -> dict:
    """Create a new OIDC user in the system.

    Deprecated:
        Use [`create_user`][pixel_client.PixelClientAsync.create_user] instead.

    Args:
        create_input: OIDCUserCreateInput object containing the user information.

    Returns:
        dict: The created user object.
    """
    warnings.warn(
        "create_oidc_user is deprecated, use create_user instead",
        DeprecationWarning,
        stacklevel=2,
    )
    return await self._create_user(create_input)

update_oidc_user async

update_oidc_user(
    email: str, update_input: OIDCUserUpdateInput
) -> dict

Update an existing OIDC user with new values.

Deprecated

Use update_user instead, which also keeps the user's active status unchanged.

Parameters:

Name Type Description Default
email str

The email address of the user to update.

required
update_input OIDCUserUpdateInput

OIDCUserUpdateInput object containing the fields to update.

required

Returns:

Name Type Description
dict dict

The updated user object.

Source code in src/pixel_client/_base.py
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
async def update_oidc_user(
    self, email: str, update_input: OIDCUserUpdateInput
) -> dict:
    """
    Update an existing OIDC user with new values.

    Deprecated:
        Use [`update_user`][pixel_client.PixelClientAsync.update_user] instead,
        which also keeps the user's active status unchanged.

    Args:
        email: The email address of the user to update.
        update_input: OIDCUserUpdateInput object containing the fields to update.

    Returns:
        dict: The updated user object.
    """
    warnings.warn(
        "update_oidc_user is deprecated, use update_user instead",
        DeprecationWarning,
        stacklevel=2,
    )
    return await self._update_user(email, update_input)

list_attachments async

list_attachments(
    resource_type: AttachmentResourceType,
    resource_id: int,
    status: Literal["Pending", "Completed"] | None = None,
) -> list[dict]

List attachments for a specific resource with optional status filtering.

Parameters:

Name Type Description Default
resource_type AttachmentResourceType

The type of resource the attachments belong to.

required
resource_id int

The ID of the resource to list attachments for.

required
status Literal['Pending', 'Completed'] | None

Optional filter for attachment status, either "Pending" or "Completed".

None

Returns:

Type Description
list[dict]

list[dict]: A list of attachment objects matching the filter criteria.

Source code in src/pixel_client/_base.py
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
async def list_attachments(
    self,
    resource_type: AttachmentResourceType,
    resource_id: int,
    status: Literal["Pending", "Completed"] | None = None,
) -> list[dict]:
    """
    List attachments for a specific resource with optional status filtering.

    Args:
        resource_type: The type of resource the attachments belong to.
        resource_id: The ID of the resource to list attachments for.
        status: Optional filter for attachment status, either "Pending" or "Completed".

    Returns:
        list[dict]: A list of attachment objects matching the filter criteria.
    """
    params = {"resource_type": resource_type, "resource_id": resource_id}
    if status:
        params["status"] = status
    response = await self._get(
        "/attachments/",
        params=params,
    )
    return response.json()

add_attachments async

add_attachments(
    resource_type: AttachmentResourceType,
    resource_id: int,
    files: list[PixelAttachmentUpload | Path]
    | list[Path]
    | list[PixelAttachmentUpload],
) -> list[dict]

Add one or more file attachments to a resource.

Parameters:

Name Type Description Default
resource_type AttachmentResourceType

The type of resource to attach files to.

required
resource_id int

The ID of the resource to attach files to.

required
files list[PixelAttachmentUpload | Path] | list[Path] | list[PixelAttachmentUpload]

List of files to attach, which can be Path objects or PixelAttachmentUpload objects.

required

Returns:

Type Description
list[dict]

list[dict]: A list of the created attachment objects.

Raises:

Type Description
AssertionError

If any attachment names are not unique.

Source code in src/pixel_client/_base.py
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
async def add_attachments(
    self,
    resource_type: AttachmentResourceType,
    resource_id: int,
    files: list[PixelAttachmentUpload | Path]
    | list[Path]
    | list[PixelAttachmentUpload],
) -> list[dict]:
    """
    Add one or more file attachments to a resource.

    Args:
        resource_type: The type of resource to attach files to.
        resource_id: The ID of the resource to attach files to.
        files: List of files to attach, which can be Path objects or PixelAttachmentUpload objects.

    Returns:
        list[dict]: A list of the created attachment objects.

    Raises:
        AssertionError: If any attachment names are not unique.
    """
    pixel_attachments = [
        PixelAttachmentUpload(
            file=f,
        )
        if isinstance(f, Path)
        else f
        for f in files
    ]
    assert len(set(pa.name for pa in pixel_attachments)) == len(
        pixel_attachments
    ), "Attachment names must be unique"
    response = await self._post(
        "/attachments/",
        params={"resource_type": resource_type, "resource_id": resource_id},
        json={
            "files": [
                pa.model_dump(mode="json", exclude_none=True)
                for pa in pixel_attachments
            ]
        },
    )
    attachments = response.json()
    sorted_attachments = sorted(attachments, key=lambda a: a["name"])
    sorted_files = sorted(pixel_attachments, key=lambda f: f.name)
    attachments = await asyncio.gather(
        *[
            self._upload_attachment_to_s3(resource_type, resource_id, a, pa.file)
            for a, pa in zip(sorted_attachments, sorted_files)
        ]
    )
    return attachments

move_attachment async

move_attachment(
    resource_type: AttachmentResourceType,
    resource_id: int,
    attachment_id: int,
    new_resource_type: AttachmentResourceType,
    new_resource_id: int,
) -> dict

Move an attachment from one resource to another.

Parameters:

Name Type Description Default
resource_type AttachmentResourceType

The current resource type of the attachment.

required
resource_id int

The current resource ID the attachment belongs to.

required
attachment_id int

The ID of the attachment to move.

required
new_resource_type AttachmentResourceType

The target resource type to move the attachment to.

required
new_resource_id int

The target resource ID to move the attachment to.

required

Returns:

Name Type Description
dict dict

The updated attachment object.

Source code in src/pixel_client/_base.py
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
async def move_attachment(
    self,
    resource_type: AttachmentResourceType,
    resource_id: int,
    attachment_id: int,
    new_resource_type: AttachmentResourceType,
    new_resource_id: int,
) -> dict:
    """
    Move an attachment from one resource to another.

    Args:
        resource_type: The current resource type of the attachment.
        resource_id: The current resource ID the attachment belongs to.
        attachment_id: The ID of the attachment to move.
        new_resource_type: The target resource type to move the attachment to.
        new_resource_id: The target resource ID to move the attachment to.

    Returns:
        dict: The updated attachment object.
    """
    resp = await self._put(
        "/attachments/move",
        params={
            "resource_type": resource_type,
            "resource_id": resource_id,
            "attachment_id": attachment_id,
            "new_resource_type": new_resource_type,
            "new_resource_id": new_resource_id,
        },
    )
    return resp.json()

delete_attachment async

delete_attachment(
    resource_type: AttachmentResourceType,
    resource_id: int,
    attachment_id: int,
) -> dict

Delete a specific attachment from a resource.

Parameters:

Name Type Description Default
resource_type AttachmentResourceType

The resource type the attachment belongs to.

required
resource_id int

The resource ID the attachment belongs to.

required
attachment_id int

The ID of the attachment to delete.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Source code in src/pixel_client/_base.py
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
async def delete_attachment(
    self,
    resource_type: AttachmentResourceType,
    resource_id: int,
    attachment_id: int,
) -> dict:
    """
    Delete a specific attachment from a resource.

    Args:
        resource_type: The resource type the attachment belongs to.
        resource_id: The resource ID the attachment belongs to.
        attachment_id: The ID of the attachment to delete.

    Returns:
        dict: The response confirming deletion.
    """
    resp = await self._delete(
        "/attachments/",
        params={
            "resource_type": resource_type,
            "resource_id": resource_id,
            "attachment_id": attachment_id,
        },
    )
    return resp.json()

search_info async

search_info(on: SearchOn)

Retrieve search metadata for a specific resource type.

Parameters:

Name Type Description Default
on SearchOn

The resource type to retrieve search metadata for.

required
Source code in src/pixel_client/_base.py
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
async def search_info(self, on: SearchOn):
    """
    Retrieve search metadata for a specific resource type.

    Args:
        on: The resource type to retrieve search metadata for.
    Returns:
        dict: A dictionary containing output fields, filterable fields and search capabilities.
    """
    response = await self._get(
        "/search/info",
        params={"on": on},
    )
    return response.json()

search async

search(search_query: dict | SearchQuery) -> SearchResults

Perform a search across various resources.

Parameters:

Name Type Description Default
search_query dict | SearchQuery

SearchQuery object or dict containing the search parameters.

required
Source code in src/pixel_client/_base.py
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
async def search(
    self,
    search_query: dict | SearchQuery,
) -> SearchResults:
    """
    Perform a search across various resources.

    Args:
        search_query: SearchQuery object or dict containing the search parameters.
    Returns:
        SearchResults: The search results dictionary.
    """
    search_model = (
        SearchQuery.model_validate(search_query)
        if isinstance(search_query, dict)
        else search_query
    )
    response = await self._post(
        "/search/",
        json=search_model.model_dump(mode="json", exclude_none=True),
    )
    return response.json()
paginate_search(
    search_query: dict | SearchQuery, page_size: int
) -> AsyncGenerator[dict, None]

Perform a paginated search across various resources.

Parameters:

Name Type Description Default
search_query dict | SearchQuery

SearchQuery object or dict containing the search parameters.

required
page_size int

Number of results to retrieve per page.

required

Yields:

Name Type Description
dict AsyncGenerator[dict, None]

Individual search result items.

Source code in src/pixel_client/_base.py
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
async def paginate_search(
    self, search_query: dict | SearchQuery, page_size: int
) -> AsyncGenerator[dict, None]:
    """
    Perform a paginated search across various resources.

    Args:
        search_query: SearchQuery object or dict containing the search parameters.
        page_size: Number of results to retrieve per page.

    Yields:
        dict: Individual search result items.
    """
    search_model = (
        SearchQuery.model_validate(search_query)
        if isinstance(search_query, dict)
        else search_query
    )
    search_query_body = search_model.model_dump(
        mode="json", exclude_none=True, exclude={"limit", "offset"}
    )
    async for item in self._paginate(
        "/search/",
        method="POST",
        page_size=page_size,
        use_body=True,
        # The return of the search endpoint is in the "results" field
        results_parser=lambda resp: resp.get("results", []),
        json=search_query_body,
    ):
        yield item

list_analysis_modules async

list_analysis_modules() -> list[dict]

Retrieve a list of available analysis modules.

Returns:

Type Description
list[dict]

list[dict]: A list of analysis module objects.

Source code in src/pixel_client/_base.py
3404
3405
3406
3407
3408
3409
3410
3411
3412
async def list_analysis_modules(self) -> list[dict]:
        """
        Retrieve a list of available analysis modules.

        Returns:
            list[dict]: A list of analysis module objects.
        """
        response = await self._get("/analysis/modules/")
        return response.json()

list_analysis_services async

list_analysis_services(
    params: AnalysisServiceListParams | None = None,
    **kwargs,
) -> list[dict]

Retrieve a list of available analysis services.

Returns:

Type Description
list[dict]

list[dict]: A list of analysis service objects.

Source code in src/pixel_client/_base.py
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
async def list_analysis_services(self, params: AnalysisServiceListParams | None = None, **kwargs) -> list[dict]:
        """
        Retrieve a list of available analysis services.

        Returns:
            list[dict]: A list of analysis service objects.
        """
        if params and kwargs:
            logger.warning("Ignoring kwargs when params is provided")
        params_dict = (
            params.model_dump(exclude_none=True, mode="json")
            if params
            else AnalysisServiceListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get("/analysis/services/", params=params_dict)
        return response.json()

create_analysis_service async

create_analysis_service(
    create_input: AnalysisServiceCreateUpdateInput
    | None = None,
    **kwargs,
) -> dict

Create a new analysis service.

Returns:

Name Type Description
dict dict

The created analysis service object.

Source code in src/pixel_client/_base.py
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
async def create_analysis_service(self, create_input: AnalysisServiceCreateUpdateInput | None = None, **kwargs) -> dict:
        """
        Create a new analysis service.

        Returns:
            dict: The created analysis service object.
        """
        if create_input and kwargs:
            logger.warning("Ignoring kwargs when create_input is provided")
        input_dict = (
            create_input.model_dump(mode="json", exclude_none=True)
            if create_input
            else AnalysisServiceCreateUpdateInput.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._post(
            "/analysis/services/", json=input_dict
        )
        return response.json()

patch_analysis_service async

patch_analysis_service(
    service_id: int,
    patch_input: AnalysisServicePatchInput | None = None,
    **kwargs,
) -> dict

Partially update an analysis service.

Only fields explicitly set on patch_input (or passed as kwargs) are sent. Backend deep-merges config; omitted fields are kept as-is. module_name cannot be changed.

Returns:

Name Type Description
dict dict

The updated analysis service object.

Source code in src/pixel_client/_base.py
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
async def patch_analysis_service(
    self,
    service_id: int,
    patch_input: AnalysisServicePatchInput | None = None,
    **kwargs,
) -> dict:
        """
        Partially update an analysis service.

        Only fields explicitly set on `patch_input` (or passed as kwargs)
        are sent. Backend deep-merges `config`; omitted fields are kept
        as-is. `module_name` cannot be changed.

        Returns:
            dict: The updated analysis service object.
        """
        if patch_input and kwargs:
            logger.warning("Ignoring kwargs when patch_input is provided")
        model = patch_input or AnalysisServicePatchInput.model_validate(kwargs)
        input_dict = model.model_dump(exclude_unset=True, mode="json")
        response = await self._patch(
            f"/analysis/services/{service_id}", json=input_dict
        )
        return response.json()

delete_analysis_service async

delete_analysis_service(service_id: int) -> bool

Delete an existing analysis service.

Returns:

Name Type Description
dict bool

The response confirming deletion.

Source code in src/pixel_client/_base.py
3479
3480
3481
3482
3483
3484
3485
3486
3487
async def delete_analysis_service(self, service_id: int) -> bool:
        """
        Delete an existing analysis service.

        Returns:
            dict: The response confirming deletion.
        """
        _ = await self._delete(f"/analysis/services/{service_id}")
        return True

list_analysis_tasks async

list_analysis_tasks(
    service_id: int,
    list_input: AnalysisTaskListParams | None = None,
    **kwargs,
) -> list[dict]

Retrieve a list of analysis tasks.

Returns:

Type Description
list[dict]

list[dict]: A list of analysis task objects.

Source code in src/pixel_client/_base.py
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
async def list_analysis_tasks(self, service_id: int, list_input: AnalysisTaskListParams | None = None, **kwargs) -> list[dict]:
        """
        Retrieve a list of analysis tasks.

        Returns:
            list[dict]: A list of analysis task objects.
        """
        if list_input and kwargs:
            logger.warning("Ignoring kwargs when list_input is provided")
        params_dict = (
            list_input.model_dump(exclude_none=True, mode="json")
            if list_input
            else AnalysisTaskListParams.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )
        response = await self._get(f"/analysis/services/{service_id}/tasks/", params=params_dict)
        return response.json()

create_analysis_task async

create_analysis_task(
    service_id: int,
    params: AnalysisTaskCreateInput | None = None,
    **kwargs,
) -> dict

Create a new analysis task.

Returns:

Name Type Description
dict dict

The created analysis task object.

Source code in src/pixel_client/_base.py
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
async def create_analysis_task(self, service_id: int, params: AnalysisTaskCreateInput | None = None, **kwargs) -> dict:
        """
        Create a new analysis task.

        Returns:
            dict: The created analysis task object.
        """
        if params and kwargs:
            logger.warning("Ignoring kwargs when params is provided")
        input_dict = (
            params.model_dump(mode="json", exclude_none=True)
            if params
            else AnalysisTaskCreateInput.model_validate(kwargs).model_dump(
                exclude_none=True, mode="json"
            )
        )


        response = await self._post(
            f"/analysis/services/{service_id}/tasks/", json=input_dict
        )
        return response.json()

delete_analysis_task async

delete_analysis_task(service_id: int, task_id: int) -> bool

Delete an existing analysis task.

Returns:

Name Type Description
dict bool

The response confirming deletion.

Source code in src/pixel_client/_base.py
3531
3532
3533
3534
3535
3536
3537
3538
3539
async def delete_analysis_task(self, service_id: int, task_id: int) -> bool:
        """
        Delete an existing analysis task.

        Returns:
            dict: The response confirming deletion.
        """
        _ = await self._delete(f"/analysis/services/{service_id}/tasks/{task_id}")
        return True

run_analysis_task async

run_analysis_task(service_id: int, task_id: int) -> dict

Run an existing analysis task.

Returns:

Name Type Description
dict dict

The response confirming the task has been started.

Source code in src/pixel_client/_base.py
3541
3542
3543
3544
3545
3546
3547
3548
3549
async def run_analysis_task(self, service_id: int, task_id: int) -> dict:
        """
        Run an existing analysis task.

        Returns:
            dict: The response confirming the task has been started.
        """
        response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/run")
        return response.json()

revoke_analysis_task async

revoke_analysis_task(service_id: int, task_id: int) -> dict

Revoke an existing analysis task.

Returns:

Name Type Description
dict dict

The response confirming the task has been revoked.

Source code in src/pixel_client/_base.py
3551
3552
3553
3554
3555
3556
3557
3558
3559
async def revoke_analysis_task(self, service_id: int, task_id: int) -> dict:
        """
        Revoke an existing analysis task.

        Returns:
            dict: The response confirming the task has been revoked.
        """
        response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/revoke")
        return response.json()

pause_analysis_task async

pause_analysis_task(service_id: int, task_id: int) -> dict

Pause a running analysis task. Only modules with pausable set support this.

The task moves to PAUSING, then to PAUSED at the next step boundary.

Returns:

Name Type Description
dict dict

The task ID and its new status.

Source code in src/pixel_client/_base.py
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
async def pause_analysis_task(self, service_id: int, task_id: int) -> dict:
        """
        Pause a running analysis task. Only modules with `pausable` set support this.

        The task moves to `PAUSING`, then to `PAUSED` at the next step boundary.

        Returns:
            dict: The task ID and its new status.
        """
        response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/pause")
        return response.json()

resume_analysis_task async

resume_analysis_task(service_id: int, task_id: int) -> dict

Resume a paused analysis task.

Returns:

Name Type Description
dict dict

The task ID and its new status.

Source code in src/pixel_client/_base.py
3573
3574
3575
3576
3577
3578
3579
3580
3581
async def resume_analysis_task(self, service_id: int, task_id: int) -> dict:
        """
        Resume a paused analysis task.

        Returns:
            dict: The task ID and its new status.
        """
        response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/resume")
        return response.json()

list_analysis_service_field_options async

list_analysis_service_field_options(
    service_id: int, field: str
) -> list[dict]

List the allowed values for a field of an analysis service's config or task parameters.

Parameters:

Name Type Description Default
service_id int

The ID of the analysis service.

required
field str

The name of the config or params field to list options for.

required

Returns:

Type Description
list[dict]

list[dict]: Options with value, label and an optional description.

Source code in src/pixel_client/_base.py
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
async def list_analysis_service_field_options(
    self, service_id: int, field: str
) -> list[dict]:
        """
        List the allowed values for a field of an analysis service's config or task parameters.

        Args:
            service_id: The ID of the analysis service.
            field: The name of the config or params field to list options for.

        Returns:
            list[dict]: Options with `value`, `label` and an optional `description`.
        """
        response = await self._get(f"/analysis/services/{service_id}/options/{field}")
        return response.json()

list_roles async

list_roles() -> list[dict]

List the roles that can be granted, with the permissions each one bundles.

Returns:

Type Description
list[dict]

list[dict]: Role objects with name, is_system and permissions (each a kind and verb).

Source code in src/pixel_client/_base.py
3599
3600
3601
3602
3603
3604
3605
3606
3607
async def list_roles(self) -> list[dict]:
    """List the roles that can be granted, with the permissions each one bundles.

    Returns:
        list[dict]: Role objects with `name`, `is_system` and `permissions`
            (each a `kind` and `verb`).
    """
    response = await self._get("/roles/")
    return response.json()

get_role async

get_role(name: str) -> dict

Retrieve a single role and the permissions it bundles.

Parameters:

Name Type Description Default
name str

The role name, e.g. "editor".

required

Returns:

Name Type Description
dict dict

The role object.

Source code in src/pixel_client/_base.py
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
async def get_role(self, name: str) -> dict:
    """Retrieve a single role and the permissions it bundles.

    Args:
        name: The role name, e.g. `"editor"`.

    Returns:
        dict: The role object.
    """
    response = await self._get(f"/roles/{name}")
    return response.json()

list_permissions async

list_permissions() -> list[dict]

List every permission that exists, independent of which roles bundle it.

Returns:

Type Description
list[dict]

list[dict]: Permission objects with a kind (e.g. "project") and a verb (e.g. "read").

Source code in src/pixel_client/_base.py
3621
3622
3623
3624
3625
3626
3627
3628
async def list_permissions(self) -> list[dict]:
    """List every permission that exists, independent of which roles bundle it.

    Returns:
        list[dict]: Permission objects with a `kind` (e.g. `"project"`) and a `verb` (e.g. `"read"`).
    """
    response = await self._get("/permissions/")
    return response.json()

paginate_grants async

paginate_grants(
    page_size: int,
    project_ids: list[int] | None = None,
    principal_kind: Literal["user", "group"] | None = None,
    principal_ids: list[int] | None = None,
    include_root: bool = False,
) -> AsyncGenerator[dict, None]

Iterate over the user and group grants on the projects you administer, page by page.

See list_grants for the filters.

Parameters:

Name Type Description Default
page_size int

Number of grants to fetch per request.

required

Yields:

Name Type Description
dict AsyncGenerator[dict, None]

Individual grant objects.

Source code in src/pixel_client/_base.py
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
async def paginate_grants(
    self,
    page_size: int,
    project_ids: list[int] | None = None,
    principal_kind: Literal["user", "group"] | None = None,
    principal_ids: list[int] | None = None,
    include_root: bool = False,
) -> AsyncGenerator[dict, None]:
    """Iterate over the user and group grants on the projects you administer, page by page.

    See [`list_grants`][pixel_client.PixelClientAsync.list_grants] for the filters.

    Args:
        page_size: Number of grants to fetch per request.

    Yields:
        dict: Individual grant objects.
    """
    params: dict[str, Any] = {"include_root": include_root}
    if project_ids:
        params["project_id"] = list(project_ids)
    if principal_kind:
        params["principal_kind"] = principal_kind
    if principal_ids:
        params["principal_id"] = list(principal_ids)
    offset = 0
    while True:
        response = await self._get(
            "/access/grants",
            params={**params, "offset": offset, "limit": page_size},
        )
        page = response.json()
        for item in page["items"]:
            yield item
        offset += len(page["items"])
        if not page["items"] or offset >= page["total"]:
            break

list_grants async

list_grants(
    project_ids: list[int] | None = None,
    principal_kind: Literal["user", "group"] | None = None,
    principal_ids: list[int] | None = None,
    include_root: bool = False,
) -> list[dict]

List the user and group grants on the projects you administer.

Each grant says who holds which role, where it is held, and the project it is listed on. A grant held on a project above the ones you administer is listed on the highest of your projects it reaches, with held_on set to "above". Group grants include the group's member ids in member_ids, so access people get through a group can be worked out. Fetches every page.

Parameters:

Name Type Description Default
project_ids list[int] | None

Only grants listed on these projects.

None
principal_kind Literal['user', 'group'] | None

Only grants held by users, or only by groups.

None
principal_ids list[int] | None

Only grants held by these users or groups.

None
include_root bool

Also include organisation-wide grants.

False

Returns:

Type Description
list[dict]

list[dict]: Grant objects.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
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
async def list_grants(
    self,
    project_ids: list[int] | None = None,
    principal_kind: Literal["user", "group"] | None = None,
    principal_ids: list[int] | None = None,
    include_root: bool = False,
) -> list[dict]:
    """List the user and group grants on the projects you administer.

    Each grant says who holds which role, where it is held, and the project
    it is listed on. A grant held on a project above the ones you administer
    is listed on the highest of your projects it reaches, with `held_on`
    set to `"above"`. Group grants include the group's member ids in
    `member_ids`, so access people get through a group can be worked out.
    Fetches every page.

    Args:
        project_ids: Only grants listed on these projects.
        principal_kind: Only grants held by users, or only by groups.
        principal_ids: Only grants held by these users or groups.
        include_root: Also include organisation-wide grants.

    Returns:
        list[dict]: Grant objects.

    Note:
        Cannot be called with an api key.
    """
    return [
        grant
        async for grant in self.paginate_grants(
            GRANTS_PAGE_SIZE, project_ids, principal_kind, principal_ids, include_root
        )
    ]

get_user_access async

get_user_access(user: UserRef) -> dict

What a user can do, and why.

Returns the user's organisation-wide grants and every project they reach, each with their effective role and permissions and the grants behind them (direct, inherited from a parent project, or through a group). For another user you need to be able to list users, and you only see projects you administer.

Parameters:

Name Type Description Default
user UserRef

The user's ID or email address.

required

Returns:

Name Type Description
dict dict

The user's access, with root and projects.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
async def get_user_access(self, user: UserRef) -> dict:
    """What a user can do, and why.

    Returns the user's organisation-wide grants and every project they reach,
    each with their effective role and permissions and the grants behind
    them (direct, inherited from a parent project, or through a group).
    For another user you need to be able to list users, and you only see
    projects you administer.

    Args:
        user: The user's ID or email address.

    Returns:
        dict: The user's access, with `root` and `projects`.

    Note:
        Cannot be called with an api key.
    """
    user_id = await self._resolve_user_id(user)
    response = await self._get(f"/users/{user_id}/access")
    return response.json()

get_group_access async

get_group_access(group_id: int) -> dict

What a group can do: its own grants, and every project it reaches with the effective permissions there. Only projects you can read are listed.

Parameters:

Name Type Description Default
group_id int

The ID of the group.

required

Returns:

Name Type Description
dict dict

The group's access, with root, projects and member_count.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
async def get_group_access(self, group_id: int) -> dict:
    """What a group can do: its own grants, and every project it reaches with
    the effective permissions there. Only projects you can read are listed.

    Args:
        group_id: The ID of the group.

    Returns:
        dict: The group's access, with `root`, `projects` and `member_count`.

    Note:
        Cannot be called with an api key.
    """
    response = await self._get(f"/groups/{group_id}/access")
    return response.json()

grant_access_on async

grant_access_on(
    resources: Resource | list[Resource],
    role: str | None = None,
    *,
    users: list[UserRef] | None = None,
    groups: list[int] | None = None,
    geo_service_users: list[GeoServiceUserRef]
    | None = None,
) -> list[dict]

Give users, groups or geo service users a role on one or more resources.

Everyone listed gets the same role; to give different roles, call again. A principal that already holds a role directly on the resource is moved to the requested role, also when that lowers it, so running the same call twice gives the same result. Access inherited from a parent project or through a group is not changed, and still applies.

Which principals and roles a resource accepts depends on its type:

  • ProjectResource: users and groups, with role "viewer", "editor" or "admin". You need the admin role on the project, can only give roles you hold there, and must be a member of each group.
  • ArcgisServiceResource: geo service users only; the role can be omitted.

Parameters:

Name Type Description Default
resources Resource | list[Resource]

The resource, or a list of resources, to give access on.

required
role str | None

The role to give.

None
users list[UserRef] | None

Users, by ID or email address.

None
groups list[int] | None

Groups, by ID.

None
geo_service_users list[GeoServiceUserRef] | None

Geo service users, by ID or username.

None

Returns:

Type Description
list[dict]

list[dict]: One entry per principal and resource, with resource, principal_kind, principal_id, role and action ("granted", "updated" or "unchanged").

Raises:

Type Description
ValueError

If the resource does not accept these principals or this role, or a user or geo service user cannot be found. Raised before any change is made.

PixelAccessUpdateError

If some changes failed. All other changes were still applied.

Source code in src/pixel_client/_base.py
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
async def grant_access_on(
    self,
    resources: Resource | list[Resource],
    role: str | None = None,
    *,
    users: list[UserRef] | None = None,
    groups: list[int] | None = None,
    geo_service_users: list[GeoServiceUserRef] | None = None,
) -> list[dict]:
    """Give users, groups or geo service users a role on one or more resources.

    Everyone listed gets the same role; to give different roles, call again.
    A principal that already holds a role directly on the resource is moved
    to the requested role, also when that lowers it, so running the same
    call twice gives the same result. Access inherited from a parent project
    or through a group is not changed, and still applies.

    Which principals and roles a resource accepts depends on its type:

    - [`ProjectResource`][pixel_client.models.ProjectResource]: users and
      groups, with role `"viewer"`, `"editor"` or `"admin"`. You need the
      admin role on the project, can only give roles you hold there, and
      must be a member of each group.
    - [`ArcgisServiceResource`][pixel_client.models.ArcgisServiceResource]:
      geo service users only; the role can be omitted.

    Args:
        resources: The resource, or a list of resources, to give access on.
        role: The role to give.
        users: Users, by ID or email address.
        groups: Groups, by ID.
        geo_service_users: Geo service users, by ID or username.

    Returns:
        list[dict]: One entry per principal and resource, with `resource`,
            `principal_kind`, `principal_id`, `role` and `action`
            (`"granted"`, `"updated"` or `"unchanged"`).

    Raises:
        ValueError: If the resource does not accept these principals or this
            role, or a user or geo service user cannot be found. Raised before
            any change is made.
        PixelAccessUpdateError: If some changes failed. All other changes
            were still applied.
    """
    resources, principals = await self._prepare_access_change(
        resources, users, groups, geo_service_users, role=role, granting=True
    )
    outcome = Outcome()
    for resource in resources:
        handler = handler_for(resource)
        await handler.grant(
            self, resource, handler.check_role(resource, role), principals, outcome
        )
    if outcome.failed:
        raise PixelAccessUpdateError(outcome.succeeded, outcome.failed)
    return outcome.succeeded

revoke_access_on async

revoke_access_on(
    resources: Resource | list[Resource],
    *,
    users: list[UserRef] | None = None,
    groups: list[int] | None = None,
    geo_service_users: list[GeoServiceUserRef]
    | None = None,
) -> list[dict]

Remove the access users, groups or geo service users hold directly on one or more resources.

Principals without a direct grant on a resource are skipped. Access inherited from a parent project or through a group is not changed.

Parameters:

Name Type Description Default
resources Resource | list[Resource]

The resource, or a list of resources, to remove access on.

required
users list[UserRef] | None

Users, by ID or email address.

None
groups list[int] | None

Groups, by ID.

None
geo_service_users list[GeoServiceUserRef] | None

Geo service users, by ID or username.

None

Returns:

Type Description
list[dict]

list[dict]: One entry per principal and resource, with action "revoked" or "unchanged".

Raises:

Type Description
ValueError

If the resource does not accept these principals, or a user or geo service user cannot be found.

PixelAccessUpdateError

If some changes failed. All other changes were still applied.

Source code in src/pixel_client/_base.py
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
async def revoke_access_on(
    self,
    resources: Resource | list[Resource],
    *,
    users: list[UserRef] | None = None,
    groups: list[int] | None = None,
    geo_service_users: list[GeoServiceUserRef] | None = None,
) -> list[dict]:
    """Remove the access users, groups or geo service users hold directly on
    one or more resources.

    Principals without a direct grant on a resource are skipped. Access
    inherited from a parent project or through a group is not changed.

    Args:
        resources: The resource, or a list of resources, to remove access on.
        users: Users, by ID or email address.
        groups: Groups, by ID.
        geo_service_users: Geo service users, by ID or username.

    Returns:
        list[dict]: One entry per principal and resource, with `action`
            `"revoked"` or `"unchanged"`.

    Raises:
        ValueError: If the resource does not accept these principals, or a
            user or geo service user cannot be found.
        PixelAccessUpdateError: If some changes failed. All other changes
            were still applied.
    """
    resources, principals = await self._prepare_access_change(
        resources, users, groups, geo_service_users, role=None, granting=False
    )
    outcome = Outcome()
    for resource in resources:
        await handler_for(resource).revoke(self, resource, principals, outcome)
    if outcome.failed:
        raise PixelAccessUpdateError(outcome.succeeded, outcome.failed)
    return outcome.succeeded

grant_project_access async

grant_project_access(
    projects: int | list[int],
    role: RoleType,
    *,
    users: list[UserRef] | None = None,
    groups: list[int] | None = None,
) -> list[dict]

Give users and groups a role on one or more projects (and their subprojects).

Everyone listed gets the same role. Anyone who already has a role directly on a project is moved to role, also when that lowers it. Access inherited from a parent project or through a group still applies.

You need the admin role on each project, can only give roles you hold there yourself, and must be a member of each group.

Parameters:

Name Type Description Default
projects int | list[int]

The project ID, or a list of project IDs.

required
role RoleType

"viewer", "editor" or "admin".

required
users list[UserRef] | None

Users, by ID or email address.

None
groups list[int] | None

Groups, by ID.

None

Returns:

Type Description
list[dict]

list[dict]: One entry per principal and project, with action "granted", "updated" or "unchanged".

Raises:

Type Description
ValueError

If the role is not a project role or a user cannot be found.

PixelAccessUpdateError

If some changes failed. All other changes were still applied.

Source code in src/pixel_client/_base.py
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
async def grant_project_access(
    self,
    projects: int | list[int],
    role: RoleType,
    *,
    users: list[UserRef] | None = None,
    groups: list[int] | None = None,
) -> list[dict]:
    """Give users and groups a role on one or more projects (and their subprojects).

    Everyone listed gets the same role. Anyone who already has a role
    directly on a project is moved to `role`, also when that lowers it.
    Access inherited from a parent project or through a group still applies.

    You need the admin role on each project, can only give roles you hold
    there yourself, and must be a member of each group.

    Args:
        projects: The project ID, or a list of project IDs.
        role: `"viewer"`, `"editor"` or `"admin"`.
        users: Users, by ID or email address.
        groups: Groups, by ID.

    Returns:
        list[dict]: One entry per principal and project, with `action`
            `"granted"`, `"updated"` or `"unchanged"`.

    Raises:
        ValueError: If the role is not a project role or a user cannot be found.
        PixelAccessUpdateError: If some changes failed. All other changes
            were still applied.
    """
    return await self.grant_access_on(
        self._project_resources(projects), role, users=users, groups=groups
    )

revoke_project_access async

revoke_project_access(
    projects: int | list[int],
    *,
    users: list[UserRef] | None = None,
    groups: list[int] | None = None,
) -> list[dict]

Remove the access users and groups hold directly on one or more projects.

Access inherited from a parent project or through a group still applies. Admins of the project can remove anyone; group admins can also remove their group.

Parameters:

Name Type Description Default
projects int | list[int]

The project ID, or a list of project IDs.

required
users list[UserRef] | None

Users, by ID or email address.

None
groups list[int] | None

Groups, by ID.

None

Returns:

Type Description
list[dict]

list[dict]: One entry per principal and project, with action "revoked" or "unchanged".

Source code in src/pixel_client/_base.py
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
async def revoke_project_access(
    self,
    projects: int | list[int],
    *,
    users: list[UserRef] | None = None,
    groups: list[int] | None = None,
) -> list[dict]:
    """Remove the access users and groups hold directly on one or more projects.

    Access inherited from a parent project or through a group still applies.
    Admins of the project can remove anyone; group admins can also remove
    their group.

    Args:
        projects: The project ID, or a list of project IDs.
        users: Users, by ID or email address.
        groups: Groups, by ID.

    Returns:
        list[dict]: One entry per principal and project, with `action`
            `"revoked"` or `"unchanged"`.
    """
    return await self.revoke_access_on(
        self._project_resources(projects), users=users, groups=groups
    )

list_project_users async

list_project_users(project_id: int) -> list[dict]

List the users with a role directly on a project.

Users who reach the project through a parent project or a group are not included; see list_grants.

Parameters:

Name Type Description Default
project_id int

The ID of the project.

required

Returns:

Type Description
list[dict]

list[dict]: User objects, each with their role on the project.

Source code in src/pixel_client/_base.py
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
async def list_project_users(self, project_id: int) -> list[dict]:
    """List the users with a role directly on a project.

    Users who reach the project through a parent project or a group are not
    included; see [`list_grants`][pixel_client.PixelClientAsync.list_grants].

    Args:
        project_id: The ID of the project.

    Returns:
        list[dict]: User objects, each with their `role` on the project.
    """
    response = await self._get(f"/projects/{project_id}/users")
    return response.json()

list_project_groups async

list_project_groups(project_id: int) -> list[dict]

List the groups with a role directly on a project.

Parameters:

Name Type Description Default
project_id int

The ID of the project.

required

Returns:

Type Description
list[dict]

list[dict]: Group objects, each with their role on the project.

Source code in src/pixel_client/_base.py
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
async def list_project_groups(self, project_id: int) -> list[dict]:
    """List the groups with a role directly on a project.

    Args:
        project_id: The ID of the project.

    Returns:
        list[dict]: Group objects, each with their `role` on the project.
    """
    response = await self._get(f"/projects/{project_id}/groups")
    return response.json()

create_user async

create_user(
    email: str,
    first_name: str,
    last_name: str,
    password: str | SecretStr,
    user_type: UserType = "viewer",
    *,
    groups: list[int] | None = None,
    projects: dict[int, RoleType] | None = None,
) -> dict

Create a user, optionally adding them to groups and giving them project roles.

A new user sees nothing until they are given access, directly or through a group. Superusers only.

Parameters:

Name Type Description Default
email str

The user's email address, used to sign in.

required
first_name str

The user's first name.

required
last_name str

The user's last name.

required
password str | SecretStr

A temporary password. The user chooses their own the first time they sign in, so share it securely.

required
user_type UserType

The account type. "viewer" sees only what they are given access to; "creator" can also create top-level projects, groups and api keys, and list users; "superuser" can see and change everything in the organisation.

'viewer'
groups list[int] | None

Groups to add the user to, by ID. You must be a group admin of each.

None
projects dict[int, RoleType] | None

Mapping of project ID to the role the user gets there, e.g. {42: "editor"}.

None

Returns:

Name Type Description
dict dict

The created user.

Raises:

Type Description
PixelAccessUpdateError

If the user was created but some project roles could not be given. The user is in result.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
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
async def create_user(
    self,
    email: str,
    first_name: str,
    last_name: str,
    password: str | SecretStr,
    user_type: UserType = "viewer",
    *,
    groups: list[int] | None = None,
    projects: dict[int, RoleType] | None = None,
) -> dict:
    """Create a user, optionally adding them to groups and giving them project roles.

    A new user sees nothing until they are given access, directly or
    through a group. Superusers only.

    Args:
        email: The user's email address, used to sign in.
        first_name: The user's first name.
        last_name: The user's last name.
        password: A temporary password. The user chooses their own the first
            time they sign in, so share it securely.
        user_type: The account type. `"viewer"` sees only what they are given
            access to; `"creator"` can also create top-level projects, groups
            and api keys, and list users; `"superuser"` can see and change
            everything in the organisation.
        groups: Groups to add the user to, by ID. You must be a group admin
            of each.
        projects: Mapping of project ID to the role the user gets there,
            e.g. `{42: "editor"}`.

    Returns:
        dict: The created user.

    Raises:
        PixelAccessUpdateError: If the user was created but some project
            roles could not be given. The user is in `result`.

    Note:
        Cannot be called with an api key.
    """
    create_input = OIDCUserCreateInput(
        email=email,
        first_name=first_name,
        last_name=last_name,
        password=password,  # type: ignore[arg-type]
        user_type=user_type,
        groups=[GroupMembershipInput(group_id=group_id) for group_id in groups or []],
    )
    user = await self._create_user(create_input)
    if projects:
        await self._grant_projects_by_role(projects, result=user, users=[user["id"]])
    return user

update_user async

update_user(
    user: UserRef,
    *,
    first_name: str | None = None,
    last_name: str | None = None,
    password: str | SecretStr | None = None,
    user_type: UserType | None = None,
) -> dict

Change a user's name, account type or password. Superusers only.

Fields left out are not changed. The user's active status is kept.

Parameters:

Name Type Description Default
user UserRef

The user's ID or email address.

required
first_name str | None

New first name.

None
last_name str | None

New last name.

None
password str | SecretStr | None

A new temporary password. The user chooses their own the next time they sign in.

None
user_type UserType | None

New account type: "viewer", "creator" or "superuser".

None

Returns:

Name Type Description
dict dict

The updated user.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
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
async def update_user(
    self,
    user: UserRef,
    *,
    first_name: str | None = None,
    last_name: str | None = None,
    password: str | SecretStr | None = None,
    user_type: UserType | None = None,
) -> dict:
    """Change a user's name, account type or password. Superusers only.

    Fields left out are not changed. The user's active status is kept.

    Args:
        user: The user's ID or email address.
        first_name: New first name.
        last_name: New last name.
        password: A new temporary password. The user chooses their own the
            next time they sign in.
        user_type: New account type: `"viewer"`, `"creator"` or `"superuser"`.

    Returns:
        dict: The updated user.

    Note:
        Cannot be called with an api key.
    """
    email = await self._resolve_user_email(user)
    current = await self.get_user(email)
    update_input = OIDCUserUpdateInput(
        first_name=first_name,
        last_name=last_name,
        password=password,  # type: ignore[arg-type]
        user_type=user_type,
        enabled=current["is_active"],
    )
    return await self._update_user(email, update_input)

get_user async

get_user(user: UserRef) -> dict

Retrieve a user.

Parameters:

Name Type Description Default
user UserRef

The user's ID or email address.

required

Returns:

Name Type Description
dict dict

The user, including id, email, is_active and user_type.

Source code in src/pixel_client/_base.py
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
async def get_user(self, user: UserRef) -> dict:
    """Retrieve a user.

    Args:
        user: The user's ID or email address.

    Returns:
        dict: The user, including `id`, `email`, `is_active` and `user_type`.
    """
    email = await self._resolve_user_email(user)
    response = await self._get(f"/users/{email}/info")
    return response.json()

list_users async

list_users(
    params: UserListParams | None = None, **kwargs
) -> list[dict]

List the users in the organisation, including deactivated ones.

Needs the creator or superuser account type.

Parameters:

Name Type Description Default
params UserListParams | None

Optional UserListParams object with name, ids, offset and limit.

None
**kwargs

Alternative way to provide the filtering parameters.

{}

Returns:

Type Description
list[dict]

list[dict]: User objects.

Source code in src/pixel_client/_base.py
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
async def list_users(
    self, params: UserListParams | None = None, **kwargs
) -> list[dict]:
    """List the users in the organisation, including deactivated ones.

    Needs the creator or superuser account type.

    Args:
        params: Optional UserListParams object with `name`, `ids`, `offset` and `limit`.
        **kwargs: Alternative way to provide the filtering parameters.

    Returns:
        list[dict]: User objects.
    """
    params = params or UserListParams.model_validate(kwargs)
    response = await self._get(
        "/users/", params=params.model_dump(exclude_none=True, mode="json")
    )
    return response.json()

paginate_users async

paginate_users(
    page_size: int,
    params: UserListParams | None = None,
    **kwargs,
) -> AsyncGenerator[dict, None]

Iterate over the users in the organisation, page by page.

Parameters:

Name Type Description Default
page_size int

Number of users to fetch per request.

required
params UserListParams | None

Optional UserListParams object with filtering parameters.

None
**kwargs

Alternative way to provide the filtering parameters.

{}

Yields:

Name Type Description
dict AsyncGenerator[dict, None]

Individual user objects.

Source code in src/pixel_client/_base.py
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
async def paginate_users(
    self, page_size: int, params: UserListParams | None = None, **kwargs
) -> AsyncGenerator[dict, None]:
    """Iterate over the users in the organisation, page by page.

    Args:
        page_size: Number of users to fetch per request.
        params: Optional UserListParams object with filtering parameters.
        **kwargs: Alternative way to provide the filtering parameters.

    Yields:
        dict: Individual user objects.
    """
    params = params or UserListParams.model_validate(kwargs)
    async for user in self._paginate(
        "/users/",
        page_size=page_size,
        params=params.model_dump(exclude_none=True, mode="json", exclude={"offset", "limit"}),
    ):
        yield user

create_group async

create_group(
    name: str,
    description: str = "",
    *,
    members: list[UserRef] | None = None,
    projects: dict[int, RoleType] | None = None,
) -> dict

Create a group, optionally with members and project roles.

You become the group's first member and admin. Members get the group's access on its projects.

Parameters:

Name Type Description Default
name str

The name of the group.

required
description str

A description of the group.

''
members list[UserRef] | None

Users to add, by ID or email address.

None
projects dict[int, RoleType] | None

Mapping of project ID to the role the group gets there, e.g. {42: "editor"}. You need the admin role on each project.

None

Returns:

Name Type Description
dict dict

The created group.

Raises:

Type Description
ValueError

If a member cannot be found. Raised before the group is created.

PixelAccessUpdateError

If the group was created but some members or project roles could not be added. The group is in result.

Source code in src/pixel_client/_base.py
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
async def create_group(
    self,
    name: str,
    description: str = "",
    *,
    members: list[UserRef] | None = None,
    projects: dict[int, RoleType] | None = None,
) -> dict:
    """Create a group, optionally with members and project roles.

    You become the group's first member and admin. Members get the group's
    access on its projects.

    Args:
        name: The name of the group.
        description: A description of the group.
        members: Users to add, by ID or email address.
        projects: Mapping of project ID to the role the group gets there,
            e.g. `{42: "editor"}`. You need the admin role on each project.

    Returns:
        dict: The created group.

    Raises:
        ValueError: If a member cannot be found. Raised before the group is created.
        PixelAccessUpdateError: If the group was created but some members or
            project roles could not be added. The group is in `result`.
    """
    user_ids = await self._resolve_user_ids(members)
    response = await self._post(
        "/groups/",
        json=GroupCreateInput(name=name, description=description).model_dump(mode="json"),
    )
    group = response.json()
    succeeded: list[dict] = []
    failed: list[tuple[dict, Exception]] = []
    if user_ids:
        changes = [
            {
                "resource": {"kind": "group", "id": group["id"]},
                "principal_kind": "user",
                "principal_id": user_id,
                "role": None,
                "action": "added",
            }
            for user_id in user_ids
        ]
        try:
            await self._add_group_members(group["id"], user_ids, admin=False)
        except (PixelBadRequestError, httpx.HTTPError) as e:
            failed += [(c, e) for c in changes]
        else:
            succeeded += changes
    if projects:
        try:
            await self._grant_projects_by_role(projects, result=group, groups=[group["id"]])
        except PixelAccessUpdateError as e:
            succeeded += e.succeeded
            failed += e.failed
    if failed:
        raise PixelAccessUpdateError(succeeded, failed, result=group)
    return group

list_groups async

list_groups(
    params: GroupListParams | None = None, **kwargs
) -> list[dict]

List the groups you are a member of. Superusers see every group.

Parameters:

Name Type Description Default
params GroupListParams | None

Optional GroupListParams object with name, ids, offset and limit.

None
**kwargs

Alternative way to provide the filtering parameters.

{}

Returns:

Type Description
list[dict]

list[dict]: Group objects.

Source code in src/pixel_client/_base.py
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
async def list_groups(
    self, params: GroupListParams | None = None, **kwargs
) -> list[dict]:
    """List the groups you are a member of. Superusers see every group.

    Args:
        params: Optional GroupListParams object with `name`, `ids`, `offset` and `limit`.
        **kwargs: Alternative way to provide the filtering parameters.

    Returns:
        list[dict]: Group objects.
    """
    params = params or GroupListParams.model_validate(kwargs)
    response = await self._get(
        "/groups/", params=params.model_dump(exclude_none=True, mode="json")
    )
    return response.json()

get_group async

get_group(group_id: int) -> dict

Retrieve a group with its members and the projects it has a role on.

Visible to members of the group and to superusers.

Parameters:

Name Type Description Default
group_id int

The ID of the group.

required

Returns:

Name Type Description
dict dict

The group, with members (each with is_admin) and projects (each with the group's role).

Source code in src/pixel_client/_base.py
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
async def get_group(self, group_id: int) -> dict:
    """Retrieve a group with its members and the projects it has a role on.

    Visible to members of the group and to superusers.

    Args:
        group_id: The ID of the group.

    Returns:
        dict: The group, with `members` (each with `is_admin`) and `projects`
            (each with the group's `role`).
    """
    response = await self._get(f"/groups/{group_id}")
    return response.json()

update_group async

update_group(
    group_id: int,
    *,
    name: str | None = None,
    description: str | None = None,
) -> dict

Rename a group or change its description. Group admins only.

Members and access are not changed.

Parameters:

Name Type Description Default
group_id int

The ID of the group.

required
name str | None

New name.

None
description str | None

New description.

None

Returns:

Name Type Description
dict dict

The updated group.

Source code in src/pixel_client/_base.py
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
async def update_group(
    self,
    group_id: int,
    *,
    name: str | None = None,
    description: str | None = None,
) -> dict:
    """Rename a group or change its description. Group admins only.

    Members and access are not changed.

    Args:
        group_id: The ID of the group.
        name: New name.
        description: New description.

    Returns:
        dict: The updated group.
    """
    update_input = GroupUpdateInput(name=name, description=description)
    response = await self._patch(
        f"/groups/{group_id}",
        json=update_input.model_dump(mode="json", exclude_none=True),
    )
    return response.json()

delete_group async

delete_group(group_id: int) -> dict

Delete a group. Group admins only.

Every member, and every api key that follows the group, loses the access it had through the group. This cannot be undone.

Parameters:

Name Type Description Default
group_id int

The ID of the group.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Source code in src/pixel_client/_base.py
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
async def delete_group(self, group_id: int) -> dict:
    """Delete a group. Group admins only.

    Every member, and every api key that follows the group, loses the access
    it had through the group. This cannot be undone.

    Args:
        group_id: The ID of the group.

    Returns:
        dict: The response confirming deletion.
    """
    response = await self._delete(f"/groups/{group_id}")
    return response.json()

add_group_members async

add_group_members(
    group_id: int,
    users: list[UserRef],
    *,
    admin: bool = False,
) -> list[dict]

Add users to a group. They get the group's access. Group admins only.

Parameters:

Name Type Description Default
group_id int

The ID of the group.

required
users list[UserRef]

Users to add, by ID or email address.

required
admin bool

Also make them group admins. Admins can rename and delete the group and manage its members; it gives no access to data.

False

Returns:

Type Description
list[dict]

list[dict]: The added members.

Source code in src/pixel_client/_base.py
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
async def add_group_members(
    self, group_id: int, users: list[UserRef], *, admin: bool = False
) -> list[dict]:
    """Add users to a group. They get the group's access. Group admins only.

    Args:
        group_id: The ID of the group.
        users: Users to add, by ID or email address.
        admin: Also make them group admins. Admins can rename and delete the
            group and manage its members; it gives no access to data.

    Returns:
        list[dict]: The added members.
    """
    return await self._add_group_members(
        group_id, await self._resolve_user_ids(users), admin=admin
    )

remove_group_member async

remove_group_member(group_id: int, user: UserRef) -> dict

Remove a member from a group. They lose the access the group gave them.

Group admins can remove anyone; any member can remove themselves to leave the group. The last admin cannot be removed.

Parameters:

Name Type Description Default
group_id int

The ID of the group.

required
user UserRef

The member, by ID or email address.

required

Returns:

Name Type Description
dict dict

The response confirming removal.

Source code in src/pixel_client/_base.py
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
async def remove_group_member(self, group_id: int, user: UserRef) -> dict:
    """Remove a member from a group. They lose the access the group gave them.

    Group admins can remove anyone; any member can remove themselves to
    leave the group. The last admin cannot be removed.

    Args:
        group_id: The ID of the group.
        user: The member, by ID or email address.

    Returns:
        dict: The response confirming removal.
    """
    user_id = await self._resolve_user_id(user)
    response = await self._delete(f"/groups/{group_id}/users/{user_id}")
    return response.json()

set_group_admin async

set_group_admin(
    group_id: int, user: UserRef, admin: bool = True
) -> dict

Make a member a group admin, or remove their admin status. Group admins only.

Only members can be admins, and a group always keeps at least one.

Parameters:

Name Type Description Default
group_id int

The ID of the group.

required
user UserRef

The member, by ID or email address.

required
admin bool

True to make them admin, False to remove admin status.

True

Returns:

Name Type Description
dict dict

The updated member.

Source code in src/pixel_client/_base.py
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
async def set_group_admin(
    self, group_id: int, user: UserRef, admin: bool = True
) -> dict:
    """Make a member a group admin, or remove their admin status. Group admins only.

    Only members can be admins, and a group always keeps at least one.

    Args:
        group_id: The ID of the group.
        user: The member, by ID or email address.
        admin: `True` to make them admin, `False` to remove admin status.

    Returns:
        dict: The updated member.
    """
    user_id = await self._resolve_user_id(user)
    response = await self._put(
        f"/groups/{group_id}/users/{user_id}/admin", params={"is_admin": admin}
    )
    return response.json()

create_api_key async

create_api_key(
    name: str,
    *,
    projects: dict[int, RoleType] | None = None,
    groups: list[int] | None = None,
    base_role: BaseRoleType | None = None,
    expires_in_days: int = 90,
    expires_at: datetime.datetime | None = None,
) -> dict

Create an api key for scripts and integrations.

A key can never do more than you can: its access is always limited to your own current access, so it loses access when you do. The scope cannot be changed later; use replace_api_key to get a key with a different scope.

Parameters:

Name Type Description Default
name str

A name to recognise the key by.

required
projects dict[int, RoleType] | None

Mapping of project ID to the role the key gets there, e.g. {42: "editor"}.

None
groups list[int] | None

Groups the key follows, by ID. The key gets whatever each group can reach, even as that changes. You must be a member.

None
base_role BaseRoleType | None

An organisation-wide role: "viewer" reads all projects, "creator" can create projects and groups, "superuser" can do everything. You can only give a role you hold yourself.

None
expires_in_days int

Days until the key expires. Ignored if expires_at is given.

90
expires_at datetime.datetime | None

When the key expires.

None

Returns:

Name Type Description
dict dict

The key's details under api_key, and the secret under token.

Warning

The token is returned only this once and can never be retrieved again. Store it somewhere safe.

Raises:

Type Description
ValueError

If none of projects, groups or base_role is given.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
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
async def create_api_key(
    self,
    name: str,
    *,
    projects: dict[int, RoleType] | None = None,
    groups: list[int] | None = None,
    base_role: BaseRoleType | None = None,
    expires_in_days: int = 90,
    expires_at: datetime.datetime | None = None,
) -> dict:
    """Create an api key for scripts and integrations.

    A key can never do more than you can: its access is always limited to
    your own current access, so it loses access when you do. The scope
    cannot be changed later; use
    [`replace_api_key`][pixel_client.PixelClientAsync.replace_api_key] to
    get a key with a different scope.

    Args:
        name: A name to recognise the key by.
        projects: Mapping of project ID to the role the key gets there,
            e.g. `{42: "editor"}`.
        groups: Groups the key follows, by ID. The key gets whatever each
            group can reach, even as that changes. You must be a member.
        base_role: An organisation-wide role: `"viewer"` reads all projects,
            `"creator"` can create projects and groups, `"superuser"` can do
            everything. You can only give a role you hold yourself.
        expires_in_days: Days until the key expires. Ignored if `expires_at` is given.
        expires_at: When the key expires.

    Returns:
        dict: The key's details under `api_key`, and the secret under `token`.

    Warning:
        The `token` is returned only this once and can never be retrieved
        again. Store it somewhere safe.

    Raises:
        ValueError: If none of `projects`, `groups` or `base_role` is given.

    Note:
        Cannot be called with an api key.
    """
    grants = self._api_key_grants(projects, groups, base_role)
    if not grants:
        raise ValueError(
            "An api key needs at least one of projects, groups or base_role."
        )
    return await self._create_api_key(
        ApiKeyCreateInput(
            name=name,
            expires_at=self._api_key_expiry(expires_in_days, expires_at),
            grants=grants,
        )
    )

list_api_keys async

list_api_keys(all: bool = False) -> list[dict]

List your api keys. Never includes the secret.

Each key has a status ("active", "expired", "revoked" or "owner_inactive") and is weakened when its owner has lost some of the access it was given.

Parameters:

Name Type Description Default
all bool

Superusers only. List every key in the organisation.

False

Returns:

Type Description
list[dict]

list[dict]: Api key objects, with their grants.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
async def list_api_keys(self, all: bool = False) -> list[dict]:
    """List your api keys. Never includes the secret.

    Each key has a `status` (`"active"`, `"expired"`, `"revoked"` or
    `"owner_inactive"`) and is `weakened` when its owner has lost some of the
    access it was given.

    Args:
        all: Superusers only. List every key in the organisation.

    Returns:
        list[dict]: Api key objects, with their `grants`.

    Note:
        Cannot be called with an api key.
    """
    response = await self._get("/api_keys/", params={"all": all})
    return response.json()

rename_api_key async

rename_api_key(api_key_id: str | UUID, name: str) -> dict

Rename an api key. Only the name can change. Owner only.

Parameters:

Name Type Description Default
api_key_id str | UUID

The ID of the api key.

required
name str

The new name.

required

Returns:

Name Type Description
dict dict

The updated api key.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
async def rename_api_key(self, api_key_id: str | UUID, name: str) -> dict:
    """Rename an api key. Only the name can change. Owner only.

    Args:
        api_key_id: The ID of the api key.
        name: The new name.

    Returns:
        dict: The updated api key.

    Note:
        Cannot be called with an api key.
    """
    response = await self._patch(f"/api_keys/{api_key_id}", json={"name": name})
    return response.json()

revoke_api_key async

revoke_api_key(api_key_id: str | UUID) -> dict

Revoke an api key. Scripts using it stop working within minutes.

The owner or a superuser can revoke a key. Revoking twice is harmless.

Parameters:

Name Type Description Default
api_key_id str | UUID

The ID of the api key.

required

Returns:

Name Type Description
dict dict

The response confirming revocation.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
async def revoke_api_key(self, api_key_id: str | UUID) -> dict:
    """Revoke an api key. Scripts using it stop working within minutes.

    The owner or a superuser can revoke a key. Revoking twice is harmless.

    Args:
        api_key_id: The ID of the api key.

    Returns:
        dict: The response confirming revocation.

    Note:
        Cannot be called with an api key.
    """
    response = await self._delete(f"/api_keys/{api_key_id}")
    return response.json()

replace_api_key async

replace_api_key(
    api_key_id: str | UUID,
    *,
    name: str | None = None,
    projects: dict[int, RoleType] | None = None,
    groups: list[int] | None = None,
    base_role: BaseRoleType | None = None,
    expires_in_days: int = 90,
    expires_at: datetime.datetime | None = None,
    take_over: bool = False,
) -> dict

Create a new api key with the same scope as an existing one, then revoke the old one.

Use it to rotate a key, renew an expired one, or change a key's scope: each of projects, groups and base_role that you give replaces that part of the copied scope. An expired or revoked key is not revoked again.

Parameters:

Name Type Description Default
api_key_id str | UUID

The ID of the key to replace.

required
name str | None

Name of the new key. Defaults to the old name with " (new)" added.

None
projects dict[int, RoleType] | None

Replaces the old key's project roles.

None
groups list[int] | None

Replaces the groups the old key follows.

None
base_role BaseRoleType | None

Replaces the old key's organisation-wide role.

None
expires_in_days int

Days until the new key expires. Ignored if expires_at is given.

90
expires_at datetime.datetime | None

When the new key expires.

None
take_over bool

Superusers only. Allow replacing someone else's key. The new key belongs to you and is limited to your access, and the owner's key is revoked, so their scripts stop working.

False

Returns:

Name Type Description
dict dict

The new key's details under api_key, and the secret under token.

Warning

The token is returned only this once and can never be retrieved again.

Raises:

Type Description
ValueError

If the key is not found, or belongs to someone else and take_over is not set.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
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
async def replace_api_key(
    self,
    api_key_id: str | UUID,
    *,
    name: str | None = None,
    projects: dict[int, RoleType] | None = None,
    groups: list[int] | None = None,
    base_role: BaseRoleType | None = None,
    expires_in_days: int = 90,
    expires_at: datetime.datetime | None = None,
    take_over: bool = False,
) -> dict:
    """Create a new api key with the same scope as an existing one, then revoke the old one.

    Use it to rotate a key, renew an expired one, or change a key's scope:
    each of `projects`, `groups` and `base_role` that you give replaces that
    part of the copied scope. An expired or revoked key is not revoked again.

    Args:
        api_key_id: The ID of the key to replace.
        name: Name of the new key. Defaults to the old name with " (new)" added.
        projects: Replaces the old key's project roles.
        groups: Replaces the groups the old key follows.
        base_role: Replaces the old key's organisation-wide role.
        expires_in_days: Days until the new key expires. Ignored if `expires_at` is given.
        expires_at: When the new key expires.
        take_over: Superusers only. Allow replacing someone else's key. The
            new key belongs to you and is limited to your access, and the
            owner's key is revoked, so their scripts stop working.

    Returns:
        dict: The new key's details under `api_key`, and the secret under `token`.

    Warning:
        The `token` is returned only this once and can never be retrieved again.

    Raises:
        ValueError: If the key is not found, or belongs to someone else and
            `take_over` is not set.

    Note:
        Cannot be called with an api key.
    """
    key = await self._find_api_key(str(api_key_id), take_over)
    copied = [self._api_key_grant_from_response(g) for g in key["grants"]]
    grants: list[ApiKeyGrant] = (
        self._api_key_grants(projects, None, None)
        if projects is not None
        else [g for g in copied if isinstance(g, ApiKeyProjectGrant)]
    )
    grants += (
        self._api_key_grants(None, groups, None)
        if groups is not None
        else [g for g in copied if isinstance(g, ApiKeyGroupGrant)]
    )
    grants += (
        self._api_key_grants(None, None, base_role)
        if base_role is not None
        else [g for g in copied if isinstance(g, ApiKeyRootGrant)]
    )
    new_key = await self._create_api_key(
        ApiKeyCreateInput(
            name=name or f"{key['name']} (new)",
            expires_at=self._api_key_expiry(expires_in_days, expires_at),
            grants=grants,
        )
    )
    if key["status"] not in ("revoked", "expired"):
        await self.revoke_api_key(key["id"])
    return new_key

create_geo_service_user async

create_geo_service_user(
    username: str,
    description: str = "",
    password: str | SecretStr | None = None,
) -> dict

Create a geo service user: a username and password ArcGIS clients use to sign in to the map services.

A geo service user can only reach the services it is given access to (see grant_arcgis_service_access), starts with access to none, and can never sign in to Pixel itself. Only works on ArcGIS Server v2. Superusers only.

Parameters:

Name Type Description Default
username str

3-64 characters: lowercase letters, digits, _, . and -, starting with a letter or digit. Cannot be changed later.

required
description str

What the user is for.

''
password str | SecretStr | None

Leave out to have a strong password generated. A password you choose (12-128 characters) is never shown again.

None

Returns:

Name Type Description
dict dict

The user under geo_service_user, and under password the generated password, or None if you chose one.

Warning

A generated password is returned only this once. Store it somewhere safe.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
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
async def create_geo_service_user(
    self,
    username: str,
    description: str = "",
    password: str | SecretStr | None = None,
) -> dict:
    """Create a geo service user: a username and password ArcGIS clients use
    to sign in to the map services.

    A geo service user can only reach the services it is given access to
    (see [`grant_arcgis_service_access`][pixel_client.PixelClientAsync.grant_arcgis_service_access]),
    starts with access to none, and can never sign in to Pixel itself. Only
    works on ArcGIS Server v2. Superusers only.

    Args:
        username: 3-64 characters: lowercase letters, digits, `_`, `.` and
            `-`, starting with a letter or digit. Cannot be changed later.
        description: What the user is for.
        password: Leave out to have a strong password generated. A password
            you choose (12-128 characters) is never shown again.

    Returns:
        dict: The user under `geo_service_user`, and under `password` the
            generated password, or `None` if you chose one.

    Warning:
        A generated password is returned only this once. Store it somewhere safe.

    Note:
        Cannot be called with an api key.
    """
    create_input = GeoServiceUserCreateInput(
        username=username,
        description=description,
        password=password,  # type: ignore[arg-type]
    )
    response = await self._post(
        "/geo_service_users/",
        json=create_input.model_dump(mode="json", exclude_none=True),
        sensitive_content=True,
    )
    return response.json()

list_geo_service_users async

list_geo_service_users() -> list[dict]

List the geo service users, with the services each can access.

Returns:

Type Description
list[dict]

list[dict]: Geo service user objects, with their grants.

Source code in src/pixel_client/_base.py
4679
4680
4681
4682
4683
4684
4685
4686
async def list_geo_service_users(self) -> list[dict]:
    """List the geo service users, with the services each can access.

    Returns:
        list[dict]: Geo service user objects, with their `grants`.
    """
    response = await self._get("/geo_service_users/")
    return response.json()

get_geo_service_user async

get_geo_service_user(
    geo_service_user: GeoServiceUserRef,
) -> dict

Retrieve a geo service user.

Parameters:

Name Type Description Default
geo_service_user GeoServiceUserRef

The geo service user's ID or username.

required

Returns:

Name Type Description
dict dict

The geo service user, with the services it can access.

Source code in src/pixel_client/_base.py
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
async def get_geo_service_user(self, geo_service_user: GeoServiceUserRef) -> dict:
    """Retrieve a geo service user.

    Args:
        geo_service_user: The geo service user's ID or username.

    Returns:
        dict: The geo service user, with the services it can access.
    """
    user_id = await self._geo_service_user_id(geo_service_user)
    response = await self._get(f"/geo_service_users/{user_id}")
    return response.json()

update_geo_service_user async

update_geo_service_user(
    geo_service_user: GeoServiceUserRef,
    *,
    description: str | None = None,
) -> dict

Change a geo service user's description. Superusers only.

Parameters:

Name Type Description Default
geo_service_user GeoServiceUserRef

The geo service user's ID or username.

required
description str | None

The new description.

None

Returns:

Name Type Description
dict dict

The updated geo service user.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
async def update_geo_service_user(
    self, geo_service_user: GeoServiceUserRef, *, description: str | None = None
) -> dict:
    """Change a geo service user's description. Superusers only.

    Args:
        geo_service_user: The geo service user's ID or username.
        description: The new description.

    Returns:
        dict: The updated geo service user.

    Note:
        Cannot be called with an api key.
    """
    return await self._patch_geo_service_user(
        geo_service_user, {"description": description}
    )

disable_geo_service_user async

disable_geo_service_user(
    geo_service_user: GeoServiceUserRef,
) -> dict

Stop a geo service user from signing in. Its service access is kept and comes back when it is enabled again. Superusers only.

Parameters:

Name Type Description Default
geo_service_user GeoServiceUserRef

The geo service user's ID or username.

required

Returns:

Name Type Description
dict dict

The updated geo service user.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
async def disable_geo_service_user(self, geo_service_user: GeoServiceUserRef) -> dict:
    """Stop a geo service user from signing in. Its service access is kept
    and comes back when it is enabled again. Superusers only.

    Args:
        geo_service_user: The geo service user's ID or username.

    Returns:
        dict: The updated geo service user.

    Note:
        Cannot be called with an api key.
    """
    return await self._patch_geo_service_user(geo_service_user, {"disabled": True})

enable_geo_service_user async

enable_geo_service_user(
    geo_service_user: GeoServiceUserRef,
) -> dict

Let a disabled geo service user sign in again, with the access it had. Superusers only.

Parameters:

Name Type Description Default
geo_service_user GeoServiceUserRef

The geo service user's ID or username.

required

Returns:

Name Type Description
dict dict

The updated geo service user.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
async def enable_geo_service_user(self, geo_service_user: GeoServiceUserRef) -> dict:
    """Let a disabled geo service user sign in again, with the access it had.
    Superusers only.

    Args:
        geo_service_user: The geo service user's ID or username.

    Returns:
        dict: The updated geo service user.

    Note:
        Cannot be called with an api key.
    """
    return await self._patch_geo_service_user(geo_service_user, {"disabled": False})

rotate_geo_service_user_password async

rotate_geo_service_user_password(
    geo_service_user: GeoServiceUserRef,
    password: str | SecretStr | None = None,
) -> dict

Replace a geo service user's password. The old one stops working immediately. Superusers only.

Parameters:

Name Type Description Default
geo_service_user GeoServiceUserRef

The geo service user's ID or username.

required
password str | SecretStr | None

Leave out to have a strong password generated. A password you choose (12-128 characters) is never shown again.

None

Returns:

Name Type Description
dict dict

The user under geo_service_user, and under password the generated password, or None if you chose one.

Warning

A generated password is returned only this once. Store it somewhere safe.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
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
async def rotate_geo_service_user_password(
    self,
    geo_service_user: GeoServiceUserRef,
    password: str | SecretStr | None = None,
) -> dict:
    """Replace a geo service user's password. The old one stops working
    immediately. Superusers only.

    Args:
        geo_service_user: The geo service user's ID or username.
        password: Leave out to have a strong password generated. A password
            you choose (12-128 characters) is never shown again.

    Returns:
        dict: The user under `geo_service_user`, and under `password` the
            generated password, or `None` if you chose one.

    Warning:
        A generated password is returned only this once. Store it somewhere safe.

    Note:
        Cannot be called with an api key.
    """
    user_id = await self._geo_service_user_id(geo_service_user)
    if isinstance(password, SecretStr):
        password = password.get_secret_value()
    response = await self._post(
        f"/geo_service_users/{user_id}/rotate",
        json={"password": password} if password else {},
        sensitive_content=True,
    )
    return response.json()

delete_geo_service_user async

delete_geo_service_user(
    geo_service_user: GeoServiceUserRef,
) -> dict

Delete a geo service user and all its service access. This cannot be undone; use disable_geo_service_user to stop it temporarily. Superusers only.

Parameters:

Name Type Description Default
geo_service_user GeoServiceUserRef

The geo service user's ID or username.

required

Returns:

Name Type Description
dict dict

The response confirming deletion.

Note

Cannot be called with an api key.

Source code in src/pixel_client/_base.py
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
async def delete_geo_service_user(self, geo_service_user: GeoServiceUserRef) -> dict:
    """Delete a geo service user and all its service access. This cannot be
    undone; use [`disable_geo_service_user`][pixel_client.PixelClientAsync.disable_geo_service_user]
    to stop it temporarily. Superusers only.

    Args:
        geo_service_user: The geo service user's ID or username.

    Returns:
        dict: The response confirming deletion.

    Note:
        Cannot be called with an api key.
    """
    user_id = await self._geo_service_user_id(geo_service_user)
    response = await self._delete(f"/geo_service_users/{user_id}")
    return response.json()

grant_arcgis_service_access async

grant_arcgis_service_access(
    service_type: Literal["Feature", "Image"],
    service_id: int,
    geo_service_users: list[GeoServiceUserRef],
) -> list[dict]

Give geo service users access to an ArcGIS service. Superusers only.

Changes reach the map services within a few minutes.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

"Feature" or "Image".

required
service_id int

The ID of the ArcGIS service.

required
geo_service_users list[GeoServiceUserRef]

Geo service users, by ID or username.

required

Returns:

Type Description
list[dict]

list[dict]: One entry per geo service user, with action "granted" or "unchanged".

Source code in src/pixel_client/_base.py
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
async def grant_arcgis_service_access(
    self,
    service_type: Literal["Feature", "Image"],
    service_id: int,
    geo_service_users: list[GeoServiceUserRef],
) -> list[dict]:
    """Give geo service users access to an ArcGIS service. Superusers only.

    Changes reach the map services within a few minutes.

    Args:
        service_type: `"Feature"` or `"Image"`.
        service_id: The ID of the ArcGIS service.
        geo_service_users: Geo service users, by ID or username.

    Returns:
        list[dict]: One entry per geo service user, with `action`
            `"granted"` or `"unchanged"`.
    """
    return await self.grant_access_on(
        ArcgisServiceResource(service_type, service_id),
        geo_service_users=geo_service_users,
    )

revoke_arcgis_service_access async

revoke_arcgis_service_access(
    service_type: Literal["Feature", "Image"],
    service_id: int,
    geo_service_users: list[GeoServiceUserRef],
) -> list[dict]

Remove geo service users' access to an ArcGIS service. Superusers only.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

"Feature" or "Image".

required
service_id int

The ID of the ArcGIS service.

required
geo_service_users list[GeoServiceUserRef]

Geo service users, by ID or username.

required

Returns:

Type Description
list[dict]

list[dict]: One entry per geo service user, with action "revoked" or "unchanged".

Source code in src/pixel_client/_base.py
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
async def revoke_arcgis_service_access(
    self,
    service_type: Literal["Feature", "Image"],
    service_id: int,
    geo_service_users: list[GeoServiceUserRef],
) -> list[dict]:
    """Remove geo service users' access to an ArcGIS service. Superusers only.

    Args:
        service_type: `"Feature"` or `"Image"`.
        service_id: The ID of the ArcGIS service.
        geo_service_users: Geo service users, by ID or username.

    Returns:
        list[dict]: One entry per geo service user, with `action`
            `"revoked"` or `"unchanged"`.
    """
    return await self.revoke_access_on(
        ArcgisServiceResource(service_type, service_id),
        geo_service_users=geo_service_users,
    )

list_arcgis_service_access async

list_arcgis_service_access(
    service_type: Literal["Feature", "Image"],
    service_id: int,
) -> list[dict]

List the geo service users with access to an ArcGIS service.

Parameters:

Name Type Description Default
service_type Literal['Feature', 'Image']

"Feature" or "Image".

required
service_id int

The ID of the ArcGIS service.

required

Returns:

Type Description
list[dict]

list[dict]: Geo service user objects.

Source code in src/pixel_client/_base.py
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
async def list_arcgis_service_access(
    self, service_type: Literal["Feature", "Image"], service_id: int
) -> list[dict]:
    """List the geo service users with access to an ArcGIS service.

    Args:
        service_type: `"Feature"` or `"Image"`.
        service_id: The ID of the ArcGIS service.

    Returns:
        list[dict]: Geo service user objects.
    """
    response = await self._get(
        f"/arcgis_services/{service_type}/{service_id}/access"
    )
    return response.json()