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

/**
 * A routing rule represents a specification for traffic to treat and where to
 * send it, along with health probe information.
 *
 * @extends models['SubResource']
 */
class RoutingRule extends models['SubResource'] {
  /**
   * Create a RoutingRule.
   * @member {array} [frontendEndpoints] Frontend endpoints associated with
   * this rule
   * @member {array} [acceptedProtocols] Protocol schemes to match for this
   * rule
   * @member {array} [patternsToMatch] The route patterns of the rule.
   * @member {string} [customForwardingPath] A custom path used to rewrite
   * resource paths matched by this rule. Leave empty to use incoming path.
   * @member {string} [forwardingProtocol] Protocol this rule will use when
   * forwarding traffic to backends. Possible values include: 'HttpOnly',
   * 'HttpsOnly', 'MatchRequest'
   * @member {object} [cacheConfiguration] The caching configuration associated
   * with this rule.
   * @member {string} [cacheConfiguration.queryParameterStripDirective]
   * Treatment of URL query terms when forming the cache key. Possible values
   * include: 'StripNone', 'StripAll'
   * @member {string} [cacheConfiguration.dynamicCompression] Whether to use
   * dynamic compression for cached content. Possible values include:
   * 'Enabled', 'Disabled'
   * @member {object} [backendPool] A reference to the BackendPool which this
   * rule routes to.
   * @member {string} [backendPool.id] Resource ID.
   * @member {string} [enabledState] Whether to enable use of this rule.
   * Permitted values are 'Enabled' or 'Disabled'. Possible values include:
   * 'Enabled', 'Disabled'
   * @member {string} [resourceState] Resource status. Possible values include:
   * 'Creating', 'Enabling', 'Enabled', 'Disabling', 'Disabled', 'Deleting'
   * @member {string} [name] Resource name.
   * @member {string} [type] Resource type.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of RoutingRule
   *
   * @returns {object} metadata of RoutingRule
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'RoutingRule',
      type: {
        name: 'Composite',
        className: 'RoutingRule',
        modelProperties: {
          id: {
            required: false,
            serializedName: 'id',
            type: {
              name: 'String'
            }
          },
          frontendEndpoints: {
            required: false,
            serializedName: 'properties.frontendEndpoints',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'SubResourceElementType',
                  type: {
                    name: 'Composite',
                    className: 'SubResource'
                  }
              }
            }
          },
          acceptedProtocols: {
            required: false,
            serializedName: 'properties.acceptedProtocols',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'FrontDoorProtocolElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          patternsToMatch: {
            required: false,
            serializedName: 'properties.patternsToMatch',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          customForwardingPath: {
            required: false,
            serializedName: 'properties.customForwardingPath',
            type: {
              name: 'String'
            }
          },
          forwardingProtocol: {
            required: false,
            serializedName: 'properties.forwardingProtocol',
            type: {
              name: 'String'
            }
          },
          cacheConfiguration: {
            required: false,
            serializedName: 'properties.cacheConfiguration',
            type: {
              name: 'Composite',
              className: 'CacheConfiguration'
            }
          },
          backendPool: {
            required: false,
            serializedName: 'properties.backendPool',
            type: {
              name: 'Composite',
              className: 'SubResource'
            }
          },
          enabledState: {
            required: false,
            serializedName: 'properties.enabledState',
            type: {
              name: 'String'
            }
          },
          resourceState: {
            required: false,
            serializedName: 'properties.resourceState',
            type: {
              name: 'String'
            }
          },
          name: {
            required: false,
            serializedName: 'name',
            type: {
              name: 'String'
            }
          },
          type: {
            required: false,
            readOnly: true,
            serializedName: 'type',
            type: {
              name: 'String'
            }
          }
        }
      }
    };
  }
}

module.exports = RoutingRule;
