Skip to content

Commit 8fa53ac

Browse files
Adapt to the latest HTTP API client
1 parent 9b17833 commit 8fa53ac

File tree

6 files changed

+42
-20
lines changed

6 files changed

+42
-20
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use super::tanzu_cli::tanzu_subcommands;
1919
use crate::output::TableStyle;
2020
use clap::{Arg, ArgAction, ArgGroup, Command, value_parser};
2121
use rabbitmq_http_client::commons::{
22-
BindingDestinationType, ExchangeType, PolicyTarget, QueueType, ShovelAcknowledgementMode,
23-
SupportedProtocol,
22+
BindingDestinationType, ExchangeType, MessageTransferAcknowledgementMode, PolicyTarget,
23+
QueueType, SupportedProtocol,
2424
};
2525

2626
pub fn parser() -> Command {
@@ -1468,7 +1468,7 @@ pub fn shovel_subcommands() -> [Command; 4] {
14681468
.long("ack-mode")
14691469
.help("One of: on-confirm, on-publish, no-ack")
14701470
.default_value("on-confirm")
1471-
.value_parser(value_parser!(ShovelAcknowledgementMode)),
1471+
.value_parser(value_parser!(MessageTransferAcknowledgementMode)),
14721472
)
14731473
.arg(
14741474
Arg::new("source_queue")
@@ -1558,7 +1558,7 @@ pub fn shovel_subcommands() -> [Command; 4] {
15581558
.long("ack-mode")
15591559
.help("One of: on-confirm, on-publish, no-ack")
15601560
.default_value("on-confirm")
1561-
.value_parser(value_parser!(ShovelAcknowledgementMode)),
1561+
.value_parser(value_parser!(MessageTransferAcknowledgementMode)),
15621562
)
15631563
.arg(Arg::new("source_address").long("source-address"))
15641564
.arg(Arg::new("destination_address").long("destination-address"))

src/commands.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use rabbitmq_http_client::blocking_api::Client;
1818
use rabbitmq_http_client::blocking_api::Result as ClientResult;
1919
use rabbitmq_http_client::commons;
2020
use rabbitmq_http_client::commons::{ExchangeType, SupportedProtocol};
21+
use rabbitmq_http_client::commons::{MessageTransferAcknowledgementMode, UserLimitTarget};
2122
use rabbitmq_http_client::commons::{PolicyTarget, VirtualHostLimitTarget};
22-
use rabbitmq_http_client::commons::{ShovelAcknowledgementMode, UserLimitTarget};
2323
use rabbitmq_http_client::requests::{
2424
Amqp10ShovelDestinationParams, Amqp10ShovelParams, Amqp10ShovelSourceParams,
2525
Amqp091ShovelDestinationParams, Amqp091ShovelParams, Amqp091ShovelSourceParams,
@@ -210,7 +210,7 @@ pub fn declare_amqp10_shovel(
210210
.unwrap();
211211

212212
let ack_mode = command_args
213-
.get_one::<ShovelAcknowledgementMode>("ack_mode")
213+
.get_one::<MessageTransferAcknowledgementMode>("ack_mode")
214214
.cloned()
215215
.unwrap();
216216
let reconnect_delay = command_args
@@ -256,7 +256,7 @@ pub fn declare_amqp091_shovel(
256256
.unwrap();
257257

258258
let ack_mode = command_args
259-
.get_one::<ShovelAcknowledgementMode>("ack_mode")
259+
.get_one::<MessageTransferAcknowledgementMode>("ack_mode")
260260
.cloned()
261261
.unwrap();
262262
let reconnect_delay = command_args

src/errors.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ pub enum CommandRunError {
7373
ConflictingOptions { message: String },
7474
#[error("{message}")]
7575
MissingOptions { message: String },
76+
#[error("Missing argument value for property (field) {property}")]
77+
MissingArgumentValue { property: String },
7678
#[error("Unsupported argument value for property (field) {property}")]
7779
UnsupportedArgumentValue { property: String },
7880
#[error("This request produces an invalid HTTP header value")]
@@ -93,26 +95,29 @@ impl From<HttpClientError> for CommandRunError {
9395
fn from(value: HttpClientError) -> Self {
9496
match value {
9597
ApiClientError::UnsupportedArgumentValue { property } => {
96-
Self::UnsupportedArgumentValue { property }
97-
}
98+
Self::UnsupportedArgumentValue { property }
99+
}
98100
ApiClientError::ClientErrorResponse { status_code, url, body, headers, .. } => {
99-
Self::ClientError { status_code, url, body, headers }
100-
},
101+
Self::ClientError { status_code, url, body, headers }
102+
},
101103
ApiClientError::ServerErrorResponse { status_code, url, body, headers, .. } => {
102-
Self::ServerError { status_code, url, body, headers }
103-
},
104+
Self::ServerError { status_code, url, body, headers }
105+
},
104106
ApiClientError::HealthCheckFailed { path, details, status_code } => {
105-
Self::HealthCheckFailed { health_check_path: path, details, status_code }
106-
},
107+
Self::HealthCheckFailed { health_check_path: path, details, status_code }
108+
},
107109
ApiClientError::NotFound => Self::NotFound,
108110
ApiClientError::MultipleMatchingBindings => Self::ConflictingOptions {
109-
message: "multiple bindings match, cannot determine which binding to delete without explicitly provided binding properties".to_owned()
110-
},
111+
message: "multiple bindings match, cannot determine which binding to delete without explicitly provided binding properties".to_owned()
112+
},
111113
ApiClientError::InvalidHeaderValue { error } => {
112-
Self::InvalidHeaderValue { error }
113-
},
114+
Self::InvalidHeaderValue { error }
115+
},
114116
ApiClientError::RequestError { error, .. } => Self::RequestError { error },
115117
ApiClientError::Other => Self::Other,
118+
ApiClientError::MissingProperty { argument } => {
119+
Self::MissingArgumentValue { property: argument }
120+
},
116121
}
117122
}
118123
}

src/output.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ impl<'a> ResultHandler<'a> {
387387
// We cannot implement From<T> for two types in other crates, so…
388388
pub(crate) fn client_error_to_exit_code(error: &HttpClientError) -> ExitCode {
389389
match error {
390+
ClientError::MissingProperty { .. } => ExitCode::DataErr,
390391
ClientError::UnsupportedArgumentValue { .. } => ExitCode::DataErr,
391392
ClientError::ClientErrorResponse { .. } => ExitCode::DataErr,
392393
ClientError::ServerErrorResponse { .. } => ExitCode::Unavailable,

src/tables.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,22 @@ pub fn schema_definition_sync_status(status: SchemaDefinitionSyncStatus) -> Tabl
252252

253253
pub fn failure_details(error: &HttpClientError) -> Table {
254254
match error {
255+
HttpClientError::MissingProperty { argument } => {
256+
let message = format!("Missing value for property (field) {}", argument);
257+
let data = vec![
258+
RowOfTwo {
259+
key: "result",
260+
value: "request was not executed",
261+
},
262+
RowOfTwo {
263+
key: "message",
264+
value: &message,
265+
},
266+
];
267+
268+
let tb = Table::builder(data);
269+
tb.build()
270+
}
255271
HttpClientError::UnsupportedArgumentValue { property } => {
256272
let message = format!(
257273
"Unsupported argument value for property (field) {}",

0 commit comments

Comments
 (0)