Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-burlacu-software authored May 13, 2024
1 parent c7029a7 commit 4f1dc83
Showing 1 changed file with 2 additions and 325 deletions.
327 changes: 2 additions & 325 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,328 +63,5 @@ inactive after 1 day.
-f, --simple Do not run change-tracking queries (default: false)
-h, --help display help for command
```

## HTTP API

### /{DB}/login

#### POST /{DB}/login

##### Summary: DB Login

##### Description: Logs into a database.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| DB | path | The database. | Yes | string |
| pid | query | The process ID. This is generated by the client. | Yes | string |

##### Body Example

```json
{
"username": "admin",
"password": "admin"
}
```

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The login was sucessful. |
| 401 | The login failed for the credentials. |
| 403 | The login failed for the DB. |

### /logout

#### POST /logout

##### Summary: User logout

##### Description:

Logs out of a user.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| pid | query | The process ID. This is generated by the client. | Yes | string |

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The logout was successful. |

### /users

#### GET /users

##### Summary: Get users

##### Description:

Get the users in the system. Regular users can only get their own user. Admins can get all the users.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| pid | query | The process ID. This is generated by the client. | Yes | string |
| ID | query | The user ID. | No | string |
| name | query | The username. | No | string |

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The requested user(s). |
| 401 | The user is not logged in. |
| 403 | The logged in user either doesn't have permission to view the user or the user wasn't found. |

#### POST /users

##### Summary: Add user

##### Description:

Add a user. Only Admins can do this.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| pid | query | The process ID. This is generated by the client. | Yes | string |

##### Body Example

```json
{
"username": "admin",
"password": "admin",
"salt": ""
}
```

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The user was added. |
| 401 | The user is not logged in. |
| 403 | The logged in user doesn't have permission to add the user or the user entity had an error. |

#### PUT /users

##### Summary:

Set user

##### Description:

Set a user. Regular users can only set their own user. Admins can set any user.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| pid | query | The process ID. This is generated by the client. | Yes | string |

##### Body Example

```json
{
"ID": 2,
"username": "user1",
"password": "password1",
"salt": ""
}
```

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The user was set. |
| 401 | The user is not logged in. |
| 403 | The logged in user either doesn't have permission to set the user or the user entity was not found. |

#### DELETE /users

##### Summary: Delete user

##### Description:

Delete a user. Regular users can only delete their own user. Admins can delete any user.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| pid | query | The process ID. This is generated by the client. | Yes | string |
| ID | query | The user ID | No | string |
| name | query | The username | No | string |

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The user was deleted |
| 401 | The user is not logged in. |
| 403 | The logged in user either doesn't have permission to delete the user or the user wasn't found. |

### /DBs

#### GET /DBs

##### Summary: Get DBs

##### Description:

Get the DBs in the system. Regular users can only get their own DBs. Admins can get all the DBs.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| pid | query | The process ID. This is generated by the client. | Yes | string |
| ID | query | The DB ID. | No | string |
| name | query | The DB name. | No | string |

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The requested DB(s). |
| 401 | The user is not logged in. |
| 403 | The logged in user either doesn't have permission to get the DB or the DB wasn't found. |

#### POST /DBs

##### Summary: Add DB

##### Description:

Add a DB. Only Admins can do this.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| pid | query | The process ID. This is generated by the client. | Yes | string |

##### Body Example

```json
{
"name": "database1",
"admins": [
1,
2
],
"readers": [],
"writers": []
}
```

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The DB was added. |

#### PUT /DBs

##### Summary: Set DB

##### Description:

Set a DB. DB Admins can update their own DBs while Admins can update all DBs.

##### Body Example

```json
{
"ID": 2,
"name": "database1",
"admins": [
1,
2
],
"readers": [],
"writers": []
}
```

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| pid | query | The process ID. This is generated by the client. | Yes | string |

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The DB was set. |

#### DELETE /DBs

##### Summary: Delete DB

##### Description:

Delete a DB. DB Admins can delete their own DBs while Admins can delete any DB.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| pid | query | The process ID. This is generated by the client. | Yes | string |
| ID | query | The DB ID | No | string |
| name | query | The DB name | No | string |

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The DB was deleted |

### /{DB}/query

#### POST /{DB}/query

##### Summary: DB Query

##### Description:

Queries a database.

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| DB | path | The database. | Yes | string |
| pid | query | The process ID. This is generated by the client. | Yes | string |

##### Body Example

```json
{
"query": "SELECT * FROM sqlite_master;",
"params": []
}
```

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | The successful query results. |
| 401 | The login failed for the credentials. |
| 403 | The login failed for the DB. |
| 500 | The server was not able to respond to the query. |
## Wiki
See the Wiki for [HTTP API Documentation](https://github.com/WeWatchWall/stark-db/wiki/HTTP-API-Documentation).

0 comments on commit 4f1dc83

Please sign in to comment.