dex-connector-sentry 0.1.0__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.
- dex_connector_sentry-0.1.0/.gitignore +6 -0
- dex_connector_sentry-0.1.0/PKG-INFO +52 -0
- dex_connector_sentry-0.1.0/README.md +41 -0
- dex_connector_sentry-0.1.0/examples/issue_review/__init__.py +3 -0
- dex_connector_sentry-0.1.0/examples/issue_review/flow.py +81 -0
- dex_connector_sentry-0.1.0/examples/issue_review/worker.py +51 -0
- dex_connector_sentry-0.1.0/pyproject.toml +37 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/__init__.py +60 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/_generated/__init__.py +2 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/_generated/config.py +25 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/_generated/connection.py +145 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/_generated/definitions.py +75 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/_generated/mock.py +158 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/_generated/models.py +82 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/_generated/steps.py +187 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/client.py +471 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/connection.py +47 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/dex-connector.json +120 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/models.py +24 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/py.typed +0 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/sentrymock/__init__.py +58 -0
- dex_connector_sentry-0.1.0/src/dex_connectors/sentry/steps.py +43 -0
- dex_connector_sentry-0.1.0/tests/test_conformance.py +32 -0
- dex_connector_sentry-0.1.0/tests/test_manifest_contract.py +15 -0
- dex_connector_sentry-0.1.0/tests/test_operations.py +200 -0
- dex_connector_sentry-0.1.0/uv.lock +932 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dex-connector-sentry
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Sentry connector for Dex Flows
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Requires-Dist: dex-connectors-sdk==0.1.0
|
|
8
|
+
Requires-Dist: dex-python-sdk>=1.28.0
|
|
9
|
+
Requires-Dist: httpx>=0.27
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# Sentry connector for Python
|
|
13
|
+
|
|
14
|
+
Install with `pip install dex-connector-sentry==0.1.0`. The package requires
|
|
15
|
+
`dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, and implements the
|
|
16
|
+
manifest operations `listIssues` and `getIssue` (Queries) and
|
|
17
|
+
`updateIssueStatus` (Mutation) with the same branches, defaults, and failure
|
|
18
|
+
classification as the Go module.
|
|
19
|
+
|
|
20
|
+
## Operations
|
|
21
|
+
|
|
22
|
+
| Operation | Factory | Happy branch | Optional branches |
|
|
23
|
+
| --- | --- | --- | --- |
|
|
24
|
+
| `listIssues` | `new_list_issues_step` | `listed` | `providerRejected`, `invalidResponse`, `defect` |
|
|
25
|
+
| `getIssue` | `new_get_issue_step` | `found` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
|
|
26
|
+
| `updateIssueStatus` | `new_update_issue_status_step` | `updated` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
|
|
27
|
+
|
|
28
|
+
Every operation needs the organization slug. `listIssues` passes an optional
|
|
29
|
+
Sentry search `query` and returns the first result page. `updateIssueStatus`
|
|
30
|
+
sets `resolved`, `unresolved`, or `ignored`; the absolute replacement makes a
|
|
31
|
+
repeated attempt safe. 408, 429, 5xx, and transport failures retry; other
|
|
32
|
+
non-success responses select `providerRejected`, and HTTP 404 selects
|
|
33
|
+
`notFound` where the operation declares it.
|
|
34
|
+
|
|
35
|
+
## Authorization
|
|
36
|
+
|
|
37
|
+
Create a Dex Web connection named `sentry` as described in the
|
|
38
|
+
[connector README](../README.md#authorization). The auth token travels only in
|
|
39
|
+
the `Authorization: Bearer` header and is resolved for every attempt.
|
|
40
|
+
|
|
41
|
+
## Example
|
|
42
|
+
|
|
43
|
+
[`examples/issue_review`](examples/issue_review/flow.py) checks the
|
|
44
|
+
organization slug, lists issues with `new_list_issues_step`, and records the
|
|
45
|
+
page. Run the Worker with `uv run python -m examples.issue_review.worker` after
|
|
46
|
+
`dexcli dev` has loaded a project containing the `sentry` connection.
|
|
47
|
+
|
|
48
|
+
## Tests
|
|
49
|
+
|
|
50
|
+
`sentrymock.Mock` scripts all three operations and defaults to the manifest
|
|
51
|
+
mock answers. Run `uv run pytest tests` for provider parity and manifest
|
|
52
|
+
contract checks.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Sentry connector for Python
|
|
2
|
+
|
|
3
|
+
Install with `pip install dex-connector-sentry==0.1.0`. The package requires
|
|
4
|
+
`dex-connectors-sdk==0.1.0` and `dex-python-sdk>=1.28.0`, and implements the
|
|
5
|
+
manifest operations `listIssues` and `getIssue` (Queries) and
|
|
6
|
+
`updateIssueStatus` (Mutation) with the same branches, defaults, and failure
|
|
7
|
+
classification as the Go module.
|
|
8
|
+
|
|
9
|
+
## Operations
|
|
10
|
+
|
|
11
|
+
| Operation | Factory | Happy branch | Optional branches |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| `listIssues` | `new_list_issues_step` | `listed` | `providerRejected`, `invalidResponse`, `defect` |
|
|
14
|
+
| `getIssue` | `new_get_issue_step` | `found` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
|
|
15
|
+
| `updateIssueStatus` | `new_update_issue_status_step` | `updated` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
|
|
16
|
+
|
|
17
|
+
Every operation needs the organization slug. `listIssues` passes an optional
|
|
18
|
+
Sentry search `query` and returns the first result page. `updateIssueStatus`
|
|
19
|
+
sets `resolved`, `unresolved`, or `ignored`; the absolute replacement makes a
|
|
20
|
+
repeated attempt safe. 408, 429, 5xx, and transport failures retry; other
|
|
21
|
+
non-success responses select `providerRejected`, and HTTP 404 selects
|
|
22
|
+
`notFound` where the operation declares it.
|
|
23
|
+
|
|
24
|
+
## Authorization
|
|
25
|
+
|
|
26
|
+
Create a Dex Web connection named `sentry` as described in the
|
|
27
|
+
[connector README](../README.md#authorization). The auth token travels only in
|
|
28
|
+
the `Authorization: Bearer` header and is resolved for every attempt.
|
|
29
|
+
|
|
30
|
+
## Example
|
|
31
|
+
|
|
32
|
+
[`examples/issue_review`](examples/issue_review/flow.py) checks the
|
|
33
|
+
organization slug, lists issues with `new_list_issues_step`, and records the
|
|
34
|
+
page. Run the Worker with `uv run python -m examples.issue_review.worker` after
|
|
35
|
+
`dexcli dev` has loaded a project containing the `sentry` connection.
|
|
36
|
+
|
|
37
|
+
## Tests
|
|
38
|
+
|
|
39
|
+
`sentrymock.Mock` scripts all three operations and defaults to the manifest
|
|
40
|
+
mock answers. Run `uv run pytest tests` for provider parity and manifest
|
|
41
|
+
contract checks.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Runnable issue review Flow using the Sentry listIssues Query."""
|
|
4
|
+
|
|
5
|
+
import dex
|
|
6
|
+
from dex_connectors.sdk import QueryResult
|
|
7
|
+
|
|
8
|
+
from dex_connectors.sentry import (
|
|
9
|
+
Connection,
|
|
10
|
+
IssuePage,
|
|
11
|
+
ListIssuesInput,
|
|
12
|
+
new_list_issues_step,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
FLOW_TYPE = "SentryIssueReview"
|
|
16
|
+
CONNECTION_NAME = "sentry"
|
|
17
|
+
_LIST_STEP_TYPE = "ListIssues"
|
|
18
|
+
_OUTCOME = dex.Attribute("sentry-issue-review-outcome", IssuePage)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def map_to_list_issues_input(request: ListIssuesInput) -> ListIssuesInput:
|
|
22
|
+
"""List with the requested organization and query unchanged."""
|
|
23
|
+
return request
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# dex:group group-id:issue-review group-label:"Issue review"
|
|
27
|
+
# dex:explanation text:"Check the requested page window before calling Sentry."
|
|
28
|
+
class _PrepareRequest(dex.Step[ListIssuesInput]):
|
|
29
|
+
def get_step_type(self) -> str:
|
|
30
|
+
return "PrepareRequest"
|
|
31
|
+
|
|
32
|
+
def execute(self, context: dex.Context, input: ListIssuesInput) -> dex.StepDecision:
|
|
33
|
+
if not input.organization.strip():
|
|
34
|
+
return dex.force_fail("organization slug is required")
|
|
35
|
+
return dex.go_to(dex.StepRef(_LIST_STEP_TYPE), input)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# dex:group group-id:issue-review group-label:"Issue review"
|
|
39
|
+
# dex:explanation text:"Record the issue page and complete the Flow."
|
|
40
|
+
class _CompleteRequest(dex.Step[QueryResult[IssuePage]]):
|
|
41
|
+
def get_step_type(self) -> str:
|
|
42
|
+
return "CompleteRequest"
|
|
43
|
+
|
|
44
|
+
def execute(self, context: dex.Context, input: QueryResult[IssuePage]) -> dex.StepDecision:
|
|
45
|
+
_OUTCOME.set(context, input.value)
|
|
46
|
+
return dex.graceful_complete(input.value)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class IssueReviewFlow(dex.Flow[ListIssuesInput]):
|
|
50
|
+
"""List one page of issues through the static sentry connection."""
|
|
51
|
+
|
|
52
|
+
def __init__(self, connection: Connection) -> None:
|
|
53
|
+
if connection.reference.name != CONNECTION_NAME:
|
|
54
|
+
raise ValueError("issue review requires the static sentry connection")
|
|
55
|
+
self._prepare = _PrepareRequest()
|
|
56
|
+
self._complete = _CompleteRequest()
|
|
57
|
+
self._list = new_list_issues_step(
|
|
58
|
+
step_type=_LIST_STEP_TYPE,
|
|
59
|
+
step_input_type=ListIssuesInput,
|
|
60
|
+
annotations={
|
|
61
|
+
"groupId": "sentry",
|
|
62
|
+
"groupLabel": "Sentry",
|
|
63
|
+
"explanation": "List the organization's issues from Sentry.",
|
|
64
|
+
},
|
|
65
|
+
connection=connection,
|
|
66
|
+
connection_name=CONNECTION_NAME,
|
|
67
|
+
map_to_operation_input=map_to_list_issues_input,
|
|
68
|
+
listed=self._complete,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
def get_flow_type(self) -> str:
|
|
72
|
+
"""Return the stable Flow identity used in Dex Web."""
|
|
73
|
+
return FLOW_TYPE
|
|
74
|
+
|
|
75
|
+
def get_steps(self) -> dex.StepList[ListIssuesInput]:
|
|
76
|
+
"""Register request check, provider list, and completion Steps."""
|
|
77
|
+
return dex.StepList.start_step(self._prepare).other_steps(self._list, self._complete)
|
|
78
|
+
|
|
79
|
+
def get_persistence_schema(self) -> dex.PersistenceSchema:
|
|
80
|
+
"""Persist the issue page."""
|
|
81
|
+
return dex.PersistenceSchema.of(_OUTCOME)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Worker entrypoint for the Sentry issue review Flow."""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import os
|
|
7
|
+
import tempfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import dex
|
|
11
|
+
from dex_connectors.sdk.projectconfig import load_from_environment
|
|
12
|
+
|
|
13
|
+
from dex_connectors.sentry import new_project_connection
|
|
14
|
+
|
|
15
|
+
from .flow import CONNECTION_NAME, IssueReviewFlow
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
async def run_worker() -> None:
|
|
19
|
+
"""Load the named Dex Web connection and serve issue reviews."""
|
|
20
|
+
project = await load_from_environment()
|
|
21
|
+
connection = None
|
|
22
|
+
cache = None
|
|
23
|
+
try:
|
|
24
|
+
connection = new_project_connection(project, CONNECTION_NAME)
|
|
25
|
+
registry = dex.Registry([IssueReviewFlow(connection)], allow_async_handlers=True)
|
|
26
|
+
cache_directory = os.environ.get(
|
|
27
|
+
"DEX_BLOB_CACHE_DIR", str(Path(tempfile.gettempdir()) / "dex-sentry-issue-review-blobs")
|
|
28
|
+
)
|
|
29
|
+
cache = dex.open_blob_cache(dex.BlobCacheConfig(cache_directory, 1 << 30))
|
|
30
|
+
worker = dex.AsyncWorker(
|
|
31
|
+
registry,
|
|
32
|
+
cache,
|
|
33
|
+
dex.WorkerOptions(server_address=os.environ.get("DEX_FLOW_SERVICE_ADDRESS", "localhost:8801")),
|
|
34
|
+
)
|
|
35
|
+
async with worker:
|
|
36
|
+
await worker.start()
|
|
37
|
+
finally:
|
|
38
|
+
if connection is not None:
|
|
39
|
+
await connection.aclose()
|
|
40
|
+
if cache is not None:
|
|
41
|
+
cache.close()
|
|
42
|
+
await project.close()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def main() -> None:
|
|
46
|
+
"""Run until the Worker stops or the process receives an interrupt."""
|
|
47
|
+
asyncio.run(run_worker())
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == "__main__":
|
|
51
|
+
main()
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dex-connector-sentry"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Sentry connector for Dex Flows"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
dependencies = ["dex-connectors-sdk==0.1.0", "dex-python-sdk>=1.28.0", "httpx>=0.27"]
|
|
13
|
+
|
|
14
|
+
[dependency-groups]
|
|
15
|
+
dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.13", "ruff>=0.7", "pyyaml>=6", "types-PyYAML>=6"]
|
|
16
|
+
|
|
17
|
+
[tool.hatch.build.targets.wheel]
|
|
18
|
+
packages = ["src/dex_connectors"]
|
|
19
|
+
|
|
20
|
+
[tool.pytest.ini_options]
|
|
21
|
+
testpaths = ["tests"]
|
|
22
|
+
pythonpath = [".", "src"]
|
|
23
|
+
asyncio_mode = "auto"
|
|
24
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
25
|
+
|
|
26
|
+
[tool.mypy]
|
|
27
|
+
python_version = "3.11"
|
|
28
|
+
strict = true
|
|
29
|
+
mypy_path = "src"
|
|
30
|
+
explicit_package_bases = true
|
|
31
|
+
|
|
32
|
+
[tool.ruff]
|
|
33
|
+
target-version = "py311"
|
|
34
|
+
line-length = 110
|
|
35
|
+
|
|
36
|
+
[tool.ruff.lint]
|
|
37
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Sentry issue operations for Dex connector Steps."""
|
|
4
|
+
|
|
5
|
+
from .client import (
|
|
6
|
+
CONNECTOR_ID,
|
|
7
|
+
DEFECT,
|
|
8
|
+
FOUND,
|
|
9
|
+
GET_ISSUE_DEFINITION,
|
|
10
|
+
INVALID_RESPONSE,
|
|
11
|
+
ISSUE_STATUSES,
|
|
12
|
+
LIST_ISSUES_DEFINITION,
|
|
13
|
+
LISTED,
|
|
14
|
+
NOT_FOUND,
|
|
15
|
+
PROVIDER_REJECTED,
|
|
16
|
+
UPDATE_ISSUE_STATUS_DEFINITION,
|
|
17
|
+
UPDATED,
|
|
18
|
+
Client,
|
|
19
|
+
Config,
|
|
20
|
+
Credentials,
|
|
21
|
+
GetIssueOperation,
|
|
22
|
+
ListIssuesOperation,
|
|
23
|
+
UpdateIssueStatusOperation,
|
|
24
|
+
)
|
|
25
|
+
from .connection import Connection, new_connection, new_connection_with_operations, new_project_connection
|
|
26
|
+
from .models import GetIssueInput, Issue, IssuePage, ListIssuesInput, UpdateIssueStatusInput
|
|
27
|
+
from .steps import new_get_issue_step, new_list_issues_step, new_update_issue_status_step
|
|
28
|
+
|
|
29
|
+
__all__ = [
|
|
30
|
+
"Client",
|
|
31
|
+
"Config",
|
|
32
|
+
"Connection",
|
|
33
|
+
"Credentials",
|
|
34
|
+
"GetIssueInput",
|
|
35
|
+
"GetIssueOperation",
|
|
36
|
+
"Issue",
|
|
37
|
+
"IssuePage",
|
|
38
|
+
"ListIssuesInput",
|
|
39
|
+
"ListIssuesOperation",
|
|
40
|
+
"UpdateIssueStatusInput",
|
|
41
|
+
"UpdateIssueStatusOperation",
|
|
42
|
+
"new_connection",
|
|
43
|
+
"new_connection_with_operations",
|
|
44
|
+
"new_get_issue_step",
|
|
45
|
+
"new_list_issues_step",
|
|
46
|
+
"new_project_connection",
|
|
47
|
+
"new_update_issue_status_step",
|
|
48
|
+
"CONNECTOR_ID",
|
|
49
|
+
"DEFECT",
|
|
50
|
+
"FOUND",
|
|
51
|
+
"GET_ISSUE_DEFINITION",
|
|
52
|
+
"INVALID_RESPONSE",
|
|
53
|
+
"ISSUE_STATUSES",
|
|
54
|
+
"LIST_ISSUES_DEFINITION",
|
|
55
|
+
"LISTED",
|
|
56
|
+
"NOT_FOUND",
|
|
57
|
+
"PROVIDER_REJECTED",
|
|
58
|
+
"UPDATE_ISSUE_STATUS_DEFINITION",
|
|
59
|
+
"UPDATED",
|
|
60
|
+
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
# ruff: noqa
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from dex_connectors.sdk import SecretString
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True)
|
|
11
|
+
class Config:
|
|
12
|
+
|
|
13
|
+
base_url: str = "https://sentry.io/api/0"
|
|
14
|
+
timeout_seconds: float = 15
|
|
15
|
+
max_response_bytes: int = 2097152
|
|
16
|
+
|
|
17
|
+
setattr(Config, '__module__', 'dex_connectors.sentry.client')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True, slots=True)
|
|
21
|
+
class Credentials:
|
|
22
|
+
|
|
23
|
+
api_key: SecretString
|
|
24
|
+
|
|
25
|
+
setattr(Credentials, '__module__', 'dex_connectors.sentry.client')
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
# ruff: noqa
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
from dex_connectors.sdk import ConnectionRef, Mutation, Query, Call, SecretString
|
|
9
|
+
from dex_connectors.sdk.projectconfig import ConnectionKey, LoadedProject
|
|
10
|
+
|
|
11
|
+
from ..client import Client, Config, Credentials
|
|
12
|
+
from .definitions import CONNECTOR_ID, GET_ISSUE_DEFINITION, LIST_ISSUES_DEFINITION, UPDATE_ISSUE_STATUS_DEFINITION
|
|
13
|
+
from ..models import GetIssueInput, Issue, IssuePage, ListIssuesInput, UpdateIssueStatusInput
|
|
14
|
+
|
|
15
|
+
class Connection:
|
|
16
|
+
|
|
17
|
+
__slots__ = ('_list_issues', '_get_issue', '_update_issue_status', '_client', 'reference')
|
|
18
|
+
|
|
19
|
+
def __init__(self,
|
|
20
|
+
reference: ConnectionRef,
|
|
21
|
+
list_issues: Query[ListIssuesInput, IssuePage],
|
|
22
|
+
get_issue: Query[GetIssueInput, Issue],
|
|
23
|
+
update_issue_status: Mutation[UpdateIssueStatusInput, Issue],
|
|
24
|
+
client: Client | None = None,
|
|
25
|
+
) -> None:
|
|
26
|
+
reference.validate()
|
|
27
|
+
if reference.provider != CONNECTOR_ID or list_issues is None or get_issue is None or update_issue_status is None:
|
|
28
|
+
raise ValueError("Sentry connection provider and operations are required")
|
|
29
|
+
if list_issues.definition().operation != LIST_ISSUES_DEFINITION.operation:
|
|
30
|
+
raise ValueError("Sentry connection operation identity differs")
|
|
31
|
+
if get_issue.definition().operation != GET_ISSUE_DEFINITION.operation:
|
|
32
|
+
raise ValueError("Sentry connection operation identity differs")
|
|
33
|
+
if update_issue_status.definition().operation != UPDATE_ISSUE_STATUS_DEFINITION.operation:
|
|
34
|
+
raise ValueError("Sentry connection operation identity differs")
|
|
35
|
+
self.reference = reference
|
|
36
|
+
self._list_issues = list_issues
|
|
37
|
+
self._get_issue = get_issue
|
|
38
|
+
self._update_issue_status = update_issue_status
|
|
39
|
+
self._client = client
|
|
40
|
+
|
|
41
|
+
def list_issues(self) -> Query[ListIssuesInput, IssuePage]:
|
|
42
|
+
return self._list_issues
|
|
43
|
+
|
|
44
|
+
def get_issue(self) -> Query[GetIssueInput, Issue]:
|
|
45
|
+
return self._get_issue
|
|
46
|
+
|
|
47
|
+
def update_issue_status(self) -> Mutation[UpdateIssueStatusInput, Issue]:
|
|
48
|
+
return self._update_issue_status
|
|
49
|
+
|
|
50
|
+
async def aclose(self) -> None:
|
|
51
|
+
if self._client is not None:
|
|
52
|
+
await self._client.aclose()
|
|
53
|
+
|
|
54
|
+
def __repr__(self) -> str:
|
|
55
|
+
return "sentry.Connection([REDACTED])"
|
|
56
|
+
|
|
57
|
+
def __reduce__(self) -> tuple[object, ...]:
|
|
58
|
+
raise TypeError("Sentry connections cannot be serialized")
|
|
59
|
+
|
|
60
|
+
setattr(Connection, '__module__', 'dex_connectors.sentry.connection')
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def new_connection(client: Client, reference: ConnectionRef) -> Connection:
|
|
64
|
+
if client is None:
|
|
65
|
+
raise ValueError("Sentry client is required")
|
|
66
|
+
return Connection(reference, client.list_issues(), client.get_issue(), client.update_issue_status(), client)
|
|
67
|
+
|
|
68
|
+
setattr(new_connection, '__module__', 'dex_connectors.sentry.connection')
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def new_connection_with_operations(
|
|
72
|
+
list_issues: Query[ListIssuesInput, IssuePage],
|
|
73
|
+
get_issue: Query[GetIssueInput, Issue],
|
|
74
|
+
update_issue_status: Mutation[UpdateIssueStatusInput, Issue],
|
|
75
|
+
reference: ConnectionRef,
|
|
76
|
+
) -> Connection:
|
|
77
|
+
return Connection(reference, list_issues, get_issue, update_issue_status)
|
|
78
|
+
|
|
79
|
+
setattr(new_connection_with_operations, '__module__', 'dex_connectors.sentry.connection')
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class _ProjectCredentialSource:
|
|
83
|
+
|
|
84
|
+
def __init__(self, project: LoadedProject, key: ConnectionKey) -> None:
|
|
85
|
+
self.project = project
|
|
86
|
+
self.key = key
|
|
87
|
+
|
|
88
|
+
async def resolve(self, call: Call) -> Credentials:
|
|
89
|
+
material = await self.project.resolve_credential(self.key, str(call.id))
|
|
90
|
+
if not isinstance(material, dict):
|
|
91
|
+
raise ValueError("Sentry stored credential does not match the connector credential fields")
|
|
92
|
+
if set(material) - set(('api_key',)):
|
|
93
|
+
raise ValueError("Sentry stored credential does not match the connector credential fields")
|
|
94
|
+
api_key = material.get("api_key")
|
|
95
|
+
if api_key is not None and not (isinstance(api_key, str)):
|
|
96
|
+
raise ValueError("Sentry credential api_key has an invalid type")
|
|
97
|
+
if not api_key:
|
|
98
|
+
raise ValueError("Sentry credential api_key is required")
|
|
99
|
+
return Credentials(SecretString(api_key))
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def new_project_connection(
|
|
103
|
+
project: LoadedProject, connection_name: str, http_client: httpx.AsyncClient | None = None
|
|
104
|
+
) -> Connection:
|
|
105
|
+
if project is None:
|
|
106
|
+
raise ValueError("Sentry connection requires loaded project configuration")
|
|
107
|
+
reference = ConnectionRef(CONNECTOR_ID, connection_name)
|
|
108
|
+
reference.validate()
|
|
109
|
+
key = ConnectionKey(CONNECTOR_ID, connection_name)
|
|
110
|
+
matching = [
|
|
111
|
+
entry
|
|
112
|
+
for entry in project.configuration.connections
|
|
113
|
+
if entry.connector_id == CONNECTOR_ID and entry.connection_name == connection_name
|
|
114
|
+
]
|
|
115
|
+
if len(matching) != 1:
|
|
116
|
+
raise ValueError("Sentry project connection is missing or duplicated")
|
|
117
|
+
if matching[0].provider != CONNECTOR_ID:
|
|
118
|
+
raise ValueError("Sentry project connection provider differs")
|
|
119
|
+
config = _decode_config(matching[0].configuration)
|
|
120
|
+
client = Client(config, _ProjectCredentialSource(project, key), http_client)
|
|
121
|
+
return new_connection(client, reference)
|
|
122
|
+
|
|
123
|
+
setattr(new_project_connection, '__module__', 'dex_connectors.sentry.connection')
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _decode_config(value: dict[str, Any]) -> Config:
|
|
127
|
+
if set(value) - {"baseUrl", "timeout", "maxResponseBytes"}:
|
|
128
|
+
raise ValueError("Sentry configuration has unknown fields")
|
|
129
|
+
config_arguments: dict[str, Any] = {}
|
|
130
|
+
if "baseUrl" in value:
|
|
131
|
+
base_url = value["baseUrl"]
|
|
132
|
+
if not (isinstance(base_url, str)):
|
|
133
|
+
raise ValueError("Sentry configuration baseUrl has an invalid type")
|
|
134
|
+
config_arguments['base_url'] = base_url
|
|
135
|
+
if "timeout" in value:
|
|
136
|
+
timeout = value["timeout"]
|
|
137
|
+
if not (type(timeout) is int):
|
|
138
|
+
raise ValueError("Sentry configuration timeout has an invalid type")
|
|
139
|
+
config_arguments['timeout_seconds'] = timeout / 1_000_000_000
|
|
140
|
+
if "maxResponseBytes" in value:
|
|
141
|
+
max_response_bytes = value["maxResponseBytes"]
|
|
142
|
+
if not (type(max_response_bytes) is int):
|
|
143
|
+
raise ValueError("Sentry configuration maxResponseBytes has an invalid type")
|
|
144
|
+
config_arguments['max_response_bytes'] = max_response_bytes
|
|
145
|
+
return Config(**config_arguments)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
# ruff: noqa
|
|
4
|
+
|
|
5
|
+
from datetime import timedelta
|
|
6
|
+
|
|
7
|
+
from dex_connectors.sdk import (
|
|
8
|
+
BranchDefinition,
|
|
9
|
+
MutationDefinition,
|
|
10
|
+
OperationRef,
|
|
11
|
+
QueryDefinition,
|
|
12
|
+
RetryPolicy,
|
|
13
|
+
StepDefaults,
|
|
14
|
+
default_connector_step_execute_retry_policy,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
CONNECTOR_ID = "sentry"
|
|
18
|
+
PROVIDER = "sentry"
|
|
19
|
+
LIST_ISSUES_OPERATION_ID = "listIssues"
|
|
20
|
+
GET_ISSUE_OPERATION_ID = "getIssue"
|
|
21
|
+
UPDATE_ISSUE_STATUS_OPERATION_ID = "updateIssueStatus"
|
|
22
|
+
DEFECT = "defect"
|
|
23
|
+
FOUND = "found"
|
|
24
|
+
INVALID_RESPONSE = "invalidResponse"
|
|
25
|
+
LISTED = "listed"
|
|
26
|
+
NOT_FOUND = "notFound"
|
|
27
|
+
PROVIDER_REJECTED = "providerRejected"
|
|
28
|
+
UPDATED = "updated"
|
|
29
|
+
|
|
30
|
+
LIST_ISSUES_DEFINITION = QueryDefinition(
|
|
31
|
+
OperationRef(CONNECTOR_ID, LIST_ISSUES_OPERATION_ID),
|
|
32
|
+
(
|
|
33
|
+
BranchDefinition(LISTED, "Sentry returned the requested result.", False),
|
|
34
|
+
BranchDefinition(PROVIDER_REJECTED, "The provider definitively rejected the request.", True),
|
|
35
|
+
BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
|
|
36
|
+
BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
|
|
37
|
+
),
|
|
38
|
+
StepDefaults(
|
|
39
|
+
timedelta(seconds=30),
|
|
40
|
+
2,
|
|
41
|
+
execute_retry=default_connector_step_execute_retry_policy(),
|
|
42
|
+
),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
GET_ISSUE_DEFINITION = QueryDefinition(
|
|
46
|
+
OperationRef(CONNECTOR_ID, GET_ISSUE_OPERATION_ID),
|
|
47
|
+
(
|
|
48
|
+
BranchDefinition(FOUND, "Sentry returned the requested result.", False),
|
|
49
|
+
BranchDefinition(NOT_FOUND, "The requested resource does not exist.", True),
|
|
50
|
+
BranchDefinition(PROVIDER_REJECTED, "The provider definitively rejected the request.", True),
|
|
51
|
+
BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
|
|
52
|
+
BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
|
|
53
|
+
),
|
|
54
|
+
StepDefaults(
|
|
55
|
+
timedelta(seconds=30),
|
|
56
|
+
2,
|
|
57
|
+
execute_retry=default_connector_step_execute_retry_policy(),
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
UPDATE_ISSUE_STATUS_DEFINITION = MutationDefinition(
|
|
62
|
+
OperationRef(CONNECTOR_ID, UPDATE_ISSUE_STATUS_OPERATION_ID),
|
|
63
|
+
(
|
|
64
|
+
BranchDefinition(UPDATED, "Sentry returned the requested result.", False),
|
|
65
|
+
BranchDefinition(NOT_FOUND, "The requested resource does not exist.", True),
|
|
66
|
+
BranchDefinition(PROVIDER_REJECTED, "The provider definitively rejected the request.", True),
|
|
67
|
+
BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
|
|
68
|
+
BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
|
|
69
|
+
),
|
|
70
|
+
StepDefaults(
|
|
71
|
+
timedelta(seconds=30),
|
|
72
|
+
2,
|
|
73
|
+
execute_retry=default_connector_step_execute_retry_policy(),
|
|
74
|
+
),
|
|
75
|
+
)
|