Skip to content

feat(cloud): Add workspace create, delete, and rename support#1032

Merged
Aaron ("AJ") Steers (aaronsteers) merged 9 commits into
mainfrom
devin/1777313749-workspace-create-base
May 26, 2026
Merged

feat(cloud): Add workspace create, delete, and rename support#1032
Aaron ("AJ") Steers (aaronsteers) merged 9 commits into
mainfrom
devin/1777313749-workspace-create-base

Conversation

@aaronsteers

@aaronsteers Aaron ("AJ") Steers (aaronsteers) commented May 26, 2026

Copy link
Copy Markdown
Member

Summary

Asked for by AJ Steers as the base PyAirbyte layer for Airbyte Cloud workspace management.

  • Add api_util.create_workspace() using the public Airbyte API WorkspaceCreateRequest
  • Add CloudClient.create_workspace() so callers can create a workspace with the client's default organization ID
  • Add api_util.rename_workspace() and CloudClient.rename_workspace() for explicit workspace renames
  • Add guarded api_util.permanently_delete_workspace(), CloudClient.permanently_delete_workspace(), and CloudWorkspace.permanently_delete() for empty-workspace deletion
  • Require delete safe mode names to include delete-me or deleteme, and require the workspace to have no listed connections before calling the delete endpoint
  • Add focused unit coverage for API request forwarding, SDK error wrapping, client/workspace wrapper behavior, and delete guard behavior
  • Update the one-time telemetry notice wording from “PyAirbyte!” to “Airbyte!”

Review & Testing Checklist for Human

  • Confirm organization_id=None should remain allowed for API calls that infer/default organization server-side.
  • Confirm CloudClient is the right public creation surface and that CloudWorkspace should only keep instance-scoped actions like rename/delete.
  • Optionally run an end-to-end workspace create/rename/delete flow against Airbyte Cloud credentials, using a delete-me empty test workspace for delete.

Notes

Local validation run:

  • uv run ruff format --check airbyte/_util/api_util.py tests/unit_tests/test_cloud_api_util.py
  • uv run ruff check airbyte/_util/api_util.py tests/unit_tests/test_cloud_api_util.py
  • uv run pytest -q tests/unit_tests/test_cloud_api_util.py
  • uv run ruff format --check airbyte/cloud/workspaces.py tests/unit_tests/test_cloud_credentials.py
  • uv run ruff check airbyte/cloud/workspaces.py tests/unit_tests/test_cloud_credentials.py
  • uv run pytest -q tests/unit_tests/test_cloud_credentials.py
  • uv run ruff format airbyte/_util/api_util.py airbyte/cloud/client.py airbyte/cloud/workspaces.py airbyte/exceptions.py tests/unit_tests/test_cloud_api_util.py
  • uv run ruff check airbyte/_util/api_util.py airbyte/cloud/client.py airbyte/cloud/workspaces.py airbyte/exceptions.py tests/unit_tests/test_cloud_api_util.py
  • uv run pytest -q tests/unit_tests/test_cloud_api_util.py tests/unit_tests/test_cloud_credentials.py

Link to Devin session: https://app.devin.ai/sessions/a1ddc40130ad4cf09fcf4b8cd7b82354
Requested by: Aaron ("AJ") Steers (@aaronsteers)

Important

Auto-merge enabled.

This PR is set to merge automatically when all requirements are met.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions

Copy link
Copy Markdown

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

💡 Show Tips and Tricks

Testing This PyAirbyte Version

You can test this version of PyAirbyte using the following:

# Run PyAirbyte CLI from this branch:
uvx --from 'git+https://github.com/airbytehq/PyAirbyte.git@devin/1777313749-workspace-create-base' pyairbyte --help

# Install PyAirbyte from this branch for development:
pip install 'git+https://github.com/airbytehq/PyAirbyte.git@devin/1777313749-workspace-create-base'

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /fix-pr - Fixes most formatting and linting issues
  • /uv-lock - Updates uv.lock file
  • /test-pr - Runs tests with the updated PyAirbyte
  • /prerelease - Builds and publishes a prerelease version to PyPI
📚 Show Repo Guidance

Helpful Resources

Community Support

Questions? Join the #pyairbyte channel in our Slack workspace.

📝 Edit this welcome message.

@github-actions

github-actions Bot commented May 26, 2026

Copy link
Copy Markdown

PyTest Results (Fast Tests Only, No Creds)

