pixel-client 1.2.6__tar.gz → 1.2.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -141,4 +141,13 @@ cython_debug/
141
141
  .env.*
142
142
 
143
143
  **/examples/**
144
- tmp/
144
+ tmp/
145
+
146
+ # Claude Code
147
+ .claude/
148
+
149
+ # Node
150
+ node_modules/
151
+
152
+ # OS
153
+ .DS_Store
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixel-client
3
- Version: 1.2.6
3
+ Version: 1.2.8
4
4
  Summary: Client library for Geodata Pixel
5
5
  Project-URL: Documentation, https://doc.geodatapixel.no/
6
6
  Project-URL: Organization, https://geodata.no
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pixel-client"
3
- version = "1.2.6"
3
+ version = "1.2.8"
4
4
  description = "Client library for Geodata Pixel"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -58,7 +58,8 @@ docs = [
58
58
  include = [
59
59
  "src/*"
60
60
  ]
61
-
61
+ [tool.uv]
62
+ exclude-newer = "10 days"
62
63
 
63
64
  [tool.basedpyright]
64
65
  include = ["src"]
@@ -56,6 +56,12 @@ from .models import (
56
56
  SearchOn,
57
57
  SearchQuery,
58
58
  SearchResults,
59
+ AnalysisServiceCreateUpdateInput,
60
+ AnalysisServicePatchInput,
61
+ AnalysisServiceListParams,
62
+ AnalysisTaskListParams,
63
+ AnalysisTaskCreateInput
64
+
59
65
  )
60
66
  from .settings import PixelApiSettings
61
67
  from .types import AttachmentResourceType, DataCollectionType, OverviewResampling
@@ -274,6 +280,18 @@ class PixelClientAsync:
274
280
  """
275
281
  return await self._make_request("PUT", url, **kwargs)
276
282
 
283
+ async def _patch(self, url: str, **kwargs) -> httpx.Response:
284
+ """Make a PATCH request to the Pixel API.
285
+
286
+ Args:
287
+ url: The URL to request, relative to the base URL.
288
+ **kwargs: Additional arguments to pass to the request method.
289
+
290
+ Returns:
291
+ httpx.Response: The HTTP response object.
292
+ """
293
+ return await self._make_request("PATCH", url, **kwargs)
294
+
277
295
  async def _delete(self, url: str, **kwargs) -> httpx.Response:
278
296
  """
279
297
  Make a DELETE request to the Pixel API.
@@ -543,7 +561,7 @@ class PixelClientAsync:
543
561
  # If None is provided, set to -1 to move to root
544
562
  new_parent_project_id = new_parent_project_id or -1
545
563
  response = await self._put(
546
- f"/projects/{project_id}",
564
+ f"/projects/{project_id}/move",
547
565
  params={"new_parent_id": new_parent_project_id},
548
566
  )
549
567
  return response.json()
@@ -714,7 +732,7 @@ class PixelClientAsync:
714
732
  dict: The updated data collection object.
715
733
  """
716
734
  response = await self._put(
717
- f"/projects/{project_id}/data_collections/{data_collection_id}",
735
+ f"/projects/{project_id}/data_collections/{data_collection_id}/move",
718
736
  params={"new_project_id": new_project_id},
719
737
  )
720
738
  return response.json()
@@ -907,7 +925,7 @@ class PixelClientAsync:
907
925
  dict: The updated image object.
908
926
  """
909
927
  response = await self._put(
910
- f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}",
928
+ f"/projects/{project_id}/data_collections/{data_collection_id}/images/{image_id}/move",
911
929
  params={
912
930
  "new_project_id": new_project_id,
913
931
  "new_data_collection_id": new_data_collection_id,
@@ -1068,7 +1086,7 @@ class PixelClientAsync:
1068
1086
  dict: The updated raster object.
1069
1087
  """
1070
1088
  response = await self._put(
1071
- f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}",
1089
+ f"/projects/{project_id}/data_collections/{data_collection_id}/rasters/{raster_id}/move",
1072
1090
  params={
1073
1091
  "new_project_id": new_project_id,
1074
1092
  "new_data_collection_id": new_data_collection_id,
@@ -3266,3 +3284,161 @@ class PixelClientAsync:
3266
3284
  json=search_query_body,
3267
3285
  ):
3268
3286
  yield item
3287
+
3288
+
3289
+ async def list_analysis_modules(self) -> list[dict]:
3290
+ """
3291
+ Retrieve a list of available analysis modules.
3292
+
3293
+ Returns:
3294
+ list[dict]: A list of analysis module objects.
3295
+ """
3296
+ response = await self._get("/analysis/modules/")
3297
+ return response.json()
3298
+
3299
+ async def list_analysis_services(self, params: AnalysisServiceListParams | None = None, **kwargs) -> list[dict]:
3300
+ """
3301
+ Retrieve a list of available analysis services.
3302
+
3303
+ Returns:
3304
+ list[dict]: A list of analysis service objects.
3305
+ """
3306
+ if params and kwargs:
3307
+ logger.warning("Ignoring kwargs when params is provided")
3308
+ params_dict = (
3309
+ params.model_dump(exclude_none=True, mode="json")
3310
+ if params
3311
+ else AnalysisServiceListParams.model_validate(kwargs).model_dump(
3312
+ exclude_none=True, mode="json"
3313
+ )
3314
+ )
3315
+ response = await self._get("/analysis/services/", params=params_dict)
3316
+ return response.json()
3317
+
3318
+ async def create_analysis_service(self, create_input: AnalysisServiceCreateUpdateInput | None = None, **kwargs) -> dict:
3319
+ """
3320
+ Create a new analysis service.
3321
+
3322
+ Returns:
3323
+ dict: The created analysis service object.
3324
+ """
3325
+ if create_input and kwargs:
3326
+ logger.warning("Ignoring kwargs when create_input is provided")
3327
+ input_dict = (
3328
+ create_input.model_dump(mode="json", exclude_none=True)
3329
+ if create_input
3330
+ else AnalysisServiceCreateUpdateInput.model_validate(kwargs).model_dump(
3331
+ exclude_none=True, mode="json"
3332
+ )
3333
+ )
3334
+ response = await self._post(
3335
+ "/analysis/services/", json=input_dict
3336
+ )
3337
+ return response.json()
3338
+
3339
+ async def patch_analysis_service(
3340
+ self,
3341
+ service_id: int,
3342
+ patch_input: AnalysisServicePatchInput | None = None,
3343
+ **kwargs,
3344
+ ) -> dict:
3345
+ """
3346
+ Partially update an analysis service.
3347
+
3348
+ Only fields explicitly set on `patch_input` (or passed as kwargs)
3349
+ are sent. Backend deep-merges `config`; omitted fields are kept
3350
+ as-is. `module_name` cannot be changed.
3351
+
3352
+ Returns:
3353
+ dict: The updated analysis service object.
3354
+ """
3355
+ if patch_input and kwargs:
3356
+ logger.warning("Ignoring kwargs when patch_input is provided")
3357
+ model = patch_input or AnalysisServicePatchInput.model_validate(kwargs)
3358
+ input_dict = model.model_dump(exclude_unset=True, mode="json")
3359
+ response = await self._patch(
3360
+ f"/analysis/services/{service_id}", json=input_dict
3361
+ )
3362
+ return response.json()
3363
+
3364
+ async def delete_analysis_service(self, service_id: int) -> bool:
3365
+ """
3366
+ Delete an existing analysis service.
3367
+
3368
+ Returns:
3369
+ dict: The response confirming deletion.
3370
+ """
3371
+ _ = await self._delete(f"/analysis/services/{service_id}")
3372
+ return True
3373
+
3374
+ async def list_analysis_tasks(self, service_id: int, list_input: AnalysisTaskListParams | None = None, **kwargs) -> list[dict]:
3375
+ """
3376
+ Retrieve a list of analysis tasks.
3377
+
3378
+ Returns:
3379
+ list[dict]: A list of analysis task objects.
3380
+ """
3381
+ if list_input and kwargs:
3382
+ logger.warning("Ignoring kwargs when list_input is provided")
3383
+ params_dict = (
3384
+ list_input.model_dump(exclude_none=True, mode="json")
3385
+ if list_input
3386
+ else AnalysisTaskListParams.model_validate(kwargs).model_dump(
3387
+ exclude_none=True, mode="json"
3388
+ )
3389
+ )
3390
+ response = await self._get(f"/analysis/services/{service_id}/tasks/", params=params_dict)
3391
+ return response.json()
3392
+
3393
+ async def create_analysis_task(self, service_id: int, params: AnalysisTaskCreateInput | None = None, **kwargs) -> dict:
3394
+ """
3395
+ Create a new analysis task.
3396
+
3397
+ Returns:
3398
+ dict: The created analysis task object.
3399
+ """
3400
+ if params and kwargs:
3401
+ logger.warning("Ignoring kwargs when params is provided")
3402
+ input_dict = (
3403
+ params.model_dump(mode="json", exclude_none=True)
3404
+ if params
3405
+ else AnalysisTaskCreateInput.model_validate(kwargs).model_dump(
3406
+ exclude_none=True, mode="json"
3407
+ )
3408
+ )
3409
+
3410
+
3411
+ response = await self._post(
3412
+ f"/analysis/services/{service_id}/tasks/", json=input_dict
3413
+ )
3414
+ return response.json()
3415
+
3416
+ async def delete_analysis_task(self, service_id: int, task_id: int) -> bool:
3417
+ """
3418
+ Delete an existing analysis task.
3419
+
3420
+ Returns:
3421
+ dict: The response confirming deletion.
3422
+ """
3423
+ _ = await self._delete(f"/analysis/services/{service_id}/tasks/{task_id}")
3424
+ return True
3425
+
3426
+ async def run_analysis_task(self, service_id: int, task_id: int) -> dict:
3427
+ """
3428
+ Run an existing analysis task.
3429
+
3430
+ Returns:
3431
+ dict: The response confirming the task has been started.
3432
+ """
3433
+ response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/run")
3434
+ return response.json()
3435
+
3436
+ async def revoke_analysis_task(self, service_id: int, task_id: int) -> dict:
3437
+ """
3438
+ Revoke an existing analysis task.
3439
+
3440
+ Returns:
3441
+ dict: The response confirming the task has been revoked.
3442
+ """
3443
+ response = await self._post(f"/analysis/services/{service_id}/tasks/{task_id}/revoke")
3444
+ return response.json()
@@ -25,6 +25,12 @@ from .models import (
25
25
  SearchOn,
26
26
  SearchQuery,
27
27
  SearchResults,
28
+ AnalysisServiceCreateUpdateInput,
29
+ AnalysisServicePatchInput,
30
+ AnalysisServiceListParams,
31
+ AnalysisTaskListParams,
32
+ AnalysisTaskCreateInput
33
+
28
34
  )
29
35
  from .types import AttachmentResourceType, OverviewResampling, DataCollectionType
30
36
  from .exceptions import PixelUploadJobError
@@ -1996,3 +2002,145 @@ class PixelClient:
1996
2002
  page_size,
1997
2003
  )
1998
2004
  )
2005
+
2006
+ def list_analysis_modules(self) -> list[dict]:
2007
+ """
2008
+ Retrieve a list of available analysis modules.
2009
+
2010
+ Returns:
2011
+ list[dict]: A list of analysis module objects.
2012
+ """
2013
+ return run_sync(self._async_client.list_analysis_modules())
2014
+
2015
+ def list_analysis_services(self, list_input: AnalysisServiceListParams | None = None, **kwargs) -> list[dict]:
2016
+ """
2017
+ Retrieve a list of analysis services.
2018
+
2019
+ Args:
2020
+ list_input: Optional AnalysisServiceListParams object containing filtering parameters.
2021
+ **kwargs: Alternative way to provide filtering parameters.
2022
+
2023
+ Returns:
2024
+ list[dict]: A list of analysis service objects.
2025
+ """
2026
+ return run_sync(
2027
+ self._async_client.list_analysis_services(list_input, **kwargs)
2028
+ )
2029
+
2030
+ def create_analysis_service(self, create_input: AnalysisServiceCreateUpdateInput) -> dict:
2031
+ """
2032
+ Create a new analysis service.
2033
+
2034
+ Args:
2035
+ create_input: AnalysisServiceCreateUpdateInput object containing the service configuration.
2036
+
2037
+ Returns:
2038
+ dict: The created analysis service object.
2039
+ """
2040
+ return run_sync(
2041
+ self._async_client.create_analysis_service(create_input)
2042
+ )
2043
+
2044
+ def patch_analysis_service(
2045
+ self,
2046
+ service_id: int,
2047
+ patch_input: AnalysisServicePatchInput | None = None,
2048
+ **kwargs,
2049
+ ) -> dict:
2050
+ """
2051
+ Partially update an analysis service.
2052
+
2053
+ Args:
2054
+ service_id: The ID of the analysis service to update.
2055
+ patch_input: Optional AnalysisServicePatchInput with fields to patch.
2056
+ Only fields explicitly set are sent. `module_name`
2057
+ cannot be patched.
2058
+ **kwargs: Alternative way to provide patch fields.
2059
+
2060
+ Returns:
2061
+ dict: The updated analysis service object.
2062
+ """
2063
+ return run_sync(
2064
+ self._async_client.patch_analysis_service(service_id, patch_input, **kwargs)
2065
+ )
2066
+
2067
+ def delete_analysis_service(self, service_id: int) -> bool:
2068
+ """
2069
+ Delete a specific analysis service by its ID.
2070
+ Args:
2071
+ service_id: The ID of the analysis service to delete.
2072
+ Returns:
2073
+ dict: The response confirming deletion.
2074
+ """
2075
+ return run_sync(
2076
+ self._async_client.delete_analysis_service(service_id)
2077
+ )
2078
+
2079
+ def list_analysis_tasks(self, service_id: int, list_input: AnalysisTaskListParams | None = None, **kwargs) -> list[dict]:
2080
+ """
2081
+ Retrieve a list of analysis tasks.
2082
+
2083
+ Args:
2084
+ service_id: The ID of the analysis service to list tasks for.
2085
+ list_input: Optional AnalysisTaskListParams object containing filtering parameters.
2086
+ **kwargs: Alternative way to provide filtering parameters.
2087
+
2088
+ Returns:
2089
+ list[dict]: A list of analysis task objects.
2090
+ """
2091
+ return run_sync(
2092
+ self._async_client.list_analysis_tasks(service_id, list_input, **kwargs)
2093
+ )
2094
+
2095
+ def create_analysis_task(self, service_id: int, params: AnalysisTaskCreateInput | None = None, **kwargs) -> dict:
2096
+ """
2097
+ Create a new analysis task.
2098
+ Args:
2099
+ service_id: The ID of the analysis service to use for the task.
2100
+ params: Optional AnalysisTaskCreateInput object containing the task configuration.
2101
+ **kwargs: Alternative way to provide task parameters.
2102
+ Returns:
2103
+ dict: The created analysis task object.
2104
+ """
2105
+ return run_sync(
2106
+ self._async_client.create_analysis_task(service_id, params, **kwargs)
2107
+ )
2108
+
2109
+ def run_analysis_task(self, service_id: int, task_id: int) -> dict:
2110
+ """
2111
+ Run a specific analysis task by its ID.
2112
+ Args:
2113
+ service_id: The ID of the analysis service to use for the task.
2114
+ task_id: The ID of the analysis task to run.
2115
+ Returns:
2116
+ dict: The response confirming the task has been started.
2117
+ """
2118
+ return run_sync(
2119
+ self._async_client.run_analysis_task(service_id, task_id)
2120
+ )
2121
+
2122
+ def revoke_analysis_task(self, service_id: int, task_id: int) -> dict:
2123
+ """
2124
+ Revoke a running analysis task by its ID.
2125
+ Args:
2126
+ service_id: The ID of the analysis service to use for the task.
2127
+ task_id: The ID of the analysis task to revoke.
2128
+ Returns:
2129
+ dict: The response confirming the task has been revoked.
2130
+ """
2131
+ return run_sync(
2132
+ self._async_client.revoke_analysis_task(service_id, task_id)
2133
+ )
2134
+
2135
+ def delete_analysis_task(self, service_id: int, task_id: int) -> bool:
2136
+ """
2137
+ Delete an existing analysis task.
2138
+ Args:
2139
+ service_id: The ID of the analysis service to use for the task.
2140
+ task_id: The ID of the analysis task to delete.
2141
+ Returns:
2142
+ dict: The response confirming deletion.
2143
+ """
2144
+ return run_sync(
2145
+ self._async_client.delete_analysis_task(service_id, task_id)
2146
+ )
@@ -3,7 +3,7 @@ import datetime
3
3
  from enum import StrEnum
4
4
  from functools import cached_property
5
5
  from pathlib import Path
6
- from typing import Annotated, Literal, Self, Union
6
+ from typing import Annotated, Literal, Self, Union, Any
7
7
 
8
8
  # Import TypedDict from typing_extensions if python version is < 3.12
9
9
  if sys.version_info >= (3, 12):
@@ -63,6 +63,11 @@ __all__ = [
63
63
  "PointCloudUpdateInput",
64
64
  "ArcGISImageServiceOptions",
65
65
  "ArcGISImageServiceWMSOptions",
66
+ "AnalysisServiceListParams",
67
+ "AnalysisServiceCreateUpdateInput",
68
+ "AnalysisServicePatchInput",
69
+ "AnalysisTaskListParams",
70
+ "AnalysisTaskCreateInput",
66
71
  ]
67
72
 
68
73
  CommaSeperatedString = str
@@ -543,3 +548,59 @@ class SearchResults(TypedDict):
543
548
  count: int
544
549
  results: list[dict]
545
550
  total_count: int
551
+
552
+
553
+
554
+ class AnalysisTaskStatusEnum(StrEnum):
555
+ REVOKED = "REVOKED"
556
+ PENDING = "PENDING"
557
+ SCHEDULED = "SCHEDULED"
558
+ RUNNING = "RUNNING"
559
+ SUCCESS = "SUCCESS"
560
+ FAILED = "FAILED"
561
+
562
+
563
+ class AnalysisServiceListParams(BaseModel):
564
+ name: str | None = None
565
+ ids: (
566
+ Annotated[list[int] | None, PlainSerializer(_serialize_to_comma_sep_list)]
567
+ | None
568
+ ) = None
569
+ enabled: bool | None = None
570
+ offset: int | None = None
571
+ limit: int | None = None
572
+
573
+
574
+
575
+ class AnalysisServiceCreateUpdateInput(BaseModel):
576
+ name: str
577
+ module_name: str
578
+ enabled: bool = True
579
+ config: dict[str, Any]
580
+
581
+
582
+ class AnalysisServicePatchInput(BaseModel):
583
+ """Partial update for an analysis service.
584
+
585
+ Mirrors backend ``PatchAnalysisServiceInput``: all fields optional, no
586
+ ``module_name`` (module type is fixed once the service is created). The
587
+ backend deep-merges ``config``; send only the keys you want to change.
588
+ """
589
+ name: str | None = None
590
+ enabled: bool | None = None
591
+ config: dict[str, Any] | None = None
592
+
593
+
594
+ class AnalysisTaskListParams(BaseModel):
595
+ name: str | None = None
596
+ ids: (
597
+ Annotated[list[int] | None, PlainSerializer(_serialize_to_comma_sep_list)]
598
+ | None
599
+ ) = None
600
+ status: AnalysisTaskStatusEnum | None = None
601
+ offset: int | None = None
602
+ limit: int | None = None
603
+
604
+ class AnalysisTaskCreateInput(BaseModel):
605
+ name: str | None = None
606
+ params: dict[str, Any]
File without changes
File without changes