Skip to content

Commit

Permalink
fix: create directory
Browse files Browse the repository at this point in the history
allows directory creation with configuration
  • Loading branch information
Erez Sharim authored and ErezSha committed Dec 8, 2024
1 parent 895f186 commit bd6477d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/routers/directories.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Annotated, Any, List
from typing import Annotated, Any, List, Optional

import jsonpatch
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, status
Expand Down Expand Up @@ -35,9 +35,11 @@
)


# TODO consider adding provisioning_config, data_owner_config, etc.
class CreateDirectoryBody(BaseModel):
name: str
provisioning_config: Optional[dict] = None
read_config: Optional[dict] = None
data_owner_config: Optional[dict] = None


@router.post(
Expand All @@ -58,6 +60,9 @@ def create(
dir = Directory(
workspace_id=workspace.id,
name=body.name,
provisioning_config=body.provisioning_config,
read_config=body.read_config,
data_owner_config=body.data_owner_config,
created_by=current_user.email,
)
pdir = directory_store.insert(
Expand All @@ -73,7 +78,7 @@ def create(
error = ErrorDetails(
type="uniqueness",
loc=("body", "name"),
msg=f"name '{workspace.name}' already exists",
msg=f"name '{body.name}' already exists",
)
raise HTTPException(status_code=409, detail=[error])
else:
Expand Down

0 comments on commit bd6477d

Please sign in to comment.