Skip to main content

ReservationRepo

No overview available.

Methods


Get()

@classmethod
def Get(
ctx: context.Context,
key: string
) - > *models.Reservation, error

Fetches a reservation by its unique key. Callers use this to retrieve details of a specific reservation.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the request, used for cancellation and deadlines.
keystringThe unique identifier for the reservation to retrieve.

Returns

TypeDescription
*models.Reservation, errorThe Reservation object if found, otherwise an error.

Create()

@classmethod
def Create(
ctx: context.Context,
reservation: *models.Reservation
) - > error

Creates a new reservation in the repository. This method is used to persist a new reservation record.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the request, used for cancellation and deadlines.
reservation*models.ReservationThe Reservation object to be created.

Returns

TypeDescription
errorAn error if the reservation could not be created, otherwise nil.

UpdateIfExpiredOrOwned()

@classmethod
def UpdateIfExpiredOrOwned(
ctx: context.Context,
reservation: *models.Reservation,
now: time.Time
) - > error

Updates an existing reservation only if it is expired or currently owned by the caller. This ensures that reservations are only modified under specific conditions.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the request, used for cancellation and deadlines.
reservation*models.ReservationThe Reservation object containing the updated details.
nowtime.TimeThe current time, used to check if the reservation has expired.

Returns

TypeDescription
errorAn error if the update fails or conditions are not met, otherwise nil.

DeleteByKeyAndOwner()

@classmethod
def DeleteByKeyAndOwner(
ctx: context.Context,
key: string,
ownerID: string
) - > error

Deletes a reservation identified by its key, but only if it is owned by the specified owner ID. This prevents unauthorized deletion of reservations.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the request, used for cancellation and deadlines.
keystringThe unique identifier of the reservation to delete.
ownerIDstringThe ID of the owner who is attempting to delete the reservation.

Returns

TypeDescription
errorAn error if the deletion fails or the owner ID does not match, otherwise nil.