Skip to content

feat(api): manual updates #20

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 @@

Types:

- <code><a href="./src/resources/shared.ts">ArbitraryData</a></code>
- <code><a href="./src/resources/shared.ts">AutomationTrigger</a></code>
- <code><a href="./src/resources/shared.ts">EnvironmentClass</a></code>
- <code><a href="./src/resources/shared.ts">ErrorCode</a></code>
- <code><a href="./src/resources/shared.ts">FieldValue</a></code>
- <code><a href="./src/resources/shared.ts">OrganizationRole</a></code>
- <code><a href="./src/resources/shared.ts">Principal</a></code>
Expand Down
2 changes: 2 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1145,8 +1145,10 @@ export declare namespace Gitpod {
type UserSetSuspendedParams as UserSetSuspendedParams,
};

export type ArbitraryData = API.ArbitraryData;
export type AutomationTrigger = API.AutomationTrigger;
export type EnvironmentClass = API.EnvironmentClass;
export type ErrorCode = API.ErrorCode;
export type FieldValue = API.FieldValue;
export type OrganizationRole = API.OrganizationRole;
export type Principal = API.Principal;
Expand Down
16 changes: 16 additions & 0 deletions src/error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { castToError } from './internal/errors';
import * as Shared from './resources/shared';

export class GitpodError extends Error {}

Expand All @@ -16,11 +17,26 @@ export class APIError<
/** JSON body of the response that caused the error */
readonly error: TError;

/**
* The status code, which should be an enum value of
* [google.rpc.Code][google.rpc.Code].
*/
readonly code?: Shared.ErrorCode | undefined;
/**
* Contains an arbitrary serialized message along with a @type that describes the
* type of the serialized message.
*/
readonly detail?: Shared.ArbitraryData | undefined;

constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
super(`${APIError.makeMessage(status, error, message)}`);
this.status = status;
this.headers = headers;
this.error = error;

const data = error as Record<string, any>;
this.code = data?.['code'];
this.detail = data?.['detail'];
}

private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
Expand Down
36 changes: 36 additions & 0 deletions src/resources/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

import * as Shared from './shared';
import { EnvironmentClassesPage, TaskExecutionsPage, TasksPage } from '../pagination';
import { type Uploadable } from '../uploads';

/**
* Contains an arbitrary serialized message along with a @type that describes the
* type of the serialized message.
*/
export interface ArbitraryData {
debug?: Record<string, unknown>;

type?: string;

value?: Uploadable;
[k: string]: unknown;
}

/**
* An AutomationTrigger represents a trigger for an automation action. The
Expand Down Expand Up @@ -51,6 +65,28 @@ export interface EnvironmentClass {
runnerId?: string;
}

/**
* The status code, which should be an enum value of
* [google.rpc.Code][google.rpc.Code].
*/
export type ErrorCode =
| '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';

export interface FieldValue {
key?: string;

Expand Down