Skip to content

Commit e9ee319

Browse files
committed
doc: document group endpoints
1 parent c374b0c commit e9ee319

File tree

1 file changed

+184
-0
lines changed

1 file changed

+184
-0
lines changed

doc/api/group.md

+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Group Endpoints
2+
3+
## POST `/group/create` (auth required)
4+
5+
### Description
6+
7+
Creates a group and returns a UID (UUID formatted).
8+
Groups do not have names, or any other descriptive attributes.
9+
Instead they are always identified with a UUID, and they have
10+
a `metadata` property.
11+
12+
The `metadata` property will always be given back to the client
13+
in the same way it was provided. The `extra` property, also an
14+
object, may be changed by the backend. The behavior of setting
15+
any property on `extra` is currently undefined as all properties
16+
are reserved for future use.
17+
18+
### Parameters
19+
20+
- **metadata:** _- optional_
21+
- **accepts:** `object`
22+
- **description:** arbitrary metadata to describe the group
23+
- **extra:** _- optional_
24+
- **accepts:** `object`
25+
- **description:** extra parameters (server may change these)
26+
27+
### Request Example
28+
29+
```javascript
30+
await fetch(`${window.api_origin}/group/create`, {
31+
"headers": {
32+
"Content-Type": "application/json",
33+
"Authorization": `Bearer ${puter.authToken}`,
34+
},
35+
"body": JSON.stringify({
36+
metadata: { title: 'Some Title' }
37+
}),
38+
"method": "POST",
39+
});
40+
41+
// { uid: '9c644a1c-3e43-4df4-ab67-de5b68b235b6' }
42+
```
43+
44+
### Response Example
45+
46+
```json
47+
{
48+
"uid": "9c644a1c-3e43-4df4-ab67-de5b68b235b6"
49+
}
50+
```
51+
52+
## POST `/group/add-users`
53+
54+
### Description
55+
56+
Adds one or more users to a group
57+
58+
### Parameters
59+
60+
- **uid:** _- required_
61+
- **accepts:** `string`
62+
UUID of an existing group
63+
- **users:** `Array<string>`
64+
usernames of users to add to the group
65+
66+
### Request Example
67+
68+
```javascript
69+
await fetch(`${window.api_origin}/group/add-users`, {
70+
"headers": {
71+
"Content-Type": "application/json",
72+
"Authorization": `Bearer ${puter.authToken}`,
73+
},
74+
"body": JSON.stringify({
75+
uid: '9c644a1c-3e43-4df4-ab67-de5b68b235b6',
76+
users: ['first_user', 'second_user'],
77+
}),
78+
"method": "POST",
79+
});
80+
```
81+
82+
## POST `/group/remove-users`
83+
84+
### Description
85+
86+
Remove one or more users from a group
87+
88+
### Parameters
89+
90+
- **uid:** _- required_
91+
- **accepts:** `string`
92+
UUID of an existing group
93+
- **users:** `Array<string>`
94+
usernames of users to remove from the group
95+
96+
### Request Example
97+
98+
```javascript
99+
await fetch(`${window.api_origin}/group/add-users`, {
100+
"headers": {
101+
"Content-Type": "application/json",
102+
"Authorization": `Bearer ${puter.authToken}`,
103+
},
104+
"body": JSON.stringify({
105+
uid: '9c644a1c-3e43-4df4-ab67-de5b68b235b6',
106+
users: ['first_user', 'second_user'],
107+
}),
108+
"method": "POST",
109+
});
110+
```
111+
112+
# Group Permission Endpoints
113+
114+
## POST `/grant-user-group`
115+
116+
Grant permission from the current user to a group.
117+
This creates an association between the user and the
118+
group for this permission; the group will only have
119+
the permission effectively while the user who granted
120+
permission has the permission.
121+
122+
### Parameters
123+
124+
- **group_uid:** _- required_
125+
- **accepts:** `string`
126+
UUID of an existing group
127+
- **permission:** _- required_
128+
- **accepts:** `string`
129+
A permission string
130+
131+
### Request Example
132+
133+
```javascript
134+
await fetch("http://puter.localhost:4100/auth/grant-user-group", {
135+
"headers": {
136+
"Content-Type": "application/json",
137+
"Authorization": `Bearer ${puter.authToken}`,
138+
},
139+
"body": JSON.stringify({
140+
group_uid: '9c644a1c-3e43-4df4-ab67-de5b68b235b6',
141+
permission: 'fs:/someuser/somedir/somefile:read'
142+
}),
143+
"method": "POST",
144+
});
145+
```
146+
147+
## POST `/revoke-user-group`
148+
149+
Revoke permission granted from the current user
150+
to a group.
151+
152+
### Parameters
153+
154+
- **group_uid:** _- required_
155+
- **accepts:** `string`
156+
UUID of an existing group
157+
- **permission:** _- required_
158+
- **accepts:** `string`
159+
A permission string
160+
161+
### Request Example
162+
163+
```javascript
164+
await fetch("http://puter.localhost:4100/auth/grant-user-group", {
165+
"headers": {
166+
"Content-Type": "application/json",
167+
"Authorization": `Bearer ${puter.authToken}`,
168+
},
169+
"body": JSON.stringify({
170+
group_uid: '9c644a1c-3e43-4df4-ab67-de5b68b235b6',
171+
permission: 'fs:/someuser/somedir/somefile:read'
172+
}),
173+
"method": "POST",
174+
});
175+
```
176+
177+
- > **TODO** figure out how to manage documentation that could
178+
reasonably show up in two files. For example: this is a group
179+
endpoint as well as a permission system endpoint.
180+
(architecturally it's a permission system endpoint, and
181+
the permissions feature depends on the groups feature;
182+
at least until a time when PermissionService is refactored
183+
so a service like GroupService can mutate the permission
184+
check sequences)

0 commit comments

Comments
 (0)