Skip to content

Commit

Permalink
Write cloud functions SDK and CLI docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitrov-d committed Oct 24, 2024
1 parent bbdc525 commit 63a9fae
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
43 changes: 43 additions & 0 deletions build/5-apillon-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,49 @@ console.log(
);
```

## Cloud Functions

The Cloud Functions module provides functionalities for managing cloud functions, including creating functions, listing functions, and interacting with specific functions for operations like job creation and environment variable management.

### Usage example

```ts
import { CloudFunctions } from '@apillon/sdk';

const cloudFunctions = new CloudFunctions({ key: 'yourApiKey', secret: 'yourApiSecret' });

// Create a new cloud function
const newCloudFunction = await cloudFunctions.createCloudFunction({
name: 'My Cloud Function',
description: 'Description of my cloud function',
});

// List all cloud functions
const { items: cloudFunctionsList } = await cloudFunctions.listCloudFunctions();

// Get details of a specific cloud function
const cloudFunctionDetails = await cloudFunctions.cloudFunction(newCloudFunction.uuid).get();

// Create a job for the cloud function
const newJob = await cloudFunctions.cloudFunction(newCloudFunction.uuid).createJob({
name: 'My Job',
scriptCid: 'QmYtHkLrtGEybxXg53swTHuKPYMXQCbHGeBqpYjYbaVyFV',
});

// Set environment variables for the cloud function
const environmentVariables = [
{ key: 'VAR1', value: 'value1' },
{ key: 'VAR2', value: 'value2' },
];
await cloudFunctions.cloudFunction(newCloudFunction.uuid).setEnvironment(environmentVariables);

// List jobs for the cloud function
const { jobs: cloudFunctionJobs } = await cloudFunctions.cloudFunction(newCloudFunction.uuid).get();

// Delete a job for the cloud function
await cloudFunctionJobs[0].delete();
```

## Social

The Social module provides functionalities for managing social hubs and channels within the Apillon platform. This includes creating, listing, and interacting with hubs and channels. In the background it utilizes Grill.chat, a mobile-friendly, anonymous chat application powered by Subsocial.
Expand Down
102 changes: 102 additions & 0 deletions build/6-apillon-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,108 @@ apillon nfts list-transactions --uuid "123e4567-e89b-12d3-a456-426655440000"
}
```

## Cloud Function Commands

The Apillon CLI provides a set of commands to manage cloud functions on the Apillon platform. These commands allow you to create, list, and manage cloud functions and their associated jobs.

#### `cloud-functions list`

Lists all cloud functions available in your project.

**Example**

```sh
apillon cloud-functions list --limit 10 --page 1
```

#### `cloud-functions get`

Retrieves details of a specific cloud function.

**Options**

- `--uuid <cloud-function-uuid>`: UUID of the cloud function to retrieve.

**Example**

```sh
apillon cloud-functions get --uuid "123e4567-e89b-12d3-a456-426655440000"
```

#### `cloud-functions create`

Creates a new cloud function.

**Options**

- `--name <name>`: Name of the cloud function.
- `--description <description>`: Description of the cloud function (optional).

**Example**

```sh
apillon cloud-functions create --name "MyFunction" --description "This is a test function"
```

#### `cloud-functions create-job`

Creates a job for a cloud function from a script file.

**Options**

- `--uuid <cloud-function-uuid>`: UUID of the cloud function.
- `--name <job-name>`: Name of the job.
- `--script <path>`: Path to the script file.

**Example**

```sh
apillon cloud-functions create-job --uuid "123e4567-e89b-12d3-a456-426655440000" --name "MyJob" --script "./path/to/script.js"
```

#### `cloud-functions set-environment`

Sets environment variables for a cloud function.

**Options**

- `--uuid <cloud-function-uuid>`: UUID of the cloud function.
- `--variables <variables>`: Environment variables in key=value format, separated by commas.

**Example**

```sh
apillon cloud-functions set-environment --uuid "123e4567-e89b-12d3-a456-426655440000" --variables "KEY1=value1,KEY2=value2"
```

#### `cloud-functions list-jobs`

Lists all jobs for a specific cloud function.

**Options**

- `--uuid <cloud-function-uuid>`: UUID of the cloud function.

**Example**

```sh
apillon cloud-functions list-jobs --uuid "123e4567-e89b-12d3-a456-426655440000"
```

#### `cloud-functions delete-job`

Deletes a job from a cloud function.

**Options**

- `-j, --job-uuid <job-uuid>`: UUID of the job to delete.

**Example**

```sh
apillon cloud-functions delete-job --job-uuid "987e6543-e21c-32f1-b123-426655441111"
```

## Using in CI/CD tools

CLI is particularly useful for CI/CD builds and pipelines.
Expand Down

0 comments on commit 63a9fae

Please sign in to comment.