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

feat: added support for bucket data object and updating bucket metadata #128

Merged
merged 3 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions aw_server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def create_bucket(
client: str,
hostname: str,
created: Optional[datetime] = None,
data: Optional[Dict[str, Any]] = None,
) -> bool:
"""
Create bucket.
Expand All @@ -154,9 +155,29 @@ def create_bucket(
client=client,
hostname=hostname,
created=created,
data=data,
)
return True

@check_bucket_exists
def update_bucket(
self,
bucket_id: str,
event_type: Optional[str] = None,
client: Optional[str] = None,
hostname: Optional[str] = None,
data: Optional[Dict[str, Any]] = None,
) -> None:
"""Update bucket metadata"""
self.db.update_bucket(
bucket_id,
type=event_type,
client=client,
hostname=hostname,
data=data,
)
return None

@check_bucket_exists
def delete_bucket(self, bucket_id: str) -> None:
"""Delete a bucket"""
Expand Down
23 changes: 23 additions & 0 deletions aw_server/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ def format(self, value):
},
)

update_bucket = api.model(
"UpdateBucket",
{
"client": fields.String(required=False),
"type": fields.String(required=False),
"hostname": fields.String(required=False),
"data": fields.String(required=False),
},
)

query = api.model(
"Query",
{
Expand Down Expand Up @@ -173,6 +183,19 @@ def post(self, bucket_id):
else:
return {}, 304

@api.expect(update_bucket)
@copy_doc(ServerAPI.update_bucket)
def put(self, bucket_id):
data = request.get_json()
current_app.api.update_bucket(
bucket_id,
event_type=data["type"],
client=data["client"],
hostname=data["hostname"],
data=data["data"],
)
return {}, 200

@copy_doc(ServerAPI.delete_bucket)
@api.param("force", "Needs to be =1 to delete a bucket it non-testing mode")
def delete(self, bucket_id):
Expand Down
Loading