-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30bb15f
commit 70ab3d0
Showing
85 changed files
with
1,165 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./BadRequestError"; | ||
export * from "./NotFoundError"; | ||
export * from "./ForbiddenError"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
* Role ID | ||
* | ||
* @example | ||
* "us_rol_a7Ws9cue" | ||
* "us_rol_YOUR_ID" | ||
*/ | ||
export type RoleId = string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
File renamed without changes.
16 changes: 16 additions & 0 deletions
16
src/api/resources/entitlements/client/requests/ListEntitlementsRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { ListEntitlementsRequest } from "./ListEntitlementsRequest"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./types"; | ||
export * from "./client"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
20
src/api/resources/entitlements/types/ListEntitlementsResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./ListEntitlementsResponse"; | ||
export * from "./Entitlement"; |
Oops, something went wrong.