Method: Appwrite::Functions#update

Defined in:
lib/appwrite/services/functions.rb

#update(function_id:, name:, execute:, vars: nil, events: nil, schedule: nil, timeout: nil) ⇒ Function

Update function by its unique ID.

Parameters:

  • function_id (string)

    Function ID.

  • name (string)

    Function name. Max length: 128 chars.

  • execute (array)

    An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](appwrite.io/docs/permissions) and get a full list of available permissions. Maximum of 100 scopes are allowed, each 64 characters long.

  • vars (object) (defaults to: nil)

    Key-value JSON object that will be passed to the function as environment variables.

  • events (array) (defaults to: nil)

    Events list. Maximum of 100 events are allowed.

  • schedule (string) (defaults to: nil)

    Schedule CRON syntax.

  • timeout (number) (defaults to: nil)

    Maximum execution time in seconds.

Returns:

  • (Function)


162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/appwrite/services/functions.rb', line 162

def update(function_id:, name:, execute:, vars: nil, events: nil, schedule: nil, timeout: nil)
    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 execute.nil?
        raise Appwrite::Exception.new('Missing required parameter: "execute"')
    end

    path = '/functions/{functionId}'
        .gsub('{functionId}', function_id)

    params = {
        name: name,
        execute: execute,
        vars: vars,
        events: events,
        schedule: schedule,
        timeout: timeout,
    }

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

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