Skip to content
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

Add flag for Y/M/D tree creation #33

Merged
merged 7 commits into from
Feb 6, 2024
14 changes: 14 additions & 0 deletions src/nsls2api/api/models/beamline_model.py
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# This is for response models relating to the beamline api endpoints.

from enum import Enum


class AssetDirectoryGranularity(Enum):
"""
Represents the granularity options for asset directory YYYY/MM/DD/HH tree structure.
The value specifies the most granular level to create directories for.
"""

year = "year"
month = "month"
day = "day"
hour = "hour"
17 changes: 12 additions & 5 deletions src/nsls2api/api/models/proposal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pydantic

from nsls2api.models.proposals import Proposal, User
from nsls2api.api.models.beamline_model import AssetDirectoryGranularity


class UsernamesList(pydantic.BaseModel):
Expand Down Expand Up @@ -61,6 +62,7 @@ class ProposalDirectories(pydantic.BaseModel):
cycle: str | None = None
users: list[dict[str, str]]
groups: list[dict[str, str]]
directory_most_granular_level: AssetDirectoryGranularity | None = None

model_config = {
"json_schema_extra": {
Expand All @@ -71,6 +73,7 @@ class ProposalDirectories(pydantic.BaseModel):
"group": "xf31id1",
"beamline": "TST",
"cycle": "1066-1",
"directory_most_granular_level": "month",
"users": [
{"name": "xf31id", "permissions": "rw"},
{"name": "service-account", "permissions": "rw"},
Expand All @@ -84,23 +87,27 @@ class ProposalDirectories(pydantic.BaseModel):
}
}

# Not used - may remove

# Not used - may remove
class ACL(pydantic.BaseModel):
entity: str
permissions: str

# Not used - may remove


# Not used - may remove
class Directory(pydantic.BaseModel):
path: str
is_aboslute: bool
owner: str
group: str
acls: list[ACL] | None = []
acls: list[ACL] | None = []

# Not used - may remove

# Not used - may remove
class ProposalDirectorySkeleton(pydantic.BaseModel):
asset_directories: list[Directory]


class ProposalDirectoriesList(pydantic.BaseModel):
directory_count: int
directories: list[ProposalDirectories]
Expand Down
3 changes: 3 additions & 0 deletions src/nsls2api/services/beamline_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from beanie.odm.operators.find.comparison import In

from nsls2api.api.models.beamline_model import AssetDirectoryGranularity
from nsls2api.models.beamlines import (
Beamline,
Detector,
Expand Down Expand Up @@ -207,6 +208,7 @@ async def proposal_directory_skeleton(name: str):
"users": users_acl,
"groups": groups_acl,
"beamline": name.upper(),
"directory_most_granular_level": AssetDirectoryGranularity.day,
}
directory_list.append(directory)

Expand All @@ -218,6 +220,7 @@ async def proposal_directory_skeleton(name: str):
"users": users_acl,
"groups": groups_acl,
"beamline": name.upper(),
"directory_most_granular_level": AssetDirectoryGranularity.day,
}
directory_list.append(default_directory)

Expand Down
Loading