src.awards.awards_client_port

Client port for awards operations.

 1"""Client port for awards operations."""
 2
 3from abc import ABC, abstractmethod
 4
 5from .models import Award
 6
 7
 8class AwardNotFound(Exception):
 9    """Raised when the awards service returns 404."""
10
11
12class AwardForbidden(Exception):
13    """Raised when the awards service returns 403."""
14
15
16class AwardsClientError(Exception):
17    """Raised when awards service returns an unexpected error or invalid response."""
18
19
20class AwardsClientPort(ABC):
21    """Port: fetches awards from the external awards service."""
22
23    @abstractmethod
24    def get(self, award_id: str) -> Award:
25        """Fetch an award by its identifier.
26
27        Args:
28            award_id: The unique award identifier.
29
30        Returns:
31            The matching Award.
32
33        Raises:
34            AwardNotFound: When the award does not exist.
35            AwardForbidden: When access to the award is denied.
36            AwardsClientError: When the service returns an error or invalid response.
37        """
38        ...
class AwardNotFound(builtins.Exception):
 9class AwardNotFound(Exception):
10    """Raised when the awards service returns 404."""

Raised when the awards service returns 404.

class AwardForbidden(builtins.Exception):
13class AwardForbidden(Exception):
14    """Raised when the awards service returns 403."""

Raised when the awards service returns 403.

class AwardsClientError(builtins.Exception):
17class AwardsClientError(Exception):
18    """Raised when awards service returns an unexpected error or invalid response."""

Raised when awards service returns an unexpected error or invalid response.

class AwardsClientPort(abc.ABC):
21class AwardsClientPort(ABC):
22    """Port: fetches awards from the external awards service."""
23
24    @abstractmethod
25    def get(self, award_id: str) -> Award:
26        """Fetch an award by its identifier.
27
28        Args:
29            award_id: The unique award identifier.
30
31        Returns:
32            The matching Award.
33
34        Raises:
35            AwardNotFound: When the award does not exist.
36            AwardForbidden: When access to the award is denied.
37            AwardsClientError: When the service returns an error or invalid response.
38        """
39        ...

Port: fetches awards from the external awards service.

@abstractmethod
def get(self, award_id: str) -> src.awards.models.Award:
24    @abstractmethod
25    def get(self, award_id: str) -> Award:
26        """Fetch an award by its identifier.
27
28        Args:
29            award_id: The unique award identifier.
30
31        Returns:
32            The matching Award.
33
34        Raises:
35            AwardNotFound: When the award does not exist.
36            AwardForbidden: When access to the award is denied.
37            AwardsClientError: When the service returns an error or invalid response.
38        """
39        ...

Fetch an award by its identifier.

Args: award_id: The unique award identifier.

Returns: The matching Award.

Raises: AwardNotFound: When the award does not exist. AwardForbidden: When access to the award is denied. AwardsClientError: When the service returns an error or invalid response.