/** * Apimatic APILib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ import { ApiResponse, RequestOptions } from '../core.js'; import { ApiEntityCodeGeneration, apiEntityCodeGenerationSchema, } from '../models/apiEntityCodeGeneration.js'; import { Platforms, platformsSchema } from '../models/platforms.js'; import { array, string } from '../schema.js'; import { BaseController } from './baseController.js'; export class CodeGenerationImportedApisController extends BaseController { /** * Generate an SDK for an API Version. * * This endpoint generates and then uploads the generated SDK to APIMatic's cloud storage. An ID for * the generation performed is returned as part of the response. * * @param apiEntityId The ID of the API Entity to generate the SDK for. * @param template The structure contains platforms that APIMatic CodeGen can generate SDKs and * Docs in. * @return Response from the API call */ async generateSdk( apiEntityId: string, template: Platforms, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('POST'); const mapped = req.prepareArgs({ apiEntityId: [apiEntityId, string()], template: [template, platformsSchema], }); req.header('Content-Type', 'application/x-www-form-urlencoded'); req.form({ template: mapped.template }); req.appendTemplatePath`/api-entities/${mapped.apiEntityId}/code-generations/generate`; req.authenticate([{ authorization: true }]); return req.callAsJson(apiEntityCodeGenerationSchema, requestOptions); } /** * Download the SDK generated via the Generate SDK endpoint. * * @param apiEntityId The ID of the API Entity for which the SDK was generated. * @param codegenId The ID of code generation received in the response of the [SDK generation * call]($e/Code%20Generation%20-%20Imported%20APIs/Generate%20SDK). * @return Response from the API call */ async downloadSdk( apiEntityId: string, codegenId: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ apiEntityId: [apiEntityId, string()], codegenId: [codegenId, string()], }); req.appendTemplatePath`/api-entities/${mapped.apiEntityId}/code-generations/${mapped.codegenId}/generated-sdk`; req.authenticate([{ authorization: true }]); return req.callAsStream(requestOptions); } /** * Get a list of all SDK generations done against an API Version via the Generate SDK endpoint. * * @param apiEntityId The ID of the API Entity for which to list code generations. * @return Response from the API call */ async listAllCodeGenerations( apiEntityId: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ apiEntityId: [apiEntityId, string()] }); req.appendTemplatePath`/api-entities/${mapped.apiEntityId}/code-generations`; req.authenticate([{ authorization: true }]); return req.callAsJson(array(apiEntityCodeGenerationSchema), requestOptions); } /** * Get details on an SDK generation performed via the Generate SDK endpoint. * * @param apiEntityId The ID of the API Entity to fetch the code generation for. * @param codegenId The ID of the code generation to fetch. The code generation ID is received in the * response of the [SDK generation call]($e/Code%20Generation%20- * %20Imported%20APIs/Generate%20SDK). * @return Response from the API call */ async getACodeGeneration( apiEntityId: string, codegenId: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('GET'); const mapped = req.prepareArgs({ apiEntityId: [apiEntityId, string()], codegenId: [codegenId, string()], }); req.appendTemplatePath`/api-entities/${mapped.apiEntityId}/code-generations/${mapped.codegenId}`; req.authenticate([{ authorization: true }]); return req.callAsJson(apiEntityCodeGenerationSchema, requestOptions); } /** * Delete an SDK generation performed for an API Version via the Generate SDK endpoint. * * @param apiEntityId The ID of the API Entity to delete the code generation for. * @param codegenId The ID of the code generation to delete. The code generation ID is received in the * response of the [SDK generation call]($e/Code%20Generation%20- * %20Imported%20APIs/Generate%20SDK). * @return Response from the API call */ async deleteCodeGeneration( apiEntityId: string, codegenId: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('DELETE'); const mapped = req.prepareArgs({ apiEntityId: [apiEntityId, string()], codegenId: [codegenId, string()], }); req.appendTemplatePath`/api-entities/${mapped.apiEntityId}/code-generations/${mapped.codegenId}`; req.authenticate([{ authorization: true }]); return req.call(requestOptions); } }