Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #159

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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