Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Mar 21, 2024
1 parent 15686e4 commit abb60d4
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Shared Types

```python
from cloudflare.types import ErrorData
```

# Accounts

Types:
Expand Down
14 changes: 13 additions & 1 deletion src/cloudflare/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

from __future__ import annotations

from typing import Any, List, cast
from typing_extensions import Literal

import httpx

from ._utils import is_dict
from ._models import construct_type
from .types.shared import ErrorData

__all__ = [
"BadRequestError",
"AuthenticationError",
Expand Down Expand Up @@ -37,12 +42,19 @@ class APIError(CloudflareError):
If there was no response associated with this error then it will be `None`.
"""

def __init__(self, message: str, request: httpx.Request, *, body: object | None) -> None: # noqa: ARG002
errors: List[ErrorData]

def __init__(self, message: str, request: httpx.Request, *, body: object | None) -> None:
super().__init__(message)
self.request = request
self.message = message
self.body = body

if is_dict(body):
self.errors = cast(Any, construct_type(type_=List[ErrorData], value=body.get("errors")))
else:
self.errors = []


class APIResponseValidationError(APIError):
response: httpx.Response
Expand Down
1 change: 1 addition & 0 deletions src/cloudflare/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from .ips import IPs as IPs
from .zone import Zone as Zone
from .shared import ErrorData as ErrorData
from .account import Account as Account
from .snippet import Snippet as Snippet
from .calls_app import CallsApp as CallsApp
Expand Down
3 changes: 3 additions & 0 deletions src/cloudflare/types/shared/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .error_data import ErrorData as ErrorData
13 changes: 13 additions & 0 deletions src/cloudflare/types/shared/error_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional

from ..._models import BaseModel

__all__ = ["ErrorData"]


class ErrorData(BaseModel):
code: Optional[int] = None

message: Optional[str] = None

0 comments on commit abb60d4

Please sign in to comment.