import * as url from 'url'; declare namespace io.apibuilder.common.v0.enums { type MembershipRole = 'member' | 'admin'; } declare namespace io.apibuilder.common.v0.models { interface Audit { readonly 'created_at': string; readonly 'created_by': io.apibuilder.common.v0.models.ReferenceGuid; readonly 'updated_at': string; readonly 'updated_by': io.apibuilder.common.v0.models.ReferenceGuid; } interface Healthcheck { readonly 'status': string; } interface Reference { readonly 'guid': string; readonly 'key': string; } interface ReferenceGuid { readonly 'guid': string; } } declare namespace io.apibuilder.spec.v0.enums { type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE'; type ParameterLocation = 'Path' | 'Query' | 'Form' | 'Header'; type ResponseCodeOption = 'Default'; } declare namespace io.apibuilder.spec.v0.models { interface Annotation { readonly 'name': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; } interface Apidoc { readonly 'version': string; } interface Application { readonly 'key': string; } interface Attribute { readonly 'name': string; readonly 'value': any/*object*/; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; } interface Body { readonly 'type': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; } interface Contact { readonly 'name'?: string; readonly 'url'?: string; readonly 'email'?: string; } interface Deprecation { readonly 'description'?: string; } interface Enum { readonly 'name': string; readonly 'plural': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'values': io.apibuilder.spec.v0.models.EnumValue[]; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; } interface EnumValue { readonly 'name': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; readonly 'value'?: string; } interface Field { readonly 'name': string; readonly 'type': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'default'?: string; readonly 'required': boolean; readonly 'minimum'?: number; readonly 'maximum'?: number; readonly 'example'?: string; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; readonly 'annotations': string[]; } interface Header { readonly 'name': string; readonly 'type': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'required': boolean; readonly 'default'?: string; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; } interface Import { readonly 'uri': string; readonly 'namespace': string; readonly 'organization': io.apibuilder.spec.v0.models.Organization; readonly 'application': io.apibuilder.spec.v0.models.Application; readonly 'version': string; readonly 'enums': string[]; readonly 'interfaces': string[]; readonly 'unions': string[]; readonly 'models': string[]; readonly 'annotations': io.apibuilder.spec.v0.models.Annotation[]; } interface Info { readonly 'license'?: io.apibuilder.spec.v0.models.License; readonly 'contact'?: io.apibuilder.spec.v0.models.Contact; } interface Interface { readonly 'name': string; readonly 'plural': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'fields': io.apibuilder.spec.v0.models.Field[]; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; } interface License { readonly 'name': string; readonly 'url'?: string; } interface Model { readonly 'name': string; readonly 'plural': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'fields': io.apibuilder.spec.v0.models.Field[]; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; readonly 'interfaces': string[]; } interface Operation { readonly 'method': io.apibuilder.spec.v0.enums.Method; readonly 'path': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'body'?: io.apibuilder.spec.v0.models.Body; readonly 'parameters': io.apibuilder.spec.v0.models.Parameter[]; readonly 'responses': io.apibuilder.spec.v0.models.Response[]; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; } interface Organization { readonly 'key': string; } interface Parameter { readonly 'name': string; readonly 'type': string; readonly 'location': io.apibuilder.spec.v0.enums.ParameterLocation; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'required': boolean; readonly 'default'?: string; readonly 'minimum'?: number; readonly 'maximum'?: number; readonly 'example'?: string; readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; } interface Resource { readonly 'type': string; readonly 'plural': string; readonly 'path'?: string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'operations': io.apibuilder.spec.v0.models.Operation[]; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; } interface Response { readonly 'code': io.apibuilder.spec.v0.unions.ResponseCode; readonly 'type': string; readonly 'headers'?: io.apibuilder.spec.v0.models.Header[]; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'attributes'?: io.apibuilder.spec.v0.models.Attribute[]; } interface Service { readonly 'apidoc'?: io.apibuilder.spec.v0.models.Apidoc; readonly 'name': string; readonly 'organization': io.apibuilder.spec.v0.models.Organization; readonly 'application': io.apibuilder.spec.v0.models.Application; readonly 'namespace': string; readonly 'version': string; readonly 'base_url'?: string; readonly 'description'?: string; readonly 'info': io.apibuilder.spec.v0.models.Info; readonly 'headers': io.apibuilder.spec.v0.models.Header[]; readonly 'imports': io.apibuilder.spec.v0.models.Import[]; readonly 'enums': io.apibuilder.spec.v0.models.Enum[]; readonly 'interfaces': io.apibuilder.spec.v0.models.Interface[]; readonly 'unions': io.apibuilder.spec.v0.models.Union[]; readonly 'models': io.apibuilder.spec.v0.models.Model[]; readonly 'resources': io.apibuilder.spec.v0.models.Resource[]; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; readonly 'annotations': io.apibuilder.spec.v0.models.Annotation[]; } interface Union { readonly 'name': string; readonly 'plural': string; readonly 'discriminator'?: string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'types': io.apibuilder.spec.v0.models.UnionType[]; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; readonly 'interfaces': string[]; } interface UnionType { readonly 'type': string; readonly 'description'?: string; readonly 'deprecation'?: io.apibuilder.spec.v0.models.Deprecation; readonly 'fields'?: io.apibuilder.spec.v0.models.Field[]; readonly 'attributes': io.apibuilder.spec.v0.models.Attribute[]; readonly 'default'?: boolean; readonly 'discriminator_value'?: string; } } declare namespace io.apibuilder.spec.v0.unions { type ResponseCode = ({ discriminator: 'integer', value: number } | { discriminator: 'response_code_option', value: io.apibuilder.spec.v0.enums.ResponseCodeOption }); } declare namespace cerium.termsteelversionapi.v0.enums { type FileFlag = 'scaffolding'; } declare namespace cerium.termsteelversionapi.v0.models { interface Attribute { readonly 'name': string; readonly 'value': string; } interface Error { readonly 'code': string; readonly 'message': string; } interface File { readonly 'name': string; readonly 'dir'?: string; readonly 'contents': string; readonly 'flags'?: cerium.termsteelversionapi.v0.enums.FileFlag[]; } interface Generator { readonly 'key': string; readonly 'name': string; readonly 'language'?: string; readonly 'description'?: string; readonly 'attributes': string[]; } interface Healthcheck { readonly 'status': string; } interface Invocation { readonly 'source': string; readonly 'files': cerium.termsteelversionapi.v0.models.File[]; } interface InvocationForm { readonly 'service': io.apibuilder.spec.v0.models.Service; readonly 'attributes': cerium.termsteelversionapi.v0.models.Attribute[]; readonly 'user_agent'?: string; readonly 'imported_services'?: io.apibuilder.spec.v0.models.Service[]; } } export type Attribute = cerium.termsteelversionapi.v0.models.Attribute; export type Error = cerium.termsteelversionapi.v0.models.Error; export type File = cerium.termsteelversionapi.v0.models.File; export type FileFlag = cerium.termsteelversionapi.v0.enums.FileFlag; export type Generator = cerium.termsteelversionapi.v0.models.Generator; export type Healthcheck = cerium.termsteelversionapi.v0.models.Healthcheck; export type Invocation = cerium.termsteelversionapi.v0.models.Invocation; export type InvocationForm = cerium.termsteelversionapi.v0.models.InvocationForm; export interface $FetchOptions { body?: string; headers?: $HttpHeaders; method?: $HttpMethod; } export type $FetchFunction = (url: string, options?: $FetchOptions) => Promise; export interface $HttpHeaders { [key: string]: string; } export type $HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE'; export interface $HttpQuery { [key: string]: string | number | boolean | string[] | number[] | boolean[] | undefined | null; } export interface $HttpRequest { body?: any; url: string; headers: $HttpHeaders; method: $HttpMethod; } export interface $HttpRequestOptions { body?: any; endpoint: string; headers?: $HttpHeaders; method: $HttpMethod; query?: $HttpQuery; } export interface $HttpResponse { body: B; headers: $HttpHeaders; ok: O; request: $HttpRequest; status: S; statusText: string; } export type $HttpContinue = $HttpResponse; export type $HttpSwitchingProtocol = $HttpResponse; export type $HttpProcessing = $HttpResponse; export type $HttpOk = $HttpResponse; export type $HttpCreated = $HttpResponse; export type $HttpAccepted = $HttpResponse; export type $HttpNonAuthoritativeInformation = $HttpResponse; export type $HttpNoContent = $HttpResponse; export type $HttpResetContent = $HttpResponse; export type $HttpPartialContent = $HttpResponse; export type $HttpMultiStatus = $HttpResponse; export type $HttpAlreadyReported = $HttpResponse; export type $HttpImUsed = $HttpResponse; export type $HttpMultipleChoices = $HttpResponse; export type $HttpMovedPermanently = $HttpResponse; export type $HttpFound = $HttpResponse; export type $HttpSeeOther = $HttpResponse; export type $HttpNotModified = $HttpResponse; export type $HttpUseProxy = $HttpResponse; export type $HttpTemporaryRedirect = $HttpResponse; export type $HttpPermanentRedirect = $HttpResponse; export type $HttpBadRequest = $HttpResponse; export type $HttpUnauthorized = $HttpResponse; export type $HttpPaymentRequired = $HttpResponse; export type $HttpForbidden = $HttpResponse; export type $HttpNotFound = $HttpResponse; export type $HttpMethodNotAllowed = $HttpResponse; export type $HttpNotAcceptable = $HttpResponse; export type $HttpProxyAuthenticationRequired = $HttpResponse; export type $HttpRequestTimeout = $HttpResponse; export type $HttpConflict = $HttpResponse; export type $HttpGone = $HttpResponse; export type $HttpLengthRequired = $HttpResponse; export type $HttpPreconditionFailed = $HttpResponse; export type $HttpRequestEntityTooLarge = $HttpResponse; export type $HttpRequestUriTooLong = $HttpResponse; export type $HttpUnsupportedMediaType = $HttpResponse; export type $HttpRequestedRangeNotSatisfiable = $HttpResponse; export type $HttpExpectationFailed = $HttpResponse; export type $HttpMisdirectedRequest = $HttpResponse; export type $HttpUnprocessableEntity = $HttpResponse; export type $HttpLocked = $HttpResponse; export type $HttpFailedDependency = $HttpResponse; export type $HttpUpgradeRequired = $HttpResponse; export type $HttpPreconditionRequired = $HttpResponse; export type $HttpTooManyRequests = $HttpResponse; export type $HttpRequestHeaderFieldsTooLarge = $HttpResponse; export type $HttpNoResponse = $HttpResponse; export type $HttpRetryWith = $HttpResponse; export type $HttpBlockedByWindowsParentalControls = $HttpResponse; export type $HttpUnavailableForLegalReasons = $HttpResponse; export type $HttpClientClosedRequest = $HttpResponse; export type $HttpInternalServerError = $HttpResponse; export type $HttpNotImplemented = $HttpResponse; export type $HttpBadGateway = $HttpResponse; export type $HttpServiceUnavailable = $HttpResponse; export type $HttpGatewayTimeout = $HttpResponse; export type $HttpHttpVersionNotSupported = $HttpResponse; export type $HttpInsufficientStorage = $HttpResponse; export type $HttpLoopDetected = $HttpResponse; export type $HttpBandwidthLimitExceeded = $HttpResponse; export type $HttpNotExtended = $HttpResponse; export type $HttpNetworkAuthenticationRequired = $HttpResponse; export type $HttpNetworkReadTimeoutError = $HttpResponse; export type $HttpNetworkConnectTimeoutError = $HttpResponse; export interface $HttpClientOptions { fetch: $FetchFunction; } export function isResponseEmpty(response: Response): boolean { const contentLength = response.headers.get('Content-Length'); return response.status === 204 || contentLength != null && Number.parseInt(contentLength, 10) === 0; } export function isResponseJson(response: Response): boolean { const contentType = response.headers.get('Content-Type'); return contentType != null && contentType.indexOf('json') >= 0; } export function parseJson(response: Response): Promise { return !isResponseEmpty(response) && isResponseJson(response) ? response.json() : Promise.resolve(); } export function parseHeaders(response: Response): Record { const headers: Record = {}; response.headers.forEach((value, key) => { headers[key.toLowerCase()] = value; }); return headers; } export function stripQuery(query: $HttpQuery = {}): $HttpQuery { const initialValue: $HttpQuery = {}; return Object.keys(query).reduce((previousValue, key) => { const value = query[key]; if (value != null) previousValue[key] = value; return previousValue; }, initialValue); } export class $HttpClient { private options: $HttpClientOptions; constructor(options: $HttpClientOptions) { this.options = options; } public request(options: $HttpRequestOptions): Promise<$HttpResponse> { const finalUrl: string = url.format({ hostname: 'api.apibuilder.io', pathname: options.endpoint, protocol: 'https:', query: stripQuery(options.query), }); const finalHeaders: $HttpHeaders = { accept: 'application/json', 'content-type': 'application/json', ...options.headers, }; const request: $HttpRequest = { body: options.body, headers: finalHeaders, method: options.method, url: finalUrl, }; return this.options.fetch(request.url, { body: JSON.stringify(request.body), headers: request.headers, method: request.method, }).then((response) => { return parseJson(response).then((json) => { return { body: json, headers: parseHeaders(response), ok: response.ok, request, status: response.status, statusText: response.statusText, }; }); }); } } export class $Resource { protected client: $HttpClient; constructor(options: $HttpClientOptions) { this.client = new $HttpClient(options); } } export interface GeneratorsGetParameters { headers?: $HttpHeaders; /*Filter generators with this key*/ key?: string; /*The number of records to return*/ limit?: number; /*Used to paginate. First page of results is 0.*/ offset?: number; } export interface GeneratorsGetByKeyParameters { headers?: $HttpHeaders; key: string; } export interface HealthchecksGetParameters { headers?: $HttpHeaders; } export interface InvocationsPostByKeyParameters { body: cerium.termsteelversionapi.v0.models.InvocationForm; headers?: $HttpHeaders; key: string; } export type GeneratorsGetResponse = $HttpOk; export type GeneratorsGetByKeyResponse = $HttpOk | $HttpNotFound; export type HealthchecksGetResponse = $HttpOk; export type InvocationsPostByKeyResponse = $HttpOk | $HttpConflict; export class GeneratorsResource extends $Resource { /*Get all available generators*/ public get(params: GeneratorsGetParameters): Promise { return this.client.request({ endpoint: '/generators', headers: params.headers, method: 'GET', query: { key: params.key, limit: params.limit, offset: params.offset, }, }); } /*Get generator with this key*/ public getByKey(params: GeneratorsGetByKeyParameters): Promise { return this.client.request({ endpoint: `/generators/${encodeURIComponent(params.key)}`, headers: params.headers, method: 'GET', }); } } export class HealthchecksResource extends $Resource { public get(params: HealthchecksGetParameters = {}): Promise { return this.client.request({ endpoint: '/_internal_/healthcheck', headers: params.headers, method: 'GET', }); } } export class InvocationsResource extends $Resource { /*Invoke a generator*/ public postByKey(params: InvocationsPostByKeyParameters): Promise { return this.client.request({ body: params.body, endpoint: `/invocations/${encodeURIComponent(params.key)}`, headers: params.headers, method: 'POST', }); } } export interface ClientInstance { generators: GeneratorsResource; healthchecks: HealthchecksResource; invocations: InvocationsResource; } export function createClient(options: $HttpClientOptions): ClientInstance { return { generators: new GeneratorsResource(options), healthchecks: new HealthchecksResource(options), invocations: new InvocationsResource(options), }; }