create method

Future<Func> create({
  1. required String functionId,
  2. required String name,
  3. required Runtime runtime,
  4. List<String>? execute,
  5. List<String>? events,
  6. String? schedule,
  7. int? timeout,
  8. bool? enabled,
  9. bool? logging,
  10. String? entrypoint,
  11. String? commands,
  12. String? installationId,
  13. String? providerRepositoryId,
  14. String? providerBranch,
  15. bool? providerSilentMode,
  16. String? providerRootDirectory,
  17. String? templateRepository,
  18. String? templateOwner,
  19. String? templateRootDirectory,
  20. String? templateBranch,
})

Create function

Create a new function. You can pass a list of permissions to allow different project users or team with access to execute the function using the client API.

Implementation

Future<models.Func> create(
    {required String functionId,
    required String name,
    required enums.Runtime runtime,
    List<String>? execute,
    List<String>? events,
    String? schedule,
    int? timeout,
    bool? enabled,
    bool? logging,
    String? entrypoint,
    String? commands,
    String? installationId,
    String? providerRepositoryId,
    String? providerBranch,
    bool? providerSilentMode,
    String? providerRootDirectory,
    String? templateRepository,
    String? templateOwner,
    String? templateRootDirectory,
    String? templateBranch}) async {
  final String apiPath = '/functions';

  final Map<String, dynamic> apiParams = {
    'functionId': functionId,
    'name': name,
    'runtime': runtime.value,
    'execute': execute,
    'events': events,
    'schedule': schedule,
    'timeout': timeout,
    'enabled': enabled,
    'logging': logging,
    'entrypoint': entrypoint,
    'commands': commands,
    'installationId': installationId,
    'providerRepositoryId': providerRepositoryId,
    'providerBranch': providerBranch,
    'providerSilentMode': providerSilentMode,
    'providerRootDirectory': providerRootDirectory,
    'templateRepository': templateRepository,
    'templateOwner': templateOwner,
    'templateRootDirectory': templateRootDirectory,
    'templateBranch': templateBranch,
  };

  final Map<String, String> apiHeaders = {
    'content-type': 'application/json',
  };

  final res = await client.call(HttpMethod.post,
      path: apiPath, params: apiParams, headers: apiHeaders);

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