plato-sdk-v2 2.8.5__py3-none-any.whl → 2.8.7__py3-none-any.whl
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.
- plato/_generated/__init__.py +1 -1
- plato/_generated/api/v1/session/__init__.py +2 -0
- plato/_generated/api/v1/session/upload_review_screenshot.py +74 -0
- plato/_generated/api/v1/testcases/__init__.py +2 -0
- plato/_generated/api/v1/testcases/assign_testcases_to_work_order_item.py +74 -0
- plato/_generated/api/v2/__init__.py +2 -0
- plato/_generated/api/v2/jobs/__init__.py +4 -0
- plato/_generated/api/v2/jobs/heartbeat.py +69 -0
- plato/_generated/api/v2/jobs/rdp_url.py +93 -0
- plato/_generated/api/v2/releases/__init__.py +2 -0
- plato/_generated/api/v2/releases/deploy.py +6 -6
- plato/_generated/api/v2/releases/get.py +8 -8
- plato/_generated/api/v2/releases/prep_release_assigned_testcases.py +6 -6
- plato/_generated/api/v2/releases/prep_release_from_work_order.py +85 -0
- plato/_generated/api/v2/releases/update.py +6 -6
- plato/_generated/api/v2/sessions/__init__.py +2 -0
- plato/_generated/api/v2/sessions/get_rdp_url.py +87 -0
- plato/_generated/api/v2/work_orders/__init__.py +19 -0
- plato/_generated/api/v2/work_orders/archive_work_order.py +81 -0
- plato/_generated/api/v2/work_orders/archive_work_order_item.py +81 -0
- plato/_generated/api/v2/work_orders/create_work_order.py +76 -0
- plato/_generated/api/v2/work_orders/create_work_order_item.py +81 -0
- plato/_generated/api/v2/work_orders/get_work_order.py +75 -0
- plato/_generated/api/v2/work_orders/list_work_orders.py +80 -0
- plato/_generated/models/__init__.py +274 -7
- plato/cli/pm.py +2 -1
- {plato_sdk_v2-2.8.5.dist-info → plato_sdk_v2-2.8.7.dist-info}/METADATA +1 -1
- {plato_sdk_v2-2.8.5.dist-info → plato_sdk_v2-2.8.7.dist-info}/RECORD +30 -17
- {plato_sdk_v2-2.8.5.dist-info → plato_sdk_v2-2.8.7.dist-info}/WHEEL +0 -0
- {plato_sdk_v2-2.8.5.dist-info → plato_sdk_v2-2.8.7.dist-info}/entry_points.txt +0 -0
|
@@ -11,13 +11,13 @@ from plato._generated.models import ReleaseResponse, UpdateReleaseRequest
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def _build_request_args(
|
|
14
|
-
|
|
14
|
+
public_id: str,
|
|
15
15
|
body: UpdateReleaseRequest,
|
|
16
16
|
authorization: str | None = None,
|
|
17
17
|
x_api_key: str | None = None,
|
|
18
18
|
) -> dict[str, Any]:
|
|
19
19
|
"""Build request arguments."""
|
|
20
|
-
url = f"/api/v2/releases/{
|
|
20
|
+
url = f"/api/v2/releases/{public_id}"
|
|
21
21
|
|
|
22
22
|
headers: dict[str, str] = {}
|
|
23
23
|
if authorization is not None:
|
|
@@ -35,7 +35,7 @@ def _build_request_args(
|
|
|
35
35
|
|
|
36
36
|
def sync(
|
|
37
37
|
client: httpx.Client,
|
|
38
|
-
|
|
38
|
+
public_id: str,
|
|
39
39
|
body: UpdateReleaseRequest,
|
|
40
40
|
authorization: str | None = None,
|
|
41
41
|
x_api_key: str | None = None,
|
|
@@ -43,7 +43,7 @@ def sync(
|
|
|
43
43
|
"""Update a release's manifest. Only drafted releases can be updated."""
|
|
44
44
|
|
|
45
45
|
request_args = _build_request_args(
|
|
46
|
-
|
|
46
|
+
public_id=public_id,
|
|
47
47
|
body=body,
|
|
48
48
|
authorization=authorization,
|
|
49
49
|
x_api_key=x_api_key,
|
|
@@ -56,7 +56,7 @@ def sync(
|
|
|
56
56
|
|
|
57
57
|
async def asyncio(
|
|
58
58
|
client: httpx.AsyncClient,
|
|
59
|
-
|
|
59
|
+
public_id: str,
|
|
60
60
|
body: UpdateReleaseRequest,
|
|
61
61
|
authorization: str | None = None,
|
|
62
62
|
x_api_key: str | None = None,
|
|
@@ -64,7 +64,7 @@ async def asyncio(
|
|
|
64
64
|
"""Update a release's manifest. Only drafted releases can be updated."""
|
|
65
65
|
|
|
66
66
|
request_args = _build_request_args(
|
|
67
|
-
|
|
67
|
+
public_id=public_id,
|
|
68
68
|
body=body,
|
|
69
69
|
authorization=authorization,
|
|
70
70
|
x_api_key=x_api_key,
|
|
@@ -12,6 +12,7 @@ from . import (
|
|
|
12
12
|
get_connect_url,
|
|
13
13
|
get_presigned_url,
|
|
14
14
|
get_public_url,
|
|
15
|
+
get_rdp_url,
|
|
15
16
|
get_s3_content,
|
|
16
17
|
get_session_details,
|
|
17
18
|
get_session_documents,
|
|
@@ -60,6 +61,7 @@ __all__ = [
|
|
|
60
61
|
"wait_for_ready",
|
|
61
62
|
"get_public_url",
|
|
62
63
|
"get_connect_url",
|
|
64
|
+
"get_rdp_url",
|
|
63
65
|
"list_sessions",
|
|
64
66
|
"get_session_details",
|
|
65
67
|
"get_session_documents",
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Get Rdp Url"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import RdpUrlResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
session_id: str,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = f"/api/v2/sessions/{session_id}/rdp_url"
|
|
20
|
+
|
|
21
|
+
headers: dict[str, str] = {}
|
|
22
|
+
if authorization is not None:
|
|
23
|
+
headers["authorization"] = authorization
|
|
24
|
+
if x_api_key is not None:
|
|
25
|
+
headers["X-API-Key"] = x_api_key
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
"method": "GET",
|
|
29
|
+
"url": url,
|
|
30
|
+
"headers": headers,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def sync(
|
|
35
|
+
client: httpx.Client,
|
|
36
|
+
session_id: str,
|
|
37
|
+
authorization: str | None = None,
|
|
38
|
+
x_api_key: str | None = None,
|
|
39
|
+
) -> RdpUrlResponse:
|
|
40
|
+
"""Get RDP viewer URLs for all jobs in a session.
|
|
41
|
+
|
|
42
|
+
Returns browser-accessible URLs to the Guacamole-based RDP viewer for Windows VMs.
|
|
43
|
+
The URLs include a trailing slash which is required for proper routing.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
session_id: The session ID.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
RdpUrlResponse with RDP URL for each job."""
|
|
50
|
+
|
|
51
|
+
request_args = _build_request_args(
|
|
52
|
+
session_id=session_id,
|
|
53
|
+
authorization=authorization,
|
|
54
|
+
x_api_key=x_api_key,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
response = client.request(**request_args)
|
|
58
|
+
raise_for_status(response)
|
|
59
|
+
return RdpUrlResponse.model_validate(response.json())
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
async def asyncio(
|
|
63
|
+
client: httpx.AsyncClient,
|
|
64
|
+
session_id: str,
|
|
65
|
+
authorization: str | None = None,
|
|
66
|
+
x_api_key: str | None = None,
|
|
67
|
+
) -> RdpUrlResponse:
|
|
68
|
+
"""Get RDP viewer URLs for all jobs in a session.
|
|
69
|
+
|
|
70
|
+
Returns browser-accessible URLs to the Guacamole-based RDP viewer for Windows VMs.
|
|
71
|
+
The URLs include a trailing slash which is required for proper routing.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
session_id: The session ID.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
RdpUrlResponse with RDP URL for each job."""
|
|
78
|
+
|
|
79
|
+
request_args = _build_request_args(
|
|
80
|
+
session_id=session_id,
|
|
81
|
+
authorization=authorization,
|
|
82
|
+
x_api_key=x_api_key,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
response = await client.request(**request_args)
|
|
86
|
+
raise_for_status(response)
|
|
87
|
+
return RdpUrlResponse.model_validate(response.json())
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""API endpoints."""
|
|
2
|
+
|
|
3
|
+
from . import (
|
|
4
|
+
archive_work_order,
|
|
5
|
+
archive_work_order_item,
|
|
6
|
+
create_work_order,
|
|
7
|
+
create_work_order_item,
|
|
8
|
+
get_work_order,
|
|
9
|
+
list_work_orders,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"list_work_orders",
|
|
14
|
+
"create_work_order",
|
|
15
|
+
"get_work_order",
|
|
16
|
+
"create_work_order_item",
|
|
17
|
+
"archive_work_order",
|
|
18
|
+
"archive_work_order_item",
|
|
19
|
+
]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Archive Work Order"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import WorkOrderResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
public_id: str,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = f"/api/v2/work-orders/{public_id}/archive"
|
|
20
|
+
|
|
21
|
+
headers: dict[str, str] = {}
|
|
22
|
+
if authorization is not None:
|
|
23
|
+
headers["authorization"] = authorization
|
|
24
|
+
if x_api_key is not None:
|
|
25
|
+
headers["X-API-Key"] = x_api_key
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
"method": "POST",
|
|
29
|
+
"url": url,
|
|
30
|
+
"headers": headers,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def sync(
|
|
35
|
+
client: httpx.Client,
|
|
36
|
+
public_id: str,
|
|
37
|
+
authorization: str | None = None,
|
|
38
|
+
x_api_key: str | None = None,
|
|
39
|
+
) -> WorkOrderResponse:
|
|
40
|
+
"""Archive a work order and all its items and testcase statuses.
|
|
41
|
+
|
|
42
|
+
For each testcase that would become orphaned (no other active statuses
|
|
43
|
+
and not in Plato General), creates a copy in Plato General.
|
|
44
|
+
|
|
45
|
+
Users can only archive work orders belonging to their organization.
|
|
46
|
+
Admins can archive any work order."""
|
|
47
|
+
|
|
48
|
+
request_args = _build_request_args(
|
|
49
|
+
public_id=public_id,
|
|
50
|
+
authorization=authorization,
|
|
51
|
+
x_api_key=x_api_key,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
response = client.request(**request_args)
|
|
55
|
+
raise_for_status(response)
|
|
56
|
+
return WorkOrderResponse.model_validate(response.json())
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
async def asyncio(
|
|
60
|
+
client: httpx.AsyncClient,
|
|
61
|
+
public_id: str,
|
|
62
|
+
authorization: str | None = None,
|
|
63
|
+
x_api_key: str | None = None,
|
|
64
|
+
) -> WorkOrderResponse:
|
|
65
|
+
"""Archive a work order and all its items and testcase statuses.
|
|
66
|
+
|
|
67
|
+
For each testcase that would become orphaned (no other active statuses
|
|
68
|
+
and not in Plato General), creates a copy in Plato General.
|
|
69
|
+
|
|
70
|
+
Users can only archive work orders belonging to their organization.
|
|
71
|
+
Admins can archive any work order."""
|
|
72
|
+
|
|
73
|
+
request_args = _build_request_args(
|
|
74
|
+
public_id=public_id,
|
|
75
|
+
authorization=authorization,
|
|
76
|
+
x_api_key=x_api_key,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
response = await client.request(**request_args)
|
|
80
|
+
raise_for_status(response)
|
|
81
|
+
return WorkOrderResponse.model_validate(response.json())
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Archive Work Order Item"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import WorkOrderItemResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
item_public_id: str,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = f"/api/v2/work-orders/items/{item_public_id}/archive"
|
|
20
|
+
|
|
21
|
+
headers: dict[str, str] = {}
|
|
22
|
+
if authorization is not None:
|
|
23
|
+
headers["authorization"] = authorization
|
|
24
|
+
if x_api_key is not None:
|
|
25
|
+
headers["X-API-Key"] = x_api_key
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
"method": "POST",
|
|
29
|
+
"url": url,
|
|
30
|
+
"headers": headers,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def sync(
|
|
35
|
+
client: httpx.Client,
|
|
36
|
+
item_public_id: str,
|
|
37
|
+
authorization: str | None = None,
|
|
38
|
+
x_api_key: str | None = None,
|
|
39
|
+
) -> WorkOrderItemResponse:
|
|
40
|
+
"""Archive a work order item and all its testcase statuses.
|
|
41
|
+
|
|
42
|
+
For each testcase that would become orphaned (no other active statuses
|
|
43
|
+
and not in Plato General), creates a copy in Plato General.
|
|
44
|
+
|
|
45
|
+
Users can only archive items belonging to their organization's work orders.
|
|
46
|
+
Admins can archive any item."""
|
|
47
|
+
|
|
48
|
+
request_args = _build_request_args(
|
|
49
|
+
item_public_id=item_public_id,
|
|
50
|
+
authorization=authorization,
|
|
51
|
+
x_api_key=x_api_key,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
response = client.request(**request_args)
|
|
55
|
+
raise_for_status(response)
|
|
56
|
+
return WorkOrderItemResponse.model_validate(response.json())
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
async def asyncio(
|
|
60
|
+
client: httpx.AsyncClient,
|
|
61
|
+
item_public_id: str,
|
|
62
|
+
authorization: str | None = None,
|
|
63
|
+
x_api_key: str | None = None,
|
|
64
|
+
) -> WorkOrderItemResponse:
|
|
65
|
+
"""Archive a work order item and all its testcase statuses.
|
|
66
|
+
|
|
67
|
+
For each testcase that would become orphaned (no other active statuses
|
|
68
|
+
and not in Plato General), creates a copy in Plato General.
|
|
69
|
+
|
|
70
|
+
Users can only archive items belonging to their organization's work orders.
|
|
71
|
+
Admins can archive any item."""
|
|
72
|
+
|
|
73
|
+
request_args = _build_request_args(
|
|
74
|
+
item_public_id=item_public_id,
|
|
75
|
+
authorization=authorization,
|
|
76
|
+
x_api_key=x_api_key,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
response = await client.request(**request_args)
|
|
80
|
+
raise_for_status(response)
|
|
81
|
+
return WorkOrderItemResponse.model_validate(response.json())
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Create Work Order"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import CreateWorkOrderRequest, WorkOrderResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
body: CreateWorkOrderRequest,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = "/api/v2/work-orders"
|
|
20
|
+
|
|
21
|
+
headers: dict[str, str] = {}
|
|
22
|
+
if authorization is not None:
|
|
23
|
+
headers["authorization"] = authorization
|
|
24
|
+
if x_api_key is not None:
|
|
25
|
+
headers["X-API-Key"] = x_api_key
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
"method": "POST",
|
|
29
|
+
"url": url,
|
|
30
|
+
"json": body.model_dump(mode="json", exclude_none=True),
|
|
31
|
+
"headers": headers,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def sync(
|
|
36
|
+
client: httpx.Client,
|
|
37
|
+
body: CreateWorkOrderRequest,
|
|
38
|
+
authorization: str | None = None,
|
|
39
|
+
x_api_key: str | None = None,
|
|
40
|
+
) -> WorkOrderResponse:
|
|
41
|
+
"""Create a new work order.
|
|
42
|
+
|
|
43
|
+
Users create work orders for their own organization.
|
|
44
|
+
Admins can create work orders for any organization by specifying organization_id."""
|
|
45
|
+
|
|
46
|
+
request_args = _build_request_args(
|
|
47
|
+
body=body,
|
|
48
|
+
authorization=authorization,
|
|
49
|
+
x_api_key=x_api_key,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
response = client.request(**request_args)
|
|
53
|
+
raise_for_status(response)
|
|
54
|
+
return WorkOrderResponse.model_validate(response.json())
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async def asyncio(
|
|
58
|
+
client: httpx.AsyncClient,
|
|
59
|
+
body: CreateWorkOrderRequest,
|
|
60
|
+
authorization: str | None = None,
|
|
61
|
+
x_api_key: str | None = None,
|
|
62
|
+
) -> WorkOrderResponse:
|
|
63
|
+
"""Create a new work order.
|
|
64
|
+
|
|
65
|
+
Users create work orders for their own organization.
|
|
66
|
+
Admins can create work orders for any organization by specifying organization_id."""
|
|
67
|
+
|
|
68
|
+
request_args = _build_request_args(
|
|
69
|
+
body=body,
|
|
70
|
+
authorization=authorization,
|
|
71
|
+
x_api_key=x_api_key,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
response = await client.request(**request_args)
|
|
75
|
+
raise_for_status(response)
|
|
76
|
+
return WorkOrderResponse.model_validate(response.json())
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Create Work Order Item"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import CreateWorkOrderItemRequest, WorkOrderItemResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
public_id: str,
|
|
15
|
+
body: CreateWorkOrderItemRequest,
|
|
16
|
+
authorization: str | None = None,
|
|
17
|
+
x_api_key: str | None = None,
|
|
18
|
+
) -> dict[str, Any]:
|
|
19
|
+
"""Build request arguments."""
|
|
20
|
+
url = f"/api/v2/work-orders/{public_id}/items"
|
|
21
|
+
|
|
22
|
+
headers: dict[str, str] = {}
|
|
23
|
+
if authorization is not None:
|
|
24
|
+
headers["authorization"] = authorization
|
|
25
|
+
if x_api_key is not None:
|
|
26
|
+
headers["X-API-Key"] = x_api_key
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
"method": "POST",
|
|
30
|
+
"url": url,
|
|
31
|
+
"json": body.model_dump(mode="json", exclude_none=True),
|
|
32
|
+
"headers": headers,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def sync(
|
|
37
|
+
client: httpx.Client,
|
|
38
|
+
public_id: str,
|
|
39
|
+
body: CreateWorkOrderItemRequest,
|
|
40
|
+
authorization: str | None = None,
|
|
41
|
+
x_api_key: str | None = None,
|
|
42
|
+
) -> WorkOrderItemResponse:
|
|
43
|
+
"""Create a new work order item.
|
|
44
|
+
|
|
45
|
+
Users can only add items to work orders belonging to their organization.
|
|
46
|
+
Admins can add items to any work order."""
|
|
47
|
+
|
|
48
|
+
request_args = _build_request_args(
|
|
49
|
+
public_id=public_id,
|
|
50
|
+
body=body,
|
|
51
|
+
authorization=authorization,
|
|
52
|
+
x_api_key=x_api_key,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
response = client.request(**request_args)
|
|
56
|
+
raise_for_status(response)
|
|
57
|
+
return WorkOrderItemResponse.model_validate(response.json())
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def asyncio(
|
|
61
|
+
client: httpx.AsyncClient,
|
|
62
|
+
public_id: str,
|
|
63
|
+
body: CreateWorkOrderItemRequest,
|
|
64
|
+
authorization: str | None = None,
|
|
65
|
+
x_api_key: str | None = None,
|
|
66
|
+
) -> WorkOrderItemResponse:
|
|
67
|
+
"""Create a new work order item.
|
|
68
|
+
|
|
69
|
+
Users can only add items to work orders belonging to their organization.
|
|
70
|
+
Admins can add items to any work order."""
|
|
71
|
+
|
|
72
|
+
request_args = _build_request_args(
|
|
73
|
+
public_id=public_id,
|
|
74
|
+
body=body,
|
|
75
|
+
authorization=authorization,
|
|
76
|
+
x_api_key=x_api_key,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
response = await client.request(**request_args)
|
|
80
|
+
raise_for_status(response)
|
|
81
|
+
return WorkOrderItemResponse.model_validate(response.json())
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Get Work Order"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import WorkOrderWithItemsResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
public_id: str,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = f"/api/v2/work-orders/{public_id}"
|
|
20
|
+
|
|
21
|
+
headers: dict[str, str] = {}
|
|
22
|
+
if authorization is not None:
|
|
23
|
+
headers["authorization"] = authorization
|
|
24
|
+
if x_api_key is not None:
|
|
25
|
+
headers["X-API-Key"] = x_api_key
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
"method": "GET",
|
|
29
|
+
"url": url,
|
|
30
|
+
"headers": headers,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def sync(
|
|
35
|
+
client: httpx.Client,
|
|
36
|
+
public_id: str,
|
|
37
|
+
authorization: str | None = None,
|
|
38
|
+
x_api_key: str | None = None,
|
|
39
|
+
) -> WorkOrderWithItemsResponse:
|
|
40
|
+
"""Get a work order with its items and testcase statuses.
|
|
41
|
+
|
|
42
|
+
Users can only view work orders belonging to their organization.
|
|
43
|
+
Admins can view any work order."""
|
|
44
|
+
|
|
45
|
+
request_args = _build_request_args(
|
|
46
|
+
public_id=public_id,
|
|
47
|
+
authorization=authorization,
|
|
48
|
+
x_api_key=x_api_key,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
response = client.request(**request_args)
|
|
52
|
+
raise_for_status(response)
|
|
53
|
+
return WorkOrderWithItemsResponse.model_validate(response.json())
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
async def asyncio(
|
|
57
|
+
client: httpx.AsyncClient,
|
|
58
|
+
public_id: str,
|
|
59
|
+
authorization: str | None = None,
|
|
60
|
+
x_api_key: str | None = None,
|
|
61
|
+
) -> WorkOrderWithItemsResponse:
|
|
62
|
+
"""Get a work order with its items and testcase statuses.
|
|
63
|
+
|
|
64
|
+
Users can only view work orders belonging to their organization.
|
|
65
|
+
Admins can view any work order."""
|
|
66
|
+
|
|
67
|
+
request_args = _build_request_args(
|
|
68
|
+
public_id=public_id,
|
|
69
|
+
authorization=authorization,
|
|
70
|
+
x_api_key=x_api_key,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
response = await client.request(**request_args)
|
|
74
|
+
raise_for_status(response)
|
|
75
|
+
return WorkOrderWithItemsResponse.model_validate(response.json())
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""List Work Orders"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from plato._generated.errors import raise_for_status
|
|
10
|
+
from plato._generated.models import WorkOrderResponse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _build_request_args(
|
|
14
|
+
organization_id: int | None = None,
|
|
15
|
+
authorization: str | None = None,
|
|
16
|
+
x_api_key: str | None = None,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
"""Build request arguments."""
|
|
19
|
+
url = "/api/v2/work-orders"
|
|
20
|
+
|
|
21
|
+
params: dict[str, Any] = {}
|
|
22
|
+
if organization_id is not None:
|
|
23
|
+
params["organization_id"] = organization_id
|
|
24
|
+
|
|
25
|
+
headers: dict[str, str] = {}
|
|
26
|
+
if authorization is not None:
|
|
27
|
+
headers["authorization"] = authorization
|
|
28
|
+
if x_api_key is not None:
|
|
29
|
+
headers["X-API-Key"] = x_api_key
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
"method": "GET",
|
|
33
|
+
"url": url,
|
|
34
|
+
"params": params,
|
|
35
|
+
"headers": headers,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def sync(
|
|
40
|
+
client: httpx.Client,
|
|
41
|
+
organization_id: int | None = None,
|
|
42
|
+
authorization: str | None = None,
|
|
43
|
+
x_api_key: str | None = None,
|
|
44
|
+
) -> list[WorkOrderResponse]:
|
|
45
|
+
"""List work orders.
|
|
46
|
+
|
|
47
|
+
Admins can see all work orders or filter by org_id.
|
|
48
|
+
Non-admins see only their org's work orders."""
|
|
49
|
+
|
|
50
|
+
request_args = _build_request_args(
|
|
51
|
+
organization_id=organization_id,
|
|
52
|
+
authorization=authorization,
|
|
53
|
+
x_api_key=x_api_key,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
response = client.request(**request_args)
|
|
57
|
+
raise_for_status(response)
|
|
58
|
+
return response.json()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
async def asyncio(
|
|
62
|
+
client: httpx.AsyncClient,
|
|
63
|
+
organization_id: int | None = None,
|
|
64
|
+
authorization: str | None = None,
|
|
65
|
+
x_api_key: str | None = None,
|
|
66
|
+
) -> list[WorkOrderResponse]:
|
|
67
|
+
"""List work orders.
|
|
68
|
+
|
|
69
|
+
Admins can see all work orders or filter by org_id.
|
|
70
|
+
Non-admins see only their org's work orders."""
|
|
71
|
+
|
|
72
|
+
request_args = _build_request_args(
|
|
73
|
+
organization_id=organization_id,
|
|
74
|
+
authorization=authorization,
|
|
75
|
+
x_api_key=x_api_key,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
response = await client.request(**request_args)
|
|
79
|
+
raise_for_status(response)
|
|
80
|
+
return response.json()
|