dex-connector-google-workspace-admin 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_google_workspace_admin-0.1.0/.gitignore +16 -0
- dex_connector_google_workspace_admin-0.1.0/LICENSE +21 -0
- dex_connector_google_workspace_admin-0.1.0/PKG-INFO +24 -0
- dex_connector_google_workspace_admin-0.1.0/README.md +12 -0
- dex_connector_google_workspace_admin-0.1.0/examples/account_lifecycle/README.md +48 -0
- dex_connector_google_workspace_admin-0.1.0/examples/account_lifecycle/__init__.py +3 -0
- dex_connector_google_workspace_admin-0.1.0/examples/account_lifecycle/flow.py +61 -0
- dex_connector_google_workspace_admin-0.1.0/examples/account_lifecycle/integration_test.py +113 -0
- dex_connector_google_workspace_admin-0.1.0/examples/account_lifecycle/main.py +27 -0
- dex_connector_google_workspace_admin-0.1.0/examples/account_lifecycle/worker.py +30 -0
- dex_connector_google_workspace_admin-0.1.0/pyproject.toml +38 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/__init__.py +78 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/_generated/__init__.py +2 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/_generated/config.py +31 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/_generated/connection.py +273 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/_generated/definitions.py +148 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/_generated/mock.py +416 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/_generated/models.py +247 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/_generated/refresh.py +9 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/_generated/steps.py +399 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/client.py +361 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/connection.py +8 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/dex-connector.json +272 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/json_values.py +23 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/models.py +5 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/operations.py +790 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/py.typed +0 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/query_values.py +16 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/steps.py +5 -0
- dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/workspaceadminmock/__init__.py +6 -0
- dex_connector_google_workspace_admin-0.1.0/tests/refresh_agreement_cases.json +1184 -0
- dex_connector_google_workspace_admin-0.1.0/tests/test_conformance.py +49 -0
- dex_connector_google_workspace_admin-0.1.0/tests/test_json_values.py +15 -0
- dex_connector_google_workspace_admin-0.1.0/tests/test_query_values.py +36 -0
- dex_connector_google_workspace_admin-0.1.0/tests/test_refresh_agreement.py +278 -0
- dex_connector_google_workspace_admin-0.1.0/tests/test_validation.py +40 -0
- dex_connector_google_workspace_admin-0.1.0/uv.lock +866 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
node_modules/
|
|
5
|
+
dist/
|
|
6
|
+
sdkpython/dist/dex_connectors_sdk-0.1.0-py3-none-any.whl
|
|
7
|
+
/.bin/dexcli
|
|
8
|
+
/.bin/dex-server-zd
|
|
9
|
+
/sdkpython/.dexcli-data/
|
|
10
|
+
site/.catalog.yaml
|
|
11
|
+
coverage/
|
|
12
|
+
*.out
|
|
13
|
+
*.test
|
|
14
|
+
go.work
|
|
15
|
+
go.work.sum
|
|
16
|
+
.idea/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Super Durable
|
|
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.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dex-connector-google-workspace-admin
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Dex-native Python connector for Google Workspace Admin
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Requires-Dist: dex-connectors-sdk==0.7.0
|
|
9
|
+
Requires-Dist: dex-python-sdk>=1.28.0
|
|
10
|
+
Requires-Dist: httpx>=0.27
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# Google Workspace Admin for Python
|
|
14
|
+
|
|
15
|
+
This package ports all seven Google Workspace Admin Directory operations to
|
|
16
|
+
Dex Python. Use the generated `new_project_connection` binding with the static
|
|
17
|
+
connection name used by your Flow. Both Workspace domain delegation and Google
|
|
18
|
+
OAuth follow the connector manifest. See the
|
|
19
|
+
[runnable account-list Flow](examples/account_lifecycle/README.md) and the
|
|
20
|
+
[connector setup guide](../README.md).
|
|
21
|
+
|
|
22
|
+
The package has been replayed against Go-recorded provider scenarios and run
|
|
23
|
+
through a real Dex Worker with a local Directory stand-in. Authorization and
|
|
24
|
+
Directory behavior against a live Workspace tenant remain unverified.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Google Workspace Admin for Python
|
|
2
|
+
|
|
3
|
+
This package ports all seven Google Workspace Admin Directory operations to
|
|
4
|
+
Dex Python. Use the generated `new_project_connection` binding with the static
|
|
5
|
+
connection name used by your Flow. Both Workspace domain delegation and Google
|
|
6
|
+
OAuth follow the connector manifest. See the
|
|
7
|
+
[runnable account-list Flow](examples/account_lifecycle/README.md) and the
|
|
8
|
+
[connector setup guide](../README.md).
|
|
9
|
+
|
|
10
|
+
The package has been replayed against Go-recorded provider scenarios and run
|
|
11
|
+
through a real Dex Worker with a local Directory stand-in. Authorization and
|
|
12
|
+
Directory behavior against a live Workspace tenant remain unverified.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Google Workspace Admin Python account list
|
|
2
|
+
|
|
3
|
+
`AccountListFlow` reads one page of accounts with `new_list_users_step` and the static
|
|
4
|
+
`google-workspace-admin` connection. The `listed` branch completes with bounded
|
|
5
|
+
account metadata; unwired optional branches fail the Flow.
|
|
6
|
+
|
|
7
|
+
Configure the connection in Dex Web **Connections** using the
|
|
8
|
+
[Google Workspace Admin setup guide](../../../README.md). Domain delegation is
|
|
9
|
+
the default: enable the Admin SDK, authorize both Directory scopes for the
|
|
10
|
+
service account's client ID, add its JSON key, and name the delegated
|
|
11
|
+
administrator. Google OAuth is also supported. The connection's endpoint,
|
|
12
|
+
response size, and list page size have manifest defaults. This example has no
|
|
13
|
+
operation configuration fields or UI picker. Start the Flow with an optional
|
|
14
|
+
`domain` or `customer` plus search and pagination fields from `ListUsersInput`.
|
|
15
|
+
|
|
16
|
+
From the `python/` directory, generate the strict FDG 2.0 graph from this
|
|
17
|
+
runnable source using the package's interpreter:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
mkdir -p build
|
|
21
|
+
dexcli visualize ./examples/account_lifecycle/flow.py --language python \
|
|
22
|
+
--python .venv/bin/python --schema-version 2.0 --json \
|
|
23
|
+
--out ./build/account-list-python
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Run `dexcli dev` with the graph directory, load the Dex project connection, and
|
|
27
|
+
start the Worker:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
uv run python -m examples.account_lifecycle.main
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`DEX_FLOW_SERVICE_ADDRESS` selects a nondefault Dex server. Start
|
|
34
|
+
`GoogleWorkspaceAdminAccountListPython` with a unique Flow ID and a safe input,
|
|
35
|
+
for example `{"domain":"example.com","pageSize":100}`. A recent account may
|
|
36
|
+
not yet appear in Directory search results; use `getUser` for immediate read-back.
|
|
37
|
+
|
|
38
|
+
The real Dex Worker and Client integration test uses a local Directory stand-in
|
|
39
|
+
that binds an available port and verifies retry, completion, and unwired
|
|
40
|
+
provider rejection:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
DEX_FLOW_SERVICE_ADDRESS=127.0.0.1:42201 uv run \
|
|
44
|
+
pytest examples/account_lifecycle/integration_test.py -q
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Run `dexcli dev -dex-port 42201 -web-port 42202 -open=false` separately for this
|
|
48
|
+
command. The test never contacts a real Workspace tenant.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""List one Directory page through a static Google Workspace connection."""
|
|
4
|
+
|
|
5
|
+
import dex
|
|
6
|
+
from dex_connectors.sdk import QueryResult
|
|
7
|
+
|
|
8
|
+
from dex_connectors.google_workspace_admin import (
|
|
9
|
+
Connection,
|
|
10
|
+
ListUsersInput,
|
|
11
|
+
ListUsersOutput,
|
|
12
|
+
new_list_users_step,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
CONNECTION_NAME = "google-workspace-admin"
|
|
16
|
+
_PAGE = dex.Attribute("google-workspace-admin-users-page", ListUsersOutput)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# dex:group group-id:workspace-admin group-label:"Workspace Admin"
|
|
20
|
+
# dex:explanation text:"Persist the account page returned by Google and complete the Flow."
|
|
21
|
+
class CompleteUserList(dex.Step[QueryResult[ListUsersOutput]]):
|
|
22
|
+
"""Complete the Flow with non-secret account metadata."""
|
|
23
|
+
|
|
24
|
+
def execute(self, context: dex.Context, input: QueryResult[ListUsersOutput]) -> dex.StepDecision:
|
|
25
|
+
"""Store the page in the Flow schema before completing."""
|
|
26
|
+
_PAGE.set(context, input.value)
|
|
27
|
+
return dex.graceful_complete(input.value)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class AccountListFlow(dex.Flow[ListUsersInput]):
|
|
31
|
+
"""Request one bounded page of Workspace users."""
|
|
32
|
+
|
|
33
|
+
def __init__(self, connection: Connection) -> None:
|
|
34
|
+
if connection.reference.name != CONNECTION_NAME:
|
|
35
|
+
raise ValueError("account list requires the static Google Workspace connection")
|
|
36
|
+
self.complete = CompleteUserList()
|
|
37
|
+
self.list_users = new_list_users_step(
|
|
38
|
+
step_type="ListWorkspaceUsers",
|
|
39
|
+
step_input_type=ListUsersInput,
|
|
40
|
+
annotations={
|
|
41
|
+
"groupId": "workspace-admin",
|
|
42
|
+
"groupLabel": "Workspace Admin",
|
|
43
|
+
"explanation": "List one bounded page of Google Workspace accounts.",
|
|
44
|
+
},
|
|
45
|
+
connection=connection,
|
|
46
|
+
connection_name=CONNECTION_NAME,
|
|
47
|
+
map_to_operation_input=lambda input: input,
|
|
48
|
+
listed=self.complete,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def get_flow_type(self) -> str:
|
|
52
|
+
"""Return the stable example Flow identity."""
|
|
53
|
+
return "GoogleWorkspaceAdminAccountListPython"
|
|
54
|
+
|
|
55
|
+
def get_steps(self) -> dex.StepList[ListUsersInput]:
|
|
56
|
+
"""Register the provider Query and completion Step."""
|
|
57
|
+
return dex.StepList.start_step(self.list_users).other_steps(self.complete)
|
|
58
|
+
|
|
59
|
+
def get_persistence_schema(self) -> dex.PersistenceSchema:
|
|
60
|
+
"""Register the page Attribute consumed by Dex."""
|
|
61
|
+
return dex.PersistenceSchema.of(_PAGE)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Exercise Directory Query routing through a real Dex Worker and Client."""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import os
|
|
7
|
+
import tempfile
|
|
8
|
+
from datetime import timedelta
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from uuid import uuid4
|
|
11
|
+
|
|
12
|
+
import dex
|
|
13
|
+
import httpx
|
|
14
|
+
import pytest
|
|
15
|
+
from dex_connectors.sdk import ConnectionRef, SecretString, StaticCredentialProvider
|
|
16
|
+
|
|
17
|
+
from dex_connectors.google_workspace_admin import (
|
|
18
|
+
Client,
|
|
19
|
+
Config,
|
|
20
|
+
Credentials,
|
|
21
|
+
ListUsersInput,
|
|
22
|
+
ListUsersOutput,
|
|
23
|
+
new_connection,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
from .flow import CONNECTION_NAME, AccountListFlow
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.mark.asyncio
|
|
30
|
+
async def test_list_users_retries_and_unwired_rejection_fails_in_dex() -> None:
|
|
31
|
+
"""Verify a real Dex retry, successful page, and optional branch failure."""
|
|
32
|
+
server_address = os.environ["DEX_FLOW_SERVICE_ADDRESS"]
|
|
33
|
+
requests: list[str] = []
|
|
34
|
+
|
|
35
|
+
async def provider(reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
|
|
36
|
+
try:
|
|
37
|
+
request_line = await reader.readline()
|
|
38
|
+
headers = {}
|
|
39
|
+
while line := await reader.readline():
|
|
40
|
+
if line == b"\r\n":
|
|
41
|
+
break
|
|
42
|
+
name, _, value = line.decode().partition(":")
|
|
43
|
+
headers[name.lower()] = value.strip()
|
|
44
|
+
path = request_line.decode().split(" ")[1]
|
|
45
|
+
requests.append(path)
|
|
46
|
+
assert headers.get("authorization") == "Bearer inert-directory-token"
|
|
47
|
+
if "customer=C03az79cb" in path:
|
|
48
|
+
status, body, extra = "403 Forbidden", b"{}", b""
|
|
49
|
+
elif len(requests) == 1:
|
|
50
|
+
status, body, extra = "429 Too Many Requests", b"{}", b"Retry-After: 1\r\n"
|
|
51
|
+
else:
|
|
52
|
+
status = "200 OK"
|
|
53
|
+
body = b'{"users":[{"id":"1001","primaryEmail":"ada@example.com"}]}'
|
|
54
|
+
extra = b""
|
|
55
|
+
response_head = (
|
|
56
|
+
f"HTTP/1.1 {status}\r\nContent-Type: application/json\r\nContent-Length: {len(body)}\r\n"
|
|
57
|
+
).encode()
|
|
58
|
+
writer.write(response_head + extra + b"Connection: close\r\n\r\n" + body)
|
|
59
|
+
await writer.drain()
|
|
60
|
+
finally:
|
|
61
|
+
writer.close()
|
|
62
|
+
await writer.wait_closed()
|
|
63
|
+
|
|
64
|
+
server = await asyncio.start_server(provider, "127.0.0.1", 0)
|
|
65
|
+
address = server.sockets[0].getsockname()
|
|
66
|
+
endpoint = f"http://127.0.0.1:{address[1]}"
|
|
67
|
+
reference = ConnectionRef("google", CONNECTION_NAME)
|
|
68
|
+
credentials = Credentials(access_token=SecretString("inert-directory-token"))
|
|
69
|
+
try:
|
|
70
|
+
async with httpx.AsyncClient() as provider_client:
|
|
71
|
+
connector_client = Client(
|
|
72
|
+
Config(endpoint=endpoint), StaticCredentialProvider({reference: credentials}), provider_client
|
|
73
|
+
)
|
|
74
|
+
flow = AccountListFlow(new_connection(connector_client, reference))
|
|
75
|
+
registry = dex.Registry([flow], allow_async_handlers=True)
|
|
76
|
+
with tempfile.TemporaryDirectory(prefix="workspace-admin-dex-") as directory:
|
|
77
|
+
cache = dex.open_blob_cache(dex.BlobCacheConfig(str(Path(directory) / "blobs"), 1 << 24))
|
|
78
|
+
try:
|
|
79
|
+
worker = dex.AsyncWorker(
|
|
80
|
+
registry, cache, dex.WorkerOptions(server_address=server_address)
|
|
81
|
+
)
|
|
82
|
+
worker_task = asyncio.create_task(worker.start())
|
|
83
|
+
try:
|
|
84
|
+
await worker.wait_pull_registered(timeout=15)
|
|
85
|
+
async with dex.AsyncClient(
|
|
86
|
+
registry, cache, dex.ClientOptions(server_address=server_address)
|
|
87
|
+
) as dex_client:
|
|
88
|
+
completed_id = f"workspace-admin-{uuid4().hex}"
|
|
89
|
+
await dex_client.start_flow(flow, completed_id, ListUsersInput())
|
|
90
|
+
completed = await asyncio.wait_for(
|
|
91
|
+
dex_client.wait_for_flow(completed_id, timedelta(seconds=20)), 30
|
|
92
|
+
)
|
|
93
|
+
assert completed.status == dex.FlowStatus.COMPLETED, completed.error_message
|
|
94
|
+
page = completed.single_output(ListUsersOutput)
|
|
95
|
+
assert page.users[0].id == "1001"
|
|
96
|
+
rejected_id = f"workspace-admin-{uuid4().hex}"
|
|
97
|
+
await dex_client.start_flow(
|
|
98
|
+
flow, rejected_id, ListUsersInput(customer="C03az79cb")
|
|
99
|
+
)
|
|
100
|
+
rejected = await asyncio.wait_for(
|
|
101
|
+
dex_client.wait_for_flow(rejected_id, timedelta(seconds=20)), 30
|
|
102
|
+
)
|
|
103
|
+
assert rejected.status == dex.FlowStatus.FAILED
|
|
104
|
+
assert "providerRejected" in (rejected.error_message or "")
|
|
105
|
+
assert len(requests) == 3
|
|
106
|
+
finally:
|
|
107
|
+
await worker.stop()
|
|
108
|
+
await worker_task
|
|
109
|
+
finally:
|
|
110
|
+
cache.close()
|
|
111
|
+
finally:
|
|
112
|
+
server.close()
|
|
113
|
+
await server.wait_closed()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Load the Google Workspace Admin project connection and start its Worker."""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
|
|
7
|
+
from dex_connectors.sdk.projectconfig import load_from_environment
|
|
8
|
+
|
|
9
|
+
from dex_connectors.google_workspace_admin import new_project_connection
|
|
10
|
+
|
|
11
|
+
from .flow import CONNECTION_NAME, AccountListFlow
|
|
12
|
+
from .worker import run_worker
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
async def main() -> None:
|
|
16
|
+
"""Serve the account-list Flow with the configured Dex connection."""
|
|
17
|
+
project = await load_from_environment()
|
|
18
|
+
connection = new_project_connection(project, CONNECTION_NAME)
|
|
19
|
+
try:
|
|
20
|
+
await run_worker(AccountListFlow(connection))
|
|
21
|
+
finally:
|
|
22
|
+
await connection.aclose()
|
|
23
|
+
await project.close()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if __name__ == "__main__":
|
|
27
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Run the account-list Flow on a real Dex Worker."""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import tempfile
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import dex
|
|
10
|
+
|
|
11
|
+
from .flow import AccountListFlow
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async def run_worker(flow: AccountListFlow) -> None:
|
|
15
|
+
"""Register the Flow and run until the Worker stops."""
|
|
16
|
+
cache_directory = os.environ.get(
|
|
17
|
+
"DEX_BLOB_CACHE_DIR", str(Path(tempfile.gettempdir()) / "dex-workspace-admin-blobs")
|
|
18
|
+
)
|
|
19
|
+
cache = dex.open_blob_cache(dex.BlobCacheConfig(cache_directory, 1 << 24))
|
|
20
|
+
try:
|
|
21
|
+
registry = dex.Registry([flow], allow_async_handlers=True)
|
|
22
|
+
worker = dex.AsyncWorker(
|
|
23
|
+
registry,
|
|
24
|
+
cache,
|
|
25
|
+
dex.WorkerOptions(server_address=os.environ.get("DEX_FLOW_SERVICE_ADDRESS", "localhost:8801")),
|
|
26
|
+
)
|
|
27
|
+
async with worker:
|
|
28
|
+
await worker.start()
|
|
29
|
+
finally:
|
|
30
|
+
cache.close()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dex-connector-google-workspace-admin"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Dex-native Python connector for Google Workspace Admin"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
dependencies = ["dex-connectors-sdk==0.7.0", "dex-python-sdk>=1.28.0", "httpx>=0.27"]
|
|
14
|
+
|
|
15
|
+
[dependency-groups]
|
|
16
|
+
dev = ["pytest>=8", "pytest-asyncio>=0.24", "mypy>=1.13", "ruff>=0.7"]
|
|
17
|
+
|
|
18
|
+
[tool.hatch.build.targets.wheel]
|
|
19
|
+
packages = ["src/dex_connectors"]
|
|
20
|
+
|
|
21
|
+
[tool.pytest.ini_options]
|
|
22
|
+
testpaths = ["tests"]
|
|
23
|
+
pythonpath = [".", "src"]
|
|
24
|
+
asyncio_mode = "auto"
|
|
25
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
26
|
+
|
|
27
|
+
[tool.mypy]
|
|
28
|
+
python_version = "3.11"
|
|
29
|
+
strict = true
|
|
30
|
+
mypy_path = "src"
|
|
31
|
+
explicit_package_bases = true
|
|
32
|
+
|
|
33
|
+
[tool.ruff]
|
|
34
|
+
target-version = "py311"
|
|
35
|
+
line-length = 110
|
|
36
|
+
|
|
37
|
+
[tool.ruff.lint]
|
|
38
|
+
select = ["E", "F", "I", "UP", "B"]
|
dex_connector_google_workspace_admin-0.1.0/src/dex_connectors/google_workspace_admin/__init__.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Google Workspace Admin Directory operations for Dex Flows."""
|
|
4
|
+
|
|
5
|
+
from .client import Client, Config, Credentials
|
|
6
|
+
from .connection import Connection, new_connection, new_connection_with_operations, new_project_connection
|
|
7
|
+
from .models import (
|
|
8
|
+
AddUserToGroupInput,
|
|
9
|
+
AddUserToGroupOutput,
|
|
10
|
+
CreateUserInput,
|
|
11
|
+
CreateUserOutput,
|
|
12
|
+
GetUserInput,
|
|
13
|
+
GroupMembership,
|
|
14
|
+
ListUsersInput,
|
|
15
|
+
ListUsersOutput,
|
|
16
|
+
RemoveUserFromGroupInput,
|
|
17
|
+
RemoveUserFromGroupOutput,
|
|
18
|
+
SuspendUserInput,
|
|
19
|
+
UnsuspendUserInput,
|
|
20
|
+
User,
|
|
21
|
+
UserName,
|
|
22
|
+
)
|
|
23
|
+
from .operations import (
|
|
24
|
+
AddUserToGroupOperation,
|
|
25
|
+
CreateUserOperation,
|
|
26
|
+
GetUserOperation,
|
|
27
|
+
ListUsersOperation,
|
|
28
|
+
RemoveUserFromGroupOperation,
|
|
29
|
+
SuspendUserOperation,
|
|
30
|
+
UnsuspendUserOperation,
|
|
31
|
+
)
|
|
32
|
+
from .steps import (
|
|
33
|
+
new_add_user_to_group_step,
|
|
34
|
+
new_create_user_step,
|
|
35
|
+
new_get_user_step,
|
|
36
|
+
new_list_users_step,
|
|
37
|
+
new_remove_user_from_group_step,
|
|
38
|
+
new_suspend_user_step,
|
|
39
|
+
new_unsuspend_user_step,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"Client",
|
|
44
|
+
"Config",
|
|
45
|
+
"Credentials",
|
|
46
|
+
"Connection",
|
|
47
|
+
"new_connection",
|
|
48
|
+
"new_connection_with_operations",
|
|
49
|
+
"new_project_connection",
|
|
50
|
+
"AddUserToGroupInput",
|
|
51
|
+
"AddUserToGroupOutput",
|
|
52
|
+
"CreateUserInput",
|
|
53
|
+
"CreateUserOutput",
|
|
54
|
+
"GetUserInput",
|
|
55
|
+
"GroupMembership",
|
|
56
|
+
"ListUsersInput",
|
|
57
|
+
"ListUsersOutput",
|
|
58
|
+
"RemoveUserFromGroupInput",
|
|
59
|
+
"RemoveUserFromGroupOutput",
|
|
60
|
+
"SuspendUserInput",
|
|
61
|
+
"UnsuspendUserInput",
|
|
62
|
+
"User",
|
|
63
|
+
"UserName",
|
|
64
|
+
"AddUserToGroupOperation",
|
|
65
|
+
"CreateUserOperation",
|
|
66
|
+
"GetUserOperation",
|
|
67
|
+
"ListUsersOperation",
|
|
68
|
+
"RemoveUserFromGroupOperation",
|
|
69
|
+
"SuspendUserOperation",
|
|
70
|
+
"UnsuspendUserOperation",
|
|
71
|
+
"new_add_user_to_group_step",
|
|
72
|
+
"new_create_user_step",
|
|
73
|
+
"new_get_user_step",
|
|
74
|
+
"new_list_users_step",
|
|
75
|
+
"new_remove_user_from_group_step",
|
|
76
|
+
"new_suspend_user_step",
|
|
77
|
+
"new_unsuspend_user_step",
|
|
78
|
+
]
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
endpoint: str = "https://admin.googleapis.com"
|
|
14
|
+
max_response_bytes: int = 4194304
|
|
15
|
+
list_users_page_size: int = 100
|
|
16
|
+
|
|
17
|
+
setattr(Config, '__module__', 'dex_connectors.google_workspace_admin.client')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True, slots=True)
|
|
21
|
+
class Credentials:
|
|
22
|
+
|
|
23
|
+
auth_method_id: str = "workspace-domain-delegation"
|
|
24
|
+
service_account_key: SecretString | None = None
|
|
25
|
+
delegated_user: str | None = None
|
|
26
|
+
access_token: SecretString = SecretString('')
|
|
27
|
+
oauth_client_id: str | None = None
|
|
28
|
+
oauth_client_secret: SecretString | None = None
|
|
29
|
+
refresh_token: SecretString | None = None
|
|
30
|
+
|
|
31
|
+
setattr(Credentials, '__module__', 'dex_connectors.google_workspace_admin.client')
|