Skip to content
Snippets Groups Projects
Verified Commit 85690533 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Allow shorter bucket description as output

#45
parent ac8cbbd4
Branches
No related tags found
No related merge requests found
......@@ -80,6 +80,7 @@ async def list_buckets(
1 for obj in s3.Bucket(name=bucket.name).objects.all() if not obj.key.endswith(".s3keep")
),
"size": reduce(lambda x, y: x + y.size, list(s3.Bucket(name=bucket.name).objects.all()), 0),
"owner_constraint": bucket.owner_constraint,
}
)
for bucket in buckets
......@@ -215,6 +216,7 @@ async def get_bucket(
"owner": bucket.owner_id,
"num_objects": sum(1 for obj in objects if not obj.key.endswith(".s3keep")),
"size": reduce(lambda x, y: x + y.size, objects, 0),
"owner_constraint": bucket.owner_constraint,
}
)
......
from datetime import datetime
from typing import TYPE_CHECKING
from clowmdb.models import Bucket
from pydantic import BaseModel, Field
if TYPE_CHECKING:
......@@ -53,6 +54,11 @@ class BucketOut(_BaseBucket):
owner: str = Field(..., description="UID of the owner", example="28c5353b8bb34984a8bd4169ba94c606")
num_objects: int = Field(..., description="Number of Objects in this bucket", example=6)
size: int = Field(..., description="Total size of objects in this bucket in bytes", example=3256216)
owner_constraint: Bucket.Constrain | None = Field(None, description="Constraint for the owner of the bucket")
description: str = Field(
...,
description="Description of the bucket",
)
class Config:
orm_mode = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment