Class: Appwrite::Functions

Inherits:
Service
  • Object
show all
Defined in:
lib/appwrite/services/functions.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Functions

Returns a new instance of Functions.



6
7
8
# File 'lib/appwrite/services/functions.rb', line 6

def initialize(client)
    @client = client
end

Instance Method Details

#create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, template_repository: nil, template_owner: nil, template_root_directory: nil, template_branch: nil) ⇒ Function

Create a new function. You can pass a list of [permissions](appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API.

Parameters:

  • function_id (String)

    Function ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • name (String)

    Function name. Max length: 128 chars.

  • runtime (Runtime)

    Execution runtime.

  • execute (Array) (defaults to: nil)

    An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.

  • events (Array) (defaults to: nil)

    Events list. Maximum of 100 events are allowed.

  • schedule (String) (defaults to: nil)

    Schedule CRON syntax.

  • timeout (Integer) (defaults to: nil)

    Function maximum execution time in seconds.

  • []

    enabled Is function enabled? When set to ‘disabled’, users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.

  • []

    logging Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.

  • entrypoint (String) (defaults to: nil)

    Entrypoint File. This path is relative to the “providerRootDirectory”.

  • commands (String) (defaults to: nil)

    Build Commands.

  • installation_id (String) (defaults to: nil)

    Appwrite Installation ID for VCS (Version Control System) deployment.

  • provider_repository_id (String) (defaults to: nil)

    Repository ID of the repo linked to the function.

  • provider_branch (String) (defaults to: nil)

    Production branch for the repo linked to the function.

  • []

    provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.

  • provider_root_directory (String) (defaults to: nil)

    Path to function code in the linked repo.

  • template_repository (String) (defaults to: nil)

    Repository name of the template.

  • template_owner (String) (defaults to: nil)

    The name of the owner of the template.

  • template_root_directory (String) (defaults to: nil)

    Path to function code in the template repo.

  • template_branch (String) (defaults to: nil)

    Production branch for the repo linked to the function template.

Returns:

  • (Function)


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/appwrite/services/functions.rb', line 66

def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, template_repository: nil, template_owner: nil, template_root_directory: nil, template_branch: nil)
    api_path = '/functions'

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    if runtime.nil?
      raise Appwrite::Exception.new('Missing required parameter: "runtime"')
    end

    api_params = {
        functionId: function_id,
        name: name,
        runtime: runtime,
        execute: execute,
        events: events,
        schedule: schedule,
        timeout: timeout,
        enabled: enabled,
        logging: logging,
        entrypoint: entrypoint,
        commands: commands,
        installationId: installation_id,
        providerRepositoryId: provider_repository_id,
        providerBranch: provider_branch,
        providerSilentMode: provider_silent_mode,
        providerRootDirectory: provider_root_directory,
        templateRepository: template_repository,
        templateOwner: template_owner,
        templateRootDirectory: template_root_directory,
        templateBranch: template_branch,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Function
    )
end

#create_build(function_id:, deployment_id:, build_id:) ⇒ Object

Create a new build for an Appwrite Function deployment. This endpoint can be used to retry a failed build.

Parameters:

  • function_id (String)

    Function ID.

  • deployment_id (String)

    Deployment ID.

  • build_id (String)

    Build unique ID.

Returns:



477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/appwrite/services/functions.rb', line 477

