Repository navigation
Expand file tree
/
Copy pathpermissiondeniederror.py
More file actions
65 lines (57 loc) · 2.6 KB
/
Copy pathpermissiondeniederror.py
File metadata and controls
65 lines (57 loc) · 2.6 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
58
59
60
61
62
63
64
65
"""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 (
errorissue as models_errorissue,
permissiondeniederror as models_permissiondeniederror,
)
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 PermissionDeniedErrorData(BaseModel):
code: models_permissiondeniederror.PermissionDeniedErrorCode
r"""Exactly what went wrong. Stable; safe to branch on. New codes may be added.
- `permission_denied`: The API key cannot perform this request.
- `account_disabled`: The organization account is disabled.
- `quota_exceeded`: The organization has used all API requests on its plan.
- `plan_feature_unavailable`: The current plan does not include this feature.
- `plan_limit_exceeded`: The request goes over a limit of the current plan.
- `organization_key_required`: This endpoint needs an organization API key, but a project key was used.
- `missing_key_permission`: The organization key does not have the permission this endpoint needs.
- `project_not_reachable`: The organization key is limited to other projects.
"""
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["permission_error"],
AfterValidator(validate_const("permission_error")),
],
pydantic.Field(alias="type"),
] = "permission_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 PermissionDeniedError(ModerationAPIError):
r"""The API key cannot do this, or the plan limit for this resource is reached."""
data: PermissionDeniedErrorData = field(hash=False)
def __init__(
self,
data: PermissionDeniedErrorData,
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)