using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Text; namespace Amazon.Lambda.KinesisFirehoseEvents { /// /// The response for the Lambda functions handling Kinesis Firehose transformations. /// [DataContract] public class KinesisFirehoseResponse { /// /// The record was transformed successfully. /// public const string TRANSFORMED_STATE_OK = "Ok"; /// /// The record was dropped intentionally by your processing logic. /// public const string TRANSFORMED_STATE_DROPPED = "Dropped"; /// /// The record could not be transformed. /// public const string TRANSFORMED_STATE_PROCESSINGFAILED = "ProcessingFailed"; /// /// The transformed records from the KinesisFirehoseEvent. /// [DataMember(Name = "records")] #if NETCOREAPP_3_1 [System.Text.Json.Serialization.JsonPropertyName("records")] #endif public IList Records { get; set; } /// /// The transformed records after processing KinesisFirehoseEvent.Records /// [DataContract] public class FirehoseRecord { /// ///The record ID is passed from Firehose to Lambda during the invocation. The transformed record must ///contain the same record ID. Any mismatch between the ID of the original record and the ID of the ///transformed record is treated as a data transformation failure. /// [DataMember(Name = "recordId")] #if NETCOREAPP_3_1 [System.Text.Json.Serialization.JsonPropertyName("recordId")] #endif public string RecordId { get; set; } /// /// The status of the data transformation of the record. The possible values are: "Ok" /// (the record was transformed successfully), "Dropped" (the record was dropped intentionally /// by your processing logic), and "ProcessingFailed" (the record could not be transformed). /// If a record has a status of "Ok" or "Dropped", Firehose considers it successfully /// processed. Otherwise, Firehose considers it unsuccessfully processed. /// /// Possible values: /// /// /// Ok /// The record was transformed successfully /// /// /// Dropped /// The record was dropped intentionally by your processing logic /// /// /// ProcessingFailed /// The record could not be transformed /// /// /// [DataMember(Name = "result")] #if NETCOREAPP_3_1 [System.Text.Json.Serialization.JsonPropertyName("result")] #endif public string Result { get; set; } /// /// The transformed data payload, after base64-encoding. /// [DataMember(Name = "data")] #if NETCOREAPP_3_1 [System.Text.Json.Serialization.JsonPropertyName("data")] #endif public string Base64EncodedData { get; set; } /// /// The response record metadata. /// [DataMember(Name = "metadata")] #if NETCOREAPP_3_1 [System.Text.Json.Serialization.JsonPropertyName("metadata")] #endif public FirehoseResponseRecordMetadata Metadata { get; set; } /// /// Base64 encodes the data and sets the Base64EncodedData property. /// /// The data to be base64 encoded. public void EncodeData(string data) { this.Base64EncodedData = Convert.ToBase64String(Encoding.UTF8.GetBytes(data)); } } /// /// The response record metadata after processing KinesisFirehoseEvent.Records /// [DataContract] public class FirehoseResponseRecordMetadata { /// /// Key Value pairs used for Dynamic Partitioning /// https://docs.aws.amazon.com/firehose/latest/dev/dynamic-partitioning.html /// [DataMember(Name = "partitionKeys")] #if NETCOREAPP_3_1 [System.Text.Json.Serialization.JsonPropertyName("partitionKeys")] #endif public Dictionary PartitionKeys { get; set; } } } }