Repository navigation
Expand file tree
/
Copy pathconflicterror.py
More file actions
57 lines (49 loc) · 1.92 KB
/
Copy pathconflicterror.py
File metadata and controls
57 lines (49 loc) · 1.92 KB
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
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from dataclasses import dataclass, field
import httpx
from moderation_api.errors import ModerationAPIError
from moderation_api.models import (
conflicterror as models_conflicterror,
errorissue as models_errorissue,
)
from moderation_api.types import BaseModel
from moderation_api.utils import validate_const
import pydantic
from pydantic.functional_validators import AfterValidator
from typing import List, Literal, Optional
from typing_extensions import Annotated
class ConflictErrorData(BaseModel):
code: models_conflicterror.ConflictErrorCode
r"""Exactly what went wrong. Stable; safe to branch on. New codes may be added.
- `resource_conflict`: The request conflicts with an existing resource.
"""
message: str
r"""Human-readable explanation."""
request_id: str
r"""Identifies this request. Include it when you contact support."""
doc_url: str
r"""Documentation for this `code`."""
type: Annotated[
Annotated[
Literal["conflict_error"], AfterValidator(validate_const("conflict_error"))
],
pydantic.Field(alias="type"),
] = "conflict_error"
r"""Broad error category. Stable; safe to switch on."""
issues: Optional[List[models_errorissue.ErrorIssue]] = None
r"""Validation problems, when the request body is invalid."""
@dataclass(unsafe_hash=True)
class ConflictError(ModerationAPIError):
r"""The request conflicts with the current state of a resource."""
data: ConflictErrorData = field(hash=False)
def __init__(
self,
data: ConflictErrorData,
raw_response: httpx.Response,
body: Optional[str] = None,
):
fallback = body or raw_response.text
message = str(data.message) or fallback
super().__init__(message, raw_response, body)
object.__setattr__(self, "data", data)