Skip to content

Commit

Permalink
Support 'GET /api/deprecated-features/used'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Dec 28, 2024
1 parent 9509e85 commit 2712615
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,12 +1176,20 @@ where
// Deprecated Features
//

pub async fn list_deprecated_features(&self) -> Result<DeprecatedFeatureList> {
pub async fn list_all_deprecated_features(&self) -> Result<DeprecatedFeatureList> {
let response = self.http_get("deprecated-features", None, None).await?;
let response = response.json().await?;
Ok(response)
}

pub async fn list_deprecated_features_in_use(&self) -> Result<DeprecatedFeatureList> {
let response = self
.http_get("deprecated-features/used", None, None)
.await?;
let response = response.json().await?;
Ok(response)
}

//
// Implementation
//
Expand Down
8 changes: 7 additions & 1 deletion src/blocking_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,12 +1033,18 @@ where
// Deprecated Features
//

pub fn list_deprecated_features(&self) -> Result<DeprecatedFeatureList> {
pub fn list_all_deprecated_features(&self) -> Result<DeprecatedFeatureList> {
let response = self.http_get("deprecated-features", None, None)?;
let response = response.json()?;
Ok(response)
}

pub fn list_deprecated_features_in_use(&self) -> Result<DeprecatedFeatureList> {
let response = self.http_get("deprecated-features/used", None, None)?;
let response = response.json()?;
Ok(response)
}

//
// OAuth 2 Configuration
//
Expand Down
2 changes: 2 additions & 0 deletions src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,8 @@ pub struct DeprecatedFeature {
#[serde(rename = "desc")]
pub description: String,
pub deprecation_phase: DeprecationPhase,
pub doc_url: String,
pub provided_by: String,
}

impl Display for DeprecatedFeature {
Expand Down
27 changes: 25 additions & 2 deletions tests/deprecated_feature_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use rabbitmq_http_client::blocking_api::Client;
use rabbitmq_http_client::responses::DeprecationPhase;
use rabbitmq_http_client::{blocking_api::Client, commons::QueueType, requests::QueueParams};

mod test_helpers;
use crate::test_helpers::{endpoint, PASSWORD, USERNAME};
Expand All @@ -21,7 +21,7 @@ use crate::test_helpers::{endpoint, PASSWORD, USERNAME};
fn test_list_all_deprecated_features() {
let endpoint = endpoint();
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
let result = rc.list_deprecated_features();
let result = rc.list_all_deprecated_features();

assert!(result.is_ok());
let vec = result.unwrap();
Expand All @@ -30,3 +30,26 @@ fn test_list_all_deprecated_features() {
.into_iter()
.any(|df| df.deprecation_phase == DeprecationPhase::PermittedByDefault));
}

#[test]
fn test_list_deprecated_features_in_use() {
let endpoint = endpoint();
let rc = Client::new(&endpoint, USERNAME, PASSWORD);
let vh = "/";
let q = "test_list_deprecated_features_in_use";

rc.delete_queue(vh, q, true).unwrap();

let params = QueueParams::new(&q, QueueType::Classic, false, false, None);
rc.declare_queue(vh, &params).unwrap();

let result2 = rc.list_deprecated_features_in_use();
assert!(result2.is_ok());
let vec = result2.unwrap();
assert!(vec
.0
.into_iter()
.any(|df| df.deprecation_phase == DeprecationPhase::PermittedByDefault));

rc.delete_queue(vh, q, true).unwrap();
}

0 comments on commit 2712615

Please sign in to comment.