-
Notifications
You must be signed in to change notification settings - Fork 1
feat(rbac): rbac commands in the sdk #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
briangreunke
merged 14 commits into
main
from
brian/eng-3480-feat-rbac-commands-in-the-sdk
Nov 9, 2025
Merged
feat(rbac): rbac commands in the sdk #215
briangreunke
merged 14 commits into
main
from
brian/eng-3480-feat-rbac-commands-in-the-sdk
Nov 9, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This commit introduces new CLI commands under the
rbacsubgroup 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
Key Changes
dreadnode/cli/rbac/__init__.py: Initializes the newrbacCLI subgroup, exposing its commands.dreadnode/cli/rbac/organizations.py:organizationsCLI group.showcommand (list,ls) to display all organizations the user has access to.dreadnode/cli/rbac/workspaces.py:workspacesCLI group.showcommand (list,ls) to display workspaces, with an optional--organizationfilter. It intelligently handles scenarios where a user belongs to zero, one, or multiple organizations.createcommand (new) to create a new workspace within a specified or default organization, including user confirmation.deletecommand (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, andworkspaces deletecommands with various parameters and edge cases.