Skip to content

Latest commit

 

History

History
228 lines (171 loc) · 7.04 KB

code-generation-imported-apis.md

File metadata and controls

228 lines (171 loc) · 7.04 KB

Code Generation - Imported APIs

const codeGenerationImportedApisController = new CodeGenerationImportedApisController(client);

Class Name

CodeGenerationImportedApisController

Methods

Generate SDK

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.

async generateSDK(
  apiEntityId: string,
  template: Platforms,
  requestOptions?: RequestOptions
): Promise<ApiResponse<APIEntityCodeGeneration>>

Parameters

Parameter Type Tags Description
apiEntityId string Template, Required The ID of the API Entity to generate the SDK for.
template Platforms Form, Required The structure contains platforms that APIMatic CodeGen can generate SDKs and Docs in.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

APIEntityCodeGeneration

Example Usage

const apiEntityId = 'api_entity_id4';
const contentType = null;
const template = 'PHP_GENERIC_LIB';
try {
  const { result, ...httpResponse } = await codeGenerationImportedApisController.generateSDK(apiEntityId, template);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Download SDK

Download the SDK generated via the Generate SDK endpoint.

async downloadSDK(
  apiEntityId: string,
  codegenId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<NodeJS.ReadableStream | Blob>>

Parameters

Parameter Type Tags Description
apiEntityId string Template, Required The ID of the API Entity for which the SDK was generated.
codegenId string Template, Required The ID of code generation received in the response of the SDK generation call.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

NodeJS.ReadableStream | Blob

Example Usage

const apiEntityId = 'api_entity_id4';
const codegenId = 'codegen_id6';
try {
  const { result, ...httpResponse } = await codeGenerationImportedApisController.downloadSDK(apiEntityId, codegenId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

List All Code Generations

Get a list of all SDK generations done against an API Version via the Generate SDK endpoint.

async listAllCodeGenerations(
  apiEntityId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<APIEntityCodeGeneration[]>>

Parameters

Parameter Type Tags Description
apiEntityId string Template, Required The ID of the API Entity for which to list code generations.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

APIEntityCodeGeneration[]

Example Usage

const apiEntityId = 'api_entity_id4';
try {
  const { result, ...httpResponse } = await codeGenerationImportedApisController.listAllCodeGenerations(apiEntityId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Get a Code Generation

Get details on an SDK generation performed via the Generate SDK endpoint.

async getACodeGeneration(
  apiEntityId: string,
  codegenId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<APIEntityCodeGeneration>>

Parameters

Parameter Type Tags Description
apiEntityId string Template, Required The ID of the API Entity to fetch the code generation for.
codegenId string Template, Required The ID of the code generation to fetch. The code generation ID is received in the response of the SDK generation call.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

APIEntityCodeGeneration

Example Usage

const apiEntityId = 'api_entity_id4';
const codegenId = 'codegen_id6';
try {
  const { result, ...httpResponse } = await codeGenerationImportedApisController.getACodeGeneration(apiEntityId, codegenId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Delete Code Generation

Delete an SDK generation performed for an API Version via the Generate SDK endpoint.

async deleteCodeGeneration(
  apiEntityId: string,
  codegenId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<void>>

Parameters

Parameter Type Tags Description
apiEntityId string Template, Required The ID of the API Entity to delete the code generation for.
codegenId string Template, Required The ID of the code generation to delete. The code generation ID is received in the response of the SDK generation call.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

void

Example Usage

const apiEntityId = 'api_entity_id4';
const codegenId = 'codegen_id6';
try {
  const { result, ...httpResponse } = await codeGenerationImportedApisController.deleteCodeGeneration(apiEntityId, codegenId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}