From cb3dc064199e73f8135bdab349db078d7fbcdf1f Mon Sep 17 00:00:00 2001 From: Michael Vlach Date: Wed, 21 Feb 2024 19:02:52 +0100 Subject: [PATCH] [server] Add server cluster configuration #1046 (#1049) * add cluster test * add cluster configuration * fix config * move params around * fix coverage * update ts api --- agdb_api/rust/src/api.rs | 13 +- agdb_api/rust/src/api_types.rs | 22 +- agdb_api/rust/src/http_client.rs | 6 +- agdb_api/rust/src/lib.rs | 2 + agdb_api/typescript/src/schema.d.ts | 2938 +++++++++++---------- agdb_api/typescript/tests/OpenApi.test.ts | 7 + agdb_server/Cargo.toml | 2 +- agdb_server/openapi/schema.json | 49 +- agdb_server/src/api.rs | 2 + agdb_server/src/config.rs | 2 + agdb_server/src/main.rs | 3 +- agdb_server/src/routes.rs | 52 +- agdb_server/tests/routes/misc_routes.rs | 49 + agdb_server/tests/test_server.rs | 32 +- 14 files changed, 1693 insertions(+), 1486 deletions(-) diff --git a/agdb_api/rust/src/api.rs b/agdb_api/rust/src/api.rs index 1e7b763c..673d2fbe 100644 --- a/agdb_api/rust/src/api.rs +++ b/agdb_api/rust/src/api.rs @@ -4,6 +4,7 @@ use crate::api_types::ServerDatabase; use crate::api_types::UserCredentials; use crate::http_client::HttpClient; use crate::ChangePassword; +use crate::ClusterStatus; use crate::DbAudit; use crate::DbUser; use crate::DbUserRole; @@ -425,7 +426,17 @@ impl AgdbApi { } pub async fn status(&self) -> AgdbApiResult { - Ok(self.client.get::<()>(&self.url("/status"), &None).await?.0) + Ok(self + .client + .get::>(&self.url("/status"), &None) + .await? + .0) + } + + pub async fn status_cluster(&self) -> AgdbApiResult<(u16, Vec)> { + self.client + .get(&self.url("/status?cluster=true"), &None) + .await } pub async fn user_login(&mut self, user: &str, password: &str) -> AgdbApiResult { diff --git a/agdb_api/rust/src/api_types.rs b/agdb_api/rust/src/api_types.rs index 32b5f420..84d10ab2 100644 --- a/agdb_api/rust/src/api_types.rs +++ b/agdb_api/rust/src/api_types.rs @@ -42,6 +42,12 @@ pub struct ChangePassword { pub new_password: String, } +#[derive(Debug, Deserialize, Serialize, ToSchema, PartialEq)] +pub struct ClusterStatus { + pub address: String, + pub status: bool, +} + #[derive(Deserialize, ToSchema)] pub struct Queries(pub Vec); @@ -67,6 +73,11 @@ pub struct ServerDatabase { pub backup: u64, } +#[derive(Debug, Deserialize, ToSchema)] +pub struct StatusParams { + pub cluster: Option, +} + #[derive(Deserialize, Serialize, ToSchema)] pub struct UserCredentials { pub password: String, @@ -149,9 +160,8 @@ impl Display for DbUserRole { #[cfg(test)] mod tests { - use agdb::SelectIndexesQuery; - use super::*; + use agdb::SelectIndexesQuery; #[test] fn derived_from_debug() { @@ -189,6 +199,14 @@ mod tests { } ); format!("{:?}", DbAudit(vec![])); + format!( + "{:?}", + ClusterStatus { + address: "localhost".to_string(), + status: true + } + ); + format!("{:?}", StatusParams { cluster: None }); } #[test] diff --git a/agdb_api/rust/src/http_client.rs b/agdb_api/rust/src/http_client.rs index 25a3d0ab..1c2e099c 100644 --- a/agdb_api/rust/src/http_client.rs +++ b/agdb_api/rust/src/http_client.rs @@ -72,11 +72,7 @@ impl HttpClient for ReqwestClient { let response = request.send().await?; let status = response.status().as_u16(); if response.status().is_success() { - let body = if response.content_length().unwrap_or(0) != 0 { - response.json::().await? - } else { - serde_json::from_value(serde_json::Value::default())? - }; + let body = response.json::().await?; Ok((status, body)) } else { Err(AgdbApiError { diff --git a/agdb_api/rust/src/lib.rs b/agdb_api/rust/src/lib.rs index 5e93e322..65ded911 100644 --- a/agdb_api/rust/src/lib.rs +++ b/agdb_api/rust/src/lib.rs @@ -8,6 +8,7 @@ pub use api::AgdbApi; pub use api_error::AgdbApiError; pub use api_result::AgdbApiResult; pub use api_types::ChangePassword; +pub use api_types::ClusterStatus; pub use api_types::DbAudit; pub use api_types::DbType; pub use api_types::DbUser; @@ -16,6 +17,7 @@ pub use api_types::Queries; pub use api_types::QueriesResults; pub use api_types::QueryAudit; pub use api_types::ServerDatabase; +pub use api_types::StatusParams; pub use api_types::UserCredentials; pub use api_types::UserLogin; pub use api_types::UserStatus; diff --git a/agdb_api/typescript/src/schema.d.ts b/agdb_api/typescript/src/schema.d.ts index 3d29e231..448b78b5 100644 --- a/agdb_api/typescript/src/schema.d.ts +++ b/agdb_api/typescript/src/schema.d.ts @@ -1,10 +1,10 @@ import type { - OpenAPIClient, - Parameters, - UnknownParamsObject, - OperationResponse, - AxiosRequestConfig, -} from "openapi-client-axios"; + OpenAPIClient, + Parameters, + UnknownParamsObject, + OperationResponse, + AxiosRequestConfig, +} from 'openapi-client-axios'; declare namespace Components { namespace Schemas { @@ -12,6 +12,10 @@ declare namespace Components { new_password: string; password: string; } + export interface ClusterStatus { + address: string; + status: boolean; + } /** * Comparison of database values ([`DbValue`]) used * by `key()` condition. Supports @@ -22,169 +26,156 @@ declare namespace Components { * however it does not support the `bytes` and integral types * where the "contains" makes little sense (i.e. does 3 contain 1?). */ - export type Comparison = - /** - * Comparison of database values ([`DbValue`]) used - * by `key()` condition. Supports - * the usual set of named comparisons: `==, !=, <, <=, >, =>` - * plus `contains()`. The comparisons are type - * strict except for the `contains` comparison - * which allows vectorized version of the base type. Notably - * however it does not support the `bytes` and integral types - * where the "contains" makes little sense (i.e. does 3 contain 1?). - */ - | { - Equal: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - } - | { - GreaterThan: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - } - | { - GreaterThanOrEqual: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - } - | { - LessThan: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - } - | { - LessThanOrEqual: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - } - | { - NotEqual: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - } - | { - Contains: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - }; + export type Comparison = /** + * Comparison of database values ([`DbValue`]) used + * by `key()` condition. Supports + * the usual set of named comparisons: `==, !=, <, <=, >, =>` + * plus `contains()`. The comparisons are type + * strict except for the `contains` comparison + * which allows vectorized version of the base type. Notably + * however it does not support the `bytes` and integral types + * where the "contains" makes little sense (i.e. does 3 contain 1?). + */ + { + Equal: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + } | { + GreaterThan: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + } | { + GreaterThanOrEqual: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + } | { + LessThan: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + } | { + LessThanOrEqual: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + } | { + NotEqual: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + } | { + Contains: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + }; /** * Comparison of unsigned integers (`u64`) used * by `distance()` and `edge_count*()` conditions. Supports * the usual set of named comparisons: `==, !=, <, <=, >, =>`. */ - export type CountComparison = + export type CountComparison = /** + * Comparison of unsigned integers (`u64`) used + * by `distance()` and `edge_count*()` conditions. Supports + * the usual set of named comparisons: `==, !=, <, <=, >, =>`. + */ + { /** - * Comparison of unsigned integers (`u64`) used - * by `distance()` and `edge_count*()` conditions. Supports - * the usual set of named comparisons: `==, !=, <, <=, >, =>`. + * property == this + */ + Equal: number; // int64 + } | { + /** + * property > this + */ + GreaterThan: number; // int64 + } | { + /** + * property >= this + */ + GreaterThanOrEqual: number; // int64 + } | { + /** + * property < this + */ + LessThan: number; // int64 + } | { + /** + * property <= this + */ + LessThanOrEqual: number; // int64 + } | { + /** + * property != this */ - | { - /** - * property == this - */ - Equal: number; // int64 - } - | { - /** - * property > this - */ - GreaterThan: number; // int64 - } - | { - /** - * property >= this - */ - GreaterThanOrEqual: number; // int64 - } - | { - /** - * property < this - */ - LessThan: number; // int64 - } - | { - /** - * property <= this - */ - LessThanOrEqual: number; // int64 - } - | { - /** - * property != this - */ - NotEqual: number; // int64 - }; + NotEqual: number; // int64 + }; export type DbAudit = QueryAudit[]; /** * Database element used in [`QueryResult`] @@ -245,37 +236,35 @@ declare namespace Components { /** * Ordering for search queries */ - export type DbKeyOrder = /* Ordering for search queries */ - | { - Asc: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - } - | { - Desc: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - }; + export type DbKeyOrder = /* Ordering for search queries */ { + Asc: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + } | { + Desc: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + }; /** * Database key-value pair (aka property) attached to * database elements. It can be constructed from a @@ -333,86 +322,77 @@ declare namespace Components { * Getting the raw value back as string can be done * with `to_string()` but otherwise requires a `match`. */ - export type DbValue = + export type DbValue = /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + { /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. + * Byte array, sometimes referred to as blob */ - | { - /** - * Byte array, sometimes referred to as blob - */ - Bytes: string; // binary - } - | { - /** - * 64-bit wide signed integer - */ - I64: number; // int64 - } - | { - /** - * 64-bit wide unsigned integer - */ - U64: number; // int64 - } - | { - F64: /** - * Database float is a wrapper around `f64` to provide - * functionality like comparison. The comparison is - * using `total_cmp` standard library function. See its - * [docs](https://doc.rust-lang.org/std/primitive.f64.html#method.total_cmp) - * to understand how it handles NaNs and other edge cases - * of floating point numbers. - */ - DbF64 /* double */; - } - | { - /** - * UTF-8 string - */ - String: string; - } - | { - /** - * List of 64-bit wide signed integers - */ - VecI64: number /* int64 */[]; - } - | { - /** - * List of 64-bit wide unsigned integers - */ - VecU64: number /* int64 */[]; - } - | { - /** - * List of 64-bit floating point numbers - */ - VecF64: /** - * Database float is a wrapper around `f64` to provide - * functionality like comparison. The comparison is - * using `total_cmp` standard library function. See its - * [docs](https://doc.rust-lang.org/std/primitive.f64.html#method.total_cmp) - * to understand how it handles NaNs and other edge cases - * of floating point numbers. - */ - DbF64 /* double */[]; - } - | { - /** - * List of UTF-8 strings - */ - VecString: string[]; - }; + Bytes: string; // binary + } | { + /** + * 64-bit wide signed integer + */ + I64: number; // int64 + } | { + /** + * 64-bit wide unsigned integer + */ + U64: number; // int64 + } | { + F64: /** + * Database float is a wrapper around `f64` to provide + * functionality like comparison. The comparison is + * using `total_cmp` standard library function. See its + * [docs](https://doc.rust-lang.org/std/primitive.f64.html#method.total_cmp) + * to understand how it handles NaNs and other edge cases + * of floating point numbers. + */ + DbF64 /* double */; + } | { + /** + * UTF-8 string + */ + String: string; + } | { + /** + * List of 64-bit wide signed integers + */ + VecI64: number /* int64 */[]; + } | { + /** + * List of 64-bit wide unsigned integers + */ + VecU64: number /* int64 */[]; + } | { + /** + * List of 64-bit floating point numbers + */ + VecF64: /** + * Database float is a wrapper around `f64` to provide + * functionality like comparison. The comparison is + * using `total_cmp` standard library function. See its + * [docs](https://doc.rust-lang.org/std/primitive.f64.html#method.total_cmp) + * to understand how it handles NaNs and other edge cases + * of floating point numbers. + */ + DbF64 /* double */[]; + } | { + /** + * List of UTF-8 strings + */ + VecString: string[]; + }; /** * Query to insert or update aliases of existing nodes. * All `ids` must exist. None of the `aliases` can be empty. @@ -481,20 +461,19 @@ declare namespace Components { */ QueryValues; } - export type InsertIndexQuery = - /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; + export type InsertIndexQuery = /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; /** * Query to insert nodes to the database. Only one of * `count`, `values` or `aliases` need to be given as the @@ -549,18 +528,16 @@ declare namespace Components { */ QueryValues; } - export type Queries = - /* Convenience enum for serializing/deserializing queries. */ QueryType[]; - export type QueriesResults = - /** - * Universal database result. Successful - * execution of a query will always yield - * this type. The `result` field is a numerical - * representation of the result while the - * `elements` are the list of `DbElement`s - * with database ids and properties (key-value pairs). - */ - QueryResult[]; + export type Queries = /* Convenience enum for serializing/deserializing queries. */ QueryType[]; + export type QueriesResults = /** + * Universal database result. Successful + * execution of a query will always yield + * this type. The `result` field is a numerical + * representation of the result while the + * `elements` are the list of `DbElement`s + * with database ids and properties (key-value pairs). + */ + QueryResult[]; export interface QueryAudit { query: /* Convenience enum for serializing/deserializing queries. */ QueryType; timestamp: number; // int64 @@ -578,112 +555,102 @@ declare namespace Components { /** * Query condition data */ - export type QueryConditionData = /* Query condition data */ - | { - Distance: /** - * Comparison of unsigned integers (`u64`) used - * by `distance()` and `edge_count*()` conditions. Supports - * the usual set of named comparisons: `==, !=, <, <=, >, =>`. - */ - CountComparison; - } - | "Edge" - | { - EdgeCount: /** - * Comparison of unsigned integers (`u64`) used - * by `distance()` and `edge_count*()` conditions. Supports - * the usual set of named comparisons: `==, !=, <, <=, >, =>`. - */ - CountComparison; - } - | { - EdgeCountFrom: /** - * Comparison of unsigned integers (`u64`) used - * by `distance()` and `edge_count*()` conditions. Supports - * the usual set of named comparisons: `==, !=, <, <=, >, =>`. - */ - CountComparison; - } - | { - EdgeCountTo: /** - * Comparison of unsigned integers (`u64`) used - * by `distance()` and `edge_count*()` conditions. Supports - * the usual set of named comparisons: `==, !=, <, <=, >, =>`. - */ - CountComparison; - } - | { - /** - * Tests if the current id is in the list of ids. - */ - Ids: /** - * Database id used in queries that lets - * you refer to a database element as numerical - * id or a string alias. - */ - QueryId[]; - } - | { - /** - * Tests if the current element has a property `key` - * with a value that evaluates true against `comparison`. - */ - KeyValue: { - key: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - value: /** - * Comparison of database values ([`DbValue`]) used - * by `key()` condition. Supports - * the usual set of named comparisons: `==, !=, <, <=, >, =>` - * plus `contains()`. The comparisons are type - * strict except for the `contains` comparison - * which allows vectorized version of the base type. Notably - * however it does not support the `bytes` and integral types - * where the "contains" makes little sense (i.e. does 3 contain 1?). - */ - Comparison; - }; - } - | { - /** - * Test if the current element has **all** of the keys listed. - */ - Keys: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue[]; - } - | "Node" - | { - /** - * Nested list of conditions (equivalent to brackets). - */ - Where: /** - * Query condition. The condition consists of - * `data`, logic operator and a modifier. - */ - QueryCondition[]; - }; + export type QueryConditionData = /* Query condition data */ { + Distance: /** + * Comparison of unsigned integers (`u64`) used + * by `distance()` and `edge_count*()` conditions. Supports + * the usual set of named comparisons: `==, !=, <, <=, >, =>`. + */ + CountComparison; + } | ("Edge") | { + EdgeCount: /** + * Comparison of unsigned integers (`u64`) used + * by `distance()` and `edge_count*()` conditions. Supports + * the usual set of named comparisons: `==, !=, <, <=, >, =>`. + */ + CountComparison; + } | { + EdgeCountFrom: /** + * Comparison of unsigned integers (`u64`) used + * by `distance()` and `edge_count*()` conditions. Supports + * the usual set of named comparisons: `==, !=, <, <=, >, =>`. + */ + CountComparison; + } | { + EdgeCountTo: /** + * Comparison of unsigned integers (`u64`) used + * by `distance()` and `edge_count*()` conditions. Supports + * the usual set of named comparisons: `==, !=, <, <=, >, =>`. + */ + CountComparison; + } | { + /** + * Tests if the current id is in the list of ids. + */ + Ids: /** + * Database id used in queries that lets + * you refer to a database element as numerical + * id or a string alias. + */ + QueryId[]; + } | { + /** + * Tests if the current element has a property `key` + * with a value that evaluates true against `comparison`. + */ + KeyValue: { + key: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + value: /** + * Comparison of database values ([`DbValue`]) used + * by `key()` condition. Supports + * the usual set of named comparisons: `==, !=, <, <=, >, =>` + * plus `contains()`. The comparisons are type + * strict except for the `contains` comparison + * which allows vectorized version of the base type. Notably + * however it does not support the `bytes` and integral types + * where the "contains" makes little sense (i.e. does 3 contain 1?). + */ + Comparison; + }; + } | { + /** + * Test if the current element has **all** of the keys listed. + */ + Keys: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue[]; + } | ("Node") | { + /** + * Nested list of conditions (equivalent to brackets). + */ + Where: /** + * Query condition. The condition consists of + * `data`, logic operator and a modifier. + */ + QueryCondition[]; + }; /** * Logical operator for query conditions */ @@ -691,38 +658,32 @@ declare namespace Components { /** * Query condition modifier */ - export type QueryConditionModifier = - | "None" - | "Beyond" - | "Not" - | "NotBeyond"; + export type QueryConditionModifier = "None" | "Beyond" | "Not" | "NotBeyond"; /** * Database id used in queries that lets * you refer to a database element as numerical * id or a string alias. */ - export type QueryId = + export type QueryId = /** + * Database id used in queries that lets + * you refer to a database element as numerical + * id or a string alias. + */ + { + Id: /** + * Database id is a wrapper around `i64`. + * The id is an identifier of a database element + * both nodes and edges. The positive ids represent nodes, + * negative ids represent edges. The value of `0` is + * logically invalid (there cannot be element with id 0) and a default. + */ + DbId /* int64 */; + } | { /** - * Database id used in queries that lets - * you refer to a database element as numerical - * id or a string alias. + * String alias */ - | { - Id: /** - * Database id is a wrapper around `i64`. - * The id is an identifier of a database element - * both nodes and edges. The positive ids represent nodes, - * negative ids represent edges. The value of `0` is - * logically invalid (there cannot be element with id 0) and a default. - */ - DbId /* int64 */; - } - | { - /** - * String alias - */ - Alias: string; - }; + Alias: string; + }; /** * List of database ids used in queries. It * can either represent a list of [`QueryId`]s @@ -731,29 +692,27 @@ declare namespace Components { * another query most commonly with the * select queries. */ - export type QueryIds = + export type QueryIds = /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. + */ + { /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. + * List of [`QueryId`]s */ - | { - /** - * List of [`QueryId`]s - */ - Ids: /** - * Database id used in queries that lets - * you refer to a database element as numerical - * id or a string alias. - */ - QueryId[]; - } - | { - Search: /* Query to search for ids in the database following the graph. */ SearchQuery; - }; + Ids: /** + * Database id used in queries that lets + * you refer to a database element as numerical + * id or a string alias. + */ + QueryId[]; + } | { + Search: /* Query to search for ids in the database following the graph. */ SearchQuery; + }; /** * Universal database result. Successful * execution of a query will always yield @@ -780,254 +739,96 @@ declare namespace Components { /** * Convenience enum for serializing/deserializing queries. */ - export type QueryType = - /* Convenience enum for serializing/deserializing queries. */ - | { - InsertAlias: /** - * Query to insert or update aliases of existing nodes. - * All `ids` must exist. None of the `aliases` can be empty. - * If there is an existing alias for any of the elements it - * will be overwritten with a new one. - * - * NOTE: Setting `ids` to a search query will result in an error. - * - * The result will contain number of aliases inserted/updated but no elements. - */ - InsertAliasesQuery; - } - | { - InsertEdges: /** - * Query to inserts edges to the database. The `from` - * and `to` ids must exist in the database. There must be - * enough `values` for all new edges unless set to `Single` - * in which case they will be uniformly applied to all new - * edges. The `each` flag is only useful if `from and `to` are - * symmetric (same length) but you still want to connect every - * origin to every destination. By default it would connect only - * the pairs. For asymmetric inserts `each` is assumed. - * - * The result will contain number of edges inserted and elements with - * their ids but no properties. - */ - InsertEdgesQuery; - } - | { - InsertIndex: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - } - | { - InsertNodes: /** - * Query to insert nodes to the database. Only one of - * `count`, `values` or `aliases` need to be given as the - * implementation will derive the count from the other - * parameters. If `values` is set to `Single` either `count` - * or `aliases` must be provided however. If `values` are not - * set to `Single` there must be enough value for `count/aliases` - * unless they are not se and the count is derived from `values. - * - * The result will contain number of nodes inserted and elements with - * their ids but no properties. - */ - InsertNodesQuery; - } - | { - InsertValues: /** - * Query to insert or update key-value pairs (properties) - * to existing elements in the database. All `ids` must exist - * in the database. If `values` is set to `Single` the properties - * will be inserted uniformly to all `ids` otherwise there must be - * enough `values` for all `ids`. - * - * The result will be number of inserted/update values and no elements. - * - * NOTE: The result is NOT number of affected elements but individual properties. - */ - InsertValuesQuery; - } - | { - Remove: /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. - */ - QueryIds; - } - | { - RemoveAliases: /** - * Query to remove aliases from the database. It - * is not an error if an alias to be removed already - * does not exist. - * - * The result will be a negative number signifying how - * many aliases have been actually removed. - */ - RemoveAliasesQuery; - } - | { - RemoveIndex: /** - * Database value is a strongly types value. - * - * It is an enum of limited number supported types - * that are universal across all platforms - * and programming languages. - * - * The value is constructible from large number of - * raw types or associated types (e.g. i32, &str, etc.). - * Getting the raw value back as string can be done - * with `to_string()` but otherwise requires a `match`. - */ - DbValue; - } - | { - RemoveValues: /** - * Query to select elements with only certain properties of - * given ids. All ids must exist in the database and all - * of them must have the requested properties. - * - * The result will be number of elements and the - * list of elements with the requested properties. - */ - SelectValuesQuery; - } - | { - Search: /* Query to search for ids in the database following the graph. */ SearchQuery; - } - | { - Select: /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. - */ - QueryIds; - } - | { - SelectAliases: /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. - */ - QueryIds; - } - | { - SelectAllAliases: /** - * Query to select all aliases in the database. - * - * The result will be number of returned aliases and list - * of elements with a single property `String("alias")` holding - * the value `String`. - */ - SelectAllAliasesQuery; - } - | { - SelectIndexes: /** - * Query to select all indexes in the database. - * - * The result will be number of returned indexes and single element - * with index 0 and the properties corresponding to the names of the indexes - * (keys) with `u64` values representing number of indexed values in each - * index. - */ - SelectIndexesQuery; - } - | { - SelectKeys: /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. - */ - QueryIds; - } - | { - SelectKeyCount: /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. - */ - QueryIds; - } - | { - SelectValues: /** - * Query to select elements with only certain properties of - * given ids. All ids must exist in the database and all - * of them must have the requested properties. - * - * The result will be number of elements and the - * list of elements with the requested properties. - */ - SelectValuesQuery; - }; - /** - * Helper type distinguishing uniform (`Single`) values - * and multiple (`Multi`) values in database queries. - */ - export type QueryValues = - /** - * Helper type distinguishing uniform (`Single`) values - * and multiple (`Multi`) values in database queries. + export type QueryType = /* Convenience enum for serializing/deserializing queries. */ { + InsertAlias: /** + * Query to insert or update aliases of existing nodes. + * All `ids` must exist. None of the `aliases` can be empty. + * If there is an existing alias for any of the elements it + * will be overwritten with a new one. + * + * NOTE: Setting `ids` to a search query will result in an error. + * + * The result will contain number of aliases inserted/updated but no elements. + */ + InsertAliasesQuery; + } | { + InsertEdges: /** + * Query to inserts edges to the database. The `from` + * and `to` ids must exist in the database. There must be + * enough `values` for all new edges unless set to `Single` + * in which case they will be uniformly applied to all new + * edges. The `each` flag is only useful if `from and `to` are + * symmetric (same length) but you still want to connect every + * origin to every destination. By default it would connect only + * the pairs. For asymmetric inserts `each` is assumed. + * + * The result will contain number of edges inserted and elements with + * their ids but no properties. + */ + InsertEdgesQuery; + } | { + InsertIndex: /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + } | { + InsertNodes: /** + * Query to insert nodes to the database. Only one of + * `count`, `values` or `aliases` need to be given as the + * implementation will derive the count from the other + * parameters. If `values` is set to `Single` either `count` + * or `aliases` must be provided however. If `values` are not + * set to `Single` there must be enough value for `count/aliases` + * unless they are not se and the count is derived from `values. + * + * The result will contain number of nodes inserted and elements with + * their ids but no properties. + */ + InsertNodesQuery; + } | { + InsertValues: /** + * Query to insert or update key-value pairs (properties) + * to existing elements in the database. All `ids` must exist + * in the database. If `values` is set to `Single` the properties + * will be inserted uniformly to all `ids` otherwise there must be + * enough `values` for all `ids`. + * + * The result will be number of inserted/update values and no elements. + * + * NOTE: The result is NOT number of affected elements but individual properties. + */ + InsertValuesQuery; + } | { + Remove: /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. */ - | { - /** - * Single list of properties (key-value pairs) - * to be applied to all elements in a query. - */ - Single: /** - * Database key-value pair (aka property) attached to - * database elements. It can be constructed from a - * tuple of types that are convertible to `DbValue`. - */ - DbKeyValue[]; - } - | { - /** - * List of lists of properties (key-value pairs) - * to be applied to all elements in a query. There - * must be as many lists of properties as ids - * in a query. - */ - Multi: /** - * Database key-value pair (aka property) attached to - * database elements. It can be constructed from a - * tuple of types that are convertible to `DbValue`. - */ - DbKeyValue[][]; - }; - /** - * Query to remove aliases from the database. It - * is not an error if an alias to be removed already - * does not exist. - * - * The result will be a negative number signifying how - * many aliases have been actually removed. - */ - export type RemoveAliasesQuery = string[]; - export type RemoveIndexQuery = - /** + QueryIds; + } | { + RemoveAliases: /** + * Query to remove aliases from the database. It + * is not an error if an alias to be removed already + * does not exist. + * + * The result will be a negative number signifying how + * many aliases have been actually removed. + */ + RemoveAliasesQuery; + } | { + RemoveIndex: /** * Database value is a strongly types value. * * It is an enum of limited number supported types @@ -1040,8 +841,20 @@ declare namespace Components { * with `to_string()` but otherwise requires a `match`. */ DbValue; - export type RemoveQuery = - /** + } | { + RemoveValues: /** + * Query to select elements with only certain properties of + * given ids. All ids must exist in the database and all + * of them must have the requested properties. + * + * The result will be number of elements and the + * list of elements with the requested properties. + */ + SelectValuesQuery; + } | { + Search: /* Query to search for ids in the database following the graph. */ SearchQuery; + } | { + Select: /** * List of database ids used in queries. It * can either represent a list of [`QueryId`]s * or a search query. Search query allows query @@ -1050,8 +863,57 @@ declare namespace Components { * select queries. */ QueryIds; - export type RemoveValuesQuery = - /** + } | { + SelectAliases: /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. + */ + QueryIds; + } | { + SelectAllAliases: /** + * Query to select all aliases in the database. + * + * The result will be number of returned aliases and list + * of elements with a single property `String("alias")` holding + * the value `String`. + */ + SelectAllAliasesQuery; + } | { + SelectIndexes: /** + * Query to select all indexes in the database. + * + * The result will be number of returned indexes and single element + * with index 0 and the properties corresponding to the names of the indexes + * (keys) with `u64` values representing number of indexed values in each + * index. + */ + SelectIndexesQuery; + } | { + SelectKeys: /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. + */ + QueryIds; + } | { + SelectKeyCount: /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. + */ + QueryIds; + } | { + SelectValues: /** * Query to select elements with only certain properties of * given ids. All ids must exist in the database and all * of them must have the requested properties. @@ -1060,6 +922,80 @@ declare namespace Components { * list of elements with the requested properties. */ SelectValuesQuery; + }; + /** + * Helper type distinguishing uniform (`Single`) values + * and multiple (`Multi`) values in database queries. + */ + export type QueryValues = /** + * Helper type distinguishing uniform (`Single`) values + * and multiple (`Multi`) values in database queries. + */ + { + /** + * Single list of properties (key-value pairs) + * to be applied to all elements in a query. + */ + Single: /** + * Database key-value pair (aka property) attached to + * database elements. It can be constructed from a + * tuple of types that are convertible to `DbValue`. + */ + DbKeyValue[]; + } | { + /** + * List of lists of properties (key-value pairs) + * to be applied to all elements in a query. There + * must be as many lists of properties as ids + * in a query. + */ + Multi: /** + * Database key-value pair (aka property) attached to + * database elements. It can be constructed from a + * tuple of types that are convertible to `DbValue`. + */ + DbKeyValue[][]; + }; + /** + * Query to remove aliases from the database. It + * is not an error if an alias to be removed already + * does not exist. + * + * The result will be a negative number signifying how + * many aliases have been actually removed. + */ + export type RemoveAliasesQuery = string[]; + export type RemoveIndexQuery = /** + * Database value is a strongly types value. + * + * It is an enum of limited number supported types + * that are universal across all platforms + * and programming languages. + * + * The value is constructible from large number of + * raw types or associated types (e.g. i32, &str, etc.). + * Getting the raw value back as string can be done + * with `to_string()` but otherwise requires a `match`. + */ + DbValue; + export type RemoveQuery = /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. + */ + QueryIds; + export type RemoveValuesQuery = /** + * Query to select elements with only certain properties of + * given ids. All ids must exist in the database and all + * of them must have the requested properties. + * + * The result will be number of elements and the + * list of elements with the requested properties. + */ + SelectValuesQuery; /** * Query to search for ids in the database following the graph. */ @@ -1104,20 +1040,16 @@ declare namespace Components { /** * Search algorithm to be used */ - export type SearchQueryAlgorithm = - | "BreadthFirst" - | "DepthFirst" - | "Index"; - export type SelectAliasesQuery = - /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. - */ - QueryIds; + export type SearchQueryAlgorithm = "BreadthFirst" | "DepthFirst" | "Index"; + export type SelectAliasesQuery = /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. + */ + QueryIds; /** * Query to select all aliases in the database. * @@ -1125,7 +1057,8 @@ declare namespace Components { * of elements with a single property `String("alias")` holding * the value `String`. */ - export interface SelectAllAliasesQuery {} + export interface SelectAllAliasesQuery { + } /** * Query to select all indexes in the database. * @@ -1134,37 +1067,35 @@ declare namespace Components { * (keys) with `u64` values representing number of indexed values in each * index. */ - export interface SelectIndexesQuery {} - export type SelectKeyCountQuery = - /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. - */ - QueryIds; - export type SelectKeysQuery = - /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. - */ - QueryIds; - export type SelectQuery = - /** - * List of database ids used in queries. It - * can either represent a list of [`QueryId`]s - * or a search query. Search query allows query - * nesting and sourcing the ids dynamically for - * another query most commonly with the - * select queries. - */ - QueryIds; + export interface SelectIndexesQuery { + } + export type SelectKeyCountQuery = /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. + */ + QueryIds; + export type SelectKeysQuery = /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. + */ + QueryIds; + export type SelectQuery = /** + * List of database ids used in queries. It + * can either represent a list of [`QueryId`]s + * or a search query. Search query allows query + * nesting and sourcing the ids dynamically for + * another query most commonly with the + * select queries. + */ + QueryIds; /** * Query to select elements with only certain properties of * given ids. All ids must exist in the database and all @@ -1207,6 +1138,9 @@ declare namespace Components { export interface ServerDatabaseRename { new_name: string; } + export interface StatusParams { + cluster?: boolean | null; + } export interface UserCredentials { password: string; } @@ -1234,10 +1168,14 @@ declare namespace Paths { db_type: Parameters.DbType; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $404 {} - export interface $465 {} + export interface $201 { + } + export interface $401 { + } + export interface $404 { + } + export interface $465 { + } } } namespace AdminDbAudit { @@ -1251,7 +1189,8 @@ declare namespace Paths { } namespace Responses { export type $200 = Components.Schemas.DbAudit; - export interface $401 {} + export interface $401 { + } } } namespace AdminDbBackup { @@ -1264,10 +1203,14 @@ declare namespace Paths { db: Parameters.Db; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $201 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace AdminDbCopy { @@ -1284,11 +1227,16 @@ declare namespace Paths { new_name: Parameters.NewName; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $404 {} - export interface $465 {} - export interface $467 {} + export interface $201 { + } + export interface $401 { + } + export interface $404 { + } + export interface $465 { + } + export interface $467 { + } } } namespace AdminDbDelete { @@ -1301,9 +1249,12 @@ declare namespace Paths { db: Parameters.Db; } namespace Responses { - export interface $204 {} - export interface $401 {} - export interface $404 {} + export interface $204 { + } + export interface $401 { + } + export interface $404 { + } } } namespace AdminDbExec { @@ -1318,15 +1269,19 @@ declare namespace Paths { export type RequestBody = Components.Schemas.Queries; namespace Responses { export type $200 = Components.Schemas.QueriesResults; - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace AdminDbList { namespace Responses { export type $200 = Components.Schemas.ServerDatabase[]; - export interface $401 {} + export interface $401 { + } } } namespace AdminDbOptimize { @@ -1340,7 +1295,8 @@ declare namespace Paths { } namespace Responses { export type $200 = Components.Schemas.ServerDatabase; - export interface $401 {} + export interface $401 { + } } } namespace AdminDbRemove { @@ -1353,9 +1309,12 @@ declare namespace Paths { db: Parameters.Db; } namespace Responses { - export interface $204 {} - export interface $401 {} - export interface $404 {} + export interface $204 { + } + export interface $401 { + } + export interface $404 { + } } } namespace AdminDbRename { @@ -1372,11 +1331,16 @@ declare namespace Paths { new_name: Parameters.NewName; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $404 {} - export interface $465 {} - export interface $467 {} + export interface $201 { + } + export interface $401 { + } + export interface $404 { + } + export interface $465 { + } + export interface $467 { + } } } namespace AdminDbRestore { @@ -1389,9 +1353,12 @@ declare namespace Paths { db: Parameters.Db; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $404 {} + export interface $201 { + } + export interface $401 { + } + export interface $404 { + } } } namespace AdminDbUserAdd { @@ -1410,10 +1377,14 @@ declare namespace Paths { db_role: Parameters.DbRole; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $201 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace AdminDbUserList { @@ -1427,8 +1398,10 @@ declare namespace Paths { } namespace Responses { export type $200 = Components.Schemas.DbUser[]; - export interface $401 {} - export interface $404 {} + export interface $401 { + } + export interface $404 { + } } } namespace AdminDbUserRemove { @@ -1443,16 +1416,22 @@ declare namespace Paths { username: Parameters.Username; } namespace Responses { - export interface $204 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $204 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace AdminShutdown { namespace Responses { - export interface $202 {} - export interface $401 {} + export interface $202 { + } + export interface $401 { + } } } namespace AdminUserAdd { @@ -1464,11 +1443,16 @@ declare namespace Paths { } export type RequestBody = Components.Schemas.UserCredentials; namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $461 {} - export interface $462 {} - export interface $463 {} + export interface $201 { + } + export interface $401 { + } + export interface $461 { + } + export interface $462 { + } + export interface $463 { + } } } namespace AdminUserChangePassword { @@ -1480,16 +1464,21 @@ declare namespace Paths { } export type RequestBody = Components.Schemas.UserCredentials; namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $461 {} - export interface $464 {} + export interface $201 { + } + export interface $401 { + } + export interface $461 { + } + export interface $464 { + } } } namespace AdminUserList { namespace Responses { export type $200 = Components.Schemas.UserStatus[]; - export interface $401 {} + export interface $401 { + } } } namespace AdminUserRemove { @@ -1501,8 +1490,10 @@ declare namespace Paths { } namespace Responses { export type $204 = Components.Schemas.UserStatus[]; - export interface $401 {} - export interface $404 {} + export interface $401 { + } + export interface $404 { + } } } namespace DbAdd { @@ -1519,11 +1510,16 @@ declare namespace Paths { db_type: Parameters.DbType; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $403 {} - export interface $465 {} - export interface $467 {} + export interface $201 { + } + export interface $401 { + } + export interface $403 { + } + export interface $465 { + } + export interface $467 { + } } } namespace DbAudit { @@ -1537,8 +1533,10 @@ declare namespace Paths { } namespace Responses { export type $200 = Components.Schemas.DbAudit; - export interface $401 {} - export interface $404 {} + export interface $401 { + } + export interface $404 { + } } } namespace DbBackup { @@ -1551,10 +1549,14 @@ declare namespace Paths { db: Parameters.Db; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $201 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace DbCopy { @@ -1571,12 +1573,18 @@ declare namespace Paths { new_name: Parameters.NewName; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} - export interface $465 {} - export interface $467 {} + export interface $201 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } + export interface $465 { + } + export interface $467 { + } } } namespace DbDelete { @@ -1589,10 +1597,14 @@ declare namespace Paths { db: Parameters.Db; } namespace Responses { - export interface $204 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $204 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace DbExec { @@ -1607,15 +1619,19 @@ declare namespace Paths { export type RequestBody = Components.Schemas.Queries; namespace Responses { export type $200 = Components.Schemas.QueriesResults; - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace DbList { namespace Responses { export type $200 = Components.Schemas.ServerDatabase[]; - export interface $401 {} + export interface $401 { + } } } namespace DbOptimize { @@ -1629,8 +1645,10 @@ declare namespace Paths { } namespace Responses { export type $200 = Components.Schemas.ServerDatabase; - export interface $401 {} - export interface $403 {} + export interface $401 { + } + export interface $403 { + } } } namespace DbRemove { @@ -1643,10 +1661,14 @@ declare namespace Paths { db: Parameters.Db; } namespace Responses { - export interface $204 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $204 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace DbRename { @@ -1663,12 +1685,18 @@ declare namespace Paths { new_name: Parameters.NewName; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} - export interface $465 {} - export interface $467 {} + export interface $201 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } + export interface $465 { + } + export interface $467 { + } } } namespace DbRestore { @@ -1681,10 +1709,14 @@ declare namespace Paths { db: Parameters.Db; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $201 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace DbUserAdd { @@ -1703,10 +1735,14 @@ declare namespace Paths { db_role: Parameters.DbRole; } namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $201 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace DbUserList { @@ -1719,9 +1755,12 @@ declare namespace Paths { db: Parameters.Db; } namespace Responses { - export interface $200 {} - export interface $401 {} - export interface $404 {} + export interface $200 { + } + export interface $401 { + } + export interface $404 { + } } } namespace DbUserRemove { @@ -1736,749 +1775,728 @@ declare namespace Paths { username: Parameters.Username; } namespace Responses { - export interface $204 {} - export interface $401 {} - export interface $403 {} - export interface $404 {} + export interface $204 { + } + export interface $401 { + } + export interface $403 { + } + export interface $404 { + } } } namespace Status { + namespace Parameters { + export type Cluster = boolean; + } + export interface PathParameters { + cluster: Parameters.Cluster; + } namespace Responses { - export interface $200 {} + export type $200 = Components.Schemas.ClusterStatus[]; } } namespace UserChangePassword { export type RequestBody = Components.Schemas.ChangePassword; namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $461 {} + export interface $201 { + } + export interface $401 { + } + export interface $461 { + } } } namespace UserLogin { export type RequestBody = Components.Schemas.UserLogin; namespace Responses { export type $200 = string; - export interface $401 {} + export interface $401 { + } } } namespace UserLogout { namespace Responses { - export interface $201 {} - export interface $401 {} - export interface $404 {} + export interface $201 { + } + export interface $401 { + } + export interface $404 { + } } } } export interface OperationMethods { + /** + * admin_db_list + */ + 'admin_db_list'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_add + */ + 'admin_db_add'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_audit + */ + 'admin_db_audit'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_backup + */ + 'admin_db_backup'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_copy + */ + 'admin_db_copy'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_delete + */ + 'admin_db_delete'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_exec + */ + 'admin_db_exec'( + parameters?: Parameters | null, + data?: Paths.AdminDbExec.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_optimize + */ + 'admin_db_optimize'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_remove + */ + 'admin_db_remove'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_rename + */ + 'admin_db_rename'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_user_list + */ + 'admin_db_user_list'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_user_add + */ + 'admin_db_user_add'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_user_remove + */ + 'admin_db_user_remove'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_shutdown + */ + 'admin_shutdown'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_user_list + */ + 'admin_user_list'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_user_add + */ + 'admin_user_add'( + parameters?: Parameters | null, + data?: Paths.AdminUserAdd.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_user_change_password + */ + 'admin_user_change_password'( + parameters?: Parameters | null, + data?: Paths.AdminUserChangePassword.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_user_remove + */ + 'admin_user_remove'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * admin_db_restore + */ + 'admin_db_restore'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_list + */ + 'db_list'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_add + */ + 'db_add'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_audit + */ + 'db_audit'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_backup + */ + 'db_backup'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_copy + */ + 'db_copy'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_delete + */ + 'db_delete'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_exec + */ + 'db_exec'( + parameters?: Parameters | null, + data?: Paths.DbExec.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_optimize + */ + 'db_optimize'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_remove + */ + 'db_remove'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_rename + */ + 'db_rename'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_restore + */ + 'db_restore'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_user_list + */ + 'db_user_list'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_user_add + */ + 'db_user_add'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * db_user_remove + */ + 'db_user_remove'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * status + */ + 'status'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + /** + * user_change_password + */ + 'user_change_password'( + parameters?: Parameters | null, + data?: Paths.UserChangePassword.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + /** + * user_login + */ + 'user_login'( + parameters?: Parameters | null, + data?: Paths.UserLogin.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + /** + * user_logout + */ + 'user_logout'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse +} + +export interface PathsDictionary { + ['/api/v1/admin/db/list']: { /** * admin_db_list */ - "admin_db_list"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'get'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/add']: { /** * admin_db_add */ - "admin_db_add"( - parameters?: Parameters< - Paths.AdminDbAdd.QueryParameters & Paths.AdminDbAdd.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/audit']: { /** * admin_db_audit */ - "admin_db_audit"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'get'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/backup']: { /** * admin_db_backup */ - "admin_db_backup"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/copy']: { /** * admin_db_copy */ - "admin_db_copy"( - parameters?: Parameters< - Paths.AdminDbCopy.QueryParameters & Paths.AdminDbCopy.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/delete']: { /** * admin_db_delete */ - "admin_db_delete"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'delete'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/exec']: { /** * admin_db_exec */ - "admin_db_exec"( - parameters?: Parameters | null, - data?: Paths.AdminDbExec.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: Paths.AdminDbExec.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/optimize']: { /** * admin_db_optimize */ - "admin_db_optimize"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/remove']: { /** * admin_db_remove */ - "admin_db_remove"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'delete'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/rename']: { /** * admin_db_rename */ - "admin_db_rename"( - parameters?: Parameters< - Paths.AdminDbRename.QueryParameters & - Paths.AdminDbRename.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/user/list']: { /** * admin_db_user_list */ - "admin_db_user_list"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'get'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/user/{username}/add']: { /** * admin_db_user_add */ - "admin_db_user_add"( - parameters?: Parameters< - Paths.AdminDbUserAdd.QueryParameters & - Paths.AdminDbUserAdd.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'put'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/db/{owner}/{db}/user/{username}/remove']: { /** * admin_db_user_remove */ - "admin_db_user_remove"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'delete'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/shutdown']: { /** * admin_shutdown */ - "admin_shutdown"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/user/list']: { /** * admin_user_list */ - "admin_user_list"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'get'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/user/{username}/add']: { /** * admin_user_add */ - "admin_user_add"( - parameters?: Parameters | null, - data?: Paths.AdminUserAdd.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: Paths.AdminUserAdd.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/user/{username}/change_password']: { /** * admin_user_change_password */ - "admin_user_change_password"( - parameters?: Parameters | null, - data?: Paths.AdminUserChangePassword.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; + 'put'( + parameters?: Parameters | null, + data?: Paths.AdminUserChangePassword.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/admin/user/{username}/remove']: { /** * admin_user_remove */ - "admin_user_remove"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'delete'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/admin/{owner}/{db}/restore']: { /** * admin_db_restore */ - "admin_db_restore"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/list']: { /** * db_list */ - "db_list"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'get'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/add']: { /** * db_add */ - "db_add"( - parameters?: Parameters< - Paths.DbAdd.QueryParameters & Paths.DbAdd.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/audit']: { /** * db_audit */ - "db_audit"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'get'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/backup']: { /** * db_backup */ - "db_backup"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/copy']: { /** * db_copy */ - "db_copy"( - parameters?: Parameters< - Paths.DbCopy.QueryParameters & Paths.DbCopy.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/delete']: { /** * db_delete */ - "db_delete"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/exec']: { /** * db_exec */ - "db_exec"( - parameters?: Parameters | null, - data?: Paths.DbExec.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: Paths.DbExec.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/optimize']: { /** * db_optimize */ - "db_optimize"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/remove']: { /** * db_remove */ - "db_remove"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/rename']: { /** * db_rename */ - "db_rename"( - parameters?: Parameters< - Paths.DbRename.QueryParameters & Paths.DbRename.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/restore']: { /** * db_restore */ - "db_restore"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/user/list']: { /** * db_user_list */ - "db_user_list"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'get'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/user/{username}/add']: { /** * db_user_add */ - "db_user_add"( - parameters?: Parameters< - Paths.DbUserAdd.QueryParameters & Paths.DbUserAdd.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/db/{owner}/{db}/user/{username}/remove']: { /** * db_user_remove */ - "db_user_remove"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/status']: { /** * status */ - "status"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; + 'get'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/user/change_password']: { /** * user_change_password */ - "user_change_password"( - parameters?: Parameters | null, - data?: Paths.UserChangePassword.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; + 'put'( + parameters?: Parameters | null, + data?: Paths.UserChangePassword.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/user/login']: { /** * user_login */ - "user_login"( - parameters?: Parameters | null, - data?: Paths.UserLogin.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; + 'post'( + parameters?: Parameters | null, + data?: Paths.UserLogin.RequestBody, + config?: AxiosRequestConfig + ): OperationResponse + } + ['/api/v1/user/logout']: { /** * user_logout */ - "user_logout"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; -} - -export interface PathsDictionary { - ["/api/v1/admin/db/list"]: { - /** - * admin_db_list - */ - "get"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/add"]: { - /** - * admin_db_add - */ - "post"( - parameters?: Parameters< - Paths.AdminDbAdd.QueryParameters & - Paths.AdminDbAdd.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/audit"]: { - /** - * admin_db_audit - */ - "get"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/backup"]: { - /** - * admin_db_backup - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/copy"]: { - /** - * admin_db_copy - */ - "post"( - parameters?: Parameters< - Paths.AdminDbCopy.QueryParameters & - Paths.AdminDbCopy.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/delete"]: { - /** - * admin_db_delete - */ - "delete"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/exec"]: { - /** - * admin_db_exec - */ - "post"( - parameters?: Parameters | null, - data?: Paths.AdminDbExec.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/optimize"]: { - /** - * admin_db_optimize - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/remove"]: { - /** - * admin_db_remove - */ - "delete"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/rename"]: { - /** - * admin_db_rename - */ - "post"( - parameters?: Parameters< - Paths.AdminDbRename.QueryParameters & - Paths.AdminDbRename.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/user/list"]: { - /** - * admin_db_user_list - */ - "get"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/user/{username}/add"]: { - /** - * admin_db_user_add - */ - "put"( - parameters?: Parameters< - Paths.AdminDbUserAdd.QueryParameters & - Paths.AdminDbUserAdd.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/db/{owner}/{db}/user/{username}/remove"]: { - /** - * admin_db_user_remove - */ - "delete"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/shutdown"]: { - /** - * admin_shutdown - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/user/list"]: { - /** - * admin_user_list - */ - "get"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/user/{username}/add"]: { - /** - * admin_user_add - */ - "post"( - parameters?: Parameters | null, - data?: Paths.AdminUserAdd.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/user/{username}/change_password"]: { - /** - * admin_user_change_password - */ - "put"( - parameters?: Parameters | null, - data?: Paths.AdminUserChangePassword.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/admin/user/{username}/remove"]: { - /** - * admin_user_remove - */ - "delete"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/admin/{owner}/{db}/restore"]: { - /** - * admin_db_restore - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/list"]: { - /** - * db_list - */ - "get"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/add"]: { - /** - * db_add - */ - "post"( - parameters?: Parameters< - Paths.DbAdd.QueryParameters & Paths.DbAdd.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/audit"]: { - /** - * db_audit - */ - "get"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/backup"]: { - /** - * db_backup - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/copy"]: { - /** - * db_copy - */ - "post"( - parameters?: Parameters< - Paths.DbCopy.QueryParameters & Paths.DbCopy.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/delete"]: { - /** - * db_delete - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/exec"]: { - /** - * db_exec - */ - "post"( - parameters?: Parameters | null, - data?: Paths.DbExec.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/optimize"]: { - /** - * db_optimize - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/remove"]: { - /** - * db_remove - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/rename"]: { - /** - * db_rename - */ - "post"( - parameters?: Parameters< - Paths.DbRename.QueryParameters & Paths.DbRename.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/restore"]: { - /** - * db_restore - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/user/list"]: { - /** - * db_user_list - */ - "get"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/user/{username}/add"]: { - /** - * db_user_add - */ - "post"( - parameters?: Parameters< - Paths.DbUserAdd.QueryParameters & Paths.DbUserAdd.PathParameters - > | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/db/{owner}/{db}/user/{username}/remove"]: { - /** - * db_user_remove - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/status"]: { - /** - * status - */ - "get"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/user/change_password"]: { - /** - * user_change_password - */ - "put"( - parameters?: Parameters | null, - data?: Paths.UserChangePassword.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/user/login"]: { - /** - * user_login - */ - "post"( - parameters?: Parameters | null, - data?: Paths.UserLogin.RequestBody, - config?: AxiosRequestConfig, - ): OperationResponse; - }; - ["/api/v1/user/logout"]: { - /** - * user_logout - */ - "post"( - parameters?: Parameters | null, - data?: any, - config?: AxiosRequestConfig, - ): OperationResponse; - }; + 'post'( + parameters?: Parameters | null, + data?: any, + config?: AxiosRequestConfig + ): OperationResponse + } } -export type Client = OpenAPIClient; +export type Client = OpenAPIClient diff --git a/agdb_api/typescript/tests/OpenApi.test.ts b/agdb_api/typescript/tests/OpenApi.test.ts index 08e4368f..9cff9bc5 100644 --- a/agdb_api/typescript/tests/OpenApi.test.ts +++ b/agdb_api/typescript/tests/OpenApi.test.ts @@ -3,6 +3,13 @@ import { describe, expect, it } from "vitest"; import { AgdbApi } from "../src/index"; describe("openapi test", () => { + it("status", async () => { + let client = await AgdbApi.client("http://localhost", 3000); + let res = await client.status({ cluster: true }); + expect(res.status).toEqual(200); + expect(res.data).toEqual([]); + }); + it("insert nodes with edges", async () => { let client = await AgdbApi.client("http://localhost", 3000); let admin_token = await client.user_login(null, { diff --git a/agdb_server/Cargo.toml b/agdb_server/Cargo.toml index 06e330ba..5b9728ba 100644 --- a/agdb_server/Cargo.toml +++ b/agdb_server/Cargo.toml @@ -17,6 +17,7 @@ agdb_api = { version = "0.6.6", path = "../agdb_api/rust", features = ["reqwest" axum = { version = "0.7", features = ["http2"] } axum-extra = { version = "0.9", features = ["typed-header"] } http-body-util = "0.1" +reqwest = { version = "0.11", features = ["json", "blocking"] } ring = "0.17" serde = { version = "1", features = ["derive"] } serde_json = "1" @@ -31,5 +32,4 @@ uuid = { version = "1", features = ["v4"] } [dev-dependencies] assert_cmd = "2" -reqwest = { version = "0.11", features = ["json", "blocking"] } anyhow = "1" diff --git a/agdb_server/openapi/schema.json b/agdb_server/openapi/schema.json index 2f130de5..40db7d39 100644 --- a/agdb_server/openapi/schema.json +++ b/agdb_server/openapi/schema.json @@ -6,7 +6,7 @@ "license": { "name": "Apache-2.0" }, - "version": "0.6.5" + "version": "0.6.6" }, "servers": [ { @@ -1661,9 +1661,30 @@ "crate::routes" ], "operationId": "status", + "parameters": [ + { + "name": "cluster", + "in": "path", + "description": "get cluster status", + "required": true, + "schema": { + "type": "boolean" + } + } + ], "responses": { "200": { - "description": "Server is ready" + "description": "Server is ready", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClusterStatus" + } + } + } + } } } } @@ -1777,6 +1798,21 @@ } } }, + "ClusterStatus": { + "type": "object", + "required": [ + "address", + "status" + ], + "properties": { + "address": { + "type": "string" + }, + "status": { + "type": "boolean" + } + } + }, "Comparison": { "oneOf": [ { @@ -2988,6 +3024,15 @@ } } }, + "StatusParams": { + "type": "object", + "properties": { + "cluster": { + "type": "boolean", + "nullable": true + } + } + }, "UserCredentials": { "type": "object", "required": [ diff --git a/agdb_server/src/api.rs b/agdb_server/src/api.rs index 6a13d2ec..0f20c595 100644 --- a/agdb_server/src/api.rs +++ b/agdb_server/src/api.rs @@ -57,10 +57,12 @@ use utoipa::OpenApi; agdb_api::DbUser, agdb_api::DbUserRole, agdb_api::ChangePassword, + agdb_api::ClusterStatus, agdb_api::Queries, agdb_api::QueriesResults, agdb_api::QueryAudit, agdb_api::ServerDatabase, + agdb_api::StatusParams, agdb_api::UserCredentials, agdb_api::UserLogin, agdb_api::UserStatus, diff --git a/agdb_server/src/config.rs b/agdb_server/src/config.rs index ff14d7dc..f59368b3 100644 --- a/agdb_server/src/config.rs +++ b/agdb_server/src/config.rs @@ -13,6 +13,7 @@ pub(crate) struct ConfigImpl { pub(crate) port: u16, pub(crate) admin: String, pub(crate) data_dir: String, + pub(crate) cluster: Vec, } pub(crate) fn new() -> ServerResult { @@ -25,6 +26,7 @@ pub(crate) fn new() -> ServerResult { port: 3000, admin: "admin".to_string(), data_dir: "agdb_server_data".to_string(), + cluster: vec![], }; std::fs::write(CONFIG_FILE, serde_yaml::to_string(&config)?)?; diff --git a/agdb_server/src/main.rs b/agdb_server/src/main.rs index 31f1dedb..f7ab12fd 100644 --- a/agdb_server/src/main.rs +++ b/agdb_server/src/main.rs @@ -32,10 +32,9 @@ async fn main() -> ServerResult { let config = config::new()?; let db_pool = DbPool::new(&config).await?; let address = format!("{}:{}", config.host, config.port); - let app = app::app(config, shutdown_sender, db_pool); + let app = app::app(config.clone(), shutdown_sender, db_pool); tracing::info!("Listening at {address}"); let listener = tokio::net::TcpListener::bind(address).await?; - axum::serve(listener, app) .with_graceful_shutdown(shutdown_signal(shutdown_receiver)) .await?; diff --git a/agdb_server/src/routes.rs b/agdb_server/src/routes.rs index cdba67a8..45ea1a62 100644 --- a/agdb_server/src/routes.rs +++ b/agdb_server/src/routes.rs @@ -1,17 +1,59 @@ -use axum::http::StatusCode; - pub(crate) mod admin; pub(crate) mod db; pub(crate) mod user; +use crate::config::Config; +use crate::server_error::ServerResult; +use agdb_api::ClusterStatus; +use agdb_api::StatusParams; +use axum::extract::Query; +use axum::extract::State; +use axum::http::StatusCode; +use axum::Json; + #[utoipa::path(get, path = "/api/v1/status", + params( + ("cluster" = bool, description = "get cluster status"), + ), responses( - (status = 200, description = "Server is ready"), + (status = 200, description = "Server is ready", body = Vec), ) )] -pub(crate) async fn status() -> StatusCode { - StatusCode::OK +pub(crate) async fn status( + State(config): State, + Query(status_params): Query, +) -> ServerResult<(StatusCode, Json>)> { + let statuses = if status_params.cluster.unwrap_or_default() { + let mut statuses = Vec::with_capacity(config.cluster.len()); + let client = reqwest::Client::new(); + let local_node = format!("{}:{}", config.host, config.port); + + for node in &config.cluster { + let status = if node == &local_node { + true + } else { + let url = format!("http://{node}/api/v1/status"); + let response = client + .get(&url) + .timeout(std::time::Duration::from_secs(1)) + .send() + .await; + response.is_ok() && response?.status().is_success() + }; + + statuses.push(ClusterStatus { + address: node.clone(), + status, + }); + } + + statuses + } else { + vec![] + }; + + Ok((StatusCode::OK, Json(statuses))) } pub(crate) async fn test_error() -> StatusCode { diff --git a/agdb_server/tests/routes/misc_routes.rs b/agdb_server/tests/routes/misc_routes.rs index e8d47beb..8a53116e 100644 --- a/agdb_server/tests/routes/misc_routes.rs +++ b/agdb_server/tests/routes/misc_routes.rs @@ -1,10 +1,13 @@ use crate::TestServer; use crate::TestServerImpl; use crate::ADMIN; +use crate::HOST; +use crate::SERVER_DATA_DIR; use agdb_api::AgdbApi; use agdb_api::ReqwestClient; use assert_cmd::cargo::CommandCargoExt; use reqwest::StatusCode; +use std::collections::HashMap; use std::process::Command; #[tokio::test] @@ -80,3 +83,49 @@ async fn db_config_reuse() -> anyhow::Result<()> { .spawn()?; Ok(()) } + +#[tokio::test] +async fn db_cluster() -> anyhow::Result<()> { + let port1 = TestServerImpl::next_port(); + let port2 = TestServerImpl::next_port(); + let port3 = TestServerImpl::next_port(); + let cluster = vec![ + format!("{HOST}:{port1}"), + format!("{HOST}:{port2}"), + format!("{HOST}:{port3}"), + ]; + + let mut config1 = HashMap::<&str, serde_yaml::Value>::new(); + config1.insert("host", HOST.into()); + config1.insert("port", port1.into()); + config1.insert("admin", ADMIN.into()); + config1.insert("data_dir", SERVER_DATA_DIR.into()); + config1.insert("cluster", cluster.into()); + + let mut config2 = config1.clone(); + config2.insert("port", port2.into()); + + let mut config3 = config1.clone(); + config3.insert("port", port3.into()); + + let server1 = TestServerImpl::with_config(config1).await?; + let server2 = TestServerImpl::with_config(config2).await?; + let server3 = TestServerImpl::with_config(config3).await?; + + let client1 = AgdbApi::new(ReqwestClient::new(), &TestServer::url_base(), server1.port); + let client2 = AgdbApi::new(ReqwestClient::new(), &TestServer::url_base(), server2.port); + let client3 = AgdbApi::new(ReqwestClient::new(), &TestServer::url_base(), server3.port); + + let status1 = client1.status_cluster().await?; + let status2 = client2.status_cluster().await?; + let status3 = client3.status_cluster().await?; + + assert_eq!(status1.0, 200); + assert_eq!(status2.0, 200); + assert_eq!(status3.0, 200); + + assert_eq!(status1.1, status2.1); + assert_eq!(status1.1, status3.1); + + Ok(()) +} diff --git a/agdb_server/tests/test_server.rs b/agdb_server/tests/test_server.rs index 24a39a38..e62b9537 100644 --- a/agdb_server/tests/test_server.rs +++ b/agdb_server/tests/test_server.rs @@ -45,20 +45,22 @@ struct TestServerImpl { } impl TestServerImpl { - pub async fn new() -> anyhow::Result { - let port = PORT.fetch_add(1, Ordering::Relaxed) + std::process::id() as u16; + pub async fn with_config(mut config: HashMap<&str, serde_yaml::Value>) -> anyhow::Result { + let port = if let Some(port) = config.get("port") { + port.as_u64() + .ok_or_else(|| anyhow!("invalid port: {:?}", port))? as u16 + } else { + let port = Self::next_port(); + config.insert("port", port.into()); + port + }; + let dir = format!("{BINARY}.{port}.test"); let data_dir = format!("{dir}/{SERVER_DATA_DIR}"); Self::remove_dir_if_exists(&dir)?; std::fs::create_dir(&dir)?; - let mut config = HashMap::<&str, serde_yaml::Value>::new(); - config.insert("host", HOST.into()); - config.insert("port", port.into()); - config.insert("admin", ADMIN.into()); - config.insert("data_dir", SERVER_DATA_DIR.into()); - let file = std::fs::File::options() .create_new(true) .write(true) @@ -87,6 +89,20 @@ impl TestServerImpl { anyhow::bail!("Failed to start server") } + pub async fn new() -> anyhow::Result { + let mut config = HashMap::<&str, serde_yaml::Value>::new(); + config.insert("host", HOST.into()); + config.insert("admin", ADMIN.into()); + config.insert("data_dir", SERVER_DATA_DIR.into()); + config.insert("cluster", Vec::::new().into()); + + Self::with_config(config).await + } + + pub fn next_port() -> u16 { + PORT.fetch_add(1, Ordering::Relaxed) + std::process::id() as u16 + } + fn shutdown_server(&mut self) -> anyhow::Result<()> { if self.process.try_wait()?.is_some() { return Ok(());