Skip to content

Commit e1ce952

Browse files
authored
Merge branch 'main' into birdcar/complete-audit-log-endpoints
2 parents 733353f + bf23a30 commit e1ce952

File tree

8 files changed

+507
-28
lines changed

8 files changed

+507
-28
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,26 @@ jobs:
3939

4040
- name: Test
4141
run: uv run pytest
42+
43+
smoke-test:
44+
name: Smoke test (Python ${{ matrix.python }})
45+
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'version-bump')
46+
runs-on: ubuntu-latest
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
51+
steps:
52+
- uses: actions/checkout@v3
53+
- uses: astral-sh/setup-uv@v7
54+
with:
55+
python-version: ${{ matrix.python }}
56+
57+
- name: Build
58+
run: uv build
59+
60+
- name: Smoke test (wheel)
61+
run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
62+
63+
- name: Smoke test (sdist)
64+
run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py

.github/workflows/release.yml

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,61 @@
11
name: Release
22

33
on:
4-
# Support manually pushing a new release
5-
workflow_dispatch: {}
6-
# Trigger when a release or pre-release is published
7-
release:
8-
types: [published]
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
97

108
defaults:
119
run:
1210
shell: bash
1311

1412
jobs:
15-
pypi:
13+
create-release:
14+
name: Create GitHub Release
15+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'version-bump')
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
steps:
20+
- name: Generate token
21+
id: generate-token
22+
uses: actions/create-github-app-token@v1
23+
with:
24+
app-id: ${{ vars.WORKOS_BOT_APP_ID }}
25+
private-key: ${{ secrets.WORKOS_BOT_PRIVATE_KEY }}
26+
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
token: ${{ steps.generate-token.outputs.token }}
31+
32+
- name: Get version from pyproject.toml
33+
id: get-version
34+
run: |
35+
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
38+
- name: Create Release
39+
uses: softprops/action-gh-release@v2
40+
with:
41+
tag_name: v${{ steps.get-version.outputs.version }}
42+
name: v${{ steps.get-version.outputs.version }}
43+
generate_release_notes: true
44+
token: ${{ steps.generate-token.outputs.token }}
45+
46+
publish:
1647
name: Publish to PyPI
48+
needs: create-release
1749
runs-on: ubuntu-latest
1850
permissions:
51+
id-token: write
1952
contents: read
2053
steps:
2154
- name: Checkout
22-
uses: actions/checkout@v5
55+
uses: actions/checkout@v4
2356
- name: Install uv
2457
uses: astral-sh/setup-uv@v6
25-
- name: Install dependencies
26-
run: uv sync --locked
27-
- name: Test
28-
run: uv run pytest
2958
- name: Build
3059
run: uv build
3160
- name: Publish
32-
env:
33-
TWINE_NON_INTERACTIVE: true
34-
TWINE_USERNAME: "__token__"
35-
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
36-
run: uvx twine upload dist/* --skip-existing
61+
run: uv publish

.github/workflows/version-bump.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Version Bump
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump_type:
7+
description: "Version bump type"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
jobs:
16+
bump-version:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
pull-requests: write
21+
steps:
22+
- name: Generate token
23+
id: generate-token
24+
uses: actions/create-github-app-token@v1
25+
with:
26+
app-id: ${{ vars.WORKOS_BOT_APP_ID }}
27+
private-key: ${{ secrets.WORKOS_BOT_PRIVATE_KEY }}
28+
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
with:
32+
token: ${{ steps.generate-token.outputs.token }}
33+
34+
- name: Configure Git
35+
run: |
36+
git config user.name "workos-bot[bot]"
37+
git config user.email "workos-bot[bot]@users.noreply.github.com"
38+
39+
- name: Read current version
40+
id: current-version
41+
run: |
42+
CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
43+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
44+
45+
- name: Bump version
46+
id: bump-version
47+
run: |
48+
CURRENT_VERSION="${{ steps.current-version.outputs.version }}"
49+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
50+
51+
case "${{ github.event.inputs.bump_type }}" in
52+
major)
53+
NEW_VERSION="$((MAJOR + 1)).0.0"
54+
;;
55+
minor)
56+
NEW_VERSION="$MAJOR.$((MINOR + 1)).0"
57+
;;
58+
patch)
59+
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
60+
;;
61+
esac
62+
63+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
64+
65+
- name: Install uv
66+
uses: astral-sh/setup-uv@v6
67+
68+
- name: Update version in pyproject.toml
69+
run: |
70+
sed -i 's/^version = ".*"/version = "${{ steps.bump-version.outputs.new_version }}"/' pyproject.toml
71+
72+
- name: Update uv.lock
73+
run: uv lock
74+
75+
- name: Create Pull Request
76+
uses: peter-evans/create-pull-request@v7
77+
with:
78+
token: ${{ steps.generate-token.outputs.token }}
79+
commit-message: "v${{ steps.bump-version.outputs.new_version }}"
80+
title: "v${{ steps.bump-version.outputs.new_version }}"
81+
body: |
82+
Bumps version from ${{ steps.current-version.outputs.version }} to ${{ steps.bump-version.outputs.new_version }}.
83+
84+
This PR was automatically created by the version-bump workflow.
85+
branch: version-bump-${{ steps.bump-version.outputs.new_version }}
86+
labels: version-bump

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "workos"
3-
version = "5.38.1"
3+
version = "5.39.1"
44
description = "WorkOS Python Client"
55
readme = "README.md"
66
license = "MIT"

src/workos/directory_sync.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Protocol
1+
from typing import Any, Dict, Optional, Protocol, Union
22

33
from workos.types.directory_sync.list_filters import (
44
DirectoryGroupListFilters,
@@ -32,6 +32,24 @@
3232
Directory, DirectoryListFilters, ListMetadata
3333
]
3434

35+
# Mapping from SDK parameter names to API parameter names
36+
PARAM_KEY_MAPPING = {
37+
"directory_id": "directory",
38+
"group_id": "group",
39+
"user_id": "user",
40+
}
41+
42+
43+
def _prepare_request_params(
44+
list_params: Union[DirectoryUserListFilters, DirectoryGroupListFilters],
45+
) -> Dict[str, Any]:
46+
"""Convert list_params to API request params by renaming keys."""
47+
request_params: Dict[str, Any] = dict(list_params)
48+
for sdk_key, api_key in PARAM_KEY_MAPPING.items():
49+
if sdk_key in request_params:
50+
request_params[api_key] = request_params.pop(sdk_key)
51+
return request_params
52+
3553

3654
class DirectorySyncModule(Protocol):
3755
"""Offers methods through the WorkOS Directory Sync service."""
@@ -191,7 +209,7 @@ def list_users(
191209
response = self._http_client.request(
192210
"directory_users",
193211
method=REQUEST_METHOD_GET,
194-
params=list_params,
212+
params=_prepare_request_params(list_params),
195213
)
196214

197215
return WorkOSListResource(
@@ -225,7 +243,7 @@ def list_groups(
225243
response = self._http_client.request(
226244
"directory_groups",
227245
method=REQUEST_METHOD_GET,
228-
params=list_params,
246+
params=_prepare_request_params(list_params),
229247
)
230248

231249
return WorkOSListResource[
@@ -329,7 +347,7 @@ async def list_users(
329347
response = await self._http_client.request(
330348
"directory_users",
331349
method=REQUEST_METHOD_GET,
332-
params=list_params,
350+
params=_prepare_request_params(list_params),
333351
)
334352

335353
return WorkOSListResource(
@@ -354,6 +372,7 @@ async def list_groups(
354372
"after": after,
355373
"order": order,
356374
}
375+
357376
if user_id is not None:
358377
list_params["user_id"] = user_id
359378
if directory_id is not None:
@@ -362,7 +381,7 @@ async def list_groups(
362381
response = await self._http_client.request(
363382
"directory_groups",
364383
method=REQUEST_METHOD_GET,
365-
params=list_params,
384+
params=_prepare_request_params(list_params),
366385
)
367386

368387
return WorkOSListResource[

0 commit comments

Comments
 (0)