Skip to content

Commit

Permalink
Merge pull request #194 from dimitrov-d/main
Browse files Browse the repository at this point in the history
Cloud functions SDK/CLi docs
  • Loading branch information
dimitrov-d authored Oct 29, 2024
2 parents ea40ff7 + dfd74dd commit 889fb0c
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 12 deletions.
24 changes: 12 additions & 12 deletions build/11-cloud-functions-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Cloud Function API provides an interface for developers to deploy, manage, a

> Create a new cloud function to be executed on decentralized processors.
<CodeDiv>POST /acurast/cloud-functions</CodeDiv>
<CodeDiv>POST /cloud-functions</CodeDiv>

<div class="split_content">
<div class="split_side">
Expand Down Expand Up @@ -34,7 +34,7 @@ The Cloud Function API provides an interface for developers to deploy, manage, a
<CodeGroupItem title="cURL" active>

```sh
curl --location --request POST "https://api.apillon.io/acurast/cloud-functions" \
curl --location --request POST "https://api.apillon.io/cloud-functions" \
--header "Authorization: Bearer :credentials" \
--header "Content-Type: application/json" \
--data-raw "{
Expand Down Expand Up @@ -73,7 +73,7 @@ curl --location --request POST "https://api.apillon.io/acurast/cloud-functions"

> Retrieve a list of cloud functions associated with a project.
<CodeDiv>GET /acurast/cloud-functions</CodeDiv>
<CodeDiv>GET /cloud-functions</CodeDiv>

<div class="split_content">
<div class="split_side">
Expand Down Expand Up @@ -103,7 +103,7 @@ All query parameters from [listing request](1-apillon-api.md#listing-requests)
<CodeGroupItem title="cURL" active>

```sh
curl --location --request GET "https://api.apillon.io/acurast/cloud-functions?project_uuid=abc123-project" \
curl --location --request GET "https://api.apillon.io/cloud-functions?project_uuid=abc123-project" \
--header "Authorization: Bearer :credentials"
```

Expand Down Expand Up @@ -144,7 +144,7 @@ curl --location --request GET "https://api.apillon.io/acurast/cloud-functions?pr

> Get the details of a specific cloud function by its UUID.
<CodeDiv>GET /acurast/cloud-functions/:function_uuid</CodeDiv>
<CodeDiv>GET /cloud-functions/:function_uuid</CodeDiv>

<div class="split_content">
<div class="split_side">
Expand Down Expand Up @@ -187,7 +187,7 @@ curl --location --request GET "https://api.apillon.io/acurast/cloud-functions?pr
<CodeGroupItem title="cURL" active>

```sh
curl --location --request GET "https://api.apillon.io/acurast/cloud-functions/d1e8b9f2-4d18-4ef7-9f59-87348590d5a6" \
curl --location --request GET "https://api.apillon.io/cloud-functions/d1e8b9f2-4d18-4ef7-9f59-87348590d5a6" \
--header "Authorization: Bearer :credentials"
```

Expand Down Expand Up @@ -237,7 +237,7 @@ curl --location --request GET "https://api.apillon.io/acurast/cloud-functions/d1
> Create a job/deployment for a specific cloud function.

<CodeDiv>POST /acurast/cloud-functions/:function_uuid/jobs</CodeDiv>
<CodeDiv>POST /cloud-functions/:function_uuid/jobs</CodeDiv>

::: warning
The deployed code should be made on top of this Node.js template: [https://github.com/Apillon/cloud-function-template](https://github.com/Apillon/cloud-function-template)
Expand Down Expand Up @@ -278,7 +278,7 @@ If it does not contain the boilerplate code, the deployment will not be accessib
<CodeGroupItem title="cURL" active>

```sh
curl --location --request POST "https://api.apillon.io/acurast/cloud-functions/d1e8b9f2-4d18-4ef7-9f59-87348590d5a6/jobs" \
curl --location --request POST "https://api.apillon.io/cloud-functions/d1e8b9f2-4d18-4ef7-9f59-87348590d5a6/jobs" \
--header "Authorization: Bearer :credentials" \
--header "Content-Type: application/json" \
--data-raw "{
Expand Down Expand Up @@ -321,7 +321,7 @@ curl --location --request POST "https://api.apillon.io/acurast/cloud-functions/d
> Set the environment variables for a specific cloud function.
<CodeDiv>POST /acurast/cloud-functions/:function_uuid/environment</CodeDiv>
<CodeDiv>POST /cloud-functions/:function_uuid/environment</CodeDiv>
<div class="split_content">
<div class="split_side">
Expand Down Expand Up @@ -352,7 +352,7 @@ curl --location --request POST "https://api.apillon.io/acurast/cloud-functions/d
<CodeGroupItem title="cURL" active>
```sh
curl --location --request POST "https://api.apillon.io/acurast/cloud-functions/d1e8b9f2-4d18-4ef7-9f59-87348590d5a6/environment" \
curl --location --request POST "https://api.apillon.io/cloud-functions/d1e8b9f2-4d18-4ef7-9f59-87348590d5a6/environment" \
--header "Authorization: Bearer :credentials" \
--header "Content-Type: application/json" \
--data-raw "{
Expand Down Expand Up @@ -386,7 +386,7 @@ curl --location --request POST "https://api.apillon.io/acurast/cloud-functions/d
> Delete a specific job using its unique identifier.
<CodeDiv>DELETE /acurast/jobs/:job_uuid</CodeDiv>
<CodeDiv>DELETE /cloud-functions/jobs/:job_uuid</CodeDiv>
<div class="split_content">
<div class="split_side">
Expand All @@ -412,7 +412,7 @@ curl --location --request POST "https://api.apillon.io/acurast/cloud-functions/d
<CodeGroupItem title="cURL" active>
```sh
curl --location --request DELETE "https://api.apillon.io/acurast/jobs/e3c86bb2-4190-4bda-9c8a-3852b6d04971" \
curl --location --request DELETE "https://api.apillon.io/cloud-functions/jobs/e3c86bb2-4190-4bda-9c8a-3852b6d04971" \
--header "Authorization: Bearer :credentials"
```
Expand Down
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"
```

## Indexing Commands

#### `indexing deploy`
Expand Down

0 comments on commit 889fb0c

Please sign in to comment.