File: exceptions.py

package info (click to toggle)
python-moto 5.1.18-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 116,520 kB
  • sloc: python: 636,725; javascript: 181; makefile: 39; sh: 3
file content (124 lines) | stat: -rw-r--r-- 3,957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from moto.core.exceptions import ServiceException


class LifecyclePolicyNotFoundException(ServiceException):
    code = "LifecyclePolicyNotFoundException"

    def __init__(self, repository_name: str, registry_id: str):
        message = (
            f"Lifecycle policy does not exist "
            f"for the repository with name '{repository_name}' "
            f"in the registry with id '{registry_id}'"
        )
        super().__init__(message)


class LimitExceededException(ServiceException):
    code = "LimitExceededException"
    message = "The scan quota per image has been exceeded. Wait and try again."


class RegistryPolicyNotFoundException(ServiceException):
    code = "RegistryPolicyNotFoundException"

    def __init__(self, registry_id: str):
        message = (
            f"Registry policy does not exist in the registry with id '{registry_id}'"
        )
        super().__init__(message)


class RepositoryAlreadyExistsException(ServiceException):
    code = "RepositoryAlreadyExistsException"

    def __init__(self, repository_name: str, registry_id: str):
        message = (
            f"The repository with name '{repository_name}' already exists "
            f"in the registry with id '{registry_id}'"
        )
        super().__init__(message)


class RepositoryNotEmptyException(ServiceException):
    code = "RepositoryNotEmptyException"

    def __init__(self, repository_name: str, registry_id: str):
        message = (
            f"The repository with name '{repository_name}' "
            f"in registry with id '{registry_id}' "
            f"cannot be deleted because it still contains images"
        )
        super().__init__(message)


class RepositoryNotFoundException(ServiceException):
    code = "RepositoryNotFoundException"

    def __init__(self, repository_name: str, registry_id: str):
        message = (
            f"The repository with name '{repository_name}' does not exist "
            f"in the registry with id '{registry_id}'"
        )
        super().__init__(message)


class RepositoryPolicyNotFoundException(ServiceException):
    code = "RepositoryPolicyNotFoundException"

    def __init__(self, repository_name: str, registry_id: str):
        message = (
            f"Repository policy does not exist "
            f"for the repository with name '{repository_name}' "
            f"in the registry with id '{registry_id}'"
        )
        super().__init__(message)


class ImageNotFoundException(ServiceException):
    code = "ImageNotFoundException"

    def __init__(self, image_id: str, repository_name: str, registry_id: str):
        message = (
            f"The image with imageId {image_id} does not exist "
            f"within the repository with name '{repository_name}' "
            f"in the registry with id '{registry_id}'"
        )
        super().__init__(message)


class ImageAlreadyExistsException(ServiceException):
    code = "ImageAlreadyExistsException"

    def __init__(
        self,
        repository_name: str,
        registry_id: str,
        digest: str,
        image_tag: str,
    ):
        message = (
            f"Image with digest '{digest}' and tag '{image_tag}' already exists "
            f"in the repository with name '{repository_name}' "
            f"in registry with id '{registry_id}'"
        )
        super().__init__(message)


class InvalidParameterException(ServiceException):
    code = "InvalidParameterException"


class ScanNotFoundException(ServiceException):
    code = "ScanNotFoundException"

    def __init__(self, image_id: str, repository_name: str, registry_id: str):
        message = (
            f"Image scan does not exist for the image with '{image_id}' "
            f"in the repository with name '{repository_name}' "
            f"in the registry with id '{registry_id}'"
        )
        super().__init__(message)


class ValidationException(ServiceException):
    code = "ValidationException"