Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[server] Add db user actions to cluster #1396 #1398

Merged
merged 12 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agdb/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use crate::{
#[cfg(any(feature = "serde", feature = "openapi"))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
#[expect(clippy::large_enum_variant)]
pub enum QueryType {
InsertAlias(InsertAliasesQuery),
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/insert_aliases_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::StorageData;
/// The result will contain number of aliases inserted/updated but no elements.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct InsertAliasesQuery {
/// Ids to be aliased
pub ids: QueryIds,
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/insert_edges_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::StorageData;
/// with their ids, origin and destination, but no properties.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct InsertEdgesQuery {
/// Origins
pub from: QueryIds,
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/insert_index_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::StorageData;
/// a given key.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct InsertIndexQuery(pub DbValue);

impl QueryMut for InsertIndexQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/insert_nodes_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::StorageData;
/// with their ids but no properties.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct InsertNodesQuery {
/// Number of nodes to be inserted.
pub count: u64,
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/insert_values_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::StorageData;
/// NOTE: The result is NOT number of affected elements but individual properties.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct InsertValuesQuery {
/// Ids whose properties should be updated
pub ids: QueryIds,
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/query_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::DbUserValue;
/// and multiple (`Multi`) values in database queries.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub enum QueryValues {
/// Single list of properties (key-value pairs)
/// to be applied to all elements in a query.
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/remove_aliases_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::StorageData;
/// many aliases have been actually removed.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct RemoveAliasesQuery(pub Vec<String>);

impl QueryMut for RemoveAliasesQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/remove_index_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::StorageData;
/// a given key.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct RemoveIndexQuery(pub DbValue);

impl QueryMut for RemoveIndexQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/remove_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::StorageData;
/// also removed along with their properties.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct RemoveQuery(pub QueryIds);

impl QueryMut for RemoveQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/remove_values_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::StorageData;
/// do not exist on any of the elements).
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct RemoveValuesQuery(pub SelectValuesQuery);

impl QueryMut for RemoveValuesQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/select_aliases_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::StorageData;
/// the value `String`.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct SelectAliasesQuery(pub QueryIds);

impl Query for SelectAliasesQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/select_all_aliases_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::StorageData;
/// the value `String`.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct SelectAllAliasesQuery {}

impl Query for SelectAllAliasesQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/select_edge_count_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::StorageData;
/// might be greater than number of unique db elements.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct SelectEdgeCountQuery {
/// Ids of the nodes to select edge count for.
pub ids: QueryIds,
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/select_indexes_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::StorageData;
/// index.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct SelectIndexesQuery {}

impl Query for SelectIndexesQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/select_key_count_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::StorageData;
/// a value `u64`.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct SelectKeyCountQuery(pub QueryIds);

impl Query for SelectKeyCountQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/select_keys_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::StorageData;
/// of elements with all properties except all values will be empty.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct SelectKeysQuery(pub QueryIds);

impl Query for SelectKeysQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/select_node_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::StorageData;
/// a value `u64` represneting number of nodes in teh database.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct SelectNodeCountQuery {}

impl Query for SelectNodeCountQuery {
Expand Down
2 changes: 1 addition & 1 deletion agdb/src/query/select_values_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::StorageData;
/// list of elements with the requested properties.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
pub struct SelectValuesQuery {
pub keys: Vec<DbValue>,
pub ids: QueryIds,
Expand Down
Binary file added agdb/storage2
Binary file not shown.
2 changes: 1 addition & 1 deletion agdb_api/rust/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<T: HttpClient> AgdbApi<T> {
&self,
owner: &str,
db: &str,
queries: &Vec<QueryType>,
queries: &[QueryType],
) -> AgdbApiResult<(u16, Vec<QueryResult>)> {
self.client
.post(
Expand Down
36 changes: 30 additions & 6 deletions agdb_api/rust/src/api_types.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use std::fmt::Display;

use agdb::DbError;
use agdb::DbValue;
use agdb::QueryResult;
use agdb::QueryType;
use serde::Deserialize;
use serde::Serialize;
use std::fmt::Display;
use utoipa::ToSchema;

#[derive(
Expand Down Expand Up @@ -70,7 +69,7 @@ pub struct AdminStatus {
pub size: u64,
}

#[derive(Deserialize, ToSchema)]
#[derive(Clone, Deserialize, Serialize, ToSchema)]
pub struct Queries(pub Vec<QueryType>);

#[derive(Serialize, ToSchema)]
Expand Down Expand Up @@ -116,9 +115,20 @@ pub struct UserStatus {
impl From<&str> for DbType {
fn from(value: &str) -> Self {
match value {
"mapped" => DbType::Mapped,
"file" => DbType::File,
_ => DbType::Memory,
"mapped" => Self::Mapped,
"file" => Self::File,
_ => Self::Memory,
}
}
}

impl From<&str> for DbResource {
fn from(value: &str) -> Self {
match value {
"db" => Self::Db,
"audit" => Self::Audit,
"backup" => Self::Backup,
_ => Self::All,
}
}
}
Expand All @@ -131,12 +141,26 @@ impl TryFrom<DbValue> for DbType {
}
}

impl TryFrom<DbValue> for DbResource {
type Error = DbError;

fn try_from(value: DbValue) -> Result<Self, Self::Error> {
Ok(Self::from(value.to_string().as_str()))
}
}

impl From<DbType> for DbValue {
fn from(value: DbType) -> Self {
value.to_string().into()
}
}

impl From<DbResource> for DbValue {
fn from(value: DbResource) -> Self {
value.to_string().into()
}
}

impl Display for DbType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand Down
94 changes: 93 additions & 1 deletion agdb_server/openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading