Updated SDKs
This commit is contained in:
parent
434f3721fe
commit
839428ce9c
|
@ -22,11 +22,11 @@ $utopia->post('/v1/functions')
|
|||
->label('sdk.method', 'create')
|
||||
->label('sdk.description', '/docs/references/functions/create-function.md')
|
||||
->param('name', '', function () { return new Text(128); }, 'Function name.')
|
||||
->param('vars', '', function () { return new Assoc();}, 'Key-value JSON object.')
|
||||
->param('trigger', '', function () { return new WhiteList(['event', 'scheudle']); }, 'Function trigger type.')
|
||||
->param('events', null, function () { return new ArrayList(new Text(256)); }, 'Events list.')
|
||||
->param('schedule', null, function () { return new Cron(); }, 'Schedule CRON syntax.')
|
||||
->param('timeout', '', function () { return new Range(1, 10); }, 'Function maximum execution time in seconds.')
|
||||
->param('vars', [], function () { return new Assoc();}, 'Key-value JSON object.', true)
|
||||
->param('trigger', 'event', function () { return new WhiteList(['event', 'scheudle']); }, 'Function trigger type.', true)
|
||||
->param('events', [], function () { return new ArrayList(new Text(256)); }, 'Events list.', true)
|
||||
->param('schedule', '', function () { return new Cron(); }, 'Schedule CRON syntax.', true)
|
||||
->param('timeout', 10, function () { return new Range(1, 10); }, 'Function maximum execution time in seconds.', true)
|
||||
->action(
|
||||
function ($name, $vars, $trigger, $events, $schedule, $timeout) use ($response, $projectDB) {
|
||||
$function = $projectDB->createDocument([
|
||||
|
@ -115,11 +115,11 @@ $utopia->put('/v1/functions/:functionId')
|
|||
->label('sdk.description', '/docs/references/functions/update-function.md')
|
||||
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
|
||||
->param('name', '', function () { return new Text(128); }, 'Function name.')
|
||||
->param('vars', '', function () { return new Assoc(); }, 'Key-value JSON object.')
|
||||
->param('trigger', '', function () { return new WhiteList(['event', 'scheudle']); }, 'Function trigger type.')
|
||||
->param('events', null, function () { return new ArrayList(new Text(256)); }, 'Events list.')
|
||||
->param('schedule', null, function () { return new Cron(); }, 'Schedule CRON syntax.')
|
||||
->param('timeout', '', function () { return new Range(1, 10); }, 'Function maximum execution time in seconds.')
|
||||
->param('vars', [], function () { return new Assoc();}, 'Key-value JSON object.', true)
|
||||
->param('trigger', 'event', function () { return new WhiteList(['event', 'scheudle']); }, 'Function trigger type.', true)
|
||||
->param('events', [], function () { return new ArrayList(new Text(256)); }, 'Events list.', true)
|
||||
->param('schedule', '', function () { return new Cron(); }, 'Schedule CRON syntax.', true)
|
||||
->param('timeout', 10, function () { return new Range(1, 10); }, 'Function maximum execution time in seconds.', true)
|
||||
->action(
|
||||
function ($functionId, $name, $vars, $trigger, $events, $schedule, $timeout) use ($response, $projectDB) {
|
||||
$function = $projectDB->getDocument($functionId);
|
||||
|
@ -151,7 +151,7 @@ $utopia->patch('/v1/functions/:functionId/active')
|
|||
->label('scope', 'functions.write')
|
||||
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'updateActive')
|
||||
->label('sdk.method', 'updateTag')
|
||||
->label('sdk.description', '/docs/references/functions/update-tag.md')
|
||||
->param('functionId', '', function () { return new UID(); }, 'Function unique ID.')
|
||||
->param('active', '', function () { return new UID(); }, 'Active tag unique ID.')
|
||||
|
|
|
@ -5,7 +5,7 @@ sdk
|
|||
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||
;
|
||||
|
||||
let promise = sdk.functions.create('[NAME]', {}, 'event', [], '', 1);
|
||||
let promise = sdk.functions.create('[NAME]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response); // Success
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
let sdk = new Appwrite();
|
||||
|
||||
sdk
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||
;
|
||||
|
||||
let promise = sdk.functions.updateTag('[FUNCTION_ID]', '[ACTIVE]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response); // Success
|
||||
}, function (error) {
|
||||
console.log(error); // Failure
|
||||
});
|
|
@ -5,7 +5,7 @@ sdk
|
|||
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||
;
|
||||
|
||||
let promise = sdk.functions.update('[FUNCTION_ID]', '[NAME]', {}, 'event', [], '', 1);
|
||||
let promise = sdk.functions.update('[FUNCTION_ID]', '[NAME]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response); // Success
|
||||
|
|
|
@ -1659,31 +1659,11 @@
|
|||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
create: function(name, vars, trigger, events, schedule, timeout) {
|
||||
create: function(name, vars = [], trigger = 'event', events = [], schedule = '', timeout = 10) {
|
||||
if(name === undefined) {
|
||||
throw new Error('Missing required parameter: "name"');
|
||||
}
|
||||
|
||||
if(vars === undefined) {
|
||||
throw new Error('Missing required parameter: "vars"');
|
||||
}
|
||||
|
||||
if(trigger === undefined) {
|
||||
throw new Error('Missing required parameter: "trigger"');
|
||||
}
|
||||
|
||||
if(events === undefined) {
|
||||
throw new Error('Missing required parameter: "events"');
|
||||
}
|
||||
|
||||
if(schedule === undefined) {
|
||||
throw new Error('Missing required parameter: "schedule"');
|
||||
}
|
||||
|
||||
if(timeout === undefined) {
|
||||
throw new Error('Missing required parameter: "timeout"');
|
||||
}
|
||||
|
||||
let path = '/functions';
|
||||
|
||||
let payload = {};
|
||||
|
@ -1755,7 +1735,7 @@
|
|||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
update: function(functionId, name, vars, trigger, events, schedule, timeout) {
|
||||
update: function(functionId, name, vars = [], trigger = 'event', events = [], schedule = '', timeout = 10) {
|
||||
if(functionId === undefined) {
|
||||
throw new Error('Missing required parameter: "functionId"');
|
||||
}
|
||||
|
@ -1764,26 +1744,6 @@
|
|||
throw new Error('Missing required parameter: "name"');
|
||||
}
|
||||
|
||||
if(vars === undefined) {
|
||||
throw new Error('Missing required parameter: "vars"');
|
||||
}
|
||||
|
||||
if(trigger === undefined) {
|
||||
throw new Error('Missing required parameter: "trigger"');
|
||||
}
|
||||
|
||||
if(events === undefined) {
|
||||
throw new Error('Missing required parameter: "events"');
|
||||
}
|
||||
|
||||
if(schedule === undefined) {
|
||||
throw new Error('Missing required parameter: "schedule"');
|
||||
}
|
||||
|
||||
if(timeout === undefined) {
|
||||
throw new Error('Missing required parameter: "timeout"');
|
||||
}
|
||||
|
||||
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||
|
||||
let payload = {};
|
||||
|
@ -1850,7 +1810,7 @@
|
|||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
updateActive: function(functionId, active) {
|
||||
updateTag: function(functionId, active) {
|
||||
if(functionId === undefined) {
|
||||
throw new Error('Missing required parameter: "functionId"');
|
||||
}
|
||||
|
|
16
app/sdks/console-javascript/src/sdk.min.js
vendored
16
app/sdks/console-javascript/src/sdk.min.js
vendored
|
@ -137,12 +137,7 @@ let path='/database/collections/{collectionId}/logs'.replace(new RegExp('{collec
|
|||
if(limit){payload.limit=limit}
|
||||
if(offset){payload.offset=offset}
|
||||
if(orderType){payload.orderType=orderType}
|
||||
return http.get(path,{'content-type':'application/json',},payload)},create:function(name,vars,trigger,events,schedule,timeout){if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
if(vars===undefined){throw new Error('Missing required parameter: "vars"')}
|
||||
if(trigger===undefined){throw new Error('Missing required parameter: "trigger"')}
|
||||
if(events===undefined){throw new Error('Missing required parameter: "events"')}
|
||||
if(schedule===undefined){throw new Error('Missing required parameter: "schedule"')}
|
||||
if(timeout===undefined){throw new Error('Missing required parameter: "timeout"')}
|
||||
return http.get(path,{'content-type':'application/json',},payload)},create:function(name,vars=[],trigger='event',events=[],schedule='',timeout=10){if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
let path='/functions';let payload={};if(name){payload.name=name}
|
||||
if(vars){payload.vars=vars}
|
||||
if(trigger){payload.trigger=trigger}
|
||||
|
@ -150,13 +145,8 @@ if(events){payload.events=events}
|
|||
if(schedule){payload.schedule=schedule}
|
||||
if(timeout){payload.timeout=timeout}
|
||||
return http.post(path,{'content-type':'application/json',},payload)},get:function(functionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||
let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},update:function(functionId,name,vars,trigger,events,schedule,timeout){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||
let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},update:function(functionId,name,vars=[],trigger='event',events=[],schedule='',timeout=10){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||
if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||
if(vars===undefined){throw new Error('Missing required parameter: "vars"')}
|
||||
if(trigger===undefined){throw new Error('Missing required parameter: "trigger"')}
|
||||
if(events===undefined){throw new Error('Missing required parameter: "events"')}
|
||||
if(schedule===undefined){throw new Error('Missing required parameter: "schedule"')}
|
||||
if(timeout===undefined){throw new Error('Missing required parameter: "timeout"')}
|
||||
let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(name){payload.name=name}
|
||||
if(vars){payload.vars=vars}
|
||||
if(trigger){payload.trigger=trigger}
|
||||
|
@ -164,7 +154,7 @@ if(events){payload.events=events}
|
|||
if(schedule){payload.schedule=schedule}
|
||||
if(timeout){payload.timeout=timeout}
|
||||
return http.put(path,{'content-type':'application/json',},payload)},delete:function(functionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||
let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateActive:function(functionId,active){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||
let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateTag:function(functionId,active){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||
if(active===undefined){throw new Error('Missing required parameter: "active"')}
|
||||
let path='/functions/{functionId}/active'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(active){payload.active=active}
|
||||
return http.patch(path,{'content-type':'application/json',},payload)},listExecutions:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||
|
|
2
app/sdks/console-javascript/types/index.d.ts
vendored
2
app/sdks/console-javascript/types/index.d.ts
vendored
|
@ -665,7 +665,7 @@ declare namespace Appwrite {
|
|||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
updateActive(functionId: string, active: string): Promise<object>;
|
||||
updateTag(functionId: string, active: string): Promise<object>;
|
||||
|
||||
/**
|
||||
* List Executions
|
||||
|
|
1
app/sdks/git/java
Submodule
1
app/sdks/git/java
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit d3fe8a096c74cdfe90b44ad26cf70aebaa17a0b7
|
25
app/sdks/server-go/docs/examples/functions/update-tag.md
Normal file
25
app/sdks/server-go/docs/examples/functions/update-tag.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/appwrite/sdk-for-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var client := appwrite.Client{}
|
||||
|
||||
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||
|
||||
var service := appwrite.Functions{
|
||||
client: &client
|
||||
}
|
||||
|
||||
var response, error := service.UpdateTag("[FUNCTION_ID]", "[ACTIVE]")
|
||||
|
||||
if error != nil {
|
||||
panic(error)
|
||||
}
|
||||
|
||||
fmt.Println(response)
|
||||
}
|
|
@ -86,8 +86,8 @@ func (srv *Functions) Delete(FunctionId string) (map[string]interface{}, error)
|
|||
return srv.client.Call("DELETE", path, nil, params)
|
||||
}
|
||||
|
||||
// UpdateActive
|
||||
func (srv *Functions) UpdateActive(FunctionId string, Active string) (map[string]interface{}, error) {
|
||||
// UpdateTag
|
||||
func (srv *Functions) UpdateTag(FunctionId string, Active string) (map[string]interface{}, error) {
|
||||
r := strings.NewReplacer("{functionId}", FunctionId)
|
||||
path := r.Replace("/functions/{functionId}/active")
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ public class Functions extends Service {
|
|||
}
|
||||
|
||||
/// Update Function Active Tag
|
||||
public Call updateActive(String functionId, String active) {
|
||||
public Call updateTag(String functionId, String active) {
|
||||
final String path = "/functions/{functionId}/active".replace("{functionId}", functionId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
|
|
|
@ -10,7 +10,7 @@ client
|
|||
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||
;
|
||||
|
||||
let promise = functions.create('[NAME]', {}, 'event', [], '', 1);
|
||||
let promise = functions.create('[NAME]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
19
app/sdks/server-nodejs/docs/examples/functions/update-tag.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/update-tag.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
const sdk = require('node-appwrite');
|
||||
|
||||
// Init SDK
|
||||
let client = new sdk.Client();
|
||||
|
||||
let functions = new sdk.Functions(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||
;
|
||||
|
||||
let promise = functions.updateTag('[FUNCTION_ID]', '[ACTIVE]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
}, function (error) {
|
||||
console.log(error);
|
||||
});
|
|
@ -10,7 +10,7 @@ client
|
|||
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||
;
|
||||
|
||||
let promise = functions.update('[FUNCTION_ID]', '[NAME]', {}, 'event', [], '', 1);
|
||||
let promise = functions.update('[FUNCTION_ID]', '[NAME]');
|
||||
|
||||
promise.then(function (response) {
|
||||
console.log(response);
|
||||
|
|
|
@ -38,7 +38,7 @@ class Functions extends Service {
|
|||
* @throws Exception
|
||||
* @return {}
|
||||
*/
|
||||
async create(name, vars, trigger, events, schedule, timeout) {
|
||||
async create(name, vars = [], trigger = 'event', events = [], schedule = '', timeout = 10) {
|
||||
let path = '/functions';
|
||||
|
||||
return await this.client.call('post', path, {
|
||||
|
@ -84,7 +84,7 @@ class Functions extends Service {
|
|||
* @throws Exception
|
||||
* @return {}
|
||||
*/
|
||||
async update(functionId, name, vars, trigger, events, schedule, timeout) {
|
||||
async update(functionId, name, vars = [], trigger = 'event', events = [], schedule = '', timeout = 10) {
|
||||
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||
|
||||
return await this.client.call('put', path, {
|
||||
|
@ -125,7 +125,7 @@ class Functions extends Service {
|
|||
* @throws Exception
|
||||
* @return {}
|
||||
*/
|
||||
async updateActive(functionId, active) {
|
||||
async updateTag(functionId, active) {
|
||||
let path = '/functions/{functionId}/active'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||
|
||||
return await this.client.call('patch', path, {
|
||||
|
|
|
@ -12,4 +12,4 @@ $client
|
|||
|
||||
$functions = new Functions($client);
|
||||
|
||||
$result = $functions->create('[NAME]', [], 'event', [], '', 1);
|
||||
$result = $functions->create('[NAME]');
|
15
app/sdks/server-php/docs/examples/functions/update-tag.md
Normal file
15
app/sdks/server-php/docs/examples/functions/update-tag.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
use Appwrite\Client;
|
||||
use Appwrite\Services\Functions;
|
||||
|
||||
$client = new Client();
|
||||
|
||||
$client
|
||||
->setProject('5df5acd0d48c2') // Your project ID
|
||||
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||
;
|
||||
|
||||
$functions = new Functions($client);
|
||||
|
||||
$result = $functions->updateTag('[FUNCTION_ID]', '[ACTIVE]');
|
|
@ -12,4 +12,4 @@ $client
|
|||
|
||||
$functions = new Functions($client);
|
||||
|
||||
$result = $functions->update('[FUNCTION_ID]', '[NAME]', [], 'event', [], '', 1);
|
||||
$result = $functions->update('[FUNCTION_ID]', '[NAME]');
|
|
@ -26,11 +26,11 @@ POST https://appwrite.io/v1/functions
|
|||
| Field Name | Type | Description | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| name | string | Function name. | |
|
||||
| vars | object | Key-value JSON object. | |
|
||||
| trigger | string | Function trigger type. | |
|
||||
| events | array | Events list. | |
|
||||
| vars | object | Key-value JSON object. | [] |
|
||||
| trigger | string | Function trigger type. | event |
|
||||
| events | array | Events list. | [] |
|
||||
| schedule | string | Schedule CRON syntax. | |
|
||||
| timeout | integer | Function maximum execution time in seconds. | |
|
||||
| timeout | integer | Function maximum execution time in seconds. | 10 |
|
||||
|
||||
## Get Function
|
||||
|
||||
|
@ -56,11 +56,11 @@ PUT https://appwrite.io/v1/functions/{functionId}
|
|||
| --- | --- | --- | --- |
|
||||
| functionId | string | **Required** Function unique ID. | |
|
||||
| name | string | Function name. | |
|
||||
| vars | object | Key-value JSON object. | |
|
||||
| trigger | string | Function trigger type. | |
|
||||
| events | array | Events list. | |
|
||||
| vars | object | Key-value JSON object. | [] |
|
||||
| trigger | string | Function trigger type. | event |
|
||||
| events | array | Events list. | [] |
|
||||
| schedule | string | Schedule CRON syntax. | |
|
||||
| timeout | integer | Function maximum execution time in seconds. | |
|
||||
| timeout | integer | Function maximum execution time in seconds. | 10 |
|
||||
|
||||
## Delete Function
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class Functions extends Service
|
|||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function create(string $name, array $vars, string $trigger, array $events, string $schedule, int $timeout):array
|
||||
public function create(string $name, array $vars = , string $trigger = 'event', array $events = [], string $schedule = '', int $timeout = 10):array
|
||||
{
|
||||
$path = str_replace([], [], '/functions');
|
||||
$params = [];
|
||||
|
@ -93,7 +93,7 @@ class Functions extends Service
|
|||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function update(string $functionId, string $name, array $vars, string $trigger, array $events, string $schedule, int $timeout):array
|
||||
public function update(string $functionId, string $name, array $vars = , string $trigger = 'event', array $events = [], string $schedule = '', int $timeout = 10):array
|
||||
{
|
||||
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}');
|
||||
$params = [];
|
||||
|
@ -136,7 +136,7 @@ class Functions extends Service
|
|||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function updateActive(string $functionId, string $active):array
|
||||
public function updateTag(string $functionId, string $active):array
|
||||
{
|
||||
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/active');
|
||||
$params = [];
|
||||
|
|
|
@ -20,7 +20,7 @@ class Functions(Service):
|
|||
'content-type': 'application/json',
|
||||
}, params)
|
||||
|
||||
def create(self, name, vars, trigger, events, schedule, timeout):
|
||||
def create(self, name, vars=[], trigger='event', events=[], schedule='', timeout=10):
|
||||
"""Create Function"""
|
||||
|
||||
params = {}
|
||||
|
@ -47,7 +47,7 @@ class Functions(Service):
|
|||
'content-type': 'application/json',
|
||||
}, params)
|
||||
|
||||
def update(self, function_id, name, vars, trigger, events, schedule, timeout):
|
||||
def update(self, function_id, name, vars=[], trigger='event', events=[], schedule='', timeout=10):
|
||||
"""Update Function"""
|
||||
|
||||
params = {}
|
||||
|
@ -75,7 +75,7 @@ class Functions(Service):
|
|||
'content-type': 'application/json',
|
||||
}, params)
|
||||
|
||||
def update_active(self, function_id, active):
|
||||
def update_tag(self, function_id, active):
|
||||
"""Update Function Active Tag"""
|
||||
|
||||
params = {}
|
||||
|
|
|
@ -10,4 +10,4 @@ client = Client()
|
|||
|
||||
functions = Functions(client)
|
||||
|
||||
result = functions.create('[NAME]', {}, 'event', {}, '', 1)
|
||||
result = functions.create('[NAME]')
|
||||
|
|
13
app/sdks/server-python/docs/examples/functions/update-tag.md
Normal file
13
app/sdks/server-python/docs/examples/functions/update-tag.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
from appwrite.client import Client
|
||||
from appwrite.services.functions import Functions
|
||||
|
||||
client = Client()
|
||||
|
||||
(client
|
||||
.set_project('5df5acd0d48c2') # Your project ID
|
||||
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||
)
|
||||
|
||||
functions = Functions(client)
|
||||
|
||||
result = functions.update_tag('[FUNCTION_ID]', '[ACTIVE]')
|
|
@ -10,4 +10,4 @@ client = Client()
|
|||
|
||||
functions = Functions(client)
|
||||
|
||||
result = functions.update('[FUNCTION_ID]', '[NAME]', {}, 'event', {}, '', 1)
|
||||
result = functions.update('[FUNCTION_ID]', '[NAME]')
|
||||
|
|
|
@ -16,7 +16,7 @@ module Appwrite
|
|||
}, params);
|
||||
end
|
||||
|
||||
def create(name:, vars:, trigger:, events:, schedule:, timeout:)
|
||||
def create(name:, vars: [], trigger: 'event', events: [], schedule: '', timeout: 10)
|
||||
path = '/functions'
|
||||
|
||||
params = {
|
||||
|
@ -45,7 +45,7 @@ module Appwrite
|
|||
}, params);
|
||||
end
|
||||
|
||||
def update(function_id:, name:, vars:, trigger:, events:, schedule:, timeout:)
|
||||
def update(function_id:, name:, vars: [], trigger: 'event', events: [], schedule: '', timeout: 10)
|
||||
path = '/functions/{functionId}'
|
||||
.gsub('{function_id}', function_id)
|
||||
|
||||
|
@ -75,7 +75,7 @@ module Appwrite
|
|||
}, params);
|
||||
end
|
||||
|
||||
def update_active(function_id:, active:)
|
||||
def update_tag(function_id:, active:)
|
||||
path = '/functions/{functionId}/active'
|
||||
.gsub('{function_id}', function_id)
|
||||
|
||||
|
|
|
@ -11,10 +11,176 @@
|
|||
<ul class="phases clear" data-ui-phases data-selected="{{router.params.tab}}">
|
||||
<li data-state="/console/functions?project={{router.params.project}}">
|
||||
<h2>Functions</h2>
|
||||
|
||||
<div class="zone xl"
|
||||
data-service="functions.list"
|
||||
data-scope="sdk"
|
||||
data-event="load,functions.create,functions.update,functions.delete"
|
||||
data-name="project-functions"
|
||||
data-param-project-id="{{router.params.project}}"
|
||||
data-success="trigger"
|
||||
data-success-param-trigger-events="functions.list">
|
||||
|
||||
<div data-ls-if="0 == {{project-functions.functions.length}} || undefined == {{project-functions.functions.length}}" class="box margin-top margin-bottom">
|
||||
<h3 class="margin-bottom-small text-bold">No Functions Found</h3>
|
||||
|
||||
<p class="margin-bottom-no">You haven't created any functions for your project yet.</p>
|
||||
</div>
|
||||
|
||||
<div class="box margin-bottom" data-ls-if="0 != {{project-functions.functions.length}}">
|
||||
<ul data-ls-loop="project-functions" data-ls-as="function" class="list">
|
||||
<li class="clear">
|
||||
|
||||
<div data-ui-modal class="modal close sticky-footer" data-button-text="Update" data-button-class="pull-end">
|
||||
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
||||
|
||||
<h1>Update Function</h1>
|
||||
|
||||
<form
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Update Project Function"
|
||||
data-service="projects.updateFunction"
|
||||
data-scope="console"
|
||||
data-event="submit"
|
||||
data-success="alert,trigger,reset"
|
||||
data-success-param-alert-text="Updated function successfully"
|
||||
data-success-param-trigger-events="projects.updateFunction"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to update function"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
|
||||
<input type="hidden" name="functionId" data-ls-bind="{{function.$id}}" />
|
||||
|
||||
<label data-ls-attrs="for=name-{{function.$id}}">Name</label>
|
||||
<input type="text" class="full-width" data-ls-attrs="id=name-{{function.$id}}" name="name" required autocomplete="off" data-ls-bind="{{function.name}}" />
|
||||
|
||||
<label data-ls-attrs="for=events-{{function.$id}}">Events</label>
|
||||
<div class="row responsive thin">
|
||||
<?php foreach ($events as $i => $event) : ?>
|
||||
<div class="col span-6 text-one-liner margin-bottom text-height-large">
|
||||
<input type="checkbox" name="events" data-ls-bind="{{function.events}}" value="<?php echo $event; ?>" /> <?php echo $event; ?>
|
||||
</div>
|
||||
<?php if (($i + 1) % 2 === 0) : ?>
|
||||
</div>
|
||||
<div class="row responsive thin">
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<label data-ls-attrs="for=url-{{function.$id}}">POST URL</label>
|
||||
<input type="url" class="full-width" data-ls-attrs="id=url-{{function.$id}}" name="url" required autocomplete="off" placeholder="https://example.com/callback" data-ls-bind="{{function.url}}" />
|
||||
|
||||
<div class="margin-bottom toggle" data-ls-ui-open>
|
||||
<i class="icon-plus pull-end margin-top-tiny"></i>
|
||||
<i class="icon-minus pull-end margin-top-tiny"></i>
|
||||
|
||||
<h3 class="margin-bottom">
|
||||
Advanced Options
|
||||
<small class="text-size-small">(optional)</small>
|
||||
</h3>
|
||||
|
||||
<label data-ls-attrs="for=security-{{task.$id}}" class="margin-bottom-small">
|
||||
<div class="margin-bottom-small text-bold">SSL / TLS (Certificate verification)</div>
|
||||
|
||||
<input name="security" type="radio" required data-ls-attrs="id=secure-yes-{{function.$id}}" data-ls-bind="{{function.security}}" value="1" /> <span>Enabled</span>
|
||||
<input name="security" type="radio" required data-ls-attrs="id=secure-no-{{function.$id}}" data-ls-bind="{{function.security}}" value="0" /> <span>Disabled</span>
|
||||
</label>
|
||||
|
||||
<p class="margin-bottom text-size-small text-fade"><span class="text-red">Warning</span>: Untrusted or self-signed certificates may not be secure.
|
||||
<a href="https://en.wikipedia.org/wiki/Self-signed_certificate" target="_blank" rel="noopener">Learn more<i class="icon-link-ext"></i></a>
|
||||
</p>
|
||||
|
||||
<label class="text-bold">HTTP Authentication <span class="tooltip" data-tooltip="Use to secure your endpoint from untrusted sources"><i class="icon-question"></i></span> <small>(optional)</small></label>
|
||||
|
||||
<div class="row responsive thin">
|
||||
<div class="col span-6 margin-bottom">
|
||||
<label data-ls-attrs="for=httpUser-{{function.$id}}">User</label>
|
||||
<input type="text" class="full-width margin-bottom-no" data-ls-attrs="id=httpUser-{{function.$id}}" name="httpUser" autocomplete="off" data-ls-bind="{{function.httpUser}}" />
|
||||
</div>
|
||||
<div class="col span-6 margin-bottom">
|
||||
<label data-ls-attrs="for=httpPass-{{function.$id}}">Password</label>
|
||||
<input type="password" class="full-width margin-bottom-no" data-ls-attrs="id=httpPass-{{function.$id}}" name="httpPass" autocomplete="off" data-ls-bind="{{function.httpPass}}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<button type="submit">Save</button> <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
|
||||
</footer>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<form class="pull-end margin-end"
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Delete Project Function"
|
||||
data-service="projects.deleteFunction"
|
||||
data-scope="console"
|
||||
data-event="submit"
|
||||
data-confirm="Are you sure you want to delete this function?"
|
||||
data-success="alert,trigger"
|
||||
data-success-param-alert-text="Deleted function successfully"
|
||||
data-success-param-trigger-events="projects.deleteFunction"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to delete function"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
|
||||
<input type="hidden" name="functionId" data-ls-bind="{{function.$id}}" />
|
||||
|
||||
<button class="danger reverse">Delete</button>
|
||||
</form>
|
||||
|
||||
<span data-ls-bind="{{function.name}}"></span> (<span data-ls-bind="{{function.events.length}}"></span> events)
|
||||
<span data-ls-if="0 == {{function.security}}">
|
||||
<small class="text-danger">(SSL/TLS Disabled)</small>
|
||||
</span>
|
||||
<div class="margin-top-tiny">
|
||||
<a data-ls-attrs="href={{function.url}}" data-ls-bind="{{function.url}}" target="_blank" class="text-one-liner"></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="clear">
|
||||
<div data-ui-modal class="modal close box sticky-footer" data-button-text="Add Function">
|
||||
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
||||
|
||||
<h1>Add Function</h1>
|
||||
|
||||
<form
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Create Project Function"
|
||||
data-service="projects.create"
|
||||
data-scope="console"
|
||||
data-event="submit"
|
||||
data-success="alert,trigger,reset"
|
||||
data-success-param-alert-text="Created function successfully"
|
||||
data-success-param-trigger-events="projects.create"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to create function"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
|
||||
|
||||
<label for="name">Name</label>
|
||||
<input type="text" id="name" name="name" required autocomplete="off" class="margin-bottom-xl" />
|
||||
|
||||
<footer>
|
||||
<button type="submit">Create</button> <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
|
||||
</footer>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li data-state="/console/users/teams?project={{router.params.project}}">
|
||||
<!-- <li data-state="/console/users/teams?project={{router.params.project}}">
|
||||
<h2>Teams</h2>
|
||||
</li>
|
||||
</li> -->
|
||||
</ul>
|
||||
</div>
|
|
@ -1659,31 +1659,11 @@
|
|||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
create: function(name, vars, trigger, events, schedule, timeout) {
|
||||
create: function(name, vars = [], trigger = 'event', events = [], schedule = '', timeout = 10) {
|
||||
if(name === undefined) {
|
||||
throw new Error('Missing required parameter: "name"');
|
||||
}
|
||||
|
||||
if(vars === undefined) {
|
||||
throw new Error('Missing required parameter: "vars"');
|
||||
}
|
||||
|
||||
if(trigger === undefined) {
|
||||
throw new Error('Missing required parameter: "trigger"');
|
||||
}
|
||||
|
||||
if(events === undefined) {
|
||||
throw new Error('Missing required parameter: "events"');
|
||||
}
|
||||
|
||||
if(schedule === undefined) {
|
||||
throw new Error('Missing required parameter: "schedule"');
|
||||
}
|
||||
|
||||
if(timeout === undefined) {
|
||||
throw new Error('Missing required parameter: "timeout"');
|
||||
}
|
||||
|
||||
let path = '/functions';
|
||||
|
||||
let payload = {};
|
||||
|
@ -1755,7 +1735,7 @@
|
|||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
update: function(functionId, name, vars, trigger, events, schedule, timeout) {
|
||||
update: function(functionId, name, vars = [], trigger = 'event', events = [], schedule = '', timeout = 10) {
|
||||
if(functionId === undefined) {
|
||||
throw new Error('Missing required parameter: "functionId"');
|
||||
}
|
||||
|
@ -1764,26 +1744,6 @@
|
|||
throw new Error('Missing required parameter: "name"');
|
||||
}
|
||||
|
||||
if(vars === undefined) {
|
||||
throw new Error('Missing required parameter: "vars"');
|
||||
}
|
||||
|
||||
if(trigger === undefined) {
|
||||
throw new Error('Missing required parameter: "trigger"');
|
||||
}
|
||||
|
||||
if(events === undefined) {
|
||||
throw new Error('Missing required parameter: "events"');
|
||||
}
|
||||
|
||||
if(schedule === undefined) {
|
||||
throw new Error('Missing required parameter: "schedule"');
|
||||
}
|
||||
|
||||
if(timeout === undefined) {
|
||||
throw new Error('Missing required parameter: "timeout"');
|
||||
}
|
||||
|
||||
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||
|
||||
let payload = {};
|
||||
|
@ -1850,7 +1810,7 @@
|
|||
* @throws {Error}
|
||||
* @return {Promise}
|
||||
*/
|
||||
updateActive: function(functionId, active) {
|
||||
updateTag: function(functionId, active) {
|
||||
if(functionId === undefined) {
|
||||
throw new Error('Missing required parameter: "functionId"');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue