The server has full branch lifecycle endpoints (POST, GET, DELETE /namespaces/{ns}/branches), but none are exposed on DJ python client. Users currently have no programmatic way to create, list, or delete branch namespaces.
To support this, we can add three public methods to the python client:
Create Branch
create_branch("myproject", "feature-x") creates namespace myproject.feature_x (branch name is slugified by the server). It returns a dict containing branch (namespace, git_branch, parent_namespace) and deployment_results:
def create_branch(self, namespace: str, branch_name: str) -> dict:
"""
Create a branch namespace from the given namespace.
Creates both the git branch and the DJ namespace with nodes copied from source.
POST /namespaces/{namespace}/branches
"""
List Branches
list_branches returns rich info including node counts and last deployment timestamp, which is useful for branch health dashboards. The return value is sorted with default branch first:
def list_branches(self, namespace: str) -> list[dict]:
"""
List all branch namespaces associated with the given namespace.
Returns num_nodes, invalid_node_count, last_deployed_at per branch.
GET /namespaces/{namespace}/branches
"""
Delete Branch
delete_branch defaults to also deleting the git branch (pass delete_git_branch=False to preserve the git branch). It returns counts of deleted nodes and whether git branch was deleted:
def delete_branch(
self,
namespace: str,
branch_namespace: str,
delete_git_branch: bool = True,
) -> dict:
"""
Delete a branch namespace and optionally its corresponding git branch.
DELETE /namespaces/{namespace}/branches/{branch_namespace}
"""
All methods raise DJClientException on error responses
The server has full branch lifecycle endpoints (
POST,GET,DELETE /namespaces/{ns}/branches), but none are exposed on DJ python client. Users currently have no programmatic way to create, list, or delete branch namespaces.To support this, we can add three public methods to the python client:
Create Branch
create_branch("myproject", "feature-x")creates namespacemyproject.feature_x(branch name is slugified by the server). It returns a dict containing branch (namespace, git_branch, parent_namespace) and deployment_results:List Branches
list_branchesreturns rich info including node counts and last deployment timestamp, which is useful for branch health dashboards. The return value is sorted with default branch first:Delete Branch
delete_branchdefaults to also deleting the git branch (passdelete_git_branch=Falseto preserve the git branch). It returns counts of deleted nodes and whether git branch was deleted:All methods raise DJClientException on error responses