def create_build(function_id:, deployment_id:, build_id:)
    api_path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'
        .gsub('{functionId}', function_id)
        .gsub('{deploymentId}', deployment_id)
        .gsub('{buildId}', build_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    if build_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "buildId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )
end

#create_deployment(function_id:, code:, activate:, entrypoint: nil, commands: nil, on_progress: nil) ⇒ 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](appwrite.io/docs/functions).

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

Parameters:

  • function_id (String)

    Function ID.

  • code (file)

    Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.

  • []

    activate Automatically activate the deployment when it is finished building.

  • entrypoint (String) (defaults to: nil)

    Entrypoint File.

  • commands (String) (defaults to: nil)

    Build Commands.

Returns:

  • (Deployment)


318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/appwrite/services/functions.rb', line 318

def create_deployment(function_id:, code:, activate:, entrypoint: nil, commands: nil, on_progress: nil)
    api_path = '/functions/{functionId}/deployments'
        .gsub('{functionId}', function_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if code.nil?
      raise Appwrite::Exception.new('Missing required parameter: "code"')
    end

    if activate.nil?
      raise Appwrite::Exception.new('Missing required parameter: "activate"')
    end

    api_params = {
        entrypoint: entrypoint,
        commands: commands,
        code: code,
        activate: activate,
    }
    
    api_headers = {
        "content-type": 'multipart/form-data',
    }

    id_param_name = nil
    param_name = 'code'

    @client.chunked_upload(
        path: api_path,
        headers: api_headers,
        params: api_params,
        param_name: param_name,
        id_param_name: id_param_name,
        on_progress: on_progress,
        response_type: Models::Deployment
    )
end

#create_execution(function_id:, body: nil, async: nil, xpath: nil, method: nil, headers: nil) ⇒ Execution

Trigger a function execution. The returned object will return you the current execution status. You can ping the ‘Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.

Parameters:

  • function_id (String)

    Function ID.

  • body (String) (defaults to: nil)

    HTTP body of execution. Default value is empty string.

  • []

    async Execute code in the background. Default value is false.

  • xpath (String) (defaults to: nil)

    HTTP path of execution. Path can include query params. Default value is /

  • method (ExecutionMethod) (defaults to: nil)

    HTTP method of execution. Default value is GET.

  • headers (Hash) (defaults to: nil)

    HTTP headers of execution. Defaults to empty.

Returns:

  • (Execution)


595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
# File 'lib/appwrite/services/functions.rb', line 595

def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: nil, headers: nil)
    api_path = '/functions/{functionId}/executions'
        .gsub('{functionId}', function_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    api_params = {
        body: body,
        async: async,
        path: xpath,
        method: method,
        headers: headers,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Execution
    )
end

#create_variable(function_id:, key:, value:) ⇒ Variable

Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables.

Parameters:

  • function_id (String)

    Function unique ID.

  • key (String)

    Variable key. Max length: 255 chars.

  • value (String)

    Variable value. Max length: 8192 chars.

Returns:

  • (Variable)


699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
# File 'lib/appwrite/services/functions.rb', line 699

def create_variable(function_id:, key:, value:)
    api_path = '/functions/{functionId}/variables'
        .gsub('{functionId}', function_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if key.nil?
      raise Appwrite::Exception.new('Missing required parameter: "key"')
    end

    if value.nil?
      raise Appwrite::Exception.new('Missing required parameter: "value"')
    end

    api_params = {
        key: key,
        value: value,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Variable
    )
end

#delete(function_id:) ⇒ Object

Delete a function by its unique ID.

Parameters:

  • function_id (String)

    Function ID.

Returns:



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/appwrite/services/functions.rb', line 241

def delete(function_id:)
    api_path = '/functions/{functionId}'
        .gsub('{functionId}', function_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )
end

#delete_deployment(function_id:, deployment_id:) ⇒ Object

Delete a code deployment by its unique ID.

Parameters:

  • function_id (String)

    Function ID.

  • deployment_id (String)

    Deployment ID.

Returns:



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/appwrite/services/functions.rb', line 440

def delete_deployment(function_id:, deployment_id:)
    api_path = '/functions/{functionId}/deployments/{deploymentId}'
        .gsub('{functionId}', function_id)
        .gsub('{deploymentId}', deployment_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )
end

#delete_variable(function_id:, variable_id:) ⇒ Object

Delete a variable by its unique ID.

Parameters:

  • function_id (String)

    Function unique ID.

  • variable_id (String)

    Variable unique ID.

Returns:



820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
# File 'lib/appwrite/services/functions.rb', line 820

def delete_variable(function_id:, variable_id:)
    api_path = '/functions/{functionId}/variables/{variableId}'
        .gsub('{functionId}', function_id)
        .gsub('{variableId}', variable_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )
end

#download_deployment(function_id:, deployment_id:) ⇒ Object

Get a Deployment’s contents by its unique ID. This endpoint supports range requests for partial or streaming file download.

Parameters:

  • function_id (String)

    Function ID.

  • deployment_id (String)

    Deployment ID.

Returns:



518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/appwrite/services/functions.rb', line 518

def download_deployment(function_id:, deployment_id:)
    api_path = '/functions/{functionId}/deployments/{deploymentId}/download'
        .gsub('{functionId}', function_id)
        .gsub('{deploymentId}', deployment_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )
end

#get(function_id:) ⇒ Function

Get a function by its unique ID.

Parameters:

  • function_id (String)

    Function ID.

Returns:

  • (Function)


147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/appwrite/services/functions.rb', line 147

def get(function_id:)
    api_path = '/functions/{functionId}'
        .gsub('{functionId}', function_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Function
    )
end

#get_deployment(function_id:, deployment_id:) ⇒ Deployment

Get a code deployment by its unique ID.

Parameters:

  • function_id (String)

    Function ID.

  • deployment_id (String)

    Deployment ID.

Returns:

  • (Deployment)


366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/appwrite/services/functions.rb', line 366

def get_deployment(function_id:, deployment_id:)
    api_path = '/functions/{functionId}/deployments/{deploymentId}'
        .gsub('{functionId}', function_id)
        .gsub('{deploymentId}', deployment_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Deployment
    )
end

#get_execution(function_id:, execution_id:) ⇒ Execution

Get a function execution log by its unique ID.

Parameters:

  • function_id (String)

    Function ID.

  • execution_id (String)

    Execution ID.

Returns:

  • (Execution)


631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
# File 'lib/appwrite/services/functions.rb', line 631

def get_execution(function_id:, execution_id:)
    api_path = '/functions/{functionId}/executions/{executionId}'
        .gsub('{functionId}', function_id)
        .gsub('{executionId}', execution_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if execution_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "executionId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Execution
    )
end

#get_variable(function_id:, variable_id:) ⇒ Variable

Get a variable by its unique ID.

Parameters:

  • function_id (String)

    Function unique ID.

  • variable_id (String)

    Variable unique ID.

Returns:

  • (Variable)


740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
# File 'lib/appwrite/services/functions.rb', line 740

def get_variable(function_id:, variable_id:)
    api_path = '/functions/{functionId}/variables/{variableId}'
        .gsub('{functionId}', function_id)
        .gsub('{variableId}', variable_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Variable
    )
end

#list(queries: nil, search: nil) ⇒ FunctionList

Get a list of all the project’s functions. You can use the query params to filter your results.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deployment, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId

  • search (String) (defaults to: nil)

    Search term to filter your list results. Max length: 256 chars.

Returns:

  • (FunctionList)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/appwrite/services/functions.rb', line 17

def list(queries: nil, search: nil)
    api_path = '/functions'

    api_params = {
        queries: queries,
        search: search,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::FunctionList
    )
end

#list_deployments(function_id:, queries: nil, search: nil) ⇒ DeploymentList

Get a list of all the project’s code deployments. You can use the query params to filter your results.

Parameters:

  • function_id (String)

    Function ID.

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: size, buildId, activate, entrypoint, commands

  • search (String) (defaults to: nil)

    Search term to filter your list results. Max length: 256 chars.

Returns:

  • (DeploymentList)


273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/appwrite/services/functions.rb', line 273

def list_deployments(function_id:, queries: nil, search: nil)
    api_path = '/functions/{functionId}/deployments'
        .gsub('{functionId}', function_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    api_params = {
        queries: queries,
        search: search,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::DeploymentList
    )
end

#list_executions(function_id:, queries: nil, search: nil) ⇒ ExecutionList

Get a list of all the current user function execution logs. You can use the query params to filter your results.

Parameters:

  • function_id (String)

    Function ID.

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration

  • search (String) (defaults to: nil)

    Search term to filter your list results. Max length: 256 chars.

Returns:

  • (ExecutionList)


555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
# File 'lib/appwrite/services/functions.rb', line 555

def list_executions(function_id:, queries: nil, search: nil)
    api_path = '/functions/{functionId}/executions'
        .gsub('{functionId}', function_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    api_params = {
        queries: queries,
        search: search,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::ExecutionList
    )
end

#list_runtimesRuntimeList

Get a list of all runtimes that are currently active on your instance.

Returns:

  • (RuntimeList)


122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/appwrite/services/functions.rb', line 122

def list_runtimes()
    api_path = '/functions/runtimes'

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::RuntimeList
    )
end

#list_variables(function_id:) ⇒ VariableList

Get a list of all variables of a specific function.

Parameters:

  • function_id (String)

    Function unique ID.

Returns:

  • (VariableList)


666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/appwrite/services/functions.rb', line 666

def list_variables(function_id:)
    api_path = '/functions/{functionId}/variables'
        .gsub('{functionId}', function_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::VariableList
    )
end

#update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil) ⇒ Function

Update function by its unique ID.

Parameters:

  • function_id (String)

    Function ID.

  • name (String)

    Function name. Max length: 128 chars.

  • runtime (Runtime) (defaults to: nil)

    Execution runtime.

  • execute (Array) (defaults to: nil)

    An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.

  • events (Array) (defaults to: nil)

    Events list. Maximum of 100 events are allowed.

  • schedule (String) (defaults to: nil)

    Schedule CRON syntax.

  • timeout (Integer) (defaults to: nil)

    Maximum execution time in seconds.

  • []

    enabled Is function enabled? When set to ‘disabled’, users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.

  • []

    logging Whether executions will be logged. When set to false, executions will not be logged, but will reduce resource used by your Appwrite project.

  • entrypoint (String) (defaults to: nil)

    Entrypoint File. This path is relative to the “providerRootDirectory”.

  • commands (String) (defaults to: nil)

    Build Commands.

  • installation_id (String) (defaults to: nil)

    Appwrite Installation ID for VCS (Version Controle System) deployment.

  • provider_repository_id (String) (defaults to: nil)

    Repository ID of the repo linked to the function

  • provider_branch (String) (defaults to: nil)

    Production branch for the repo linked to the function

  • []

    provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.

  • provider_root_directory (String) (defaults to: nil)

    Path to function code in the linked repo.

Returns:

  • (Function)


192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/appwrite/services/functions.rb', line 192

def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil)
    api_path = '/functions/{functionId}'
        .gsub('{functionId}', function_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    api_params = {
        name: name,
        runtime: runtime,
        execute: execute,
        events: events,
        schedule: schedule,
        timeout: timeout,
        enabled: enabled,
        logging: logging,
        entrypoint: entrypoint,
        commands: commands,
        installationId: installation_id,
        providerRepositoryId: provider_repository_id,
        providerBranch: provider_branch,
        providerSilentMode: provider_silent_mode,
        providerRootDirectory: provider_root_directory,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Function
    )
end

#update_deployment(function_id:, deployment_id:) ⇒ Function

Update the function code deployment ID using the unique function ID. Use this endpoint to switch the code deployment that should be executed by the execution endpoint.

Parameters:

  • function_id (String)

    Function ID.

  • deployment_id (String)

    Deployment ID.

Returns:

  • (Function)


404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/appwrite/services/functions.rb', line 404

def update_deployment(function_id:, deployment_id:)
    api_path = '/functions/{functionId}/deployments/{deploymentId}'
        .gsub('{functionId}', function_id)
        .gsub('{deploymentId}', deployment_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if deployment_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "deploymentId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Function
    )
end

#update_variable(function_id:, variable_id:, key:, value: nil) ⇒ Variable

Update variable by its unique ID.

Parameters:

  • function_id (String)

    Function unique ID.

  • variable_id (String)

    Variable unique ID.

  • key (String)

    Variable key. Max length: 255 chars.

  • value (String) (defaults to: nil)

    Variable value. Max length: 8192 chars.

Returns:

  • (Variable)


778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# File 'lib/appwrite/services/functions.rb', line 778

def update_variable(function_id:, variable_id:, key:, value: nil)
    api_path = '/functions/{functionId}/variables/{variableId}'
        .gsub('{functionId}', function_id)
        .gsub('{variableId}', variable_id)

    if function_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "functionId"')
    end

    if variable_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "variableId"')
    end

    if key.nil?
      raise Appwrite::Exception.new('Missing required parameter: "key"')
    end

    api_params = {
        key: key,
        value: value,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Variable
    )
end