|
|
@ -21,9 +21,7 @@ impl Endpoint for CleanTags {
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
|
|
pub struct AddTagsRequest {
|
|
|
|
pub struct AddTagsRequest {
|
|
|
|
pub hashes: Vec<String>,
|
|
|
|
pub hashes: Vec<String>,
|
|
|
|
pub service_names_to_tags: HashMap<String, Vec<String>>,
|
|
|
|
|
|
|
|
pub service_keys_to_tags: HashMap<String, Vec<String>>,
|
|
|
|
pub service_keys_to_tags: HashMap<String, Vec<String>>,
|
|
|
|
pub service_names_to_actions_to_tags: HashMap<String, HashMap<String, Vec<String>>>,
|
|
|
|
|
|
|
|
pub service_keys_to_actions_to_tags: HashMap<String, HashMap<String, Vec<String>>>,
|
|
|
|
pub service_keys_to_actions_to_tags: HashMap<String, HashMap<String, Vec<String>>>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -41,9 +39,7 @@ impl Endpoint for AddTags {
|
|
|
|
#[derive(Default)]
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct AddTagsRequestBuilder {
|
|
|
|
pub struct AddTagsRequestBuilder {
|
|
|
|
hashes: Vec<String>,
|
|
|
|
hashes: Vec<String>,
|
|
|
|
service_names_to_tags: HashMap<String, Vec<String>>,
|
|
|
|
|
|
|
|
service_keys_to_tags: HashMap<String, Vec<String>>,
|
|
|
|
service_keys_to_tags: HashMap<String, Vec<String>>,
|
|
|
|
service_names_to_actions_to_tags: HashMap<String, HashMap<String, Vec<String>>>,
|
|
|
|
|
|
|
|
service_keys_to_actions_to_tags: HashMap<String, HashMap<String, Vec<String>>>,
|
|
|
|
service_keys_to_actions_to_tags: HashMap<String, HashMap<String, Vec<String>>>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -100,11 +96,8 @@ impl AddTagsRequestBuilder {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Adds a single tag for a given service
|
|
|
|
/// Adds a single tag for a given service
|
|
|
|
pub fn add_tag<S: AsRef<str>>(mut self, service_id: ServiceIdentifier, tag: S) -> Self {
|
|
|
|
pub fn add_tag<S: AsRef<str>>(mut self, service_key: String, tag: S) -> Self {
|
|
|
|
let (service, relevant_mappings) = match service_id {
|
|
|
|
let (service, relevant_mappings) = (service_key, &mut self.service_keys_to_tags);
|
|
|
|
ServiceIdentifier::Name(name) => (name, &mut self.service_names_to_tags),
|
|
|
|
|
|
|
|
ServiceIdentifier::Key(key) => (key, &mut self.service_keys_to_tags),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if let Some(mappings) = relevant_mappings.get_mut(&service) {
|
|
|
|
if let Some(mappings) = relevant_mappings.get_mut(&service) {
|
|
|
|
mappings.push(tag.as_ref().into())
|
|
|
|
mappings.push(tag.as_ref().into())
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -115,11 +108,8 @@ impl AddTagsRequestBuilder {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Adds multiple tags for a given service
|
|
|
|
/// Adds multiple tags for a given service
|
|
|
|
pub fn add_tags(mut self, service_id: ServiceIdentifier, mut tags: Vec<String>) -> Self {
|
|
|
|
pub fn add_tags(mut self, service_key: String, mut tags: Vec<String>) -> Self {
|
|
|
|
let (service, relevant_mappings) = match service_id {
|
|
|
|
let (service, relevant_mappings) = (service_key, &mut self.service_keys_to_tags);
|
|
|
|
ServiceIdentifier::Name(name) => (name, &mut self.service_names_to_tags),
|
|
|
|
|
|
|
|
ServiceIdentifier::Key(key) => (key, &mut self.service_keys_to_tags),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if let Some(mappings) = relevant_mappings.get_mut(&service) {
|
|
|
|
if let Some(mappings) = relevant_mappings.get_mut(&service) {
|
|
|
|
mappings.append(&mut tags);
|
|
|
|
mappings.append(&mut tags);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -132,14 +122,11 @@ impl AddTagsRequestBuilder {
|
|
|
|
/// Adds one tag for a given service with a defined action
|
|
|
|
/// Adds one tag for a given service with a defined action
|
|
|
|
pub fn add_tag_with_action<S: AsRef<str>>(
|
|
|
|
pub fn add_tag_with_action<S: AsRef<str>>(
|
|
|
|
mut self,
|
|
|
|
mut self,
|
|
|
|
service_id: ServiceIdentifier,
|
|
|
|
service_key: String,
|
|
|
|
tag: S,
|
|
|
|
tag: S,
|
|
|
|
action: TagAction,
|
|
|
|
action: TagAction,
|
|
|
|
) -> Self {
|
|
|
|
) -> Self {
|
|
|
|
let (service, relevant_mappings) = match service_id {
|
|
|
|
let (service, relevant_mappings) = (service_key, &mut self.service_keys_to_actions_to_tags);
|
|
|
|
ServiceIdentifier::Name(name) => (name, &mut self.service_names_to_actions_to_tags),
|
|
|
|
|
|
|
|
ServiceIdentifier::Key(key) => (key, &mut self.service_keys_to_actions_to_tags),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let action_id = action.into_id();
|
|
|
|
let action_id = action.into_id();
|
|
|
|
if let Some(actions) = relevant_mappings.get_mut(&service) {
|
|
|
|
if let Some(actions) = relevant_mappings.get_mut(&service) {
|
|
|
|
if let Some(tags) = actions.get_mut(&action_id.to_string()) {
|
|
|
|
if let Some(tags) = actions.get_mut(&action_id.to_string()) {
|
|
|
@ -159,9 +146,7 @@ impl AddTagsRequestBuilder {
|
|
|
|
pub fn build(self) -> AddTagsRequest {
|
|
|
|
pub fn build(self) -> AddTagsRequest {
|
|
|
|
AddTagsRequest {
|
|
|
|
AddTagsRequest {
|
|
|
|
hashes: self.hashes,
|
|
|
|
hashes: self.hashes,
|
|
|
|
service_names_to_tags: self.service_names_to_tags,
|
|
|
|
|
|
|
|
service_keys_to_tags: self.service_keys_to_tags,
|
|
|
|
service_keys_to_tags: self.service_keys_to_tags,
|
|
|
|
service_names_to_actions_to_tags: self.service_names_to_actions_to_tags,
|
|
|
|
|
|
|
|
service_keys_to_actions_to_tags: self.service_keys_to_actions_to_tags,
|
|
|
|
service_keys_to_actions_to_tags: self.service_keys_to_actions_to_tags,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|