You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+71-3Lines changed: 71 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
A serverless function example built for DigitalOcean Functions that retrieves droplet information from the DigitalOcean API. This function demonstrates how to create API-connected serverless functions that can be integrated with GenAI platforms for function calling capabilities. Built using Python 3.11, it leverages the [pydo](https://pypi.org/project/pydo/) client to interact with DigitalOcean services.
1
+
A serverless function example built for DigitalOcean Functions that retrieves droplet information and controls power state of droplets via the DigitalOcean API. This function demonstrates how to create API-connected serverless functions that can be integrated with GenAI platforms for function calling capabilities. Built using Python 3.11, it leverages the [pydo](https://pypi.org/project/pydo/) client to interact with DigitalOcean services.
2
2
3
3
---
4
4
@@ -15,6 +15,9 @@ A serverless function example built for DigitalOcean Functions that retrieves dr
15
15
-[Deployment](#deployment)
16
16
-[Deploying to DigitalOcean Functions](#deploying-to-digitalocean-functions)
17
17
-[Sample Package](#sample-package)
18
+
-[Function Parameters](#function-parameters)
19
+
-[Response Format](#response-format)
20
+
-[Usage Examples](#usage-examples)
18
21
19
22
---
20
23
@@ -28,8 +31,9 @@ This function supports fetching details for a specific droplet by supplying a `d
28
31
29
32
This function can be used as:
30
33
- A function calling endpoint for LLMs to retrieve real-time infrastructure information
31
-
- An API connector for AI agents managing cloud resources
34
+
- An API connector for AI agents managing cloud resources, including power control operations
32
35
- A data source for AI-powered cloud management dashboards
36
+
- An automation endpoint for power management of cloud resources
33
37
34
38
> **Note:** The DigitalOcean API token must be provided via the `DO_API_TOKEN` environment variable.
35
39
@@ -39,7 +43,8 @@ This function can be used as:
39
43
40
44
-**Retrieve Specific Droplet:** Get information on a single droplet using its `droplet_id`.
41
45
-**List Droplets:** Retrieve a list of droplets with optional filtering using a `tag` and pagination via the `limit` parameter.
42
-
-**JSON Response:** Returns droplet details in a JSON formatted response.
46
+
-**Power Control:** Manage droplet power state with `power_on` and `power_off` actions.
47
+
-**JSON Response:** Returns droplet details and action status in a JSON formatted response.
43
48
-**Web-Enabled Function:** Configured to be deployed as a web-accessible function with an associated web secure token.
44
49
45
50
---
@@ -133,4 +138,67 @@ print(result)
133
138
134
139
---
135
140
141
+
## Function Parameters
142
+
143
+
The function accepts the following parameters in its input:
144
+
145
+
-`droplet_id` (optional): Specific droplet ID to retrieve information for or to perform actions on
146
+
-`tag` (optional): Filter droplets by tag when listing
147
+
-`limit` (optional): Maximum number of droplets to return (default: 10)
148
+
-`action` (optional): Power control action to perform on a droplet. Supported values:
149
+
-`power_on`: Turn on the specified droplet
150
+
-`power_off`: Turn off the specified droplet
151
+
152
+
## Response Format
153
+
154
+
The function returns a JSON response with the following structure:
155
+
156
+
For droplet information requests:
157
+
```json
158
+
{
159
+
"body": {
160
+
"droplets": "[ ... droplet information array ... ]",
161
+
"count": number,
162
+
"status": "success"
163
+
}
164
+
}
165
+
```
166
+
167
+
For power control actions:
168
+
```json
169
+
{
170
+
"body": {
171
+
"action": { ... action response object ... },
172
+
"status": "success",
173
+
"message": "Power [on/off] initiated for droplet [id]"
0 commit comments