A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://appwrite.io/docs/references/cloud/server-nodejs/functions below:

Functions API Reference - Docs

The Functions service allows you to create custom behaviour that can be triggered by any supported Appwrite system events or by a predefined schedule.

Appwrite Cloud Functions lets you automatically run backend code in response to events triggered by Appwrite or by setting it to be executed in a predefined schedule. Your code is stored in a secure way on your Appwrite instance and is executed in an isolated environment.

You can learn more by following our Cloud Functions tutorial.

https://<REGION>.cloud.appwrite.io/v1
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.

const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.create(
    '<FUNCTION_ID>', 
    '<NAME>', 
    sdk..Node145, 
    ["any"], 
    [], 
    '', 
    1, 
    false, 
    false, 
    '<ENTRYPOINT>', 
    '<COMMANDS>', 
    [], 
    '<INSTALLATION_ID>', 
    '<PROVIDER_REPOSITORY_ID>', 
    '<PROVIDER_BRANCH>', 
    false, 
    '<PROVIDER_ROOT_DIRECTORY>', 
    '' 
);
Get function

Get a function by its unique ID.

GET /functions/{functionId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.get(
    '<FUNCTION_ID>' 
);
List functions

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

const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.list(
    [], 
    '<SEARCH>' 
);
Update function

Update function by its unique ID.

PUT /functions/{functionId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.update(
    '<FUNCTION_ID>', 
    '<NAME>', 
    sdk..Node145, 
    ["any"], 
    [], 
    '', 
    1, 
    false, 
    false, 
    '<ENTRYPOINT>', 
    '<COMMANDS>', 
    [], 
    '<INSTALLATION_ID>', 
    '<PROVIDER_REPOSITORY_ID>', 
    '<PROVIDER_BRANCH>', 
    false, 
    '<PROVIDER_ROOT_DIRECTORY>', 
    '' 
);
Update function's deployment

Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function.

PATCH /functions/{functionId}/deployment
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.updateFunctionDeployment(
    '<FUNCTION_ID>', 
    '<DEPLOYMENT_ID>' 
);
Delete function

Delete a function by its unique ID.

DELETE /functions/{functionId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.delete(
    '<FUNCTION_ID>' 
);
List runtimes

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

const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.listRuntimes();
List specifications

List allowed function specifications for this instance.

GET /functions/specifications
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.listSpecifications();
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.

POST /functions/{functionId}/deployments
const sdk = require('node-appwrite');
const fs = require('fs');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.createDeployment(
    '<FUNCTION_ID>', 
    InputFile.fromPath('/path/to/file', 'filename'), 
    false, 
    '<ENTRYPOINT>', 
    '<COMMANDS>' 
);
Create duplicate deployment

Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build.

POST /functions/{functionId}/deployments/duplicate
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.createDuplicateDeployment(
    '<FUNCTION_ID>', 
    '<DEPLOYMENT_ID>', 
    '<BUILD_ID>' 
);
Create template deployment

Create a deployment based on a template.

Use this endpoint with combination of listTemplates to find the template details.

POST /functions/{functionId}/deployments/template
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.createTemplateDeployment(
    '<FUNCTION_ID>', 
    '<REPOSITORY>', 
    '<OWNER>', 
    '<ROOT_DIRECTORY>', 
    '<VERSION>', 
    false 
);
Create VCS deployment

Create a deployment when a function is connected to VCS.

This endpoint lets you create deployment from a branch, commit, or a tag.

POST /functions/{functionId}/deployments/vcs
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.createVcsDeployment(
    '<FUNCTION_ID>', 
    sdk.VCSDeploymentType.Branch, 
    '<REFERENCE>', 
    false 
);
Get deployment

Get a function deployment by its unique ID.

GET /functions/{functionId}/deployments/{deploymentId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.getDeployment(
    '<FUNCTION_ID>', 
    '<DEPLOYMENT_ID>' 
);
Get deployment download

Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.

GET /functions/{functionId}/deployments/{deploymentId}/download
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.getDeploymentDownload(
    '<FUNCTION_ID>', 
    '<DEPLOYMENT_ID>', 
    sdk.DeploymentDownloadType.Source 
);
List deployments

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

GET /functions/{functionId}/deployments
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.listDeployments(
    '<FUNCTION_ID>', 
    [], 
    '<SEARCH>' 
);
Update deployment status

Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details.

PATCH /functions/{functionId}/deployments/{deploymentId}/status
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.updateDeploymentStatus(
    '<FUNCTION_ID>', 
    '<DEPLOYMENT_ID>' 
);
Delete deployment

Delete a code deployment by its unique ID.

DELETE /functions/{functionId}/deployments/{deploymentId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.deleteDeployment(
    '<FUNCTION_ID>', 
    '<DEPLOYMENT_ID>' 
);
Create 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.

POST /functions/{functionId}/executions
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setSession(''); 

const functions = new sdk.Functions(client);

const result = await functions.createExecution(
    '<FUNCTION_ID>', 
    '<BODY>', 
    false, 
    '<PATH>', 
    sdk.ExecutionMethod.GET, 
    {}, 
    '' 
);
Get execution

Get a function execution log by its unique ID.

GET /functions/{functionId}/executions/{executionId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setSession(''); 

const functions = new sdk.Functions(client);

const result = await functions.getExecution(
    '<FUNCTION_ID>', 
    '<EXECUTION_ID>' 
);
List executions

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

GET /functions/{functionId}/executions
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setSession(''); 

const functions = new sdk.Functions(client);

const result = await functions.listExecutions(
    '<FUNCTION_ID>', 
    [] 
);
Delete execution

Delete a function execution by its unique ID.

DELETE /functions/{functionId}/executions/{executionId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.deleteExecution(
    '<FUNCTION_ID>', 
    '<EXECUTION_ID>' 
);
Create variable

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

POST /functions/{functionId}/variables
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.createVariable(
    '<FUNCTION_ID>', 
    '<KEY>', 
    '<VALUE>', 
    false 
);
Get variable

Get a variable by its unique ID.

GET /functions/{functionId}/variables/{variableId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.getVariable(
    '<FUNCTION_ID>', 
    '<VARIABLE_ID>' 
);
List variables

Get a list of all variables of a specific function.

GET /functions/{functionId}/variables
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.listVariables(
    '<FUNCTION_ID>' 
);
Update variable

Update variable by its unique ID.

PUT /functions/{functionId}/variables/{variableId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.updateVariable(
    '<FUNCTION_ID>', 
    '<VARIABLE_ID>', 
    '<KEY>', 
    '<VALUE>', 
    false 
);
Delete variable

Delete a variable by its unique ID.

DELETE /functions/{functionId}/variables/{variableId}
const sdk = require('node-appwrite');

const client = new sdk.Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') 
    .setProject('<YOUR_PROJECT_ID>') 
    .setKey('<YOUR_API_KEY>'); 

const functions = new sdk.Functions(client);

const result = await functions.deleteVariable(
    '<FUNCTION_ID>', 
    '<VARIABLE_ID>' 
);

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4