dex-connector-gitlab 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.
Files changed (26) hide show
  1. dex_connector_gitlab-0.1.0/.gitignore +6 -0
  2. dex_connector_gitlab-0.1.0/PKG-INFO +54 -0
  3. dex_connector_gitlab-0.1.0/README.md +43 -0
  4. dex_connector_gitlab-0.1.0/examples/gitlab_lookup/__init__.py +3 -0
  5. dex_connector_gitlab-0.1.0/examples/gitlab_lookup/flow.py +76 -0
  6. dex_connector_gitlab-0.1.0/examples/gitlab_lookup/worker.py +51 -0
  7. dex_connector_gitlab-0.1.0/pyproject.toml +37 -0
  8. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/__init__.py +59 -0
  9. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/_generated/__init__.py +2 -0
  10. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/_generated/config.py +25 -0
  11. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/_generated/connection.py +145 -0
  12. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/_generated/definitions.py +76 -0
  13. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/_generated/mock.py +164 -0
  14. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/_generated/models.py +106 -0
  15. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/_generated/steps.py +190 -0
  16. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/client.py +428 -0
  17. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/connection.py +50 -0
  18. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/dex-connector.json +125 -0
  19. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/gitlabmock/__init__.py +78 -0
  20. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/models.py +26 -0
  21. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/py.typed +0 -0
  22. dex_connector_gitlab-0.1.0/src/dex_connectors/gitlab/steps.py +46 -0
  23. dex_connector_gitlab-0.1.0/tests/test_conformance.py +32 -0
  24. dex_connector_gitlab-0.1.0/tests/test_manifest_contract.py +15 -0
  25. dex_connector_gitlab-0.1.0/tests/test_operations.py +244 -0
  26. dex_connector_gitlab-0.1.0/uv.lock +932 -0
@@ -0,0 +1,6 @@
1
+ /.dex-local/dexcli
2
+ /.dex-local/dex-server-zd
3
+ /.dex-local/data/
4
+ /.dex-local/cli.log
5
+ /.dex-local/visualize.json
6
+ /.dex-local/visualize.err
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.5
2
+ Name: dex-connector-gitlab
3
+ Version: 0.1.0
4
+ Summary: GitLab 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
+ # GitLab connector for Python
13
+
14
+ Install with `pip install dex-connector-gitlab==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 `getProject` and `listIssues` (Queries) and
17
+ `updateIssueLabels` (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
+ | `getProject` | `new_get_project_step` | `found` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
25
+ | `listIssues` | `new_list_issues_step` | `listed` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
26
+ | `updateIssueLabels` | `new_update_issue_labels_step` | `updated` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
27
+
28
+ A project is a numeric ID or a namespace path such as `meridian/web`, which is
29
+ path-escaped. `listIssues` reads GitLab's default first page of issues.
30
+ `updateIssueLabels` replaces the issue's complete label set with a form-encoded
31
+ `labels` value (an empty set clears every label), so a retry writes the same
32
+ absolute state; labels must be nonblank and cannot contain commas.
33
+
34
+ All operations retry on 408, 409, 429, 5xx, and transport failures. HTTP 404
35
+ selects `notFound`; other statuses select `providerRejected` with
36
+ authentication (401), authorization (403), or validation (400, 422) kinds.
37
+
38
+ ## Authorization
39
+
40
+ Create a Dex Web connection named `gitlab` as described in the
41
+ [connector README](../README.md#authorization). The access token travels only
42
+ in the `PRIVATE-TOKEN` header and is resolved for every attempt.
43
+
44
+ ## Example
45
+
46
+ [`examples/gitlab_lookup`](examples/gitlab_lookup/flow.py) reads one project.
47
+ Run the Worker with `uv run python -m examples.gitlab_lookup.worker` after
48
+ `dexcli dev` has loaded a project containing the `gitlab` connection.
49
+
50
+ ## Tests
51
+
52
+ `gitlabmock.Mock` scripts every operation and defaults to the manifest
53
+ answers. Run `uv run pytest tests` for provider parity and manifest contract
54
+ checks.
@@ -0,0 +1,43 @@
1
+ # GitLab connector for Python
2
+
3
+ Install with `pip install dex-connector-gitlab==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 `getProject` and `listIssues` (Queries) and
6
+ `updateIssueLabels` (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
+ | `getProject` | `new_get_project_step` | `found` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
14
+ | `listIssues` | `new_list_issues_step` | `listed` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
15
+ | `updateIssueLabels` | `new_update_issue_labels_step` | `updated` | `notFound`, `providerRejected`, `invalidResponse`, `defect` |
16
+
17
+ A project is a numeric ID or a namespace path such as `meridian/web`, which is
18
+ path-escaped. `listIssues` reads GitLab's default first page of issues.
19
+ `updateIssueLabels` replaces the issue's complete label set with a form-encoded
20
+ `labels` value (an empty set clears every label), so a retry writes the same
21
+ absolute state; labels must be nonblank and cannot contain commas.
22
+
23
+ All operations retry on 408, 409, 429, 5xx, and transport failures. HTTP 404
24
+ selects `notFound`; other statuses select `providerRejected` with
25
+ authentication (401), authorization (403), or validation (400, 422) kinds.
26
+
27
+ ## Authorization
28
+
29
+ Create a Dex Web connection named `gitlab` as described in the
30
+ [connector README](../README.md#authorization). The access token travels only
31
+ in the `PRIVATE-TOKEN` header and is resolved for every attempt.
32
+
33
+ ## Example
34
+
35
+ [`examples/gitlab_lookup`](examples/gitlab_lookup/flow.py) reads one project.
36
+ Run the Worker with `uv run python -m examples.gitlab_lookup.worker` after
37
+ `dexcli dev` has loaded a project containing the `gitlab` connection.
38
+
39
+ ## Tests
40
+
41
+ `gitlabmock.Mock` scripts every operation and defaults to the manifest
42
+ answers. Run `uv run pytest tests` for provider parity and manifest contract
43
+ checks.
@@ -0,0 +1,3 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """GitLab lookup example Flow."""
@@ -0,0 +1,76 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Runnable GitLab lookup Flow using the getProject Query."""
4
+
5
+ import dex
6
+ from dex_connectors.sdk import QueryResult
7
+
8
+ from dex_connectors.gitlab import Connection, GetProjectInput, Project, new_get_project_step
9
+
10
+ FLOW_TYPE = "GitLabLookup"
11
+ CONNECTION_NAME = "gitlab"
12
+ _OPERATION_STEP_TYPE = "GetProjectGitLab"
13
+ _REQUEST = dex.Attribute("gitlab-lookup-request", GetProjectInput)
14
+ _OUTPUT = dex.Attribute("gitlab-lookup-output", Project)
15
+
16
+
17
+ def map_to_operation_input(request: GetProjectInput) -> GetProjectInput:
18
+ """Read the requested project."""
19
+ return request
20
+
21
+
22
+ # dex:group group-id:gitlab group-label:"GitLab"
23
+ # dex:explanation text:"Start the GitLab lookup with its typed request."
24
+ class _StartLookup(dex.Step[GetProjectInput]):
25
+ def get_step_type(self) -> str:
26
+ return "StartGitLabLookup"
27
+
28
+ def execute(self, context: dex.Context, input: GetProjectInput) -> dex.StepDecision:
29
+ _REQUEST.set(context, input)
30
+ return dex.go_to(dex.StepRef(_OPERATION_STEP_TYPE), input)
31
+
32
+
33
+ # dex:group group-id:gitlab group-label:"GitLab"
34
+ # dex:explanation text:"Complete with the GitLab result."
35
+ class _CompleteLookup(dex.Step[QueryResult[Project]]):
36
+ def get_step_type(self) -> str:
37
+ return "CompleteGitLabLookup"
38
+
39
+ def execute(self, context: dex.Context, input: QueryResult[Project]) -> dex.StepDecision:
40
+ _OUTPUT.set(context, input.value)
41
+ return dex.graceful_complete(input.value)
42
+
43
+
44
+ class GitLabLookupFlow(dex.Flow[GetProjectInput]):
45
+ """Read one GitLab project through the static gitlab connection."""
46
+
47
+ def __init__(self, connection: Connection) -> None:
48
+ if connection.reference.name != CONNECTION_NAME:
49
+ raise ValueError("GitLab lookup requires the static gitlab connection")
50
+ self._start = _StartLookup()
51
+ self._complete = _CompleteLookup()
52
+ self._list = new_get_project_step(
53
+ step_type=_OPERATION_STEP_TYPE,
54
+ step_input_type=GetProjectInput,
55
+ annotations={
56
+ "groupId": "gitlab",
57
+ "groupLabel": "GitLab",
58
+ "explanation": "Read one GitLab project by numeric ID or namespace path.",
59
+ },
60
+ connection=connection,
61
+ connection_name=CONNECTION_NAME,
62
+ map_to_operation_input=map_to_operation_input,
63
+ found=self._complete,
64
+ )
65
+
66
+ def get_flow_type(self) -> str:
67
+ """Return the stable Flow identity used in Dex Web."""
68
+ return FLOW_TYPE
69
+
70
+ def get_steps(self) -> dex.StepList[GetProjectInput]:
71
+ """Register the start, provider list, and completion Steps."""
72
+ return dex.StepList.start_step(self._start).other_steps(self._list, self._complete)
73
+
74
+ def get_persistence_schema(self) -> dex.PersistenceSchema:
75
+ """Persist the request and project."""
76
+ return dex.PersistenceSchema.of(_REQUEST, _OUTPUT)
@@ -0,0 +1,51 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """Worker entrypoint for the GitLab lookup 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.gitlab import new_project_connection
14
+
15
+ from .flow import CONNECTION_NAME, GitLabLookupFlow
16
+
17
+
18
+ async def run_worker() -> None:
19
+ """Load the named Dex Web connection and read projects."""
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([GitLabLookupFlow(connection)], allow_async_handlers=True)
26
+ cache_directory = os.environ.get(
27
+ "DEX_BLOB_CACHE_DIR", str(Path(tempfile.gettempdir()) / "dex-gitlab-lookup-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-gitlab"
7
+ version = "0.1.0"
8
+ description = "GitLab 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,59 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
3
+ """GitLab project, issue, and label operations for Dex connector Steps."""
4
+
5
+ from .client import (
6
+ CONNECTOR_ID,
7
+ DEFECT,
8
+ FOUND,
9
+ GET_PROJECT_DEFINITION,
10
+ INVALID_RESPONSE,
11
+ LIST_ISSUES_DEFINITION,
12
+ LISTED,
13
+ NOT_FOUND,
14
+ PROVIDER_REJECTED,
15
+ UPDATE_ISSUE_LABELS_DEFINITION,
16
+ UPDATED,
17
+ Client,
18
+ Config,
19
+ Credentials,
20
+ GetProjectOperation,
21
+ ListIssuesOperation,
22
+ UpdateIssueLabelsOperation,
23
+ )
24
+ from .connection import Connection, new_connection, new_connection_with_operations, new_project_connection
25
+ from .models import GetProjectInput, Issue, IssuesPage, ListIssuesInput, Project, UpdateIssueLabelsInput
26
+ from .steps import new_get_project_step, new_list_issues_step, new_update_issue_labels_step
27
+
28
+ __all__ = [
29
+ "Client",
30
+ "Config",
31
+ "Connection",
32
+ "Credentials",
33
+ "GetProjectInput",
34
+ "GetProjectOperation",
35
+ "Issue",
36
+ "IssuesPage",
37
+ "ListIssuesInput",
38
+ "ListIssuesOperation",
39
+ "Project",
40
+ "UpdateIssueLabelsInput",
41
+ "UpdateIssueLabelsOperation",
42
+ "new_connection",
43
+ "new_connection_with_operations",
44
+ "new_get_project_step",
45
+ "new_list_issues_step",
46
+ "new_project_connection",
47
+ "new_update_issue_labels_step",
48
+ "CONNECTOR_ID",
49
+ "DEFECT",
50
+ "FOUND",
51
+ "GET_PROJECT_DEFINITION",
52
+ "INVALID_RESPONSE",
53
+ "LIST_ISSUES_DEFINITION",
54
+ "LISTED",
55
+ "NOT_FOUND",
56
+ "PROVIDER_REJECTED",
57
+ "UPDATE_ISSUE_LABELS_DEFINITION",
58
+ "UPDATED",
59
+ ]
@@ -0,0 +1,2 @@
1
+ # Copyright (c) 2026 Super Durable
2
+ # SPDX-License-Identifier: MIT
@@ -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://gitlab.com/api/v4"
14
+ timeout_seconds: float = 15
15
+ max_response_bytes: int = 2097152
16
+
17
+ setattr(Config, '__module__', 'dex_connectors.gitlab.client')
18
+
19
+
20
+ @dataclass(frozen=True, slots=True)
21
+ class Credentials:
22
+
23
+ access_token: SecretString
24
+
25
+ setattr(Credentials, '__module__', 'dex_connectors.gitlab.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_PROJECT_DEFINITION, LIST_ISSUES_DEFINITION, UPDATE_ISSUE_LABELS_DEFINITION
13
+ from ..models import GetProjectInput, Issue, IssuesPage, ListIssuesInput, Project, UpdateIssueLabelsInput
14
+
15
+ class Connection:
16
+
17
+ __slots__ = ('_get_project', '_list_issues', '_update_issue_labels', '_client', 'reference')
18
+
19
+ def __init__(self,
20
+ reference: ConnectionRef,
21
+ get_project: Query[GetProjectInput, Project],
22
+ list_issues: Query[ListIssuesInput, IssuesPage],
23
+ update_issue_labels: Mutation[UpdateIssueLabelsInput, Issue],
24
+ client: Client | None = None,
25
+ ) -> None:
26
+ reference.validate()
27
+ if reference.provider != CONNECTOR_ID or get_project is None or list_issues is None or update_issue_labels is None:
28
+ raise ValueError("GitLab connection provider and operations are required")
29
+ if get_project.definition().operation != GET_PROJECT_DEFINITION.operation:
30
+ raise ValueError("GitLab connection operation identity differs")
31
+ if list_issues.definition().operation != LIST_ISSUES_DEFINITION.operation:
32
+ raise ValueError("GitLab connection operation identity differs")
33
+ if update_issue_labels.definition().operation != UPDATE_ISSUE_LABELS_DEFINITION.operation:
34
+ raise ValueError("GitLab connection operation identity differs")
35
+ self.reference = reference
36
+ self._get_project = get_project
37
+ self._list_issues = list_issues
38
+ self._update_issue_labels = update_issue_labels
39
+ self._client = client
40
+
41
+ def get_project(self) -> Query[GetProjectInput, Project]:
42
+ return self._get_project
43
+
44
+ def list_issues(self) -> Query[ListIssuesInput, IssuesPage]:
45
+ return self._list_issues
46
+
47
+ def update_issue_labels(self) -> Mutation[UpdateIssueLabelsInput, Issue]:
48
+ return self._update_issue_labels
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 "gitlab.Connection([REDACTED])"
56
+
57
+ def __reduce__(self) -> tuple[object, ...]:
58
+ raise TypeError("GitLab connections cannot be serialized")
59
+
60
+ setattr(Connection, '__module__', 'dex_connectors.gitlab.connection')
61
+
62
+
63
+ def new_connection(client: Client, reference: ConnectionRef) -> Connection:
64
+ if client is None:
65
+ raise ValueError("GitLab client is required")
66
+ return Connection(reference, client.get_project(), client.list_issues(), client.update_issue_labels(), client)
67
+
68
+ setattr(new_connection, '__module__', 'dex_connectors.gitlab.connection')
69
+
70
+
71
+ def new_connection_with_operations(
72
+ get_project: Query[GetProjectInput, Project],
73
+ list_issues: Query[ListIssuesInput, IssuesPage],
74
+ update_issue_labels: Mutation[UpdateIssueLabelsInput, Issue],
75
+ reference: ConnectionRef,
76
+ ) -> Connection:
77
+ return Connection(reference, get_project, list_issues, update_issue_labels)
78
+
79
+ setattr(new_connection_with_operations, '__module__', 'dex_connectors.gitlab.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("GitLab stored credential does not match the connector credential fields")
92
+ if set(material) - set(('access_token',)):
93
+ raise ValueError("GitLab stored credential does not match the connector credential fields")
94
+ access_token = material.get("access_token")
95
+ if access_token is not None and not (isinstance(access_token, str)):
96
+ raise ValueError("GitLab credential access_token has an invalid type")
97
+ if not access_token:
98
+ raise ValueError("GitLab credential access_token is required")
99
+ return Credentials(SecretString(access_token))
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("GitLab 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("GitLab project connection is missing or duplicated")
117
+ if matching[0].provider != CONNECTOR_ID:
118
+ raise ValueError("GitLab 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.gitlab.connection')
124
+
125
+
126
+ def _decode_config(value: dict[str, Any]) -> Config:
127
+ if set(value) - {"baseUrl", "timeout", "maxResponseBytes"}:
128
+ raise ValueError("GitLab 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("GitLab 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("GitLab 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("GitLab configuration maxResponseBytes has an invalid type")
144
+ config_arguments['max_response_bytes'] = max_response_bytes
145
+ return Config(**config_arguments)
@@ -0,0 +1,76 @@
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 = "gitlab"
18
+ PROVIDER = "gitlab"
19
+ GET_PROJECT_OPERATION_ID = "getProject"
20
+ LIST_ISSUES_OPERATION_ID = "listIssues"
21
+ UPDATE_ISSUE_LABELS_OPERATION_ID = "updateIssueLabels"
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
+ GET_PROJECT_DEFINITION = QueryDefinition(
31
+ OperationRef(CONNECTOR_ID, GET_PROJECT_OPERATION_ID),
32
+ (
33
+ BranchDefinition(FOUND, "Read one GitLab project by numeric ID or namespace path.", False),
34
+ BranchDefinition(NOT_FOUND, "The requested resource does not exist or is inaccessible.", True),
35
+ BranchDefinition(PROVIDER_REJECTED, "The provider rejected the request.", True),
36
+ BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
37
+ BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
38
+ ),
39
+ StepDefaults(
40
+ timedelta(seconds=30),
41
+ 2,
42
+ execute_retry=default_connector_step_execute_retry_policy(),
43
+ ),
44
+ )
45
+
46
+ LIST_ISSUES_DEFINITION = QueryDefinition(
47
+ OperationRef(CONNECTOR_ID, LIST_ISSUES_OPERATION_ID),
48
+ (
49
+ BranchDefinition(LISTED, "List the first page of issues for a GitLab project.", False),
50
+ BranchDefinition(NOT_FOUND, "The requested resource does not exist or is inaccessible.", True),
51
+ BranchDefinition(PROVIDER_REJECTED, "The provider rejected the request.", True),
52
+ BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
53
+ BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
54
+ ),
55
+ StepDefaults(
56
+ timedelta(seconds=30),
57
+ 2,
58
+ execute_retry=default_connector_step_execute_retry_policy(),
59
+ ),
60
+ )
61
+
62
+ UPDATE_ISSUE_LABELS_DEFINITION = MutationDefinition(
63
+ OperationRef(CONNECTOR_ID, UPDATE_ISSUE_LABELS_OPERATION_ID),
64
+ (
65
+ BranchDefinition(UPDATED, "Replace one GitLab issue's complete label set; repeating the request is safe.", False),
66
+ BranchDefinition(NOT_FOUND, "The requested resource does not exist or is inaccessible.", True),
67
+ BranchDefinition(PROVIDER_REJECTED, "The provider rejected the request.", True),
68
+ BranchDefinition(INVALID_RESPONSE, "The provider returned malformed or oversized JSON.", True),
69
+ BranchDefinition(DEFECT, "Local input or connection credentials are invalid.", True),
70
+ ),
71
+ StepDefaults(
72
+ timedelta(seconds=30),
73
+ 2,
74
+ execute_retry=default_connector_step_execute_retry_policy(),
75
+ ),
76
+ )