Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Feb 5, 2024
1 parent 30bb15f commit 70ab3d0
Show file tree
Hide file tree
Showing 85 changed files with 1,165 additions and 112 deletions.
7 changes: 7 additions & 0 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Cells } from "./api/resources/cells/client/Client";
import { Commits } from "./api/resources/commits/client/Client";
import { DataRetentionPolicies } from "./api/resources/dataRetentionPolicies/client/Client";
import { Documents } from "./api/resources/documents/client/Client";
import { Entitlements } from "./api/resources/entitlements/client/Client";
import { Environments } from "./api/resources/environments/client/Client";
import { Events } from "./api/resources/events/client/Client";
import { Files } from "./api/resources/files/client/Client";
Expand Down Expand Up @@ -85,6 +86,12 @@ export class FlatfileClient {
return (this._documents ??= new Documents(this._options));
}

protected _entitlements: Entitlements | undefined;

public get entitlements(): Entitlements {
return (this._entitlements ??= new Entitlements(this._options));
}

protected _environments: Environments | undefined;

public get environments(): Environments {
Expand Down
17 changes: 17 additions & 0 deletions src/api/resources/commons/errors/ForbiddenError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as errors from "../../../../errors";
import * as Flatfile from "../../..";

export class ForbiddenError extends errors.FlatfileError {
constructor(body: Flatfile.Errors) {
super({
message: "ForbiddenError",
statusCode: 403,
body: body,
});
Object.setPrototypeOf(this, ForbiddenError.prototype);
}
}
1 change: 1 addition & 0 deletions src/api/resources/commons/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./BadRequestError";
export * from "./NotFoundError";
export * from "./ForbiddenError";
11 changes: 11 additions & 0 deletions src/api/resources/commons/types/ActorRoleId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

/**
* Actor Role ID
*
* @example
* "us_acr_YOUR_ID"
*/
export type ActorRoleId = string;
2 changes: 1 addition & 1 deletion src/api/resources/commons/types/RoleId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* Role ID
*
* @example
* "us_rol_a7Ws9cue"
* "us_rol_YOUR_ID"
*/
export type RoleId = string;
1 change: 1 addition & 0 deletions src/api/resources/commons/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export * from "./CommitId";
export * from "./VersionId";
export * from "./JobId";
export * from "./UserId";
export * from "./ActorRoleId";
export * from "./RoleId";
export * from "./SpaceConfigId";
export * from "./RecordId";
Expand Down
126 changes: 126 additions & 0 deletions src/api/resources/entitlements/client/Client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as environments from "../../../../environments";
import * as core from "../../../../core";
import * as Flatfile from "../../..";
import urlJoin from "url-join";
import * as serializers from "../../../../serialization";
import * as errors from "../../../../errors";

export declare namespace Entitlements {
interface Options {
environment?: core.Supplier<environments.FlatfileEnvironment | string>;
token?: core.Supplier<core.BearerToken | undefined>;
fetcher?: core.FetchFunction;
}

interface RequestOptions {
timeoutInSeconds?: number;
maxRetries?: number;
}
}

export class Entitlements {
constructor(protected readonly _options: Entitlements.Options = {}) {}

/**
* Returns all entitlements matching a filter for resourceId
* @throws {@link Flatfile.BadRequestError}
* @throws {@link Flatfile.NotFoundError}
*
* @example
* await flatfile.entitlements.list({
* resourceId: "string"
* })
*/
public async list(
request: Flatfile.ListEntitlementsRequest,
requestOptions?: Entitlements.RequestOptions
): Promise<Flatfile.ListEntitlementsResponse> {
const { resourceId } = request;
const _queryParams: Record<string, string | string[]> = {};
_queryParams["resourceId"] = resourceId;
const _response = await (this._options.fetcher ?? core.fetcher)({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.FlatfileEnvironment.Production,
"/entitlements"
),
method: "GET",
headers: {
Authorization: await this._getAuthorizationHeader(),
"X-Disable-Hooks": "true",
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@flatfile/api",
"X-Fern-SDK-Version": "1.6.7-rc",
},
contentType: "application/json",
queryParameters: _queryParams,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
});
if (_response.ok) {
return await serializers.ListEntitlementsResponse.parseOrThrow(_response.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
});
}

if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 400:
throw new Flatfile.BadRequestError(
await serializers.Errors.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
})
);
case 404:
throw new Flatfile.NotFoundError(
await serializers.Errors.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
})
);
default:
throw new errors.FlatfileError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}
}

switch (_response.error.reason) {
case "non-json":
throw new errors.FlatfileError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.FlatfileTimeoutError();
case "unknown":
throw new errors.FlatfileError({
message: _response.error.errorMessage,
});
}
}

protected async _getAuthorizationHeader() {
const bearer = await core.Supplier.get(this._options.token);
if (bearer != null) {
return `Bearer ${bearer}`;
}

return undefined;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

/**
* @example
* {
* resourceId: "string"
* }
*/
export interface ListEntitlementsRequest {
/**
* The associated Resource ID for the entitlements.
*/
resourceId: string;
}
1 change: 1 addition & 0 deletions src/api/resources/entitlements/client/requests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ListEntitlementsRequest } from "./ListEntitlementsRequest";
2 changes: 2 additions & 0 deletions src/api/resources/entitlements/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./types";
export * from "./client";
21 changes: 21 additions & 0 deletions src/api/resources/entitlements/types/Entitlement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

/**
* An entitlement belonging to a resource
*
* @example
* {
* key: "snapshots",
* metadata: {
* "files": 10
* }
* }
*/
export interface Entitlement {
/** Short name for the entitlement */
key: string;
/** Contains conditions or limits for an entitlement */
metadata?: any;
}
20 changes: 20 additions & 0 deletions src/api/resources/entitlements/types/ListEntitlementsResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as Flatfile from "../../..";

/**
* @example
* {
* data: [{
* key: "snapshots",
* metadata: {
* "files": 10
* }
* }]
* }
*/
export interface ListEntitlementsResponse {
data: Flatfile.Entitlement[];
}
2 changes: 2 additions & 0 deletions src/api/resources/entitlements/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./ListEntitlementsResponse";
export * from "./Entitlement";
Loading

0 comments on commit 70ab3d0

Please sign in to comment.