render-lab-tasks-jira 0.1.0__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.
- render_lab_tasks_jira/__init__.py +1 -0
- render_lab_tasks_jira/_app.py +3 -0
- render_lab_tasks_jira/add_attachment.py +18 -0
- render_lab_tasks_jira/assign_issue.py +18 -0
- render_lab_tasks_jira/client.py +244 -0
- render_lab_tasks_jira/comment.py +18 -0
- render_lab_tasks_jira/create_issue.py +18 -0
- render_lab_tasks_jira/get_issue.py +18 -0
- render_lab_tasks_jira/jql.py +18 -0
- render_lab_tasks_jira/link_issues.py +18 -0
- render_lab_tasks_jira/list_transitions.py +18 -0
- render_lab_tasks_jira/py.typed +0 -0
- render_lab_tasks_jira/retry.py +3 -0
- render_lab_tasks_jira/tasks.py +35 -0
- render_lab_tasks_jira/transition.py +18 -0
- render_lab_tasks_jira/types.py +117 -0
- render_lab_tasks_jira/update_issue.py +18 -0
- render_lab_tasks_jira-0.1.0.dist-info/METADATA +71 -0
- render_lab_tasks_jira-0.1.0.dist-info/RECORD +21 -0
- render_lab_tasks_jira-0.1.0.dist-info/WHEEL +4 -0
- render_lab_tasks_jira-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Import .tasks explicitly to register durable tasks."""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import AddAttachmentInput, AddAttachmentResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def add_attachment_impl(
|
|
10
|
+
ctx: TaskContext, input: AddAttachmentInput, *, deps: Deps | None = None
|
|
11
|
+
) -> AddAttachmentResult:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.add_attachment(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.addAttachment", retry=JIRA_RETRY)
|
|
17
|
+
async def add_attachment(ctx: TaskContext, input: AddAttachmentInput) -> AddAttachmentResult:
|
|
18
|
+
return await add_attachment_impl(ctx, input)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import AssignIssueInput, AssignIssueResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def assign_issue_impl(
|
|
10
|
+
ctx: TaskContext, input: AssignIssueInput, *, deps: Deps | None = None
|
|
11
|
+
) -> AssignIssueResult:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.assign_issue(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.assignIssue", retry=JIRA_RETRY)
|
|
17
|
+
async def assign_issue(ctx: TaskContext, input: AssignIssueInput) -> AssignIssueResult:
|
|
18
|
+
return await assign_issue_impl(ctx, input)
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"""Injected vendor interface and one-attempt async HTTP adapter."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import base64
|
|
6
|
+
import json
|
|
7
|
+
import math
|
|
8
|
+
import os
|
|
9
|
+
import uuid
|
|
10
|
+
from collections.abc import AsyncIterator, Mapping
|
|
11
|
+
from contextlib import asynccontextmanager
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import Any, Protocol
|
|
14
|
+
|
|
15
|
+
import httpx
|
|
16
|
+
from render_lab_tasks_core.http import HttpClient, enc, nullish, pick, required
|
|
17
|
+
|
|
18
|
+
from . import types as t
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def js_string(raw: Mapping[str, Any], key: str) -> str:
|
|
22
|
+
if key not in raw:
|
|
23
|
+
return "undefined"
|
|
24
|
+
if raw[key] is None:
|
|
25
|
+
return "null"
|
|
26
|
+
return str(raw[key])
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def text_to_adf(text: str) -> dict[str, Any]:
|
|
30
|
+
return {
|
|
31
|
+
"type": "doc",
|
|
32
|
+
"version": 1,
|
|
33
|
+
"content": [
|
|
34
|
+
{"type": "paragraph", "content": [{"type": "text", "text": line}] if line else []}
|
|
35
|
+
for line in text.split("\n")
|
|
36
|
+
],
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def to_issue(raw: Any, base: str) -> dict[str, Any]:
|
|
41
|
+
raw = raw or {}
|
|
42
|
+
key = js_string(raw, "key")
|
|
43
|
+
fields = raw.get("fields") or {}
|
|
44
|
+
return {
|
|
45
|
+
"key": key,
|
|
46
|
+
"summary": nullish(fields.get("summary"), ""),
|
|
47
|
+
"status": nullish((fields.get("status") or {}).get("name"), ""),
|
|
48
|
+
"assignee": (fields.get("assignee") or {}).get("displayName"),
|
|
49
|
+
"issueType": nullish((fields.get("issuetype") or {}).get("name"), ""),
|
|
50
|
+
"url": base + "/browse/" + key,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Port(Protocol):
|
|
55
|
+
async def add_attachment(self, input: t.AddAttachmentInput) -> t.AddAttachmentResult: ...
|
|
56
|
+
async def assign_issue(self, input: t.AssignIssueInput) -> t.AssignIssueResult: ...
|
|
57
|
+
async def comment(self, input: t.CommentInput) -> t.CommentResult: ...
|
|
58
|
+
async def create_issue(self, input: t.CreateIssueInput) -> t.CreateIssueResult: ...
|
|
59
|
+
async def get_issue(self, input: t.GetIssueInput) -> t.JiraIssueDetail: ...
|
|
60
|
+
async def jql(self, input: t.JqlInput) -> list[t.JiraIssue]: ...
|
|
61
|
+
async def link_issues(self, input: t.LinkIssuesInput) -> t.LinkIssuesResult: ...
|
|
62
|
+
async def list_transitions(self, input: t.ListTransitionsInput) -> list[t.JiraTransition]: ...
|
|
63
|
+
async def transition(self, input: t.TransitionInput) -> t.TransitionResult: ...
|
|
64
|
+
async def update_issue(self, input: t.UpdateIssueInput) -> t.UpdateIssueResult: ...
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@dataclass(frozen=True)
|
|
68
|
+
class Deps:
|
|
69
|
+
jira: Port
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class Client:
|
|
73
|
+
def __init__(self, http: httpx.AsyncClient, env: Mapping[str, str] | None = None) -> None:
|
|
74
|
+
self.env = os.environ if env is None else env
|
|
75
|
+
self.http = HttpClient(
|
|
76
|
+
http, lambda: self.base_url() + "/rest/api/3", auth=self._auth, label="Jira API"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
def base_url(self) -> str:
|
|
80
|
+
return required(self.env, "JIRA_BASE_URL").rstrip("/")
|
|
81
|
+
|
|
82
|
+
def _auth(self) -> dict[str, str]:
|
|
83
|
+
raw = required(self.env, "JIRA_EMAIL") + ":" + required(self.env, "JIRA_API_TOKEN")
|
|
84
|
+
return {
|
|
85
|
+
"authorization": "Basic " + base64.b64encode(raw.encode()).decode(),
|
|
86
|
+
"accept": "application/json",
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async def _json(self, path: str, **kwargs: Any) -> Any:
|
|
90
|
+
text = await self.http.call(path, response_type="text", **kwargs)
|
|
91
|
+
return json.loads(text) if text else {}
|
|
92
|
+
|
|
93
|
+
async def create_issue(self, input: t.CreateIssueInput) -> Any:
|
|
94
|
+
fields: dict[str, Any] = {
|
|
95
|
+
"project": {"key": input["projectKey"]},
|
|
96
|
+
"summary": input["summary"],
|
|
97
|
+
"issuetype": {"name": nullish(input.get("issueType"), "Task")},
|
|
98
|
+
}
|
|
99
|
+
if input.get("labels") is not None:
|
|
100
|
+
fields["labels"] = input["labels"]
|
|
101
|
+
if input.get("description"):
|
|
102
|
+
fields["description"] = text_to_adf(input["description"])
|
|
103
|
+
data = await self._json("/issue", method="POST", body={"fields": fields})
|
|
104
|
+
id = js_string(data, "id")
|
|
105
|
+
key = js_string(data, "key")
|
|
106
|
+
return {"id": id, "key": key, "url": self.base_url() + "/browse/" + key}
|
|
107
|
+
|
|
108
|
+
async def transition(self, input: t.TransitionInput) -> Any:
|
|
109
|
+
path = f"/issue/{enc(input['issueKey'])}/transitions"
|
|
110
|
+
data = await self._json(path)
|
|
111
|
+
match = next(
|
|
112
|
+
(
|
|
113
|
+
r
|
|
114
|
+
for r in nullish(data.get("transitions"), [])
|
|
115
|
+
if r["id"] == input["to"] or r["name"].lower() == input["to"].lower()
|
|
116
|
+
),
|
|
117
|
+
None,
|
|
118
|
+
)
|
|
119
|
+
await self.http.call(
|
|
120
|
+
path,
|
|
121
|
+
method="POST",
|
|
122
|
+
body={"transition": {"id": match["id"] if match is not None else input["to"]}},
|
|
123
|
+
response_type="text",
|
|
124
|
+
)
|
|
125
|
+
return pick(input, "issueKey", "to")
|
|
126
|
+
|
|
127
|
+
async def comment(self, input: t.CommentInput) -> Any:
|
|
128
|
+
data = await self._json(
|
|
129
|
+
f"/issue/{enc(input['issueKey'])}/comment",
|
|
130
|
+
method="POST",
|
|
131
|
+
body={"body": text_to_adf(input["body"])},
|
|
132
|
+
)
|
|
133
|
+
return {"issueKey": input["issueKey"], "commentId": js_string(data, "id")}
|
|
134
|
+
|
|
135
|
+
async def jql(self, input: t.JqlInput) -> Any:
|
|
136
|
+
limit = nullish(input.get("limit"), 50)
|
|
137
|
+
if (
|
|
138
|
+
isinstance(limit, bool)
|
|
139
|
+
or not isinstance(limit, (int, float))
|
|
140
|
+
or not math.isfinite(limit)
|
|
141
|
+
or limit < 0
|
|
142
|
+
or int(limit) != limit
|
|
143
|
+
):
|
|
144
|
+
raise ValueError("limit must be a non-negative integer")
|
|
145
|
+
if limit == 0:
|
|
146
|
+
return []
|
|
147
|
+
data = await self._json(
|
|
148
|
+
"/search/jql",
|
|
149
|
+
method="POST",
|
|
150
|
+
body={
|
|
151
|
+
"jql": input["jql"],
|
|
152
|
+
"maxResults": int(limit),
|
|
153
|
+
"fields": ["summary", "status"],
|
|
154
|
+
},
|
|
155
|
+
)
|
|
156
|
+
return [
|
|
157
|
+
pick(to_issue(r, self.base_url()), "key", "summary", "status", "url")
|
|
158
|
+
for r in nullish(data.get("issues"), [])
|
|
159
|
+
]
|
|
160
|
+
|
|
161
|
+
async def get_issue(self, input: t.GetIssueInput) -> Any:
|
|
162
|
+
return to_issue(await self._json(f"/issue/{enc(input['issueKey'])}"), self.base_url())
|
|
163
|
+
|
|
164
|
+
async def update_issue(self, input: t.UpdateIssueInput) -> Any:
|
|
165
|
+
await self.http.call(
|
|
166
|
+
f"/issue/{enc(input['issueKey'])}",
|
|
167
|
+
method="PUT",
|
|
168
|
+
body={"fields": input["fields"]},
|
|
169
|
+
response_type="text",
|
|
170
|
+
)
|
|
171
|
+
return {"key": input["issueKey"], "updated": True}
|
|
172
|
+
|
|
173
|
+
async def assign_issue(self, input: t.AssignIssueInput) -> Any:
|
|
174
|
+
await self.http.call(
|
|
175
|
+
f"/issue/{enc(input['issueKey'])}/assignee",
|
|
176
|
+
method="PUT",
|
|
177
|
+
body={"accountId": input["accountId"]},
|
|
178
|
+
response_type="text",
|
|
179
|
+
)
|
|
180
|
+
return {"key": input["issueKey"], "assigned": True}
|
|
181
|
+
|
|
182
|
+
async def list_transitions(self, input: t.ListTransitionsInput) -> Any:
|
|
183
|
+
data = await self._json(f"/issue/{enc(input['issueKey'])}/transitions")
|
|
184
|
+
return [
|
|
185
|
+
{
|
|
186
|
+
"id": js_string(r, "id"),
|
|
187
|
+
"name": js_string(r, "name"),
|
|
188
|
+
"toStatus": nullish((r.get("to") or {}).get("name"), ""),
|
|
189
|
+
}
|
|
190
|
+
for r in nullish(data.get("transitions"), [])
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
async def link_issues(self, input: t.LinkIssuesInput) -> Any:
|
|
194
|
+
await self.http.call(
|
|
195
|
+
"/issueLink",
|
|
196
|
+
method="POST",
|
|
197
|
+
body={
|
|
198
|
+
"type": {"name": input["type"]},
|
|
199
|
+
"inwardIssue": {"key": input["inwardIssue"]},
|
|
200
|
+
"outwardIssue": {"key": input["outwardIssue"]},
|
|
201
|
+
},
|
|
202
|
+
response_type="text",
|
|
203
|
+
)
|
|
204
|
+
return {"linked": True}
|
|
205
|
+
|
|
206
|
+
async def add_attachment(self, input: t.AddAttachmentInput) -> Any:
|
|
207
|
+
filename = input["filename"]
|
|
208
|
+
if any(c in filename for c in ("\r", "\n", '"')):
|
|
209
|
+
raise ValueError("filename must not contain CR, LF, or quotes")
|
|
210
|
+
boundary = "----renderTasksJira" + uuid.uuid4().hex
|
|
211
|
+
raw = (
|
|
212
|
+
f"--{boundary}\r\n"
|
|
213
|
+
f'Content-Disposition: form-data; name="file"; filename="{filename}"\r\n'
|
|
214
|
+
"Content-Type: application/octet-stream\r\n\r\n"
|
|
215
|
+
+ input["content"]
|
|
216
|
+
+ f"\r\n--{boundary}--\r\n"
|
|
217
|
+
)
|
|
218
|
+
data = await self.http.call(
|
|
219
|
+
f"/issue/{enc(input['issueKey'])}/attachments",
|
|
220
|
+
method="POST",
|
|
221
|
+
raw_body=raw,
|
|
222
|
+
headers={
|
|
223
|
+
"content-type": f"multipart/form-data; boundary={boundary}",
|
|
224
|
+
"X-Atlassian-Token": "no-check",
|
|
225
|
+
},
|
|
226
|
+
)
|
|
227
|
+
first = (data[0] if data else {}) if isinstance(data, list) else data or {}
|
|
228
|
+
return {"id": js_string(first, "id"), "filename": js_string(first, "filename")}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
@asynccontextmanager
|
|
232
|
+
async def dependencies(deps: Deps | None) -> AsyncIterator[Deps]:
|
|
233
|
+
if deps is not None:
|
|
234
|
+
yield deps
|
|
235
|
+
else:
|
|
236
|
+
async with httpx.AsyncClient(
|
|
237
|
+
timeout=30, transport=httpx.AsyncHTTPTransport(retries=0)
|
|
238
|
+
) as http:
|
|
239
|
+
yield Deps(jira=Client(http))
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
JiraPort = Port
|
|
243
|
+
JiraClient = Client
|
|
244
|
+
JiraDeps = Deps
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import CommentInput, CommentResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def comment_impl(
|
|
10
|
+
ctx: TaskContext, input: CommentInput, *, deps: Deps | None = None
|
|
11
|
+
) -> CommentResult:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.comment(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.comment", retry=JIRA_RETRY)
|
|
17
|
+
async def comment(ctx: TaskContext, input: CommentInput) -> CommentResult:
|
|
18
|
+
return await comment_impl(ctx, input)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import CreateIssueInput, CreateIssueResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def create_issue_impl(
|
|
10
|
+
ctx: TaskContext, input: CreateIssueInput, *, deps: Deps | None = None
|
|
11
|
+
) -> CreateIssueResult:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.create_issue(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.createIssue", retry=JIRA_RETRY)
|
|
17
|
+
async def create_issue(ctx: TaskContext, input: CreateIssueInput) -> CreateIssueResult:
|
|
18
|
+
return await create_issue_impl(ctx, input)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import GetIssueInput, JiraIssueDetail
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def get_issue_impl(
|
|
10
|
+
ctx: TaskContext, input: GetIssueInput, *, deps: Deps | None = None
|
|
11
|
+
) -> JiraIssueDetail:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.get_issue(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.getIssue", retry=JIRA_RETRY)
|
|
17
|
+
async def get_issue(ctx: TaskContext, input: GetIssueInput) -> JiraIssueDetail:
|
|
18
|
+
return await get_issue_impl(ctx, input)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import JiraIssue, JqlInput
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def jql_impl(
|
|
10
|
+
ctx: TaskContext, input: JqlInput, *, deps: Deps | None = None
|
|
11
|
+
) -> list[JiraIssue]:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.jql(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.jql", retry=JIRA_RETRY)
|
|
17
|
+
async def jql(ctx: TaskContext, input: JqlInput) -> list[JiraIssue]:
|
|
18
|
+
return await jql_impl(ctx, input)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import LinkIssuesInput, LinkIssuesResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def link_issues_impl(
|
|
10
|
+
ctx: TaskContext, input: LinkIssuesInput, *, deps: Deps | None = None
|
|
11
|
+
) -> LinkIssuesResult:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.link_issues(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.linkIssues", retry=JIRA_RETRY)
|
|
17
|
+
async def link_issues(ctx: TaskContext, input: LinkIssuesInput) -> LinkIssuesResult:
|
|
18
|
+
return await link_issues_impl(ctx, input)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import JiraTransition, ListTransitionsInput
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def list_transitions_impl(
|
|
10
|
+
ctx: TaskContext, input: ListTransitionsInput, *, deps: Deps | None = None
|
|
11
|
+
) -> list[JiraTransition]:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.list_transitions(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.listTransitions", retry=JIRA_RETRY)
|
|
17
|
+
async def list_transitions(ctx: TaskContext, input: ListTransitionsInput) -> list[JiraTransition]:
|
|
18
|
+
return await list_transitions_impl(ctx, input)
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from ._app import app
|
|
2
|
+
from .add_attachment import add_attachment, add_attachment_impl
|
|
3
|
+
from .assign_issue import assign_issue, assign_issue_impl
|
|
4
|
+
from .comment import comment, comment_impl
|
|
5
|
+
from .create_issue import create_issue, create_issue_impl
|
|
6
|
+
from .get_issue import get_issue, get_issue_impl
|
|
7
|
+
from .jql import jql, jql_impl
|
|
8
|
+
from .link_issues import link_issues, link_issues_impl
|
|
9
|
+
from .list_transitions import list_transitions, list_transitions_impl
|
|
10
|
+
from .transition import transition, transition_impl
|
|
11
|
+
from .update_issue import update_issue, update_issue_impl
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"app",
|
|
15
|
+
"add_attachment",
|
|
16
|
+
"add_attachment_impl",
|
|
17
|
+
"assign_issue",
|
|
18
|
+
"assign_issue_impl",
|
|
19
|
+
"comment",
|
|
20
|
+
"comment_impl",
|
|
21
|
+
"create_issue",
|
|
22
|
+
"create_issue_impl",
|
|
23
|
+
"get_issue",
|
|
24
|
+
"get_issue_impl",
|
|
25
|
+
"jql",
|
|
26
|
+
"jql_impl",
|
|
27
|
+
"link_issues",
|
|
28
|
+
"link_issues_impl",
|
|
29
|
+
"list_transitions",
|
|
30
|
+
"list_transitions_impl",
|
|
31
|
+
"transition",
|
|
32
|
+
"transition_impl",
|
|
33
|
+
"update_issue",
|
|
34
|
+
"update_issue_impl",
|
|
35
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import TransitionInput, TransitionResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def transition_impl(
|
|
10
|
+
ctx: TaskContext, input: TransitionInput, *, deps: Deps | None = None
|
|
11
|
+
) -> TransitionResult:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.transition(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.transition", retry=JIRA_RETRY)
|
|
17
|
+
async def transition(ctx: TaskContext, input: TransitionInput) -> TransitionResult:
|
|
18
|
+
return await transition_impl(ctx, input)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""JSON contracts ported from the pinned TypeScript pack."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Literal, NotRequired, TypedDict
|
|
6
|
+
|
|
7
|
+
type Json = str | float | bool | None | list[Json] | dict[str, Json]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class JiraIssue(TypedDict):
|
|
11
|
+
key: str
|
|
12
|
+
summary: str
|
|
13
|
+
status: str
|
|
14
|
+
url: str
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CreateIssueInput(TypedDict):
|
|
18
|
+
projectKey: str
|
|
19
|
+
summary: str
|
|
20
|
+
description: NotRequired[str]
|
|
21
|
+
issueType: NotRequired[str]
|
|
22
|
+
labels: NotRequired[list[str]]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CreateIssueResult(TypedDict):
|
|
26
|
+
id: str
|
|
27
|
+
key: str
|
|
28
|
+
url: str
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class TransitionInput(TypedDict):
|
|
32
|
+
issueKey: str
|
|
33
|
+
to: str
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class TransitionResult(TypedDict):
|
|
37
|
+
issueKey: str
|
|
38
|
+
to: str
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class CommentInput(TypedDict):
|
|
42
|
+
issueKey: str
|
|
43
|
+
body: str
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class CommentResult(TypedDict):
|
|
47
|
+
issueKey: str
|
|
48
|
+
commentId: str
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class JqlInput(TypedDict):
|
|
52
|
+
jql: str
|
|
53
|
+
limit: NotRequired[float]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class JiraIssueDetail(TypedDict):
|
|
57
|
+
key: str
|
|
58
|
+
summary: str
|
|
59
|
+
status: str
|
|
60
|
+
assignee: str | None
|
|
61
|
+
issueType: str
|
|
62
|
+
url: str
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class GetIssueInput(TypedDict):
|
|
66
|
+
issueKey: str
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class UpdateIssueInput(TypedDict):
|
|
70
|
+
issueKey: str
|
|
71
|
+
fields: dict[str, Json]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class UpdateIssueResult(TypedDict):
|
|
75
|
+
key: str
|
|
76
|
+
updated: Literal[True]
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class AssignIssueInput(TypedDict):
|
|
80
|
+
issueKey: str
|
|
81
|
+
accountId: str
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class AssignIssueResult(TypedDict):
|
|
85
|
+
key: str
|
|
86
|
+
assigned: Literal[True]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class ListTransitionsInput(TypedDict):
|
|
90
|
+
issueKey: str
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class JiraTransition(TypedDict):
|
|
94
|
+
id: str
|
|
95
|
+
name: str
|
|
96
|
+
toStatus: str
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class LinkIssuesInput(TypedDict):
|
|
100
|
+
type: str
|
|
101
|
+
inwardIssue: str
|
|
102
|
+
outwardIssue: str
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class LinkIssuesResult(TypedDict):
|
|
106
|
+
linked: Literal[True]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class AddAttachmentInput(TypedDict):
|
|
110
|
+
issueKey: str
|
|
111
|
+
filename: str
|
|
112
|
+
content: str
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class AddAttachmentResult(TypedDict):
|
|
116
|
+
id: str
|
|
117
|
+
filename: str
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from render import TaskContext
|
|
2
|
+
|
|
3
|
+
from ._app import app
|
|
4
|
+
from .client import Deps, dependencies
|
|
5
|
+
from .retry import JIRA_RETRY
|
|
6
|
+
from .types import UpdateIssueInput, UpdateIssueResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def update_issue_impl(
|
|
10
|
+
ctx: TaskContext, input: UpdateIssueInput, *, deps: Deps | None = None
|
|
11
|
+
) -> UpdateIssueResult:
|
|
12
|
+
async with dependencies(deps) as resolved:
|
|
13
|
+
return await resolved.jira.update_issue(input)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@app.task(name="jira.updateIssue", retry=JIRA_RETRY)
|
|
17
|
+
async def update_issue(ctx: TaskContext, input: UpdateIssueInput) -> UpdateIssueResult:
|
|
18
|
+
return await update_issue_impl(ctx, input)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: render-lab-tasks-jira
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: jira tasks for Render Workflows
|
|
5
|
+
Project-URL: Repository, https://github.com/render-lab/render-tasks-python
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Requires-Dist: httpx<0.29,>=0.28
|
|
10
|
+
Requires-Dist: render-lab-tasks-core<0.2,>=0.1.0
|
|
11
|
+
Requires-Dist: render==1.0.1
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# render-lab-tasks-jira
|
|
15
|
+
|
|
16
|
+
Python port of all 10 registered tasks in the pinned TypeScript pack at
|
|
17
|
+
`45f9c2d44bd28e01ae9813e0d2ff56ee6c533816`. Python 3.12+.
|
|
18
|
+
|
|
19
|
+
From the repository, install this pack and its supporting core together:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pip install render-lab-tasks-jira==0.1.0
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Import task definitions from `render_lab_tasks_jira.tasks`. Combine its `app` with
|
|
26
|
+
other pack apps using `Workflows.from_workflows(...)` and call tasks with
|
|
27
|
+
`await ctx.run(task, input)`. Package roots do not register tasks. JSON fields
|
|
28
|
+
retain the TS spelling; Python functions use snake_case.
|
|
29
|
+
|
|
30
|
+
## Tasks
|
|
31
|
+
|
|
32
|
+
| Registered name | Python export (also exposes `_impl`) |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `jira.addAttachment` | `add_attachment` |
|
|
35
|
+
| `jira.assignIssue` | `assign_issue` |
|
|
36
|
+
| `jira.comment` | `comment` |
|
|
37
|
+
| `jira.createIssue` | `create_issue` |
|
|
38
|
+
| `jira.getIssue` | `get_issue` |
|
|
39
|
+
| `jira.jql` | `jql` |
|
|
40
|
+
| `jira.linkIssues` | `link_issues` |
|
|
41
|
+
| `jira.listTransitions` | `list_transitions` |
|
|
42
|
+
| `jira.transition` | `transition` |
|
|
43
|
+
| `jira.updateIssue` | `update_issue` |
|
|
44
|
+
|
|
45
|
+
## Dependencies and retries
|
|
46
|
+
|
|
47
|
+
Raw implementations accept context first and keyword-only `deps`. The `.client`
|
|
48
|
+
module exports typed `Port`, `Deps`, and `Client` classes (also vendor-named aliases).
|
|
49
|
+
Inject a fake port, or pass a caller-owned `httpx.AsyncClient` to `Client` for custom
|
|
50
|
+
transport/configuration. Default dependencies close their HTTP clients after the
|
|
51
|
+
operation. Credentials resolve at first use. HTTP and SDK retries are disabled;
|
|
52
|
+
`retry.py` owns durable retry settings. DTO types live in `.types`.
|
|
53
|
+
|
|
54
|
+
## Environment
|
|
55
|
+
|
|
56
|
+
| Variable | Contract |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `JIRA_BASE_URL` | Required Jira site URL. |
|
|
59
|
+
| `JIRA_EMAIL` | Required account email for Basic authentication. |
|
|
60
|
+
| `JIRA_API_TOKEN` | Required account API token. |
|
|
61
|
+
|
|
62
|
+
## Verification and limitations
|
|
63
|
+
|
|
64
|
+
Plain text descriptions/comments become Atlassian Document Format, with one paragraph per line. JQL uses the current `/rest/api/3/search/jql` endpoint and requests summary/status fields explicitly. It returns one page (default 50); `limit: 0` makes no request. Limits must be non-negative integers. This deliberately corrects the pinned TS transport (ADR-0007); live Jira validation remains pending. Attachments use UTF-8 text and reject CR/LF/quotes in filenames before HTTP (ADR-0006). This is not a binary media upload API.
|
|
65
|
+
|
|
66
|
+
Shared JSON fixtures compare the Python task output with the actual pinned TS
|
|
67
|
+
implementation. REST fixtures also compare HTTP requests; HubSpot and Linear
|
|
68
|
+
fixtures compare source SDK arguments with HTTP payloads/GraphQL variables.
|
|
69
|
+
No live vendor calls were made for this batch. Registered-task parity does not
|
|
70
|
+
claim live readiness or all supporting TS exports. See the root verification
|
|
71
|
+
tracker and docs/porting-batches.md. Licensed under MIT.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
render_lab_tasks_jira/__init__.py,sha256=fGcyw3Sxjue9wB_1RdFbEFKm5DXSlw_6vD2ud03a6og,58
|
|
2
|
+
render_lab_tasks_jira/_app.py,sha256=nkWSD_6eq3xzdPJ_G7z6d5mv8tSB-Rq21yp07usJihA,48
|
|
3
|
+
render_lab_tasks_jira/add_attachment.py,sha256=nis_ium9r-qSeyNt2UCtx2CoGnL2KjLGuod0HLyo7W4,622
|
|
4
|
+
render_lab_tasks_jira/assign_issue.py,sha256=JqZXQOEykdrese4wABkjIHuBNCHB2M42C75hKu0Ylfw,600
|
|
5
|
+
render_lab_tasks_jira/client.py,sha256=POTA4cWRK9ZxaeBwB53oOmyn8EbzVs6b9ITClxTDQ74,8874
|
|
6
|
+
render_lab_tasks_jira/comment.py,sha256=1mCnvKN94BwHK0M8DyfApgputzYyTzMD2sIFk74fPRw,552
|
|
7
|
+
render_lab_tasks_jira/create_issue.py,sha256=d6qivAfa62wTlD5v_ZxL8wh6wtE1IEA4x_2O_yvQCzU,600
|
|
8
|
+
render_lab_tasks_jira/get_issue.py,sha256=AUVhboYn7axR5G1SFyzbAVyouLEDIBlTuHJ842hpeFM,570
|
|
9
|
+
render_lab_tasks_jira/jql.py,sha256=ooDhf8ygAxCghDrSrZuKiuoizFVrB78gvInx-NVHjBM,520
|
|
10
|
+
render_lab_tasks_jira/link_issues.py,sha256=q90LscQgdprTK6YMXYAABd3m2D-T-RMpQUObTO6cEgI,589
|
|
11
|
+
render_lab_tasks_jira/list_transitions.py,sha256=pB5FUw5CE7SPQngjSf82U8nNYIb6IHM_4IJqOuwHq7o,635
|
|
12
|
+
render_lab_tasks_jira/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
render_lab_tasks_jira/retry.py,sha256=OF8BoDUW-dYgHp5K9lqGJ9oekzJ-Hbu6KpRC1vQTSLo,102
|
|
14
|
+
render_lab_tasks_jira/tasks.py,sha256=Ir_4fQnziKbS4cSPbMyOryK4RjMs9hJCoTYSTOsIH4I,1008
|
|
15
|
+
render_lab_tasks_jira/transition.py,sha256=Dk0r88LT8Z7Vkdz9_7CuNU6WAcpvgjKW2eq_G2DFW0s,585
|
|
16
|
+
render_lab_tasks_jira/types.py,sha256=6S4EhVMZxZmTGu4F2wDJxzwbx_harXh71IGmcxNCxQ4,1861
|
|
17
|
+
render_lab_tasks_jira/update_issue.py,sha256=CSraMTzTu2XQqx_L7IpQKm2kA5pPfVO8OpJT2k2psyk,600
|
|
18
|
+
render_lab_tasks_jira-0.1.0.dist-info/METADATA,sha256=y1m2lSXfYu8ZjJgkiykkWcU2FnaZwlvmg40DO9SJ8mE,3175
|
|
19
|
+
render_lab_tasks_jira-0.1.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
20
|
+
render_lab_tasks_jira-0.1.0.dist-info/licenses/LICENSE,sha256=LvmsuKGkhvlSISJRqvBIPUQ_BqVDFRe0RghPSmDebzU,1067
|
|
21
|
+
render_lab_tasks_jira-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Render Lab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|