Skip to content

feat(api): manual updates #39

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

Merged
merged 1 commit into from
Feb 14, 2025
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
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

```python
from gitpod.types import (
ArbitraryData,
AutomationTrigger,
EnvironmentClass,
ErrorCode,
FieldValue,
OrganizationRole,
Principal,
Expand Down
31 changes: 30 additions & 1 deletion src/gitpod/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Optional, cast
from typing_extensions import Literal

import httpx

from ._utils import is_dict
from ._models import construct_type
from .types.shared.error_code import ErrorCode
from .types.shared.arbitrary_data import ArbitraryData

__all__ = [
"BadRequestError",
"AuthenticationError",
Expand Down Expand Up @@ -37,12 +43,35 @@ class APIError(GitpodError):
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
code: Optional[ErrorCode] = None
"""
The status code, which should be an enum value of
[google.rpc.Code][google.rpc.Code].
"""
detail: Optional[ArbitraryData] = None
"""
Contains an arbitrary serialized message along with a @type that describes the
type of the serialized message.
"""
if TYPE_CHECKING:
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> object: ...

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.code = cast(Any, construct_type(type_=Optional[ErrorCode], value=body.get("code")))
self.detail = cast(Any, construct_type(type_=Optional[ArbitraryData], value=body.get("detail")))
else:
self.code = None
self.detail = None


class APIResponseValidationError(APIError):
response: httpx.Response
Expand Down
2 changes: 2 additions & 0 deletions src/gitpod/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
RunsOn as RunsOn,
Subject as Subject,
TaskSpec as TaskSpec,
ErrorCode as ErrorCode,
Principal as Principal,
FieldValue as FieldValue,
UserStatus as UserStatus,
TaskMetadata as TaskMetadata,
ArbitraryData as ArbitraryData,
TaskExecution as TaskExecution,
EnvironmentClass as EnvironmentClass,
OrganizationRole as OrganizationRole,
Expand Down
2 changes: 2 additions & 0 deletions src/gitpod/types/shared/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
from .subject import Subject as Subject
from .principal import Principal as Principal
from .task_spec import TaskSpec as TaskSpec
from .error_code import ErrorCode as ErrorCode
from .field_value import FieldValue as FieldValue
from .user_status import UserStatus as UserStatus
from .task_metadata import TaskMetadata as TaskMetadata
from .arbitrary_data import ArbitraryData as ArbitraryData
from .task_execution import TaskExecution as TaskExecution
from .environment_class import EnvironmentClass as EnvironmentClass
from .organization_role import OrganizationRole as OrganizationRole
Expand Down
21 changes: 21 additions & 0 deletions src/gitpod/types/shared/arbitrary_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import TYPE_CHECKING, Dict, Optional

from ..._models import BaseModel

__all__ = ["ArbitraryData"]


class ArbitraryData(BaseModel):
debug: Optional[Dict[str, object]] = None

type: Optional[str] = None

value: Optional[object] = None

if TYPE_CHECKING:
# Stub to indicate that arbitrary properties are accepted.
# To access properties that are not valid identifiers you can use `getattr`, e.g.
# `getattr(obj, '$type')`
def __getattr__(self, attr: str) -> object: ...
24 changes: 24 additions & 0 deletions src/gitpod/types/shared/error_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing_extensions import Literal, TypeAlias

__all__ = ["ErrorCode"]

ErrorCode: TypeAlias = Literal[
"canceled",
"unknown",
"invalid_argument",
"deadline_exceeded",
"not_found",
"already_exists",
"permission_denied",
"resource_exhausted",
"failed_precondition",
"aborted",
"out_of_range",
"unimplemented",
"internal",
"unavailable",
"data_loss",
"unauthenticated",
]