Skip to content

Commit 1c45ca0

Browse files
committed
[DOP-25451] Use PUT /v1/queues/:id instead of PATCH
1 parent 3213cec commit 1c45ca0

11 files changed

Lines changed: 405 additions & 275 deletions

File tree

docs/changelog/0.2.2.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
0.2.2 (2025-04-11)
22
==================
33

4+
Breaking
5+
--------
6+
7+
- Use ``PUT /v1/queues/:id`` instead of ``PATCH /v1/queues/:id``.
8+
- Minimal queue name is 3 symbols instead of 1.
9+
10+
Improvements
11+
------------
12+
13+
- Now queue name can include spaces.
14+
- Queue slug is always lowercase. Spaces, hyphens and underscores are replaced with ``-`` symbol.
15+
416
Bug fixes
517
---------
618

7-
- Call ``kinit`` before starting Spark session conecting to ``Hive`` cluster.
8-
- Fix ``HDFS`` connection was trying to use anonymous auth instead of user/password.
19+
- Call ``kinit`` before starting Spark session conecting to ``Hive`` cluster. (:issue:`225`)
20+
- Fix ``HDFS`` connection was trying to use anonymous auth instead of user/password. (:issue:`225`)
21+
- Fix updating queue ignored name and didn't reset description.

syncmaster/db/repositories/queue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ async def update(
7373
queue_data: UpdateQueueSchema,
7474
) -> Queue:
7575
try:
76-
queue = await self.read_by_id(queue_id=queue_id)
7776
return await self._update(
7877
Queue.id == queue_id,
79-
description=queue_data.description or queue.description,
78+
name=queue_data.name,
79+
description=queue_data.description,
8080
)
8181
except IntegrityError as e:
8282
self._raise_error(e)

syncmaster/schemas/v1/queue.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
# SPDX-FileCopyrightText: 2023-2024 MTS PJSC
22
# SPDX-License-Identifier: Apache-2.0
3-
from pydantic import BaseModel, ConfigDict, Field, computed_field, constr
3+
import re
4+
from typing import Annotated
5+
6+
from pydantic import BaseModel, ConfigDict, Field, StringConstraints, computed_field
47

58
from syncmaster.schemas.v1.page import PageSchema
69

10+
ALLOWED_PATTERN = re.compile(r"^[-_ a-zA-Z0-9]+$")
11+
RESTRICTED_PATTERN = re.compile(r"[^\w\d]+")
12+
13+
QueueName = Annotated[
14+
str,
15+
StringConstraints(min_length=3, max_length=128, pattern=ALLOWED_PATTERN), # noqa: WPS432
16+
]
17+
718

819
class CreateQueueSchema(BaseModel):
9-
name: constr(max_length=128, pattern=r"^[-_a-zA-Z0-9]+$") = Field( # noqa: F722, WPS432
10-
...,
20+
name: QueueName = Field(
1121
description="Queue name that allows letters, numbers, dashes, and underscores",
1222
)
13-
group_id: int = Field(..., description="Queue owner group id")
23+
group_id: int = Field(description="Queue owner group id")
1424
description: str = Field(default="", description="Additional description")
1525

1626
@computed_field
1727
@property
1828
def slug(self) -> str:
19-
return f"{self.group_id}-{self.name}"
29+
short_name = RESTRICTED_PATTERN.sub("_", self.name.lower())
30+
return f"{self.group_id}-{short_name}"
2031

2132

2233
class ReadQueueSchema(BaseModel):
@@ -34,4 +45,5 @@ class QueuePageSchema(PageSchema):
3445

3546

3647
class UpdateQueueSchema(BaseModel):
37-
description: str | None = None
48+
name: QueueName
49+
description: str = ""

syncmaster/server/api/v1/queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def create_queue(
9494
return ReadQueueSchema.model_validate(queue, from_attributes=True)
9595

9696

97-
@router.patch("/queues/{queue_id}", description="Updating queue information")
97+
@router.put("/queues/{queue_id}", description="Updating queue information")
9898
async def update_queue(
9999
queue_id: int,
100100
queue_data: UpdateQueueSchema,

tests/test_unit/test_queue/test_update_queue.py

Lines changed: 0 additions & 210 deletions
This file was deleted.

0 commit comments

Comments
 (0)