/*
 * 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';

/**
 * A rule that specifies a set of actions and conditions
 *
 */
class DeliveryRule {
  /**
   * Create a DeliveryRule.
   * @property {number} order The order in which the rules are applied for the
   * endpoint. Possible values {0,1,2,3,………}. A rule with a lesser order will
   * be applied before a rule with a greater order. Rule with order 0 is a
   * special rule. It does not require any condition and actions listed in it
   * will always be applied.
   * @property {array} actions A list of actions that are executed when all the
   * conditions of a rule are satisfied.
   * @property {array} [conditions] A list of conditions that must be matched
   * for the actions to be executed
   */
  constructor() {
  }

  /**
   * Defines the metadata of DeliveryRule
   *
   * @returns {object} metadata of DeliveryRule
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'DeliveryRule',
      type: {
        name: 'Composite',
        className: 'DeliveryRule',
        modelProperties: {
          order: {
            required: true,
            serializedName: 'order',
            type: {
              name: 'Number'
            }
          },
          actions: {
            required: true,
            serializedName: 'actions',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'DeliveryRuleActionElementType',
                  type: {
                    name: 'Composite',
                    polymorphicDiscriminator: {
                      serializedName: 'name',
                      clientName: 'name'
                    },
                    uberParent: 'DeliveryRuleAction',
                    className: 'DeliveryRuleAction'
                  }
              }
            }
          },
          conditions: {
            required: false,
            serializedName: 'conditions',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'DeliveryRuleConditionElementType',
                  type: {
                    name: 'Composite',
                    polymorphicDiscriminator: {
                      serializedName: 'name',
                      clientName: 'name'
                    },
                    uberParent: 'DeliveryRuleCondition',
                    className: 'DeliveryRuleCondition'
                  }
              }
            }
          }
        }
      }
    };
  }
}

module.exports = DeliveryRule;
