Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs]: update configuration endpoints #435

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 56 additions & 78 deletions src/reference/torii-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,56 @@ Via this endpoint, the client first provides the starting block number (i.e. hei
sending the confirmation message, the server starts streaming all the blocks from the given block number up to the
current block and continues to stream blocks as they are added to the blockchain.

## Configuration / Retrieve

- **Protocol:** HTTP
- **Method:** `GET`
- **Endpoint:** `/configuration`
- **Responses:** with a JSON-serialized subset of configuration parameters. The subset of returned parameters is equal to
the one accepted by the [Configuration > Update endpoint](#configuration-update), i.e. it only contains the
`logger.level` parameter as of now.

**Example response:**

```json
{
"logger": {
"level": "TRACE"
}
}
```

## Configuration / Update

- **Protocol:** HTTP
- **Method:** `POST`
- **Endpoint:** `/configuration`
- **Expects:** a JSON-serialized subset of configuration parameters.
- **Response:** `202 ACCEPTED`

This endpoint only supports dynamic updating of the `logger.level` parameter for now.

For possible values please refer to the configuration reference (TODO:
[Tracking issue for configuration reference](https://github.com/hyperledger/iroha-2-docs/issues/392)).

**Example request:**

```json
{
"logger": {
"level": "DEBUG"
}
}
```

::: tip Guarantees

A successful configuration update does not guarantee that the configuration is indeed updated. While
consecutive [configuration retrievals](#configuration-retrieve) will return updated values, the actual update is
performed asynchronously.

:::

## Events

- **Protocol:** HTTP
Expand Down Expand Up @@ -140,12 +190,13 @@ Learn [how to use metrics](/guide/advanced/metrics).
results.
- **`sort_by_metadata_key`:** An optional parameter in queries. Use to sort results containing metadata with a given
key.
- **`fetch_size`:** An optional parameter in queries. Use to specify the exact number of results returned by a query.
- **`fetch_size`:** An optional parameter in queries. Use it to specify the exact number of results returned by a
query.

**Responses:**

| Response | Status | Body |
| ---------------- | ------ | ------------------------------------------------------------------------------------------ |
| Response | Status | Body |
| ---------------- | ------ | ------------------------------------------------------------------------------------------------ |
| Success | 200 | [`VersionedBatchedResponse<Value>`](/reference/data-model-schema#versionedbatchedresponse-value) |
| Conversion Error | 400 | [`QueryExecutionFail::Conversion(String)`](/reference/data-model-schema#queryexecutionfail) |
| Evaluate Error | 400 | [`QueryExecutionFail::Evaluate(String)`](/reference/data-model-schema#queryexecutionfail) |
Expand All @@ -158,7 +209,7 @@ Learn [how to use metrics](/guide/advanced/metrics).
Whether each prerequisite object was found and [`FindError`](/reference/data-model-schema#finderror):

| Domain | Account | [`FindError`](/reference/data-model-schema#finderror) |
| :----: | :-----: | ------------------------------------------------------------------- |
| :----: | :-----: | ------------------------------------------------------------------------- |
| N | - | [`FindError::Domain(DomainId)`](/reference/data-model-schema#finderror) |
| Y | N | [`FindError::Account(AccountId)`](/reference/data-model-schema#finderror) |

Expand All @@ -167,7 +218,7 @@ Whether each prerequisite object was found and [`FindError`](/reference/data-mod
Whether each prerequisite object was found and [`FindError`](/reference/data-model-schema#finderror):

| Domain | Account | Asset Definition | Asset | [`FindError`](/reference/data-model-schema#finderror) |
| :----: | :-----: | :--------------: | :---: | ----------------------------------------------------------------------------------- |
| :----: | :-----: | :--------------: | :---: | ----------------------------------------------------------------------------------------- |
| N | - | - | - | [`FindError::Domain(DomainId)`](/reference/data-model-schema#finderror) |
| Y | N | - | - | [`FindError::Account(AccountId)`](/reference/data-model-schema#finderror) |
| Y | - | N | - | [`FindError::AssetDefinition(AssetDefinitionId)`](/reference/data-model-schema#finderror) |
Expand Down Expand Up @@ -209,7 +260,6 @@ struct Uptime {
}
```


::: warning JSON Precision Lost

Almost all fields in the `Status` structure are 64-bit integers, and they are encoded in JSON as-is. Since native JSON's
Expand Down Expand Up @@ -299,75 +349,3 @@ returns the corresponding JSON value.
[GitHub repository](https://github.com/paritytech/parity-scale-codec).

<!--TODO: link to our own article about SCALE https://github.com/hyperledger/iroha-2-docs/issues/367-->

<!-- TODO: edit these endpoints when the decision is made about them (according to the config rfc)

## Get Configuration

- **Protocol:** HTTP
- **Method:** `GET`
- **Endpoint:** `/configuration`

There are 2 possible request bodies and according responses.

### Get Configuration Value as JSON

- **Request Body:**
```json
"Value"
```
- **Responses:**
- `200 OK`: Configuration value as JSON

### Get Documentation of a Field

- **Request Body:**
```json
{
"Docs": ["a", "b", "c"]
}
```
where "a.b.c" is a path of the field (e.g. `sumeragi.block_time_ms`).
- **Responses:**
- `200 OK`: Field was found and either doc or value is returned in json body.
- `404 Not Found`: Field wasn't found

::: tip

If the requested field has more fields inside of it, then all the documentation for its inner members is returned as
well. Here is an example for getting a field `a.b.c`:

**Example:** getting top-level documentation for `Torii` and all the fields within:

```bash
curl -X GET -H 'content-type: application/json' http://127.0.0.1:8080/configuration \
-d '{"Docs" : ["torii"]} ' -i
```

:::

## Configuration

::: warning

TODO: Will change as part of the config RFC

:::

- **Protocol:** HTTP
- **Method:** `POST`
- **Endpoint:** `/configuration`
- **Expects:**
- **Body:** One configuration option is currently supported: `LogLevel`. It is set to the log-level in uppercase.
```json
{
"LogLevel": "WARN"
}
```
Acceptable values are `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`.
- **Responses:**
- `200 OK`: Log level has changed successfully. The confirmed new log level is returned in the body.
- `400 Bad Request`: request body malformed.
- `500 Internal Server Error`: Request body valid, but changing the log level failed (lock contention).

-->