using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
namespace Amazon.Lambda.KinesisFirehoseEvents
{
///
/// This class represents the input event from Amazon Kinesis Firehose. It used as the input parameter
/// for Lambda functions.
///
public class KinesisFirehoseEvent
{
///
/// The Id of the invocation.
///
public string InvocationId { get; set; }
///
/// The ARN of the delivery stream sending the event.
///
public string DeliveryStreamArn { get; set; }
///
/// The AWS region for delivery stream.
///
public string Region { get; set; }
///
/// The Kinesis records to transform.
///
public IList Records { get; set; }
///
/// The records for the Kinesis Firehose event to process and transform.
///
[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")]
public string RecordId { get; set; }
///
/// The approximate time the record was sent to Kinesis Firehose as a Unix epoch.
///
[DataMember(Name = "approximateArrivalTimestamp")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("approximateArrivalTimestamp")]
#endif
public long ApproximateArrivalEpoch { get; set; }
///
/// The approximate time the record was sent to Kinesis Firehose.
///
[IgnoreDataMember]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonIgnore()]
#endif
public DateTime ApproximateArrivalTimestamp
{
get
{
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return epoch.AddMilliseconds(ApproximateArrivalEpoch);
}
}
///
/// The data sent through as a Kinesis Firehose record. The data is sent to the Lambda function base64 encoded.
///
[DataMember(Name = "data")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("data")]
#endif
public string Base64EncodedData { get; set; }
///
/// Base64 decodes the Base64EncodedData property.
///
///
public string DecodeData()
{
var decodedData = Encoding.UTF8.GetString(Convert.FromBase64String(this.Base64EncodedData));
return decodedData;
}
}
}
}