Skip to content

Conversation

@briangreunke
Copy link
Contributor

Summary

This commit introduces new CLI commands under the rbac subgroup to manage organizations and workspaces. Users can now list organizations, and list, create, and delete workspaces, with support for specifying organizations or intelligent default handling.

Conventional Commit Breakdown

  • Type: feat
  • Subject: Add CLI commands for organizations and workspaces

Key Changes

  • dreadnode/cli/rbac/__init__.py: Initializes the new rbac CLI subgroup, exposing its commands.
  • dreadnode/cli/rbac/organizations.py:
    • Adds a new organizations CLI group.
    • Implements a show command (list, ls) to display all organizations the user has access to.
  • dreadnode/cli/rbac/workspaces.py:
    • Adds a new workspaces CLI group.
    • Implements a show command (list, ls) to display workspaces, with an optional --organization filter. It intelligently handles scenarios where a user belongs to zero, one, or multiple organizations.
    • Implements a create command (new) to create a new workspace within a specified or default organization, including user confirmation.
    • Implements a delete command (rm) to remove an existing workspace, requiring user confirmation for critical data deletion.

Testing/Verification

Tested locally by executing the new organizations show, workspaces show, workspaces create, and workspaces delete commands with various parameters and edge cases.

Introduce new data models for Workspace and Organization in dreadnode/api/models.py. Also updates the Project model to include a 'workspace_id'.
Introduce four new client methods: list_organizations, get_organization, list_workspaces, and get_workspace. These methods handle CRUD-like operations for the newly introduced RBAC-related models.
Adds support for specifying default Organization and Workspace via environment variables (DREADNODE_ORGANIZATION, DREADNODE_WORKSPACE) or initialization parameters. The client now includes logic to automatically select an organization and workspace if only one exists, and raises errors for ambiguity or non-existence, enforcing the new RBAC structure.
…logic

This commit refactors the initialization logic in `Dreadnode` to automatically resolve or create the current organization, workspace, and project based on configuration or defaults.

The changes include:
* **API Client Enhancements**: Added methods for `create_workspace`, `create_project`, and updated existing `list_projects`, `get_project`, `list_workspaces`, `get_organization`, and `get_workspace` to support filters, pagination (for workspaces), and UUID identifiers.
* **RBAC Resolution**: New private methods (`_resolve_organization`, `_resolve_workspace`, `_resolve_project`, `_resolve_rbac`) handle the full resolution workflow, including default creation for workspaces and projects if they don't exist.
* **Model Updates**: Introduced `WorkspaceFilter`, and `PaginatedWorkspaces` Pydantic models.
* **RunSpan Update**: Renamed `project` attribute to `project_id` in `RunSpan` for clarity, reflecting the use of the ID in traces/spans.
* **Constants**: Added `DEFAULT_WORKSPACE_NAME` and `DEFAULT_PROJECT_NAME`.

This enables a much smoother initialization experience for users, automatically provisioning necessary resources.
…tion

Introduce robust logic for resolving organization, workspace, and project from configuration, environment variables, or path strings (e.g., 'org/ws/project').

Updates include:

* Add organization/workspace to `DreadnodeConfig`.

* `ApiClient.get_workspace` now optionally accepts `org_id`.

* Project creation now uses 'org_id' in API payload.

* Add `_extract_project_components` to parse project path format.

* Centralize configuration logging with `_log_configuration`.

* Renamed `Workspace.owner_id` to `Workspace.created_by` in models.
@dreadnode-renovate-bot dreadnode-renovate-bot bot added the area/python Changes to Python package configuration and dependencies label Nov 8, 2025
@briangreunke briangreunke changed the title Brian/eng 3480 feat rbac commands in the sdk feat(rbac): rbac commands in the sdk Nov 8, 2025
@briangreunke briangreunke merged commit 6ec0902 into main Nov 9, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/python Changes to Python package configuration and dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants