/*
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is
 * regenerated.
 */

'use strict';

const models = require('./index');

/**
 * Trigger that schedules pipeline runs for all fixed time interval windows
 * from a start time without gaps and also supports backfill scenarios (when
 * start time is in the past).
 *
 * @extends models['Trigger']
 */
class TumblingWindowTrigger extends models['Trigger'] {
  /**
   * Create a TumblingWindowTrigger.
   * @member {object} pipelineProperty Pipeline for which runs are created when
   * an event is fired for trigger window that is ready.
   * @member {object} [pipelineProperty.pipelineReference] Pipeline reference.
   * @member {string} [pipelineProperty.pipelineReference.referenceName]
   * Reference pipeline name.
   * @member {string} [pipelineProperty.pipelineReference.name] Reference name.
   * @member {object} [pipelineProperty.parameters] Pipeline parameters.
   * @member {string} frequency The frequency of the time windows. Possible
   * values include: 'Minute', 'Hour'
   * @member {number} interval The interval of the time windows. The minimum
   * interval allowed is 15 Minutes.
   * @member {date} startTime The start time for the time period for the
   * trigger during which events are fired for windows that are ready. Only UTC
   * time is currently supported.
   * @member {date} [endTime] The end time for the time period for the trigger
   * during which events are fired for windows that are ready. Only UTC time is
   * currently supported.
   * @member {object} [delay] Specifies how long the trigger waits past due
   * time before triggering new run. It doesn't alter window start and end
   * time. The default is 0. Type: string (or Expression with resultType
   * string), pattern: ((\d+)\.)?(\d\d):(60|([0-5][0-9])):(60|([0-5][0-9])).
   * @member {number} maxConcurrency The max number of parallel time windows
   * (ready for execution) for which a new run is triggered.
   * @member {object} [retryPolicy] Retry policy that will be applied for
   * failed pipeline runs.
   * @member {object} [retryPolicy.count] Maximum ordinary retry attempts.
   * Default is 0. Type: integer (or Expression with resultType integer),
   * minimum: 0.
   * @member {number} [retryPolicy.intervalInSeconds] Interval between retries
   * in seconds. Default is 30.
   * @member {array} [dependsOn] Triggers that this trigger depends on. Only
   * tumbling window triggers are supported.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of TumblingWindowTrigger
   *
   * @returns {object} metadata of TumblingWindowTrigger
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'TumblingWindowTrigger',
      type: {
        name: 'Composite',
        polymorphicDiscriminator: {
          serializedName: 'type',
          clientName: 'type'
        },
        uberParent: 'Trigger',
        className: 'TumblingWindowTrigger',
        modelProperties: {
          description: {
            required: false,
            serializedName: 'description',
            type: {
              name: 'String'
            }
          },
          runtimeState: {
            required: false,
            readOnly: true,
            serializedName: 'runtimeState',
            type: {
              name: 'String'
            }
          },
          type: {
            required: true,
            serializedName: 'type',
            isPolymorphicDiscriminator: true,
            type: {
              name: 'String'
            }
          },
          pipelineProperty: {
            required: true,
            serializedName: 'pipeline',
            defaultValue: {},
            type: {
              name: 'Composite',
              className: 'TriggerPipelineReference'
            }
          },
          frequency: {
            required: true,
            serializedName: 'typeProperties.frequency',
            type: {
              name: 'String'
            }
          },
          interval: {
            required: true,
            serializedName: 'typeProperties.interval',
            type: {
              name: 'Number'
            }
          },
          startTime: {
            required: true,
            serializedName: 'typeProperties.startTime',
            type: {
              name: 'DateTime'
            }
          },
          endTime: {
            required: false,
            serializedName: 'typeProperties.endTime',
            type: {
              name: 'DateTime'
            }
          },
          delay: {
            required: false,
            serializedName: 'typeProperties.delay',
            type: {
              name: 'Object'
            }
          },
          maxConcurrency: {
            required: true,
            serializedName: 'typeProperties.maxConcurrency',
            constraints: {
              InclusiveMaximum: 50,
              InclusiveMinimum: 1
            },
            type: {
              name: 'Number'
            }
          },
          retryPolicy: {
            required: false,
            serializedName: 'typeProperties.retryPolicy',
            type: {
              name: 'Composite',
              className: 'RetryPolicy'
            }
          },
          dependsOn: {
            required: false,
            serializedName: 'typeProperties.dependsOn',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'DependencyReferenceElementType',
                  type: {
                    name: 'Composite',
                    polymorphicDiscriminator: {
                      serializedName: 'type',
                      clientName: 'type'
                    },
                    uberParent: 'DependencyReference',
                    className: 'DependencyReference'
                  }
              }
            }
          }
        }
      }
    };
  }
}

module.exports = TumblingWindowTrigger;
