Skip to content

Commit c905468

Browse files
committed
docs: complete Cloud section content
- Overview with three-tier model explanation - Full API layer documentation - Databases commands (migrated from core-resources) - Subscriptions commands (migrated from core-resources) - Access control (users, roles, ACLs) - Networking (VPC, PSC, Transit Gateway) - Tasks monitoring - Workflows documentation
1 parent d306968 commit c905468

File tree

8 files changed

+1427
-83
lines changed

8 files changed

+1427
-83
lines changed

docs/src/cloud/api.md

Lines changed: 156 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,175 @@
11
# Cloud API Layer
22

3-
Direct REST access to the Redis Cloud API.
3+
Direct REST access to the Redis Cloud API for scripting and automation.
44

55
## Overview
66

7-
The API layer provides raw access to all Redis Cloud REST endpoints. Use this for:
8-
- Scripting and automation
9-
- Accessing endpoints not yet wrapped in human commands
10-
- CI/CD pipelines
7+
The API layer lets you call any Redis Cloud REST endpoint directly. It's like a smart curl with:
8+
- Automatic authentication
9+
- Profile support
10+
- Output formatting
1111

12-
## Authentication
12+
## Usage
1313

14-
Uses `x-api-key` and `x-api-secret-key` headers. Configure via profile or environment variables.
14+
```bash
15+
redisctl api cloud <method> <endpoint> [options]
16+
```
1517

16-
## Usage
18+
**Methods:** `get`, `post`, `put`, `delete`
19+
20+
## Examples
21+
22+
### GET Requests
1723

1824
```bash
19-
# GET request
25+
# Account info
26+
redisctl api cloud get /
27+
28+
# List subscriptions
2029
redisctl api cloud get /subscriptions
2130

22-
# POST request with data
23-
redisctl api cloud post /subscriptions -d '{"name": "test", ...}'
31+
# Get specific subscription
32+
redisctl api cloud get /subscriptions/123456
2433

25-
# PUT request
26-
redisctl api cloud put /subscriptions/123 -d '{"name": "updated"}'
34+
# List databases
35+
redisctl api cloud get /subscriptions/123456/databases
2736

28-
# DELETE request
29-
redisctl api cloud delete /subscriptions/123/databases/456
37+
# Get specific database
38+
redisctl api cloud get /subscriptions/123456/databases/789
3039
```
3140

41+
### POST Requests
42+
43+
```bash
44+
# Create subscription
45+
redisctl api cloud post /subscriptions -d @subscription.json
46+
47+
# Create database
48+
redisctl api cloud post /subscriptions/123456/databases -d '{
49+
"name": "mydb",
50+
"memoryLimitInGb": 1
51+
}'
52+
```
53+
54+
### PUT Requests
55+
56+
```bash
57+
# Update database
58+
redisctl api cloud put /subscriptions/123456/databases/789 -d '{
59+
"memoryLimitInGb": 2
60+
}'
61+
```
62+
63+
### DELETE Requests
64+
65+
```bash
66+
# Delete database
67+
redisctl api cloud delete /subscriptions/123456/databases/789
68+
69+
# Delete subscription
70+
redisctl api cloud delete /subscriptions/123456
71+
```
72+
73+
## Options
74+
75+
| Option | Description |
76+
|--------|-------------|
77+
| `-d, --data <JSON>` | Request body (inline or @file) |
78+
| `-o, --output <FORMAT>` | Output format (json, yaml, table) |
79+
| `-q, --query <JMESPATH>` | Filter output |
80+
3281
## Common Endpoints
3382

34-
- `/account` - Account information
35-
- `/subscriptions` - Subscription management
36-
- `/subscriptions/{id}/databases` - Database operations
37-
- `/acl/users` - User management
38-
- `/acl/roles` - Role management
39-
- `/tasks` - Async task status
83+
### Account
84+
- `GET /` - Account info
85+
- `GET /payment-methods` - Payment methods
86+
- `GET /regions` - Available regions
87+
88+
### Subscriptions
89+
- `GET /subscriptions` - List all
90+
- `POST /subscriptions` - Create
91+
- `GET /subscriptions/{id}` - Get one
92+
- `PUT /subscriptions/{id}` - Update
93+
- `DELETE /subscriptions/{id}` - Delete
94+
95+
### Databases
96+
- `GET /subscriptions/{id}/databases` - List
97+
- `POST /subscriptions/{id}/databases` - Create
98+
- `GET /subscriptions/{id}/databases/{dbId}` - Get
99+
- `PUT /subscriptions/{id}/databases/{dbId}` - Update
100+
- `DELETE /subscriptions/{id}/databases/{dbId}` - Delete
101+
102+
### ACL
103+
- `GET /acl/users` - List users
104+
- `GET /acl/roles` - List roles
105+
- `GET /acl/redisRules` - List Redis rules
106+
107+
### Networking
108+
- `GET /subscriptions/{id}/peerings` - VPC peerings
109+
- `GET /subscriptions/{id}/privateServiceConnect` - PSC
110+
- `GET /subscriptions/{id}/transitGateway` - Transit Gateway
111+
112+
### Tasks
113+
- `GET /tasks` - List tasks
114+
- `GET /tasks/{taskId}` - Get task
115+
116+
## Scripting Examples
117+
118+
### Create and Wait
119+
120+
```bash
121+
# Create database
122+
TASK_ID=$(redisctl api cloud post /subscriptions/123/databases \
123+
-d @database.json \
124+
-q 'taskId')
125+
126+
# Poll for completion
127+
while true; do
128+
STATUS=$(redisctl api cloud get /tasks/$TASK_ID -q 'status')
129+
[ "$STATUS" = "processing-completed" ] && break
130+
[ "$STATUS" = "processing-error" ] && exit 1
131+
sleep 10
132+
done
133+
134+
# Get result
135+
redisctl api cloud get /tasks/$TASK_ID -q 'response.resourceId'
136+
```
137+
138+
### Bulk Operations
139+
140+
```bash
141+
# Get all database IDs
142+
DBS=$(redisctl api cloud get /subscriptions/123/databases -q '[].databaseId')
143+
144+
# Process each
145+
for db in $(echo $DBS | jq -r '.[]'); do
146+
redisctl api cloud get /subscriptions/123/databases/$db
147+
done
148+
```
149+
150+
### Export to File
151+
152+
```bash
153+
# Save subscription config
154+
redisctl api cloud get /subscriptions/123 > subscription.json
155+
156+
# Save all databases
157+
redisctl api cloud get /subscriptions/123/databases > databases.json
158+
```
159+
160+
## When to Use API Layer
161+
162+
**Use API layer when:**
163+
- Endpoint isn't wrapped in human commands yet
164+
- You need exact control over the request
165+
- Building automation scripts
166+
- Exploring the API
167+
168+
**Use human commands when:**
169+
- There's a command for what you need
170+
- You want built-in `--wait` support
171+
- You prefer ergonomic flags over JSON
172+
173+
## API Documentation
40174

41-
TODO: Move detailed content from common-features/raw-api.md
175+
Full API documentation: [Redis Cloud API Docs](https://api.redislabs.com/v1/swagger-ui.html)
Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,153 @@
11
# Cloud Access Control
22

3-
User and ACL management.
3+
Manage users, roles, and ACLs for Redis Cloud.
44

5-
TODO: Consolidate from access-control/users.md and access-control/acl.md
5+
## Users
6+
7+
### List Users
8+
9+
```bash
10+
redisctl cloud user list
11+
```
12+
13+
### Get User
14+
15+
```bash
16+
redisctl cloud user get <user-id>
17+
```
18+
19+
### Create User
20+
21+
```bash
22+
redisctl cloud user create --data '{
23+
"name": "app-user",
24+
"email": "[email protected]",
25+
"role": "viewer"
26+
}'
27+
```
28+
29+
### Update User
30+
31+
```bash
32+
redisctl cloud user update <user-id> --data '{
33+
"role": "member"
34+
}'
35+
```
36+
37+
### Delete User
38+
39+
```bash
40+
redisctl cloud user delete <user-id>
41+
```
42+
43+
## Roles
44+
45+
### List Roles
46+
47+
```bash
48+
redisctl cloud acl role list
49+
```
50+
51+
### Get Role
52+
53+
```bash
54+
redisctl cloud acl role get <role-id>
55+
```
56+
57+
### Create Role
58+
59+
```bash
60+
redisctl cloud acl role create --data '{
61+
"name": "read-only",
62+
"redisRules": [
63+
{
64+
"ruleName": "Read-Only",
65+
"databases": [
66+
{"subscriptionId": 123456, "databaseId": 789}
67+
]
68+
}
69+
]
70+
}'
71+
```
72+
73+
### Update Role
74+
75+
```bash
76+
redisctl cloud acl role update <role-id> --data '{
77+
"name": "read-write"
78+
}'
79+
```
80+
81+
### Delete Role
82+
83+
```bash
84+
redisctl cloud acl role delete <role-id>
85+
```
86+
87+
## Redis Rules
88+
89+
Redis ACL rules define permissions at the Redis command level.
90+
91+
### List Redis Rules
92+
93+
```bash
94+
redisctl cloud acl redis-rule list
95+
```
96+
97+
### Get Redis Rule
98+
99+
```bash
100+
redisctl cloud acl redis-rule get <rule-id>
101+
```
102+
103+
### Create Redis Rule
104+
105+
```bash
106+
redisctl cloud acl redis-rule create --data '{
107+
"name": "Read-Only",
108+
"acl": "+@read ~*"
109+
}'
110+
```
111+
112+
### Common ACL Patterns
113+
114+
| Pattern | Description |
115+
|---------|-------------|
116+
| `+@all ~*` | Full access to all keys |
117+
| `+@read ~*` | Read-only access |
118+
| `+@write ~cache:*` | Write only to cache:* keys |
119+
| `-@dangerous` | Deny dangerous commands |
120+
121+
## Examples
122+
123+
### Set Up Read-Only User
124+
125+
```bash
126+
# Create redis rule
127+
redisctl cloud acl redis-rule create --data '{
128+
"name": "readonly-rule",
129+
"acl": "+@read -@dangerous ~*"
130+
}'
131+
132+
# Create role with rule
133+
redisctl cloud acl role create --data '{
134+
"name": "readonly-role",
135+
"redisRules": [{"ruleName": "readonly-rule", "databases": [...]}]
136+
}'
137+
```
138+
139+
### Audit Access
140+
141+
```bash
142+
# List all users and their roles
143+
redisctl cloud user list -q "[].{name:name,role:role,email:email}" -o table
144+
```
145+
146+
## API Reference
147+
148+
These commands use the following REST endpoints:
149+
- `GET/POST /v1/acl/users` - User management
150+
- `GET/POST /v1/acl/roles` - Role management
151+
- `GET/POST /v1/acl/redisRules` - Redis rule management
152+
153+
For direct API access: `redisctl api cloud get /acl/users`

0 commit comments

Comments
 (0)