Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
Add (some) CloudWatch events (#50)
Browse files Browse the repository at this point in the history
* Add (some) CloudWatch events

Adds structs for all the events that are directly listed here:
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html

* Rename directory for CloudWatch events

* Make CloudWatch events public

* Resolve naming conflicts and import HashMap

* Correct signature of aws.Event.affected_entities

* Allow mapping request_parameters and response_elements

* Run cargofmt and clippy
  • Loading branch information
martinjlowm committed Feb 11, 2022
1 parent 1e762e9 commit fc350b1
Show file tree
Hide file tree
Showing 18 changed files with 1,070 additions and 0 deletions.
47 changes: 47 additions & 0 deletions aws_lambda_events/src/cloudwatch_events/cloudtrail.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use serde_derive::Deserialize;
use serde_derive::Serialize;
use serde_json::Value;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AWSAPICall<I = Value, O = Value> {
pub event_version: String,
pub user_identity: UserIdentity,
pub event_time: String,
pub event_source: String,
pub event_name: String,
pub aws_region: String,
#[serde(rename = "sourceIPAddress")]
pub source_ipaddress: String,
pub user_agent: String,
pub request_parameters: I,
pub response_elements: O,
#[serde(rename = "requestID")]
pub request_id: String,
#[serde(rename = "eventID")]
pub event_id: String,
pub event_type: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserIdentity {
pub r#type: String,
pub principal_id: String,
pub arn: String,
pub account_id: String,
pub session_context: SessionContext,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionContext {
pub attributes: Attributes,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Attributes {
pub mfa_authenticated: String,
pub creation_date: String,
}
35 changes: 35 additions & 0 deletions aws_lambda_events/src/cloudwatch_events/codedeploy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use serde_derive::Deserialize;
use serde_derive::Serialize;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StateChangeNotification {
pub instance_group_id: String,
pub region: String,
pub application: String,
pub deployment_id: String,
pub state: String,
pub deployment_group: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DeploymentStateChangeNotification {
pub instance_id: String,
pub region: String,
pub state: String,
pub application: String,
pub deployment_id: String,
pub instance_group_id: String,
pub deployment_group: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstanceStateChangeNotification {
pub pipeline: String,
pub version: String,
pub state: String,
#[serde(rename = "execution-id")]
pub execution_id: String,
}
47 changes: 47 additions & 0 deletions aws_lambda_events/src/cloudwatch_events/codepipeline.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use serde_derive::Deserialize;
use serde_derive::Serialize;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PipelineExecutionStateChange {
pub pipeline: String,
pub version: String,
pub state: String,
#[serde(rename = "execution-id")]
pub execution_id: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StageExecutionStateChange {
pub pipeline: String,
pub version: String,
#[serde(rename = "execution-id")]
pub execution_id: String,
pub stage: String,
pub state: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ActionExecutionStateChange {
pub pipeline: String,
pub version: i64,
#[serde(rename = "execution-id")]
pub execution_id: String,
pub stage: String,
pub action: String,
pub state: String,
pub region: String,
#[serde(rename = "type")]
pub type_field: ActionExecutionStateChangeType,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ActionExecutionStateChangeType {
pub owner: String,
pub category: String,
pub provider: String,
pub version: i64,
}
10 changes: 10 additions & 0 deletions aws_lambda_events/src/cloudwatch_events/ec2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use serde_derive::Deserialize;
use serde_derive::Serialize;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstanceStateChange {
#[serde(rename = "instance-id")]
pub instance_id: String,
pub state: String,
}
50 changes: 50 additions & 0 deletions aws_lambda_events/src/cloudwatch_events/emr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use serde_derive::Deserialize;
use serde_derive::Serialize;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AutoScalingPolicyStateChange {
pub resource_id: String,
pub cluster_id: String,
pub state: String,
pub message: String,
pub scaling_resource_type: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ClusterStateChange {
pub severity: String,
pub state_change_reason: String,
pub name: String,
pub cluster_id: String,
pub state: String,
pub message: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstanceGroupStateChange {
pub market: String,
pub severity: String,
pub requested_instance_count: String,
pub instance_type: String,
pub instance_group_type: String,
pub instance_group_id: String,
pub cluster_id: String,
pub running_instance_count: String,
pub state: String,
pub message: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepStatusChange {
pub severity: String,
pub action_on_failure: String,
pub step_id: String,
pub name: String,
pub cluster_id: String,
pub state: String,
pub message: String,
}
116 changes: 116 additions & 0 deletions aws_lambda_events/src/cloudwatch_events/gamelift.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
use serde_derive::Deserialize;
use serde_derive::Serialize;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MatchmakingSearching {
pub tickets: Vec<Ticket>,
pub estimated_wait_millis: String,
pub r#type: String,
pub game_session_info: GameSessionInfo,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Ticket {
pub ticket_id: String,
pub start_time: String,
pub players: Vec<Player>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Player {
pub player_id: String,
pub team: Option<String>,
pub accepted: Option<bool>,
pub player_session_id: Option<String>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GameSessionInfo {
pub players: Vec<Player>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PotentialMatchCreated {
pub tickets: Vec<Ticket>,
pub acceptance_timeout: i64,
pub rule_evaluation_metrics: Vec<RuleEvaluationMetric>,
pub acceptance_required: bool,
pub r#type: String,
pub game_session_info: GameSessionInfo,
pub match_id: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RuleEvaluationMetric {
pub rule_name: String,
pub passed_count: i64,
pub failed_count: i64,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AcceptMatch {
pub tickets: Vec<Ticket>,
pub r#type: String,
pub game_session_info: GameSessionInfo,
pub match_id: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AcceptMatchCompleted {
pub tickets: Vec<Ticket>,
pub acceptance: String,
pub r#type: String,
pub game_session_info: GameSessionInfo,
pub match_id: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MatchmakingSucceeded {
pub tickets: Vec<Ticket>,
pub r#type: String,
pub game_session_info: GameSessionInfo,
pub match_id: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MatchmakingTimedOut {
pub reason: String,
pub tickets: Vec<Ticket>,
pub rule_evaluation_metrics: Vec<RuleEvaluationMetric>,
pub r#type: String,
pub message: String,
pub game_session_info: GameSessionInfo,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MatchmakingCancelled {
pub reason: String,
pub tickets: Vec<Ticket>,
pub rule_evaluation_metrics: Vec<RuleEvaluationMetric>,
pub r#type: String,
pub message: String,
pub game_session_info: GameSessionInfo,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MatchmakingFailed {
pub tickets: Vec<Ticket>,
pub custom_event_data: String,
pub r#type: String,
pub reason: String,
pub message: String,
pub game_session_info: GameSessionInfo,
pub match_id: String,
}
Loading

0 comments on commit fc350b1

Please sign in to comment.