import AWS = require('aws-sdk');
import AutoScaling = require('aws-sdk/clients/autoscaling');

export default async function processEvents(event: any, context: any, callback: any) {

  let as = new AWS.AutoScaling(); 
  as.describeAutoScalingGroups().on("success", (response) =>)

  // let as = new AWS.AutoScaling();
  // as.describeAutoScalingGroups(function(err: AWS.AutoScaling, data) {
  //   console.log(err);
  //   console.log(data);
  // });

  
  // const sensuEvents: SensuEvent[] = event.Records.map((record: any) => new SensuEvent(record.kinesis.data));
  // const dataPoints: DataPoint[] = [].concat.apply([], sensuEvents.map((event: SensuEvent) => event.dataPoints));
  // const points = dataPoints.map((dataPoint: DataPoint) => dataPoint.toInflux());
  // const batchSize = 10000;
  // console.info(`Discovered ${points.length} data points, submitting ${batchSize} at a time`);

  // let batch_success: number = 0;
  // const batches: number = Math.ceil(points.length / batchSize);

  // for (let i = 0; i < points.length; i += batchSize) {
  //   console.log(`Submitting points ${i} to ${i+batchSize}`)
  //   try {
  //     influx.writePoints(points.slice(i, i + batchSize), {retentionPolicy: 'raw_statistics'}).then(() => {
  //       console.log(`Done submitting ${i} to ${i+batchSize}. Currently ${batch_success} of ${batches} successful batches.`);

  //       batch_success++;
  //       if (batch_success >= batches) {
  //         console.info(`Successfully saved ${points.length}.`);
  //         callback(null, `Processed ${points.length} data points.`);
  //       }
  //     }).catch((err: any) => {
  //       console.error(`Error saving data to InfluxDB! ${err.stack}`);
  //       callback(err, null);
  //     });
  //   } catch (err) {
  //     console.log(err);
  //   }
  //   // await new Promise(resolve => setTimeout(resolve, 2500));
  // }
}
