-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c229b00
commit 12d10e7
Showing
3 changed files
with
417 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod audit_log; | ||
pub mod param_types; | ||
pub mod parameter; | ||
pub mod profile; | ||
pub mod template; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use std::ops::{Deref, DerefMut}; | ||
|
||
use serde::Deserialize; | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub struct ParamTypesListRoot<T> { | ||
#[serde(rename = "parameter-type")] | ||
parameter_type: ParamTypesList<T>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
pub struct ParamTypesList<T>(Vec<T>); | ||
|
||
impl<T> Deref for ParamTypesList<T> { | ||
type Target = Vec<T>; | ||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl<T> DerefMut for ParamTypesList<T> { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct ParamTypeEntry { | ||
pub description: String, | ||
pub name: String, | ||
pub parent: String, | ||
pub rules: String, | ||
#[serde(rename = "Created At")] | ||
pub created_at: Option<String>, | ||
#[serde(rename = "Modified At")] | ||
pub modified_at: Option<String>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct ConstraintEntry { | ||
pub constraint: String, | ||
pub name: String, | ||
pub parent: String, | ||
#[serde(rename = "Rule Type")] | ||
pub rule_type: String, | ||
#[serde(rename = "Created At")] | ||
pub created_at: Option<String>, | ||
#[serde(rename = "Modified At")] | ||
pub modified_at: Option<String>, | ||
} | ||
|
||
pub trait ParseParamTypesExt { | ||
fn parse_param_types_list(&self) -> ParamTypesList<ParamTypeEntry>; | ||
fn parse_param_types_list_with_rules(&self) -> ParamTypesList<ConstraintEntry>; | ||
} | ||
|
||
impl ParseParamTypesExt for assert_cmd::assert::Assert { | ||
fn parse_param_types_list(&self) -> ParamTypesList<ParamTypeEntry> { | ||
serde_json::from_slice::<ParamTypesListRoot<ParamTypeEntry>>(&self.get_output().stdout) | ||
.expect("Unable to parse JSON as param types list") | ||
.parameter_type | ||
} | ||
fn parse_param_types_list_with_rules(&self) -> ParamTypesList<ConstraintEntry> { | ||
serde_json::from_slice::<ParamTypesListRoot<ConstraintEntry>>(&self.get_output().stdout) | ||
.expect("Unable to parse JSON as param types list") | ||
.parameter_type | ||
} | ||
} |
Oops, something went wrong.