dynk8s-provisioner/src/model/sns.rs

86 lines
2.7 KiB
Rust

//! Amazon SNS message types
//!
//! These message types are defined in the [Parsing message formats][0] page of
//! the AWS Documentation.
//!
//! [0]: https://docs.aws.amazon.com/sns/latest/dg/sns-message-and-json-formats.html
use serde::{Deserialize, Serialize};
/// Union for all known SNS message types
///
/// This type can be used to deserialize an arbitrary SNS message into the
/// appropriate type, based on the value of the `Type` field in the JSON
/// document.
#[derive(Deserialize)]
#[serde(tag = "Type")]
pub enum Message {
SubscriptionConfirmation(SubscriptionConfirmationMessage),
UnsubscribeConfirmation(UnsubscribeConfirmationMessage),
Notification(NotificationMessage),
}
/// SNS Subscription confirmation message
///
/// See also: [HTTP/HTTPS subscription confirmation JSON format][0]
///
/// [0]: https://docs.aws.amazon.com/sns/latest/dg/sns-message-and-json-formats.html#http-subscription-confirmation-json
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct SubscriptionConfirmationMessage {
#[serde(rename = "MessageId")]
pub message_id: String,
pub token: String,
pub topic_arn: String,
pub message: String,
#[serde(rename = "SubscribeURL")]
pub subscribe_url: String,
pub timestamp: String,
pub signature_version: String,
pub signature: String,
#[serde(rename = "SigningCertURL")]
pub signing_cert_url: String,
}
/// SNS Notification message
///
/// See also: [HTTP/HTTPS notification JSON format][0]
///
/// [0]: https://docs.aws.amazon.com/sns/latest/dg/sns-message-and-json-formats.html#http-notification-json
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct NotificationMessage {
#[serde(rename = "MessageId")]
pub message_id: String,
pub topic_arn: String,
pub message: String,
#[serde(default)]
pub subject: Option<String>,
pub timestamp: String,
pub signature_version: String,
pub signature: String,
#[serde(rename = "SigningCertURL")]
pub signing_cert_url: String,
}
/// SNS Unsubscribe confirmation message
///
/// See also: [HTTP/HTTPS unsubscribe confirmation JSON format][0]
///
/// [0]: https://docs.aws.amazon.com/sns/latest/dg/sns-message-and-json-formats.html#http-unsubscribe-confirmation-json
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct UnsubscribeConfirmationMessage {
#[serde(rename = "MessageId")]
pub message_id: String,
pub token: String,
pub topic_arn: String,
pub message: String,
#[serde(rename = "SubscribeURL")]
pub subscribe_url: String,
pub timestamp: String,
pub signature_version: String,
pub signature: String,
#[serde(rename = "SigningCertURL")]
pub signing_cert_url: String,
}