# Updates

Signed bundles: upload, import, apply with a health check, roll back and commit. Aegis Core API, `UpdatesService`: 6 operations, generated from the OpenAPI document of Aegis Core 0.13.0.

## Get updates

`GET /v1/sys/updates`

The running release, the installation, the directives in force, the forced minimums and the algorithms whose new protective use they restrict.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.UpdatesService/GetUpdates`

Response `200` (`application/json`): [UpdatesStatus](#schema-updatesstatus)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Apply release

`POST /v1/sys/updates/apply`

Applies an imported release after a verified backup and the configured health check; a failed check goes back by itself. The daemon runs the new release once its service restarts.

- Role: `admin` or higher
- gRPC: `/aegis.v1.UpdatesService/ApplyRelease`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `version` | string | Its version. |

Response `200` (`application/json`): [UpdateResult](#schema-updateresult)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Commit release

`POST /v1/sys/updates/commit`

Commits the current release: ends its soak and prunes old releases, as `aegis update commit`.

- Role: `admin` or higher
- gRPC: `/aegis.v1.UpdatesService/CommitRelease`

Response `200` (`application/json`): [UpdateResult](#schema-updateresult)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Import bundle

`POST /v1/sys/updates/import`

Imports an uploaded bundle into the installation, as `aegis update import` does.

- Role: `admin` or higher
- gRPC: `/aegis.v1.UpdatesService/ImportBundle`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `bundle` | string | Its SHA2-256, as the upload named it. |

Response `200` (`application/json`): [ImportedBundle](#schema-importedbundle)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Rollback release

`POST /v1/sys/updates/rollback`

Rolls back to the previous release, or to one named, above the signed floor.

- Role: `admin` or higher
- gRPC: `/aegis.v1.UpdatesService/RollbackRelease`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `to` | string, nullable | The release to go back to; the previous one when absent. |

Response `200` (`application/json`): [UpdateResult](#schema-updateresult)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Upload bundle

`POST /v1/sys/updates/upload`

Uploads a bundle file and verifies it against the installation's trusted root without changing anything; it is kept, under its SHA2-256, only if it verifies. Over REST the body is streamed to disk up to the daemon's upload limit; a gRPC message is limited to 768 KiB, so larger bundles go over REST or `aegis update import` on the host.

- Role: `admin` or higher
- gRPC: `/aegis.v1.UpdatesService/UploadBundle`

Request body, required (`application/octet-stream`): string

Response `200` (`application/json`): [UploadedBundle](#schema-uploadedbundle)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Schemas

### ImportedBundle

A bundle imported.

| Field | Type | Description |
| --- | --- | --- |
| `imported` | [ImportOutcome](#schema-importoutcome), nullable | What the import did. |
| `status` | [UpdatesStatus](#schema-updatesstatus), nullable | The installation now. |

### UpdateResult

The outcome of an apply, a rollback or a commit.

| Field | Type | Description |
| --- | --- | --- |
| `result` | string | The outcome in a sentence. |
| `status` | [UpdatesStatus](#schema-updatesstatus), nullable | The installation now. |

### UpdatesStatus

The installation, its directives and the restrictions in force.

| Field | Type | Description |
| --- | --- | --- |
| `can_apply` | boolean | Whether the console may apply and roll back (a health check is configured). |
| `core_version` | string | The release running. |
| `directives` | [Directives](#schema-directives), nullable | The signed directives in force, if any. |
| `directives_error` | string, nullable | Why the directives file was refused, if it was; the restrictions already in force stay. |
| `installation` | [Installation](#schema-installation), nullable | The installation, when the daemon runs from one (`--install-root`). |
| `managed` | boolean | Whether the daemon runs from an installation. |
| `minimums` | array of [ForcedMinimum](#schema-forcedminimum) | The forced minimums and where each stands. |
| `modules` | array of [ModuleReport](#schema-modulereport) | The algorithm modules started from their own installations (DLV-007). |
| `restrictions` | map of string to string | The algorithms whose new protective use is restricted, each with the reason. |
| `uploads` | array of [UploadSummary](#schema-uploadsummary) | Bundles uploaded and verified, waiting for import. |

### UploadedBundle

A bundle uploaded and verified.

| Field | Type | Description |
| --- | --- | --- |
| `bundle` | string | Its SHA2-256, which names it for the import. |
| `length` | integer (int64) | Its length in bytes. |
| `report` | [BundleReport](#schema-bundlereport), nullable | What the verification found. |

### ImportOutcome

What an import did.

| Field | Type | Description |
| --- | --- | --- |
| `advisory` | boolean | Whether it was an advisory bundle: directives only, no release. |
| `already` | boolean | Whether it had been imported before, so nothing changed. |
| `directives` | integer (int64), nullable | The version of the directives kept, when the bundle carried newer ones. |
| `files` | integer (int64) | Files installed. |
| `text` | string | The outcome in a sentence. |
| `version` | string | The release. |

### Directives

Signed directives (ADR 0024, section 2).

| Field | Type | Description |
| --- | --- | --- |
| `exceptions` | array of [DirectiveException](#schema-directiveexception) | Releases below the floor allowed by name. |
| `expires` | integer (int64) | When they expire. |
| `floor` | string, nullable | The signed floor: no release below it may be installed or run. |
| `issued` | integer (int64) | When they were issued, in seconds since the Unix epoch. |
| `product` | string | The product they are for. |
| `revoked` | array of [DirectiveRevocation](#schema-directiverevocation) | Releases revoked. |
| `version` | integer (int64) | Their version; a newer file has a higher one and an older one is refused. |

### ForcedMinimum

A forced minimum: until the component reaches it, new protective use of what it names is restricted; nothing that exists stops working (DLV-006).

| Field | Type | Description |
| --- | --- | --- |
| `affects` | array of string | The algorithms it restricts. |
| `component` | string | The component: `core` or a module. |
| `grace_until` | integer (int64) | When the restriction starts, in seconds since the Unix epoch. |
| `id` | string | Its identifier. |
| `installed` | string, nullable | The release of the component installed, if known. |
| `minimum` | string | The release that fixes it. |
| `reason` | string | Why. |
| `state` | string | `met`, `warning` (in its grace), `restricting` or `not-installed`. |

### Installation

An installation of side-by-side releases.

| Field | Type | Description |
| --- | --- | --- |
| `busy` | boolean | Whether another process holds the installation. |
| `committed` | string, nullable | The last release committed. |
| `current` | string, nullable | The release linked as current. |
| `current_standing` | [ReleaseStanding](#schema-releasestanding), nullable | Where the current release stands under the directives. |
| `directives_error` | string, nullable | Why the installation's directives could not be read, if they could not. |
| `error` | string, nullable | Why the installation could not be read, if it could not. |
| `floor` | string, nullable | The local floor: the lowest release a rollback may reach. |
| `previous` | string, nullable | The release before it. |
| `releases` | array of [InstalledRelease](#schema-installedrelease) | The releases installed. |
| `transition` | [Transition](#schema-transition), nullable | A switch in flight, if any. |

### ModuleReport

An algorithm module installed on its own (DLV-007, ADR 0024, section 4).

| Field | Type | Description |
| --- | --- | --- |
| `limited` | string, nullable | Why it is limited. |
| `name` | string | The module. |
| `protocol` | integer (int64), nullable | The provider protocol it speaks. |
| `provider` | string, nullable | The provider it runs. |
| `reason` | string, nullable | Why it was refused. |
| `requires_core` | string, nullable | The core releases it supports, as a version range. |
| `root` | string | Its installation's directory. |
| `sha256` | string, nullable | The SHA2-256 of the binary started. |
| `state` | string | `running`, `limited` (revoked, not as malicious: new protection refused) or `refused`. |
| `version` | string, nullable | Its release. |

### UploadSummary

A bundle waiting for import.

| Field | Type | Description |
| --- | --- | --- |
| `bundle` | string | Its SHA2-256. |
| `created` | integer (int64) | When it was made. |
| `directives` | boolean | Whether it carries signed directives. |
| `files` | integer (int64) | The files it installs. |
| `kind` | string | `full`, `module` or `advisory`. |
| `length` | integer (int64) | Its length in bytes. |
| `product` | string | The product. |
| `version` | string | The release. |

### BundleReport

What a bundle's verification found.

| Field | Type | Description |
| --- | --- | --- |
| `created` | integer (int64) | When it was made, in seconds since the Unix epoch. |
| `directives` | boolean | Whether it carries signed directives. |
| `files` | array of [BundleFile](#schema-bundlefile) | The files it installs. |
| `kind` | string | `full`, `module` or `advisory`. |
| `members` | integer (int64) | Its members. |
| `product` | string | The product. |
| `root` | [RoleVersion](#schema-roleversion), nullable | The root metadata's version and expiry. |
| `snapshot` | [RoleVersion](#schema-roleversion), nullable | The snapshot metadata's. |
| `targets` | [RoleVersion](#schema-roleversion), nullable | The targets metadata's. |
| `timestamp` | [RoleVersion](#schema-roleversion), nullable | The timestamp metadata's. |
| `version` | string | The release. |

### DirectiveException

A release allowed below the floor.

| Field | Type | Description |
| --- | --- | --- |
| `reason` | string | Why. |
| `release` | string | The release. |

### DirectiveRevocation

A release revoked.

| Field | Type | Description |
| --- | --- | --- |
| `malicious` | boolean | Whether it is revoked as malicious: it is then refused outright. |
| `reason` | string | Why. |
| `release` | string | The release. |

### InstalledRelease

A release installed.

| Field | Type | Description |
| --- | --- | --- |
| `pinned` | boolean | Whether it is kept whatever the clean-up. |
| `standing` | [ReleaseStanding](#schema-releasestanding), nullable | Where it stands under the directives. |
| `version` | string | Its version. |

### ReleaseStanding

Where a release stands under the signed directives.

| Field | Type | Description |
| --- | --- | --- |
| `detail` | string | Why, in a sentence. |
| `state` | string | `allowed`, `excepted`, `below-floor`, `revoked` or `revoked-malicious`. |

### Transition

A switch between releases in flight.

| Field | Type | Description |
| --- | --- | --- |
| `kind` | string | `apply` or `rollback`. |
| `step` | string | The step reached. |
| `to` | string | The release it goes to. |

### BundleFile

A file of a bundle.

| Field | Type | Description |
| --- | --- | --- |
| `length` | integer (int64) | Its length in bytes. |
| `path` | string | Where it goes in the release. |
| `sha2_256` | string | Its SHA2-256. |

### RoleVersion

A metadata role's version and expiry.

| Field | Type | Description |
| --- | --- | --- |
| `expires` | integer (int64) | When it expires, in seconds since the Unix epoch. |
| `version` | integer (int64) | The version. |
