Skip to content
Merged
17 changes: 16 additions & 1 deletion cli/src/clients/admin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use super::errors::ApiError;

/// Min/max supported admin API versions
pub const MIN_ADMIN_API_VERSION: AdminApiVersion = AdminApiVersion::V2;
pub const MAX_ADMIN_API_VERSION: AdminApiVersion = AdminApiVersion::V2;
pub const MAX_ADMIN_API_VERSION: AdminApiVersion = AdminApiVersion::V3;

#[derive(Error, Debug)]
#[error(transparent)]
Expand Down Expand Up @@ -82,6 +82,20 @@ where
Ok(serde_json::from_str(&body)?)
}

pub async fn into_api_error(self) -> Result<ApiError, Error> {
let http_status_code = self.inner.status();
let url = self.inner.url().clone();

debug!("Response from {} ({})", url, http_status_code);
let body = self.inner.text().await?;
debug!(" {}", body);
Ok(ApiError {
http_status_code,
url,
body: serde_json::from_str(&body)?,
})
}

pub async fn into_text(self) -> Result<String, Error> {
Ok(self.inner.text().await?)
}
Expand Down Expand Up @@ -188,6 +202,7 @@ impl AdminClient {
// v1 clusters didn't support versioned urls
AdminApiVersion::V1 => segments.extend(path),
AdminApiVersion::V2 => segments.push("v2").extend(path),
AdminApiVersion::V3 => segments.push("v3").extend(path),
};
}

Expand Down
11 changes: 11 additions & 0 deletions cli/src/clients/admin_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use super::AdminClient;
use super::admin_client::Envelope;
use http::{Uri, Version};
use std::collections::HashMap;

use restate_admin_rest_model::deployments::*;
use restate_admin_rest_model::invocations::RestartAsNewInvocationResponse;
Expand Down Expand Up @@ -182,6 +183,7 @@ pub enum Deployment {
created_at: humantime::Timestamp,
min_protocol_version: i32,
max_protocol_version: i32,
metadata: HashMap<String, String>,
},
Lambda {
arn: LambdaARN,
Expand All @@ -190,6 +192,7 @@ pub enum Deployment {
created_at: humantime::Timestamp,
min_protocol_version: i32,
max_protocol_version: i32,
metadata: HashMap<String, String>,
},
}

Expand All @@ -208,6 +211,7 @@ impl Deployment {
min_protocol_version,
max_protocol_version,
services,
metadata,
..
} => (
id,
Expand All @@ -219,6 +223,7 @@ impl Deployment {
created_at,
min_protocol_version,
max_protocol_version,
metadata,
},
services,
),
Expand All @@ -231,6 +236,7 @@ impl Deployment {
min_protocol_version,
max_protocol_version,
services,
metadata,
..
} => (
id,
Expand All @@ -241,6 +247,7 @@ impl Deployment {
created_at,
min_protocol_version,
max_protocol_version,
metadata,
},
services,
),
Expand All @@ -261,6 +268,7 @@ impl Deployment {
min_protocol_version,
max_protocol_version,
services,
metadata,
..
} => (
id,
Expand All @@ -272,6 +280,7 @@ impl Deployment {
created_at,
min_protocol_version,
max_protocol_version,
metadata,
},
services,
),
Expand All @@ -284,6 +293,7 @@ impl Deployment {
min_protocol_version,
max_protocol_version,
services,
metadata,
..
} => (
id,
Expand All @@ -294,6 +304,7 @@ impl Deployment {
created_at,
min_protocol_version,
max_protocol_version,
metadata,
},
services,
),
Expand Down
4 changes: 2 additions & 2 deletions cli/src/clients/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use crate::console::Styled;

#[derive(Deserialize, Debug, Clone)]
pub struct ApiErrorBody {
restate_code: Option<String>,
message: String,
pub restate_code: Option<String>,
pub message: String,
}

impl From<String> for ApiErrorBody {
Expand Down
Loading
Loading