createDeployment method

Future<Deployment> createDeployment({
  1. required String functionId,
  2. required InputFile code,
  3. required bool activate,
  4. String? entrypoint,
  5. String? commands,
  6. dynamic onProgress(
    1. UploadProgress
    )?,
})

Create deployment

Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID.

This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the Appwrite Cloud Functions tutorial.

Use the "command" param to set the entrypoint used to execute your code.

Implementation

Future<models.Deployment> createDeployment(
    {required String functionId,
    required InputFile code,
    required bool activate,
    String? entrypoint,
    String? commands,
    Function(UploadProgress)? onProgress}) async {
  final String apiPath = '/functions/{functionId}/deployments'
      .replaceAll('{functionId}', functionId);

  final Map<String, dynamic> apiParams = {
    'entrypoint': entrypoint,
    'commands': commands,
    'code': code,
    'activate': activate,
  };

  final Map<String, String> apiHeaders = {
    'content-type': 'multipart/form-data',
  };

  String idParamName = '';
  final paramName = 'code';
  final res = await client.chunkedUpload(
    path: apiPath,
    params: apiParams,
    paramName: paramName,
    idParamName: idParamName,
    headers: apiHeaders,
    onProgress: onProgress,
  );

  return models.Deployment.fromMap(res.data);
}