Skip to content

ark_service

ArkService

Bases: ABC

Source code in ark_sdk_python/services/ark_service.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class ArkService(ABC):
    def __init__(self, *authenticators: Any) -> None:
        self._logger = get_logger(self.__class__.__name__)
        self._authenticators = [auth for auth in authenticators if issubclass(type(auth), ArkAuth)]
        given_auth_names = [auth.authenticator_name() for auth in self._authenticators]
        if any(a not in given_auth_names for a in self.service_config().required_authenticator_names):
            raise ArkValidationException(f'{self.service_config().service_name} missing required authenticators for service')

    @property
    def authenticators(self) -> List[ArkAuth]:
        """
        Returns all the authenticators for the service.

        Returns:
            List[ArkAuth]: _description_
        """
        return self._authenticators

    def authenticator(self, auth_name: str) -> ArkAuth:
        """
        Finds the appropriate Ark authenticator class for the specified authenticator.

        Args:
            auth_name (str): _description_

        Raises:
            ArkNotFoundException: _description_

        Returns:
            ArkAuth: _description_
        """
        for auth in self.authenticators:
            if auth.authenticator_name() == auth_name:
                return auth
        raise ArkNotFoundException(f'{self.service_config().service_name} Failed to find authenticator {auth_name}')

    def has_authenticator(self, auth_name: str) -> bool:
        """
        Checks whether the specified authenticator name exists.

        Args:
            auth_name (str): _description_

        Returns:
            bool: _description_
        """
        return any(auth.authenticator_name() == auth_name for auth in self.authenticators)

    @staticmethod
    @abstractmethod
    def service_config() -> ArkServiceConfig:
        """
        Returns the service configuration, which includes the service name, and its required and optional authenticators.

        Returns:
            ArkServiceConfig: _description_
        """

authenticators: List[ArkAuth] property

Returns all the authenticators for the service.

Returns:

Type Description
List[ArkAuth]

List[ArkAuth]: description

authenticator(auth_name)

Finds the appropriate Ark authenticator class for the specified authenticator.

Parameters:

Name Type Description Default
auth_name str

description

required

Raises:

Type Description
ArkNotFoundException

description

Returns:

Name Type Description
ArkAuth ArkAuth

description

Source code in ark_sdk_python/services/ark_service.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def authenticator(self, auth_name: str) -> ArkAuth:
    """
    Finds the appropriate Ark authenticator class for the specified authenticator.

    Args:
        auth_name (str): _description_

    Raises:
        ArkNotFoundException: _description_

    Returns:
        ArkAuth: _description_
    """
    for auth in self.authenticators:
        if auth.authenticator_name() == auth_name:
            return auth
    raise ArkNotFoundException(f'{self.service_config().service_name} Failed to find authenticator {auth_name}')

has_authenticator(auth_name)

Checks whether the specified authenticator name exists.

Parameters:

Name Type Description Default
auth_name str

description

required

Returns:

Name Type Description
bool bool

description

Source code in ark_sdk_python/services/ark_service.py
46
47
48
49
50
51
52
53
54
55
56
def has_authenticator(self, auth_name: str) -> bool:
    """
    Checks whether the specified authenticator name exists.

    Args:
        auth_name (str): _description_

    Returns:
        bool: _description_
    """
    return any(auth.authenticator_name() == auth_name for auth in self.authenticators)

service_config() abstractmethod staticmethod

Returns the service configuration, which includes the service name, and its required and optional authenticators.

Returns:

Name Type Description
ArkServiceConfig ArkServiceConfig

description

Source code in ark_sdk_python/services/ark_service.py
58
59
60
61
62
63
64
65
66
@staticmethod
@abstractmethod
def service_config() -> ArkServiceConfig:
    """
    Returns the service configuration, which includes the service name, and its required and optional authenticators.

    Returns:
        ArkServiceConfig: _description_
    """