示例#1
0
        /// <summary>
        /// Creates a new transformed record. By default the Kinesis Firehose Base64 data is decoded into UTF8 before being passed to the tranform function.
        /// </summary>
        /// <param name="record">The Kinesis Firehose record</param>
        /// <param name="transform">The function that will transform the data from the Kinesis Firehose record</param>
        /// <param name="useDefaultEncoding">Specifies if the data in the Kinesis Firehose record should be decoded using
        /// the default text encoding, UTF8. If this is false, the data will be passed to the transform function as a Base64 encoded string</param>
        /// <returns>The transformed record</returns>
        public static async Task <KinesisFirehoseTransformedRecord> BuildAsync(KinesisFirehoseRecord record, Func <string, Task <TransformationResult> > transform, bool useDefaultEncoding = true)
        {
            ParameterTests.NonNull(record, "record");
            ParameterTests.NonNull(transform, "transform");

            try
            {
                string Data = record.Data;

                if (useDefaultEncoding)
                {
                    Data = record.DecodeData();
                }

                TransformationResult Result = await transform.Invoke(Data);

                return(new KinesisFirehoseTransformedRecord(record.RecordId, Result.Data, Result.Result));
            }
            catch (AggregateException e)
            {
                return(new KinesisFirehoseTransformedRecord(record.RecordId, Convert.ToBase64String(Encoding.UTF8.GetBytes($"{e.InnerException.GetType().FullName} : {e.InnerException.Message}")), TransformationResultStatus.PROCESSING_FAILED));
            }
            catch (Exception e)
            {
                return(new KinesisFirehoseTransformedRecord(record.RecordId, Convert.ToBase64String(Encoding.UTF8.GetBytes($"{e.GetType().FullName} : {e.Message}")), TransformationResultStatus.PROCESSING_FAILED));
            }
        }
示例#2
0
 /// <summary>
 /// Constructor with all properties and appropriate value checks
 /// </summary>
 /// <param name="availabilityZone"></param>
 /// <param name="subnetID"></param>
 public AutoScalingInstanceStateEventDetails(
     string availabilityZone,
     string subnetID)
 {
     this.AvailabilityZone = ParameterTests.NotNullOrEmpty(availabilityZone, "availabilityZone");
     this.SubnetID         = ParameterTests.NotNullOrEmpty(subnetID, "subnetID");
 }
示例#3
0
 public S3BucketInfo(
     string name,
     IDictionary <string, string> ownerIdentity,
     string arn
     )
 {
     this.Name          = ParameterTests.NotNullOrEmpty(name, "name");
     this.OwnerIdentity = ownerIdentity ?? throw new ArgumentNullException("ownerIdentity");
     this.Arn           = ParameterTests.NotNullOrEmpty(arn, "arn");
 }
示例#4
0
 public S3Info(
     string s3SchemaVersion,
     string configurationId,
     S3BucketInfo bucket,
     S3ObjectInfo @object
     )
 {
     this.S3SchemaVersion = ParameterTests.NotNullOrEmpty(s3SchemaVersion, "s3SchemaVersion");
     this.ConfigurationId = ParameterTests.NotNullOrEmpty(configurationId, "configurationId");
     this.Bucket          = bucket ?? throw new ArgumentNullException("bucket");
     this.Object          = @object ?? throw new ArgumentNullException("object");
 }
示例#5
0
 public S3ObjectInfo(
     string key,
     long size,
     string eTag,
     string versionId = null,
     string sequencer = null
     )
 {
     // Remove URL encoding from key
     this.Key       = WebUtility.UrlDecode(ParameterTests.NotNullOrEmpty(key, "key"));
     this.Size      = size > 0 ? size : throw new ArgumentOutOfRangeException("The object size cannot be less than or equal to 0.");
     this.ETag      = eTag ?? String.Empty;      // Can be null (might be missing in json record)
     this.VersionId = versionId ?? String.Empty; // Can be null
     this.Sequencer = sequencer ?? String.Empty; // Can be null
 }
示例#6
0
 /// <summary>
 /// Constructor with all properties and null/empty checking.
 /// </summary>
 /// <param name="lifecycleHookName"></param>
 /// <param name="accountId"></param>
 /// <param name="requestId"></param>
 /// <param name="lifecycleTransition"></param>
 /// <param name="autoScalingGroupName"></param>
 /// <param name="service"></param>
 /// <param name="time"></param>
 /// <param name="ec2InstanceId"></param>
 /// <param name="lifecycleActionToken"></param>
 public AutoScalingLifecycleEvent(
     string lifecycleHookName,
     string lifecycleTransition,
     string autoScalingGroupName,
     string ec2InstanceId,
     Guid lifecycleActionToken,
     string notificationMetadata
     )
 {
     this.LifecycleHookName    = ParameterTests.NotNullOrEmpty(lifecycleHookName, "lifecycleHookName");
     this.LifecycleTransition  = ParameterTests.NotNullOrEmpty(lifecycleTransition, "lifecycleTransition");
     this.AutoScalingGroupName = ParameterTests.NotNullOrEmpty(autoScalingGroupName, "autoScalingGroupName");
     this.EC2InstanceId        = ParameterTests.NotNullOrEmpty(ec2InstanceId, "ec2InstanceId");
     this.LifecycleActionToken = lifecycleActionToken;
     this.NotificationMetadata = notificationMetadata;
 }
