Skip to content

Commit 31f6c01

Browse files
feat(api): manual updates (#39)
1 parent ed6623d commit 31f6c01

File tree

6 files changed

+81
-1
lines changed

6 files changed

+81
-1
lines changed

Diff for: api.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
```python
44
from gitpod.types import (
5+
ArbitraryData,
56
AutomationTrigger,
67
EnvironmentClass,
8+
ErrorCode,
79
FieldValue,
810
OrganizationRole,
911
Principal,

Diff for: src/gitpod/_exceptions.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
from __future__ import annotations
44

5+
from typing import TYPE_CHECKING, Any, Optional, cast
56
from typing_extensions import Literal
67

78
import httpx
89

10+
from ._utils import is_dict
11+
from ._models import construct_type
12+
from .types.shared.error_code import ErrorCode
13+
from .types.shared.arbitrary_data import ArbitraryData
14+
915
__all__ = [
1016
"BadRequestError",
1117
"AuthenticationError",
@@ -37,12 +43,35 @@ class APIError(GitpodError):
3743
If there was no response associated with this error then it will be `None`.
3844
"""
3945

40-
def __init__(self, message: str, request: httpx.Request, *, body: object | None) -> None: # noqa: ARG002
46+
code: Optional[ErrorCode] = None
47+
"""
48+
The status code, which should be an enum value of
49+
[google.rpc.Code][google.rpc.Code].
50+
"""
51+
detail: Optional[ArbitraryData] = None
52+
"""
53+
Contains an arbitrary serialized message along with a @type that describes the
54+
type of the serialized message.
55+
"""
56+
if TYPE_CHECKING:
57+
# Stub to indicate that arbitrary properties are accepted.
58+
# To access properties that are not valid identifiers you can use `getattr`, e.g.
59+
# `getattr(obj, '$type')`
60+
def __getattr__(self, attr: str) -> object: ...
61+
62+
def __init__(self, message: str, request: httpx.Request, *, body: object | None) -> None:
4163
super().__init__(message)
4264
self.request = request
4365
self.message = message
4466
self.body = body
4567

68+
if is_dict(body):
69+
self.code = cast(Any, construct_type(type_=Optional[ErrorCode], value=body.get("code")))
70+
self.detail = cast(Any, construct_type(type_=Optional[ArbitraryData], value=body.get("detail")))
71+
else:
72+
self.code = None
73+
self.detail = None
74+
4675

4776
class APIResponseValidationError(APIError):
4877
response: httpx.Response

Diff for: src/gitpod/types/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
RunsOn as RunsOn,
1414
Subject as Subject,
1515
TaskSpec as TaskSpec,
16+
ErrorCode as ErrorCode,
1617
Principal as Principal,
1718
FieldValue as FieldValue,
1819
UserStatus as UserStatus,
1920
TaskMetadata as TaskMetadata,
21+
ArbitraryData as ArbitraryData,
2022
TaskExecution as TaskExecution,
2123
EnvironmentClass as EnvironmentClass,
2224
OrganizationRole as OrganizationRole,

Diff for: src/gitpod/types/shared/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
from .subject import Subject as Subject
66
from .principal import Principal as Principal
77
from .task_spec import TaskSpec as TaskSpec
8+
from .error_code import ErrorCode as ErrorCode
89
from .field_value import FieldValue as FieldValue
910
from .user_status import UserStatus as UserStatus
1011
from .task_metadata import TaskMetadata as TaskMetadata
12+
from .arbitrary_data import ArbitraryData as ArbitraryData
1113
from .task_execution import TaskExecution as TaskExecution
1214
from .environment_class import EnvironmentClass as EnvironmentClass
1315
from .organization_role import OrganizationRole as OrganizationRole

Diff for: src/gitpod/types/shared/arbitrary_data.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import TYPE_CHECKING, Dict, Optional
4+
5+
from ..._models import BaseModel
6+
7+
__all__ = ["ArbitraryData"]
8+
9+
10+
class ArbitraryData(BaseModel):
11+
debug: Optional[Dict[str, object]] = None
12+
13+
type: Optional[str] = None
14+
15+
value: Optional[object] = None
16+
17+
if TYPE_CHECKING:
18+
# Stub to indicate that arbitrary properties are accepted.
19+
# To access properties that are not valid identifiers you can use `getattr`, e.g.
20+
# `getattr(obj, '$type')`
21+
def __getattr__(self, attr: str) -> object: ...

Diff for: src/gitpod/types/shared/error_code.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing_extensions import Literal, TypeAlias
4+
5+
__all__ = ["ErrorCode"]
6+
7+
ErrorCode: TypeAlias = Literal[
8+
"canceled",
9+
"unknown",
10+
"invalid_argument",
11+
"deadline_exceeded",
12+
"not_found",
13+
"already_exists",
14+
"permission_denied",
15+
"resource_exhausted",
16+
"failed_precondition",
17+
"aborted",
18+
"out_of_range",
19+
"unimplemented",
20+
"internal",
21+
"unavailable",
22+
"data_loss",
23+
"unauthenticated",
24+
]

0 commit comments

Comments
 (0)