jama-cli 0.1.2__tar.gz → 0.1.4__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.
- {jama_cli-0.1.2 → jama_cli-0.1.4}/PKG-INFO +3 -2
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/__init__.py +1 -1
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/attachments.py +1 -6
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/config_cmd.py +1 -6
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/config.py +37 -34
- jama_cli-0.1.4/jama_cli/core/api.py +422 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/core/client.py +94 -105
- jama_cli-0.1.4/jama_cli/core/exceptions.py +58 -0
- jama_cli-0.1.4/jama_cli/core/http_client.py +286 -0
- jama_cli-0.1.4/jama_cli/core/sync_wrapper.py +305 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_mcp_server/__init__.py +1 -1
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_mcp_server/core/server.py +1 -2
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_mcp_server/core/stdio_server.py +230 -118
- {jama_cli-0.1.2 → jama_cli-0.1.4}/pyproject.toml +7 -5
- {jama_cli-0.1.2 → jama_cli-0.1.4}/LICENSE +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/NOTICE +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/README.md +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/__init__.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/baseline.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/diff.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/history.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/items.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/migrate.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/picklists.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/projects.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/relationships.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/search.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/serve.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/tags.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/tests.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/trace.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/types.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/commands/users.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/core/__init__.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/main.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/models/__init__.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/output/__init__.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/output/console.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/output/formatters.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_cli/py.typed +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_mcp_server/api/__init__.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_mcp_server/api/client.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_mcp_server/config.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_mcp_server/core/__init__.py +0 -0
- {jama_cli-0.1.2 → jama_cli-0.1.4}/jama_mcp_server/models/__init__.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jama-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Command-line interface for Jama requirements management with MCP server support
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
License-File: NOTICE
|
|
8
8
|
Keywords: jama,cli,mcp,model-context-protocol,requirements-management,api
|
|
9
9
|
Author: Christian Nennemann
|
|
10
|
-
Author-email:
|
|
10
|
+
Author-email: contact@nennemann.de
|
|
11
11
|
Requires-Python: >=3.10,<4.0
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Environment :: Console
|
|
@@ -25,6 +25,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
25
25
|
Classifier: Typing :: Typed
|
|
26
26
|
Requires-Dist: aiohttp (>=3.9.0,<4.0.0)
|
|
27
27
|
Requires-Dist: aiohttp-swagger3 (>=0.8.0,<0.9.0)
|
|
28
|
+
Requires-Dist: httpx (>=0.27.0)
|
|
28
29
|
Requires-Dist: jsonschema (>=4.19.0,<5.0.0)
|
|
29
30
|
Requires-Dist: loguru (>=0.7.0,<0.8.0)
|
|
30
31
|
Requires-Dist: mcp (>=1.0.0,<2.0.0)
|
|
@@ -9,12 +9,7 @@ import typer
|
|
|
9
9
|
|
|
10
10
|
from jama_cli.config import get_profile_or_env
|
|
11
11
|
from jama_cli.core.client import JamaClient
|
|
12
|
-
from jama_cli.output import
|
|
13
|
-
OutputFormat,
|
|
14
|
-
format_single_item,
|
|
15
|
-
print_error,
|
|
16
|
-
print_success,
|
|
17
|
-
)
|
|
12
|
+
from jama_cli.output import OutputFormat, format_single_item, print_error, print_success
|
|
18
13
|
|
|
19
14
|
app = typer.Typer(name="attachments", help="Manage item attachments")
|
|
20
15
|
|
|
@@ -7,12 +7,7 @@ from typing import Annotated
|
|
|
7
7
|
import typer
|
|
8
8
|
from rich.table import Table
|
|
9
9
|
|
|
10
|
-
from jama_cli.config import
|
|
11
|
-
CONFIG_FILE,
|
|
12
|
-
get_config_path,
|
|
13
|
-
load_config,
|
|
14
|
-
save_config,
|
|
15
|
-
)
|
|
10
|
+
from jama_cli.config import CONFIG_FILE, get_config_path, load_config, save_config
|
|
16
11
|
from jama_cli.models import JamaProfile
|
|
17
12
|
from jama_cli.output import console, print_error, print_success
|
|
18
13
|
|
|
@@ -148,43 +148,46 @@ def get_profile(profile_name: str | None = None) -> JamaProfile | None:
|
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
def get_profile_or_env(profile_name: str | None = None) -> JamaProfile | None:
|
|
151
|
-
"""Get a profile
|
|
151
|
+
"""Get a profile from environment variables, or fall back to config file.
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
Environment variables take precedence over the config file when JAMA_URL
|
|
154
|
+
is set, following the standard convention (like AWS_ACCESS_KEY_ID overriding
|
|
155
|
+
~/.aws/credentials). This is critical for MCP server usage where mcp.json
|
|
156
|
+
passes credentials as env vars.
|
|
154
157
|
"""
|
|
155
|
-
#
|
|
158
|
+
# Check environment variables first (they take precedence)
|
|
159
|
+
jama_url = os.environ.get("JAMA_URL")
|
|
160
|
+
if jama_url:
|
|
161
|
+
api_key = os.environ.get("JAMA_API_KEY")
|
|
162
|
+
client_id = os.environ.get("JAMA_CLIENT_ID")
|
|
163
|
+
client_secret = os.environ.get("JAMA_CLIENT_SECRET")
|
|
164
|
+
username = os.environ.get("JAMA_USERNAME")
|
|
165
|
+
password = os.environ.get("JAMA_PASSWORD")
|
|
166
|
+
|
|
167
|
+
# Determine auth type
|
|
168
|
+
if api_key:
|
|
169
|
+
auth_type = "api_key"
|
|
170
|
+
elif client_id and client_secret:
|
|
171
|
+
auth_type = "oauth"
|
|
172
|
+
elif username and password:
|
|
173
|
+
auth_type = "basic"
|
|
174
|
+
else:
|
|
175
|
+
auth_type = None
|
|
176
|
+
|
|
177
|
+
if auth_type:
|
|
178
|
+
return JamaProfile(
|
|
179
|
+
url=jama_url,
|
|
180
|
+
auth_type=auth_type,
|
|
181
|
+
api_key=api_key,
|
|
182
|
+
client_id=client_id,
|
|
183
|
+
client_secret=client_secret,
|
|
184
|
+
username=username,
|
|
185
|
+
password=password,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
# Fall back to config file
|
|
156
189
|
profile = get_profile(profile_name)
|
|
157
190
|
if profile and profile.has_valid_credentials():
|
|
158
191
|
return profile
|
|
159
192
|
|
|
160
|
-
|
|
161
|
-
jama_url = os.environ.get("JAMA_URL")
|
|
162
|
-
if not jama_url:
|
|
163
|
-
return profile # Return config profile even if invalid
|
|
164
|
-
|
|
165
|
-
# Create profile from env vars
|
|
166
|
-
api_key = os.environ.get("JAMA_API_KEY")
|
|
167
|
-
client_id = os.environ.get("JAMA_CLIENT_ID")
|
|
168
|
-
client_secret = os.environ.get("JAMA_CLIENT_SECRET")
|
|
169
|
-
username = os.environ.get("JAMA_USERNAME")
|
|
170
|
-
password = os.environ.get("JAMA_PASSWORD")
|
|
171
|
-
|
|
172
|
-
# Determine auth type
|
|
173
|
-
if api_key:
|
|
174
|
-
auth_type = "api_key"
|
|
175
|
-
elif client_id and client_secret:
|
|
176
|
-
auth_type = "oauth"
|
|
177
|
-
elif username and password:
|
|
178
|
-
auth_type = "basic"
|
|
179
|
-
else:
|
|
180
|
-
return profile
|
|
181
|
-
|
|
182
|
-
return JamaProfile(
|
|
183
|
-
url=jama_url,
|
|
184
|
-
auth_type=auth_type,
|
|
185
|
-
api_key=api_key,
|
|
186
|
-
client_id=client_id,
|
|
187
|
-
client_secret=client_secret,
|
|
188
|
-
username=username,
|
|
189
|
-
password=password,
|
|
190
|
-
)
|
|
193
|
+
return profile
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
"""Typed async API methods for the Jama REST API.
|
|
2
|
+
|
|
3
|
+
Thin layer over JamaHttpClient that maps Jama domain operations to HTTP calls.
|
|
4
|
+
Replaces all ~60 methods from py_jama_rest_client.client.JamaClient.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any, cast
|
|
10
|
+
|
|
11
|
+
from jama_cli.core.http_client import JamaHttpClient
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _data(resp: dict[str, Any]) -> dict[str, Any]:
|
|
15
|
+
"""Extract 'data' from a Jama API response envelope."""
|
|
16
|
+
return cast(dict[str, Any], resp.get("data", resp))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _id(resp: dict[str, Any]) -> int:
|
|
20
|
+
"""Extract the created resource ID from a Jama API response."""
|
|
21
|
+
return int(resp["meta"]["id"])
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _status(resp: dict[str, Any]) -> int:
|
|
25
|
+
"""Extract the status code from a Jama API response."""
|
|
26
|
+
return int(resp.get("meta", {}).get("status", 200))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class JamaApi:
|
|
30
|
+
"""Async Jama REST API with typed methods."""
|
|
31
|
+
|
|
32
|
+
def __init__(self, http: JamaHttpClient) -> None:
|
|
33
|
+
self._http = http
|
|
34
|
+
|
|
35
|
+
# =========================================================================
|
|
36
|
+
# Projects
|
|
37
|
+
# =========================================================================
|
|
38
|
+
|
|
39
|
+
async def get_projects(self) -> list[dict[str, Any]]:
|
|
40
|
+
"""Get all accessible projects."""
|
|
41
|
+
return await self._http.get_all("projects")
|
|
42
|
+
|
|
43
|
+
async def get_project(self, project_id: int) -> dict[str, Any]:
|
|
44
|
+
"""Get a specific project by ID."""
|
|
45
|
+
data = await self._http.get(f"projects/{project_id}")
|
|
46
|
+
return _data(data)
|
|
47
|
+
|
|
48
|
+
# =========================================================================
|
|
49
|
+
# Items
|
|
50
|
+
# =========================================================================
|
|
51
|
+
|
|
52
|
+
async def get_items(self, project_id: int) -> list[dict[str, Any]]:
|
|
53
|
+
"""Get all items in a project."""
|
|
54
|
+
return await self._http.get_all("items", params={"project": project_id})
|
|
55
|
+
|
|
56
|
+
async def get_items_page(
|
|
57
|
+
self,
|
|
58
|
+
project_id: int,
|
|
59
|
+
start_at: int = 0,
|
|
60
|
+
max_results: int = 50,
|
|
61
|
+
) -> list[dict[str, Any]]:
|
|
62
|
+
"""Get a single page of items (faster than fetching all)."""
|
|
63
|
+
return await self._http.get_page(
|
|
64
|
+
"items",
|
|
65
|
+
params={"project": project_id},
|
|
66
|
+
start_at=start_at,
|
|
67
|
+
max_results=max_results,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
async def get_item(self, item_id: int) -> dict[str, Any]:
|
|
71
|
+
"""Get a specific item by ID."""
|
|
72
|
+
data = await self._http.get(f"items/{item_id}")
|
|
73
|
+
return _data(data)
|
|
74
|
+
|
|
75
|
+
async def get_item_children(self, item_id: int) -> list[dict[str, Any]]:
|
|
76
|
+
"""Get children of an item."""
|
|
77
|
+
return await self._http.get_all(f"items/{item_id}/children")
|
|
78
|
+
|
|
79
|
+
async def get_abstract_items(
|
|
80
|
+
self,
|
|
81
|
+
project: int | None = None,
|
|
82
|
+
item_type: int | None = None,
|
|
83
|
+
contains: str | None = None,
|
|
84
|
+
) -> list[dict[str, Any]]:
|
|
85
|
+
"""Get abstract items with optional filters."""
|
|
86
|
+
params: dict[str, Any] = {}
|
|
87
|
+
if project is not None:
|
|
88
|
+
params["project"] = project
|
|
89
|
+
if item_type is not None:
|
|
90
|
+
params["itemType"] = item_type
|
|
91
|
+
if contains is not None:
|
|
92
|
+
params["contains"] = contains
|
|
93
|
+
return await self._http.get_all("abstractitems", params=params)
|
|
94
|
+
|
|
95
|
+
async def post_item(
|
|
96
|
+
self,
|
|
97
|
+
project: int,
|
|
98
|
+
item_type_id: int,
|
|
99
|
+
child_item_type_id: int | None,
|
|
100
|
+
location: dict[str, Any],
|
|
101
|
+
fields: dict[str, Any],
|
|
102
|
+
global_id: str | None = None,
|
|
103
|
+
) -> int:
|
|
104
|
+
"""Create a new item. Returns the created item ID."""
|
|
105
|
+
body: dict[str, Any] = {
|
|
106
|
+
"project": project,
|
|
107
|
+
"itemType": item_type_id,
|
|
108
|
+
"location": {"parent": location},
|
|
109
|
+
"fields": fields,
|
|
110
|
+
}
|
|
111
|
+
if child_item_type_id is not None:
|
|
112
|
+
body["childItemType"] = child_item_type_id
|
|
113
|
+
if global_id is not None:
|
|
114
|
+
body["globalId"] = global_id
|
|
115
|
+
resp = await self._http.post("items", json=body)
|
|
116
|
+
return _id(resp)
|
|
117
|
+
|
|
118
|
+
async def patch_item(self, item_id: int, patches: list[dict[str, Any]]) -> int:
|
|
119
|
+
"""Update an item using JSON Patch operations."""
|
|
120
|
+
resp = await self._http.patch(f"items/{item_id}", json=patches)
|
|
121
|
+
return _status(resp)
|
|
122
|
+
|
|
123
|
+
async def put_item(
|
|
124
|
+
self,
|
|
125
|
+
project: int,
|
|
126
|
+
item_id: int,
|
|
127
|
+
item_type_id: int,
|
|
128
|
+
child_item_type_id: int | None,
|
|
129
|
+
location: dict[str, Any],
|
|
130
|
+
fields: dict[str, Any],
|
|
131
|
+
) -> int:
|
|
132
|
+
"""Replace an item entirely."""
|
|
133
|
+
body: dict[str, Any] = {
|
|
134
|
+
"project": project,
|
|
135
|
+
"itemType": item_type_id,
|
|
136
|
+
"location": {"parent": location},
|
|
137
|
+
"fields": fields,
|
|
138
|
+
}
|
|
139
|
+
if child_item_type_id is not None:
|
|
140
|
+
body["childItemType"] = child_item_type_id
|
|
141
|
+
resp = await self._http.put(f"items/{item_id}", json=body)
|
|
142
|
+
return _status(resp)
|
|
143
|
+
|
|
144
|
+
async def delete_item(self, item_id: int) -> int:
|
|
145
|
+
"""Delete an item."""
|
|
146
|
+
resp = await self._http.delete(f"items/{item_id}")
|
|
147
|
+
return _status(resp)
|
|
148
|
+
|
|
149
|
+
# =========================================================================
|
|
150
|
+
# Item Versions
|
|
151
|
+
# =========================================================================
|
|
152
|
+
|
|
153
|
+
async def get_item_versions(self, item_id: int) -> list[dict[str, Any]]:
|
|
154
|
+
"""Get version history for an item."""
|
|
155
|
+
return await self._http.get_all(f"items/{item_id}/versions")
|
|
156
|
+
|
|
157
|
+
async def get_item_version(self, item_id: int, version_num: int) -> dict[str, Any]:
|
|
158
|
+
"""Get a specific version of an item."""
|
|
159
|
+
data = await self._http.get(f"items/{item_id}/versions/{version_num}")
|
|
160
|
+
return _data(data)
|
|
161
|
+
|
|
162
|
+
# =========================================================================
|
|
163
|
+
# Relationships
|
|
164
|
+
# =========================================================================
|
|
165
|
+
|
|
166
|
+
async def get_relationships(self, project_id: int) -> list[dict[str, Any]]:
|
|
167
|
+
"""Get all relationships in a project."""
|
|
168
|
+
return await self._http.get_all("relationships", params={"project": project_id})
|
|
169
|
+
|
|
170
|
+
async def get_relationship(self, relationship_id: int) -> dict[str, Any]:
|
|
171
|
+
"""Get a specific relationship."""
|
|
172
|
+
data = await self._http.get(f"relationships/{relationship_id}")
|
|
173
|
+
return _data(data)
|
|
174
|
+
|
|
175
|
+
async def get_items_upstream_relationships(self, item_id: int) -> list[dict[str, Any]]:
|
|
176
|
+
"""Get upstream relationships for an item."""
|
|
177
|
+
return await self._http.get_all(f"items/{item_id}/upstreamrelationships")
|
|
178
|
+
|
|
179
|
+
async def get_items_downstream_relationships(self, item_id: int) -> list[dict[str, Any]]:
|
|
180
|
+
"""Get downstream relationships for an item."""
|
|
181
|
+
return await self._http.get_all(f"items/{item_id}/downstreamrelationships")
|
|
182
|
+
|
|
183
|
+
async def get_items_upstream_related(self, item_id: int) -> list[dict[str, Any]]:
|
|
184
|
+
"""Get upstream related items."""
|
|
185
|
+
return await self._http.get_all(f"items/{item_id}/upstreamrelated")
|
|
186
|
+
|
|
187
|
+
async def get_items_downstream_related(self, item_id: int) -> list[dict[str, Any]]:
|
|
188
|
+
"""Get downstream related items."""
|
|
189
|
+
return await self._http.get_all(f"items/{item_id}/downstreamrelated")
|
|
190
|
+
|
|
191
|
+
async def post_relationship(
|
|
192
|
+
self,
|
|
193
|
+
from_item: int,
|
|
194
|
+
to_item: int,
|
|
195
|
+
relationship_type: int | None = None,
|
|
196
|
+
) -> int:
|
|
197
|
+
"""Create a relationship between items. Returns relationship ID."""
|
|
198
|
+
body: dict[str, Any] = {"fromItem": from_item, "toItem": to_item}
|
|
199
|
+
if relationship_type is not None:
|
|
200
|
+
body["relationshipType"] = relationship_type
|
|
201
|
+
resp = await self._http.post("relationships", json=body)
|
|
202
|
+
return _id(resp)
|
|
203
|
+
|
|
204
|
+
async def delete_relationship(self, relationship_id: int) -> int:
|
|
205
|
+
"""Delete a relationship."""
|
|
206
|
+
resp = await self._http.delete(f"relationships/{relationship_id}")
|
|
207
|
+
return _status(resp)
|
|
208
|
+
|
|
209
|
+
# =========================================================================
|
|
210
|
+
# Relationship Types
|
|
211
|
+
# =========================================================================
|
|
212
|
+
|
|
213
|
+
async def get_relationship_types(self) -> list[dict[str, Any]]:
|
|
214
|
+
"""Get all relationship types."""
|
|
215
|
+
return await self._http.get_all("relationshiptypes")
|
|
216
|
+
|
|
217
|
+
async def get_relationship_type(self, relationship_type_id: int) -> dict[str, Any]:
|
|
218
|
+
"""Get a specific relationship type."""
|
|
219
|
+
data = await self._http.get(f"relationshiptypes/{relationship_type_id}")
|
|
220
|
+
return _data(data)
|
|
221
|
+
|
|
222
|
+
# =========================================================================
|
|
223
|
+
# Item Types
|
|
224
|
+
# =========================================================================
|
|
225
|
+
|
|
226
|
+
async def get_item_types(self) -> list[dict[str, Any]]:
|
|
227
|
+
"""Get all item types."""
|
|
228
|
+
return await self._http.get_all("itemtypes")
|
|
229
|
+
|
|
230
|
+
async def get_item_type(self, item_type_id: int) -> dict[str, Any]:
|
|
231
|
+
"""Get a specific item type."""
|
|
232
|
+
data = await self._http.get(f"itemtypes/{item_type_id}")
|
|
233
|
+
return _data(data)
|
|
234
|
+
|
|
235
|
+
# =========================================================================
|
|
236
|
+
# Pick Lists
|
|
237
|
+
# =========================================================================
|
|
238
|
+
|
|
239
|
+
async def get_pick_lists(self) -> list[dict[str, Any]]:
|
|
240
|
+
"""Get all pick lists (global, not project-specific)."""
|
|
241
|
+
return await self._http.get_all("picklists")
|
|
242
|
+
|
|
243
|
+
async def get_pick_list(self, pick_list_id: int) -> dict[str, Any]:
|
|
244
|
+
"""Get a specific pick list."""
|
|
245
|
+
data = await self._http.get(f"picklists/{pick_list_id}")
|
|
246
|
+
return _data(data)
|
|
247
|
+
|
|
248
|
+
async def get_pick_list_options(self, pick_list_id: int) -> list[dict[str, Any]]:
|
|
249
|
+
"""Get options for a pick list."""
|
|
250
|
+
return await self._http.get_all(f"picklists/{pick_list_id}/options")
|
|
251
|
+
|
|
252
|
+
# =========================================================================
|
|
253
|
+
# Tags
|
|
254
|
+
# =========================================================================
|
|
255
|
+
|
|
256
|
+
async def get_tags(self, project_id: int) -> list[dict[str, Any]]:
|
|
257
|
+
"""Get all tags in a project."""
|
|
258
|
+
return await self._http.get_all("tags", params={"project": project_id})
|
|
259
|
+
|
|
260
|
+
async def get_tagged_items(self, tag_id: int) -> list[dict[str, Any]]:
|
|
261
|
+
"""Get items with a specific tag."""
|
|
262
|
+
return await self._http.get_all(f"tags/{tag_id}/items")
|
|
263
|
+
|
|
264
|
+
async def get_item_tags(self, item_id: int) -> list[dict[str, Any]]:
|
|
265
|
+
"""Get tags for an item."""
|
|
266
|
+
return await self._http.get_all(f"items/{item_id}/tags")
|
|
267
|
+
|
|
268
|
+
async def post_item_tag(self, item_id: int, tag_id: int) -> int:
|
|
269
|
+
"""Add a tag to an item."""
|
|
270
|
+
resp = await self._http.post(f"items/{item_id}/tags", json={"tag": tag_id})
|
|
271
|
+
return _status(resp)
|
|
272
|
+
|
|
273
|
+
async def post_tag(self, name: str, project: int) -> int:
|
|
274
|
+
"""Create a new tag."""
|
|
275
|
+
resp = await self._http.post("tags", json={"name": name, "project": project})
|
|
276
|
+
return _id(resp)
|
|
277
|
+
|
|
278
|
+
# =========================================================================
|
|
279
|
+
# Tests
|
|
280
|
+
# =========================================================================
|
|
281
|
+
|
|
282
|
+
async def get_test_cycle(self, test_cycle_id: int) -> dict[str, Any]:
|
|
283
|
+
"""Get a specific test cycle."""
|
|
284
|
+
data = await self._http.get(f"testcycles/{test_cycle_id}")
|
|
285
|
+
return _data(data)
|
|
286
|
+
|
|
287
|
+
async def get_testruns(self, test_cycle_id: int) -> list[dict[str, Any]]:
|
|
288
|
+
"""Get test runs for a test cycle."""
|
|
289
|
+
return await self._http.get_all(f"testcycles/{test_cycle_id}/testruns")
|
|
290
|
+
|
|
291
|
+
async def create_test_plan(
|
|
292
|
+
self,
|
|
293
|
+
project_id: int,
|
|
294
|
+
name: str,
|
|
295
|
+
description: str | None = None,
|
|
296
|
+
start_date: str | None = None,
|
|
297
|
+
end_date: str | None = None,
|
|
298
|
+
) -> int:
|
|
299
|
+
"""Create a new test plan. Returns the test plan ID."""
|
|
300
|
+
fields: dict[str, Any] = {"name": name}
|
|
301
|
+
if description is not None:
|
|
302
|
+
fields["description"] = description
|
|
303
|
+
if start_date is not None:
|
|
304
|
+
fields["startDate"] = start_date
|
|
305
|
+
if end_date is not None:
|
|
306
|
+
fields["endDate"] = end_date
|
|
307
|
+
resp = await self._http.post("testplans", json={"project": project_id, "fields": fields})
|
|
308
|
+
return _id(resp)
|
|
309
|
+
|
|
310
|
+
async def post_testplans_testcycles(
|
|
311
|
+
self,
|
|
312
|
+
testplan_id: int,
|
|
313
|
+
testcycle_name: str,
|
|
314
|
+
start_date: str,
|
|
315
|
+
end_date: str,
|
|
316
|
+
testgroups_to_include: list[int] | None = None,
|
|
317
|
+
testrun_status_to_include: list[str] | None = None,
|
|
318
|
+
) -> int:
|
|
319
|
+
"""Create a test cycle under a test plan. Returns test cycle ID."""
|
|
320
|
+
body: dict[str, Any] = {
|
|
321
|
+
"fields": {"name": testcycle_name, "startDate": start_date, "endDate": end_date},
|
|
322
|
+
}
|
|
323
|
+
if testgroups_to_include is not None:
|
|
324
|
+
body["testGroupsToInclude"] = testgroups_to_include
|
|
325
|
+
if testrun_status_to_include is not None:
|
|
326
|
+
body["testRunStatusToInclude"] = testrun_status_to_include
|
|
327
|
+
resp = await self._http.post(f"testplans/{testplan_id}/testcycles", json=body)
|
|
328
|
+
return _id(resp)
|
|
329
|
+
|
|
330
|
+
async def put_test_run(self, test_run_id: int, data: dict[str, Any] | None = None) -> int:
|
|
331
|
+
"""Update a test run."""
|
|
332
|
+
resp = await self._http.put(f"testruns/{test_run_id}", json=data or {})
|
|
333
|
+
return _status(resp)
|
|
334
|
+
|
|
335
|
+
# =========================================================================
|
|
336
|
+
# Baselines
|
|
337
|
+
# =========================================================================
|
|
338
|
+
|
|
339
|
+
async def get_baselines(self, project_id: int) -> list[dict[str, Any]]:
|
|
340
|
+
"""Get all baselines for a project."""
|
|
341
|
+
return await self._http.get_all("baselines", params={"project": project_id})
|
|
342
|
+
|
|
343
|
+
async def get_baseline(self, baseline_id: int) -> dict[str, Any]:
|
|
344
|
+
"""Get a specific baseline."""
|
|
345
|
+
data = await self._http.get(f"baselines/{baseline_id}")
|
|
346
|
+
return _data(data)
|
|
347
|
+
|
|
348
|
+
async def get_baselines_versioneditems(self, baseline_id: int) -> list[dict[str, Any]]:
|
|
349
|
+
"""Get versioned items in a baseline."""
|
|
350
|
+
return await self._http.get_all(f"baselines/{baseline_id}/versioneditems")
|
|
351
|
+
|
|
352
|
+
# =========================================================================
|
|
353
|
+
# Users
|
|
354
|
+
# =========================================================================
|
|
355
|
+
|
|
356
|
+
async def get_users(self) -> list[dict[str, Any]]:
|
|
357
|
+
"""Get all users."""
|
|
358
|
+
return await self._http.get_all("users")
|
|
359
|
+
|
|
360
|
+
async def get_user(self, user_id: int) -> dict[str, Any]:
|
|
361
|
+
"""Get a specific user."""
|
|
362
|
+
data = await self._http.get(f"users/{user_id}")
|
|
363
|
+
return _data(data)
|
|
364
|
+
|
|
365
|
+
async def get_current_user(self) -> dict[str, Any]:
|
|
366
|
+
"""Get the current authenticated user."""
|
|
367
|
+
data = await self._http.get("users/current")
|
|
368
|
+
return _data(data)
|
|
369
|
+
|
|
370
|
+
# =========================================================================
|
|
371
|
+
# Attachments
|
|
372
|
+
# =========================================================================
|
|
373
|
+
|
|
374
|
+
async def get_attachment(self, attachment_id: int) -> dict[str, Any]:
|
|
375
|
+
"""Get attachment metadata."""
|
|
376
|
+
data = await self._http.get(f"attachments/{attachment_id}")
|
|
377
|
+
return _data(data)
|
|
378
|
+
|
|
379
|
+
async def post_item_attachment(self, item_id: int, attachment_id: int) -> int:
|
|
380
|
+
"""Link an attachment to an item."""
|
|
381
|
+
resp = await self._http.post(
|
|
382
|
+
f"items/{item_id}/attachments", json={"attachment": attachment_id}
|
|
383
|
+
)
|
|
384
|
+
return _status(resp)
|
|
385
|
+
|
|
386
|
+
# =========================================================================
|
|
387
|
+
# Workflow
|
|
388
|
+
# =========================================================================
|
|
389
|
+
|
|
390
|
+
async def get_item_workflow_transitions(self, item_id: int) -> list[dict[str, Any]]:
|
|
391
|
+
"""Get available workflow transitions for an item."""
|
|
392
|
+
data = await self._http.get(f"items/{item_id}/workflowtransitionoptions")
|
|
393
|
+
return cast(list[dict[str, Any]], data.get("data", []))
|
|
394
|
+
|
|
395
|
+
# =========================================================================
|
|
396
|
+
# Filters
|
|
397
|
+
# =========================================================================
|
|
398
|
+
|
|
399
|
+
async def get_filter_results(
|
|
400
|
+
self,
|
|
401
|
+
filter_id: int,
|
|
402
|
+
project_id: int | None = None,
|
|
403
|
+
) -> list[dict[str, Any]]:
|
|
404
|
+
"""Execute a saved filter and get results."""
|
|
405
|
+
params: dict[str, Any] = {}
|
|
406
|
+
if project_id is not None:
|
|
407
|
+
params["project"] = project_id
|
|
408
|
+
return await self._http.get_all(f"filters/{filter_id}/results", params=params)
|
|
409
|
+
|
|
410
|
+
# =========================================================================
|
|
411
|
+
# Item Lock
|
|
412
|
+
# =========================================================================
|
|
413
|
+
|
|
414
|
+
async def get_item_lock(self, item_id: int) -> dict[str, Any]:
|
|
415
|
+
"""Get lock status for an item."""
|
|
416
|
+
data = await self._http.get(f"items/{item_id}/lock")
|
|
417
|
+
return _data(data)
|
|
418
|
+
|
|
419
|
+
async def put_item_lock(self, item_id: int, locked: bool) -> int:
|
|
420
|
+
"""Lock or unlock an item."""
|
|
421
|
+
resp = await self._http.put(f"items/{item_id}/lock", json={"locked": locked})
|
|
422
|
+
return _status(resp)
|