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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
|
from typing import Optional
from moto.core.exceptions import JsonRESTError
class GlueClientError(JsonRESTError):
code = 400
class AlreadyExistsException(GlueClientError):
def __init__(self, typ: str):
super().__init__("AlreadyExistsException", f"{typ} already exists.")
class DatabaseAlreadyExistsException(AlreadyExistsException):
def __init__(self) -> None:
super().__init__("Database")
class TableAlreadyExistsException(AlreadyExistsException):
def __init__(self) -> None:
super().__init__("Table")
class PartitionAlreadyExistsException(AlreadyExistsException):
def __init__(self) -> None:
super().__init__("Partition")
class CrawlerAlreadyExistsException(AlreadyExistsException):
def __init__(self) -> None:
super().__init__("Crawler")
class SessionAlreadyExistsException(AlreadyExistsException):
def __init__(self) -> None:
super().__init__("Session")
class EntityNotFoundException(GlueClientError):
def __init__(self, msg: str):
super().__init__("EntityNotFoundException", msg)
class DatabaseNotFoundException(EntityNotFoundException):
def __init__(self, db: str):
super().__init__(f"Database {db} not found.")
class TableNotFoundException(EntityNotFoundException):
def __init__(self, tbl: str):
super().__init__(f"Table {tbl} not found.")
class PartitionNotFoundException(EntityNotFoundException):
def __init__(self) -> None:
super().__init__("Cannot find partition.")
class CrawlerNotFoundException(EntityNotFoundException):
def __init__(self, crawler: str):
super().__init__(f"Crawler {crawler} not found.")
class JobNotFoundException(EntityNotFoundException):
def __init__(self, job: str):
super().__init__(f"Job {job} not found.")
class JobRunNotFoundException(EntityNotFoundException):
def __init__(self, job_run: str):
super().__init__(f"Job run {job_run} not found.")
class VersionNotFoundException(EntityNotFoundException):
def __init__(self) -> None:
super().__init__("Version not found.")
class SchemaNotFoundException(EntityNotFoundException):
def __init__(
self,
schema_name: str,
registry_name: str,
schema_arn: Optional[str],
null: str = "null",
):
super().__init__(
f"Schema is not found. RegistryName: {registry_name if registry_name else null}, SchemaName: {schema_name if schema_name else null}, SchemaArn: {schema_arn if schema_arn else null}",
)
class SchemaVersionNotFoundFromSchemaIdException(EntityNotFoundException):
def __init__(
self,
registry_name: Optional[str],
schema_name: Optional[str],
schema_arn: Optional[str],
version_number: Optional[str],
latest_version: Optional[str],
null: str = "null",
false: str = "false",
):
super().__init__(
f"Schema version is not found. RegistryName: {registry_name if registry_name else null}, SchemaName: {schema_name if schema_name else null}, SchemaArn: {schema_arn if schema_arn else null}, VersionNumber: {version_number if version_number else null}, isLatestVersion: {latest_version if latest_version else false}",
)
class SchemaVersionNotFoundFromSchemaVersionIdException(EntityNotFoundException):
def __init__(self, schema_version_id: str):
super().__init__(
f"Schema version is not found. SchemaVersionId: {schema_version_id}",
)
class SessionNotFoundException(EntityNotFoundException):
def __init__(self, session: str):
super().__init__(f"Session {session} not found.")
class IllegalSessionStateException(GlueClientError):
def __init__(self, msg: str):
super().__init__("IllegalSessionStateException", msg)
class RegistryNotFoundException(EntityNotFoundException):
def __init__(self, resource: str, param_name: str, param_value: Optional[str]):
super().__init__(
resource + " is not found. " + param_name + ": " + param_value, # type: ignore
)
class TriggerNotFoundException(EntityNotFoundException):
def __init__(self, trigger: str):
super().__init__(f"Trigger {trigger} not found.")
class CrawlerRunningException(GlueClientError):
def __init__(self, msg: str):
super().__init__("CrawlerRunningException", msg)
class CrawlerNotRunningException(GlueClientError):
def __init__(self, msg: str):
super().__init__("CrawlerNotRunningException", msg)
class ConcurrentRunsExceededException(GlueClientError):
def __init__(self, msg: str):
super().__init__("ConcurrentRunsExceededException", msg)
class ResourceNumberLimitExceededException(GlueClientError):
def __init__(self, msg: str):
super().__init__(
"ResourceNumberLimitExceededException",
msg,
)
class GeneralResourceNumberLimitExceededException(ResourceNumberLimitExceededException):
def __init__(self, resource: str):
super().__init__(
"More "
+ resource
+ " cannot be created. The maximum limit has been reached.",
)
class SchemaVersionMetadataLimitExceededException(ResourceNumberLimitExceededException):
def __init__(self) -> None:
super().__init__(
"Your resource limits for Schema Version Metadata have been exceeded.",
)
class GSRAlreadyExistsException(GlueClientError):
def __init__(self, msg: str):
super().__init__(
"AlreadyExistsException",
msg,
)
class SchemaVersionMetadataAlreadyExistsException(GSRAlreadyExistsException):
def __init__(self, schema_version_id: str, metadata_key: str, metadata_value: str):
super().__init__(
f"Resource already exist for schema version id: {schema_version_id}, metadata key: {metadata_key}, metadata value: {metadata_value}",
)
class GeneralGSRAlreadyExistsException(GSRAlreadyExistsException):
def __init__(self, resource: str, param_name: str, param_value: str):
super().__init__(
resource + " already exists. " + param_name + ": " + param_value,
)
class InvalidStateException(GlueClientError):
def __init__(self, op: str, msg: str):
super().__init__("InvalidStateException", msg)
class InvalidInputException(GlueClientError):
def __init__(self, op: str, msg: str):
super().__init__("InvalidInputException", msg)
class GSRInvalidInputException(GlueClientError):
def __init__(self, msg: str):
super().__init__("InvalidInputException", msg)
class ResourceNameTooLongException(GSRInvalidInputException):
def __init__(self, param_name: str):
super().__init__(
"The resource name contains too many or too few characters. Parameter Name: "
+ param_name,
)
class ParamValueContainsInvalidCharactersException(GSRInvalidInputException):
def __init__(self, param_name: str):
super().__init__(
"The parameter value contains one or more characters that are not valid. Parameter Name: "
+ param_name,
)
class InvalidNumberOfTagsException(GSRInvalidInputException):
def __init__(self) -> None:
super().__init__(
"New Tags cannot be empty or more than 50",
)
class InvalidDataFormatException(GSRInvalidInputException):
def __init__(self) -> None:
super().__init__(
"Data format is not valid.",
)
class InvalidCompatibilityException(GSRInvalidInputException):
def __init__(self) -> None:
super().__init__(
"Compatibility is not valid.",
)
class InvalidSchemaDefinitionException(GSRInvalidInputException):
def __init__(self, data_format_name: str, err: ValueError):
super().__init__(
"Schema definition of "
+ data_format_name
+ " data format is invalid: "
+ str(err),
)
class InvalidRegistryIdBothParamsProvidedException(GSRInvalidInputException):
def __init__(self) -> None:
super().__init__(
"One of registryName or registryArn has to be provided, both cannot be provided.",
)
class InvalidSchemaIdBothParamsProvidedException(GSRInvalidInputException):
def __init__(self) -> None:
super().__init__(
"One of (registryName and schemaName) or schemaArn has to be provided, both cannot be provided.",
)
class InvalidSchemaIdNotProvidedException(GSRInvalidInputException):
def __init__(self) -> None:
super().__init__(
"At least one of (registryName and schemaName) or schemaArn has to be provided.",
)
class InvalidSchemaVersionNumberBothParamsProvidedException(GSRInvalidInputException):
def __init__(self) -> None:
super().__init__("Only one of VersionNumber or LatestVersion is required.")
class InvalidSchemaVersionNumberNotProvidedException(GSRInvalidInputException):
def __init__(self) -> None:
super().__init__("One of version number (or) latest version is required.")
class InvalidSchemaVersionIdProvidedWithOtherParamsException(GSRInvalidInputException):
def __init__(self) -> None:
super().__init__(
"No other input parameters can be specified when fetching by SchemaVersionId."
)
class DisabledCompatibilityVersioningException(GSRInvalidInputException):
def __init__(
self,
schema_name: str,
registry_name: str,
schema_arn: Optional[str],
null: str = "null",
):
super().__init__(
f"Compatibility DISABLED does not allow versioning. SchemaId: SchemaId(schemaArn={schema_arn if schema_arn else null}, schemaName={schema_name if schema_name else null}, registryName={registry_name if registry_name else null})"
)
class InvalidFilterOperatorException(GlueClientError):
def __init__(self, value: str, position: int) -> None:
super().__init__(
"ValidationException",
f"Value '{value}' at 'filters.{position}.member.filterOperator' failed to satisfy constraint: Member must satisfy enum value set: [LT, EQ, GT, NE, LE, GE]",
)
class InvalidFilterFieldNameException(GlueClientError):
def __init__(self, value: str, position: int) -> None:
super().__init__(
"ValidationException",
f"Value '{value}' at 'filters.{position}.member.fieldName' failed to satisfy constraint: Member must satisfy enum value set: [START_TIME, END_TIME, STATE, CRAWL_ID, DPU_HOUR]",
)
class InvalidLogicalOperatorException(GlueClientError):
def __init__(self, value: str, position: int) -> None:
super().__init__(
"ValidationException",
f"Value '{value}' at 'predicate.conditions.{position}.member.logicalOperator' failed to satisfy constraint: Member must satisfy enum value set: [Equals]",
)
class NoCrawlsEntryForCrawler(EntityNotFoundException):
def __init__(self, name: str) -> None:
super().__init__(
f"Crawler entry with name {name} does not exist",
)
class IllegalWorkflowStateException(GlueClientError):
def __init__(self, msg: str):
super().__init__("IllegalWorkflowRunStateException", msg)
|