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

feat(rust): implemented control api http server #8776

Merged
merged 6 commits into from
Feb 14, 2025
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
28 changes: 28 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,8 @@ This file contains attributions for any 3rd-party open source code used in this
| utf16_iter | Apache-2.0, MIT | https://crates.io/crates/utf16_iter |
| utf8_iter | Apache-2.0, MIT | https://crates.io/crates/utf8_iter |
| utf8parse | Apache-2.0, MIT | https://crates.io/crates/utf8parse |
| utoipa | MIT, Apache-2.0 | https://crates.io/crates/utoipa |
| utoipa-gen | MIT, Apache-2.0 | https://crates.io/crates/utoipa-gen |
| uuid | Apache-2.0, MIT | https://crates.io/crates/uuid |
| value-bag | Apache-2.0, MIT | https://crates.io/crates/value-bag |
| vcell | MIT, Apache-2.0 | https://crates.io/crates/vcell |
Expand Down
2 changes: 1 addition & 1 deletion implementations/rust/ockam/ockam_abac/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl std::error::Error for EvalError {
impl From<ParseError> for ockam_core::Error {
#[track_caller]
fn from(e: ParseError) -> Self {
ockam_core::Error::new(Origin::Application, Kind::Invalid, e.to_string())
ockam_core::Error::new(Origin::Application, Kind::Parse, e.to_string())
}
}

Expand Down
8 changes: 8 additions & 0 deletions implementations/rust/ockam/ockam_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ aws-lc = ["ockam_vault/aws-lc", "ockam_transport_tcp/aws-lc"]
rust-crypto = ["ockam_vault/rust-crypto", "ockam_transport_tcp/ring"]
privileged_portals = ["ockam_transport_tcp/privileged_portals"]

[[bin]]
name = "node_control_api_schema"
path = "src/control_api/exporter.rs"

[build-dependencies]
cfg_aliases = "0.2.1"

Expand All @@ -63,6 +67,7 @@ futures = { version = "0.3.30", features = [] }
gethostname = "0.5.0"
hex = { version = "0.4.3", default-features = false, features = ["alloc", "serde"] }
home = "0.5"
http = "1"
http-body-util = "0"
httparse = "1.9.5"
hyper = { version = "1", default-features = false, features = ["server", "http1"] }
Expand Down Expand Up @@ -99,6 +104,7 @@ sqlx = { version = "0.8.3", default-features = false }
sqlx-core = { version = "0.8.3", default-features = false }
strip-ansi-escapes = "0.2"
strum = { version = "0.26.3", default-features = false, features = ["derive"] }
subtle = "2"
syntect = { version = "5.2.0", default-features = false, features = ["default-syntaxes", "regex-onig"] }
sysinfo = "0.32"
termbg = "0.5.2"
Expand All @@ -114,6 +120,7 @@ tracing-error = "0.2.0"
tracing-opentelemetry = "0.27.0"
tracing-subscriber = { version = "0.3", features = ["json"] }
url = "2.5.2"
utoipa = { version = "^5.3", features = ["yaml"] }

ockam_multiaddr = { path = "../ockam_multiaddr", version = "0.69.0", features = ["cbor", "serde"] }
ockam_transport_core = { path = "../ockam_transport_core", version = "^0.101.0" }
Expand Down Expand Up @@ -160,6 +167,7 @@ default-features = false
[dev-dependencies]
cddl-cat = "0.6.1"
hex = "0.4.3"
hyper = { version = "1", default-features = false, features = ["server", "http1", "client"] }
multimap = "0.10.0"
ockam_macros = { path = "../ockam_macros", features = ["std"], version = "^0.37.0" }
ockam_transport_core = { path = "../ockam_transport_core", version = "^0.101.0" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ pub trait Members {
async fn show_member(
&self,
ctx: &Context,
identifier: Identifier,
identifier: &Identifier,
) -> miette::Result<AttributesEntry>;

async fn delete_all_members(&self, ctx: &Context) -> miette::Result<()>;
async fn delete_member(&self, ctx: &Context, identifier: Identifier) -> miette::Result<()>;
async fn delete_member(&self, ctx: &Context, identifier: &Identifier) -> miette::Result<()>;

async fn list_member_ids(&self, ctx: &Context) -> miette::Result<Vec<Identifier>>;

Expand Down Expand Up @@ -57,7 +57,7 @@ impl Members for AuthorityNodeClient {
async fn show_member(
&self,
ctx: &Context,
identifier: Identifier,
identifier: &Identifier,
) -> miette::Result<AttributesEntry> {
let req = Request::get(format!("/{identifier}"));
self.get_secure_client()
Expand All @@ -78,7 +78,7 @@ impl Members for AuthorityNodeClient {
.into_diagnostic()
}

async fn delete_member(&self, ctx: &Context, identifier: Identifier) -> miette::Result<()> {
async fn delete_member(&self, ctx: &Context, identifier: &Identifier) -> miette::Result<()> {
let req = Request::delete(format!("/{identifier}"));
self.get_secure_client()
.tell(ctx, DefaultAddress::DIRECT_AUTHENTICATOR, req)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ mod tests {
member: &Identifier,
attribute_key: &str,
) -> Result<Option<String>> {
let attributes_entry = client.show_member(ctx, member.clone()).await.unwrap();
let attributes_entry = client.show_member(ctx, member).await.unwrap();
Ok(attributes_entry
.attrs()
.get(&attribute_key.as_bytes().to_vec())
Expand Down
Loading
Loading