示例#7
0
        /// <summary>
        /// Creates a new transformed record. The Kinesis Firehose Base64 data is decided using the provided encoding parameter before being passed to the
        /// transform function.
        /// </summary>
        /// <param name="record">The Kinesis Firehose record</param>
        /// <param name="transform">The function that will transform the data from the Kinesis Firehose record</param>
        /// <param name="encoding">The encoding used to convert the bytes from the Base64 string into a readable string</param>
        /// <returns>The transformed record</returns>
        public static KinesisFirehoseTransformedRecord Build(KinesisFirehoseRecord record, Func <string, TransformationResult> transform, Encoding encoding)
        {
            ParameterTests.NonNull(record, "record");
            ParameterTests.NonNull(transform, "transform");
            ParameterTests.NonNull(encoding, "encoding");

            try
            {
                TransformationResult Result = transform.Invoke(record.DecodeData(encoding));
                return(new KinesisFirehoseTransformedRecord(record.RecordId, Result.Data, Result.Result));
            }
            catch (Exception e)
            {
                return(new KinesisFirehoseTransformedRecord(record.RecordId, Convert.ToBase64String(Encoding.UTF8.GetBytes($"{e.GetType().FullName} : {e.Message}")), TransformationResultStatus.PROCESSING_FAILED));
            }
        }
示例#8
0
        static void Main(string[] args)
        {
            ExtensionsTests.Run();
            ArrayTests.Run();
            ParameterTests.Run();
            ExampleTests.Run();
            ClassifierTests.Run();
            ChannelTests.Run();
            ControlTests.Run();
            SyncTests.Run();
            RandomizedQueueTests.Run();
            "Finished!".Print();

            while (true)
            {
                System.Threading.Thread.Sleep(30000);
            }
        }
示例#9
0
 /// <summary>
 /// Constructor with all properties and null/empty checking.
 /// </summary>
 /// <param name="lifecycleHookName"></param>
 /// <param name="accountId"></param>
 /// <param name="requestId"></param>
 /// <param name="lifecycleTransition"></param>
 /// <param name="autoScalingGroupName"></param>
 /// <param name="service"></param>
 /// <param name="time"></param>
 /// <param name="ec2InstanceId"></param>
 /// <param name="lifecycleActionToken"></param>
 public SNSAutoScalingLifecycleHookMessage(
     string lifecycleHookName,
     string accountId,
     Guid requestId,
     string lifecycleTransition,
     string autoScalingGroupName,
     string service,
     DateTime time,
     string ec2InstanceId,
     Guid lifecycleActionToken
     )
 {
     this.LifecycleHookName    = ParameterTests.NotNullOrEmpty(lifecycleHookName, "lifecycleHookName");
     this.AccountId            = ParameterTests.NotNullOrEmpty(accountId, "accountId");
     this.RequestId            = requestId;
     this.LifecycleTransition  = ParameterTests.NotNullOrEmpty(lifecycleTransition, "lifecycleTransition");
     this.AutoScalingGroupName = ParameterTests.NotNullOrEmpty(autoScalingGroupName, "autoScalingGroupName");
     this.Service              = ParameterTests.NotNullOrEmpty(service, "service");
     this.Time                 = time;
     this.EC2InstanceId        = ParameterTests.NotNullOrEmpty(ec2InstanceId, "ec2InstanceId");
     this.LifecycleActionToken = lifecycleActionToken;
 }
示例#10
0
 public SNSS3Record(
     string eventVersion,
     string eventSource,
     string awsRegion,
     DateTime eventTime,
     string eventName,
     IDictionary <string, string> userIdentity,
     IDictionary <string, string> requestParameters,
     IDictionary <string, string> responseElements,
     S3Info s3
     )
 {
     this.EventVersion      = ParameterTests.NotNullOrEmpty(eventVersion, "eventVersion");
     this.EventSource       = ParameterTests.NotNullOrEmpty(eventSource, "eventSource");
     this.AwsRegion         = ParameterTests.NotNullOrEmpty(awsRegion, "awsRegion");
     this.EventTime         = eventTime;
     this.EventName         = ParameterTests.NotNullOrEmpty(eventName, "eventName");
     this.UserIdentity      = userIdentity ?? throw new ArgumentNullException("userIdentity");
     this.RequestParameters = requestParameters ?? throw new ArgumentNullException("requestParameters");
     this.ResponseElements  = responseElements ?? throw new ArgumentNullException("responseElements");
     this.S3 = s3 ?? throw new ArgumentNullException("s3");
 }