Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class RpcOrganizationSlugReservation(RpcModel):
organization_id: int
user_id: int | None
slug: str
region_name: str
cell_name: str
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still a few call sites that are using region_name. Shouldn't those be updated to use cell_name before we switch the wire format.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean accessing the property .region_name?

that's fine since we still have this below:

@property
def region_name(self) -> str:
 return self.cell_name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the serialize_slug_reservation function is creating instances of this model with region_name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it works due to the root validator, but i had to change it anyway to make mypy happy

reservation_type: int

@root_validator(pre=True)
@classmethod
def _accept_cell_name(cls, values: dict[str, Any]) -> dict[str, Any]:
if "cell_name" in values and "region_name" not in values:
values["region_name"] = values.pop("cell_name")
def _accept_region_name(cls, values: dict[str, Any]) -> dict[str, Any]:
if "region_name" in values and "cell_name" not in values:
values["cell_name"] = values.pop("region_name")
return values

@property
def cell_name(self) -> str:
return self.region_name
def region_name(self) -> str:
return self.cell_name
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def serialize_slug_reservation(
id=slug_reservation.id,
organization_id=slug_reservation.organization_id,
slug=slug_reservation.slug,
region_name=slug_reservation.cell_name,
cell_name=slug_reservation.cell_name,
user_id=slug_reservation.user_id,
reservation_type=slug_reservation.reservation_type,
)
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def create_rpc_organization_slug_reservation(self, slug: str) -> RpcOrganization
slug=slug,
organization_id=self.provisioned_org.id,
user_id=self.provisioning_user.id,
region_name="us",
cell_name="us",
reservation_type=OrganizationSlugReservationType.TEMPORARY_RENAME_ALIAS.value,
)

Expand Down
Loading