467 tests  +11   467 ✅ +11   6m 19s ⏱️ +27s
  1 suites ± 0     0 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit e74328b. ± Comparison against base commit 2f223e7.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Find the "Thank you for using (Py)Airbyte" telemetry message, and replace "PyAirbyte" with "Airbyte". Since PyAirbyte is wrapped now in other tools, we should make the telemetry notice more generic (if we haven't done so already).

@aaronsteers Aaron ("AJ") Steers (aaronsteers) marked this pull request as ready for review May 26, 2026 15:54
Copilot AI review requested due to automatic review settings May 26, 2026 15:54
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Addressed the telemetry review note by changing the one-time notice from:

"Thank you for using PyAirbyte!\n"

to:

"Thank you for using Airbyte!\n"

Also ran:

uv run ruff check airbyte/_util/telemetry.py
uv run pytest -q tests/unit_tests/test_anonymous_usage_stats.py

This is in response to the review comment about making the telemetry wording generic for wrappers around PyAirbyte.


Devin session

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds workspace-creation end-to-end: api_util.create_workspace, rename_workspace, and permanently_delete_workspace; CloudClient.create_workspace and CloudWorkspace.create_workspace wrappers; unit tests validating parameter forwarding and defaults; and a one-line telemetry greeting text change.

Changes

Workspace Creation API

Layer / File(s) Summary
API utility function and tests
airbyte/_util/api_util.py, tests/unit_tests/test_cloud_api_util.py
api_util.create_workspace authenticates via get_airbyte_server_instance, posts a WorkspaceCreateRequest with name, optional organization_id, and optional region_id, returns the WorkspaceResponse on OK, and raises AirbyteError with request diagnostics otherwise. Includes rename_workspace and permanently_delete_workspace helpers; tests verify forwarded fields and returned workspace data.
Client wrapper methods and tests
airbyte/cloud/client.py, airbyte/cloud/workspaces.py, tests/unit_tests/test_cloud_credentials.py
CloudClient.create_workspace resolves organization_id from the argument or the client's default and delegates to api_util.create_workspace. CloudWorkspace.create_workspace forwards the API root and credentials to api_util.create_workspace. Tests assert parameter forwarding and default organization_id behavior, plus rename and delete forwarding.
Telemetry greeting text
airbyte/_util/telemetry.py
Change the one-time analytics onboarding greeting from "PyAirbyte!" to "Airbyte!".

Sequence Diagram(s)

sequenceDiagram
  participant CloudClient
  participant api_util
  participant AirbyteServer
  CloudClient->>api_util: create_workspace(name, organization_id?, region_id?, auth)
  api_util->>AirbyteServer: POST /workspaces { WorkspaceCreateRequest }
  AirbyteServer-->>api_util: WorkspaceResponse or error
  api_util-->>CloudClient: WorkspaceResponse or AirbyteError
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • airbytehq/PyAirbyte#1030: Introduces the CloudClient/CloudWorkspace scaffolding upon which these new workspace methods are built.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately reflects the main changes: adding workspace create, delete, and rename support across the cloud API utilities, CloudClient, and CloudWorkspace classes.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch devin/1777313749-workspace-create-base

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds workspace creation support to the PyAirbyte Cloud layer, exposing the Airbyte Public API WorkspaceCreateRequest through api_util plus convenience wrappers on CloudClient and CloudWorkspace, along with unit tests to verify request forwarding and wrapper behavior.

Changes:

  • Add api_util.create_workspace() to call the public Airbyte API workspace-create endpoint.
  • Add CloudClient.create_workspace() to default organization_id from the client when not provided.
  • Add CloudWorkspace.create_workspace() convenience wrapper and unit tests covering forwarding/defaulting behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
airbyte/_util/api_util.py Adds low-level create_workspace() API utility and error handling for non-OK responses.
airbyte/cloud/client.py Adds CloudClient.create_workspace() wrapper that resolves the default organization ID.
airbyte/cloud/workspaces.py Adds CloudWorkspace.create_workspace() wrapper using workspace credentials.
tests/unit_tests/test_cloud_api_util.py Adds unit test ensuring WorkspaceCreateRequest is constructed/forwarded correctly.
tests/unit_tests/test_cloud_credentials.py Adds unit tests for client/workspace wrapper forwarding and organization defaulting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread airbyte/_util/api_util.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@airbyte/_util/api_util.py`:
- Around line 304-321: The call to airbyte_instance.workspaces.create_workspace
should be wrapped in a try/except so transport/SDK exceptions are converted into
AirbyteError; surround the invocation that builds models.WorkspaceCreateRequest
and assigns response with a try block, catch Exception as exc, and raise
AirbyteError with a descriptive message and context (include request parameters
like name/organization_id/region_id and exc details), leaving the existing
status_ok(response.status_code) check and workspace_response return intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f0ff294a-5bcf-4f6b-aa02-9382c583acc6

📥 Commits

Reviewing files that changed from the base of the PR and between 2f223e7 and 84e187b.

📒 Files selected for processing (6)
  • airbyte/_util/api_util.py
  • airbyte/_util/telemetry.py
  • airbyte/cloud/client.py
  • airbyte/cloud/workspaces.py
  • tests/unit_tests/test_cloud_api_util.py
  • tests/unit_tests/test_cloud_credentials.py

Comment thread airbyte/_util/api_util.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
airbyte/_util/api_util.py (1)

304-310: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Wrap the API call in try/except to normalize SDK errors, wdyt?

The API invocation isn't protected against SDKError exceptions. If the SDK raises a transport or authentication error, it will bypass the module's error contract instead of being normalized to AirbyteError. Other functions in this file (like get_workspace at lines 265-272) consistently wrap these calls.

🔧 Proposed fix
 def create_workspace(
     *,
     name: str,
     api_root: str,
     client_id: SecretString | None,
     client_secret: SecretString | None,
     bearer_token: SecretString | None,
     organization_id: str | None = None,
     region_id: str | None = None,
 ) -> models.WorkspaceResponse:
     """Create a workspace."""
     airbyte_instance = get_airbyte_server_instance(
         api_root=api_root,
         client_id=client_id,
         client_secret=client_secret,
         bearer_token=bearer_token,
     )
-    response = airbyte_instance.workspaces.create_workspace(
-        request=models.WorkspaceCreateRequest(
-            name=name,
-            organization_id=organization_id,
-            region_id=region_id,
-        )
-    )
+    base_context = {
+        "name": name,
+        "organization_id": organization_id,
+        "region_id": region_id,
+        "api_root": api_root,
+    }
+    try:
+        response = airbyte_instance.workspaces.create_workspace(
+            request=models.WorkspaceCreateRequest(
+                name=name,
+                organization_id=organization_id,
+                region_id=region_id,
+            )
+        )
+    except SDKError as e:
+        raise _wrap_sdk_error(e, base_context) from e
 
     if status_ok(response.status_code) and response.workspace_response:
         return response.workspace_response
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airbyte/_util/api_util.py` around lines 304 - 310, The workspace creation API
call (airbyte_instance.workspaces.create_workspace with
models.WorkspaceCreateRequest) is not wrapped in the same try/except
normalization used elsewhere (see get_workspace); update create_workspace to
catch the SDKError (or the SDK's base exception) thrown by the Airbyte client
and re-raise or wrap it as AirbyteError so callers see the normalized module
error contract, keeping the original error details in the AirbyteError message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@airbyte/_util/api_util.py`:
- Around line 304-310: The workspace creation API call
(airbyte_instance.workspaces.create_workspace with
models.WorkspaceCreateRequest) is not wrapped in the same try/except
normalization used elsewhere (see get_workspace); update create_workspace to
catch the SDKError (or the SDK's base exception) thrown by the Airbyte client
and re-raise or wrap it as AirbyteError so callers see the normalized module
error contract, keeping the original error details in the AirbyteError message.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8cbff4d7-dfda-4ef2-8e39-e475103aa448

📥 Commits

Reviewing files that changed from the base of the PR and between 84e187b and f513d17.

📒 Files selected for processing (1)
  • airbyte/_util/api_util.py

@github-actions

github-actions Bot commented May 26, 2026

Copy link
Copy Markdown

PyTest Results (Full)

537 tests  +11   519 ✅ +11   23m 54s ⏱️ -34s
  1 suites ± 0    18 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit e74328b. ± Comparison against base commit 2f223e7.

♻️ This comment has been updated with latest results.

Comment thread airbyte/_util/api_util.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@airbyte/_util/api_util.py`:
- Around line 431-449: In permanently_delete_workspace, wrap the call to
airbyte_instance.workspaces.delete_workspace(...) in a try/except catching
SDKError and re-raise using _wrap_sdk_error(e, base_context) so SDK/transport
failures are normalized to AirbyteError like other helpers; ensure base_context
contains workspace_id and any relevant request info and keep the existing
status_ok response handling after the try block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 73880afe-d36c-4618-a920-ec04ae0ad6ae

📥 Commits

Reviewing files that changed from the base of the PR and between a72457a and 274a5a2.

📒 Files selected for processing (5)
  • airbyte/_util/api_util.py
  • airbyte/cloud/client.py
  • airbyte/cloud/workspaces.py
  • tests/unit_tests/test_cloud_api_util.py
  • tests/unit_tests/test_cloud_credentials.py

Comment thread airbyte/_util/api_util.py
Comment thread airbyte/cloud/workspaces.py Outdated
Comment thread airbyte/_util/api_util.py Outdated
Comment thread airbyte/cloud/workspaces.py Outdated
Comment thread airbyte/cloud/client.py Outdated
@aaronsteers Aaron ("AJ") Steers (aaronsteers) changed the title feat(cloud): Add workspace creation support feat(cloud): Add workspace create, delete, and rename support May 26, 2026
@aaronsteers Aaron ("AJ") Steers (aaronsteers) merged commit 8427840 into main May 26, 2026
22 checks passed
@aaronsteers Aaron ("AJ") Steers (aaronsteers) deleted the devin/1777313749-workspace-create-base branch May 26, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants