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 (87 lines) | stat: -rw-r--r-- 2,355 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
from typing import Any

from moto.core.exceptions import ServiceException


class IAMException(ServiceException):
    pass


class NotFoundException(IAMException):
    code = "NoSuchEntity"


class DeleteConflictException(IAMException):
    code = "DeleteConflict"


class ReportNotPresentException(IAMException):
    code = "ReportNotPresent"


class LimitExceededException(IAMException):
    code = "LimitExceeded"


class MalformedCertificate(IAMException):
    code = "MalformedCertificate"

    def __init__(self, cert: str):
        super().__init__(f"Certificate {cert} is malformed")


class MalformedPolicyDocument(IAMException):
    code = "MalformedPolicyDocument"


class DuplicateTags(IAMException):
    code = "InvalidInput"
    message = (
        "Duplicate tag keys found. Please note that Tag keys are case insensitive."
    )


class ValidationError(IAMException):
    code = "ValidationError"


class TagKeyTooBig(ValidationError):
    def __init__(self, tag: str, param: str = "tags.X.member.key"):
        super().__init__(
            f"1 validation error detected: Value '{tag}' at '{param}' failed to satisfy "
            "constraint: Member must have length less than or equal to 128.",
        )


class TagValueTooBig(ValidationError):
    def __init__(self, tag: str):
        super().__init__(
            f"1 validation error detected: Value '{tag}' at 'tags.X.member.value' failed to satisfy "
            "constraint: Member must have length less than or equal to 256.",
        )


class InvalidTagCharacters(ValidationError):
    def __init__(self, tag: str, param: str = "tags.X.member.key"):
        message = f"1 validation error detected: Value '{tag}' at '{param}' failed to satisfy constraint: Member must satisfy regular expression pattern: [\\p{{L}}\\p{{Z}}\\p{{N}}_.:/=+\\-@]+"
        super().__init__(message)


class TooManyTags(ValidationError):
    def __init__(self, tags: Any, param: str = "tags"):
        super().__init__(
            f"1 validation error detected: Value '{tags}' at '{param}' failed to satisfy "
            "constraint: Member must have length less than or equal to 50.",
        )


class EntityAlreadyExists(IAMException):
    code = "EntityAlreadyExists"


class InvalidInput(IAMException):
    code = "InvalidInput"


class NoSuchEntity(IAMException):
    code = "NoSuchEntity"