/*
 * 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 load balancing rule for a load balancer.
 *
 * @extends models['SubResource']
 */
class LoadBalancingRule extends models['SubResource'] {
  /**
   * Create a LoadBalancingRule.
   * @property {object} [frontendIPConfiguration] A reference to frontend IP
   * addresses.
   * @property {string} [frontendIPConfiguration.id] Resource ID.
   * @property {object} [backendAddressPool] A reference to a pool of DIPs.
   * Inbound traffic is randomly load balanced across IPs in the backend IPs.
   * @property {string} [backendAddressPool.id] Resource ID.
   * @property {object} [probe] The reference of the load balancer probe used
   * by the load balancing rule.
   * @property {string} [probe.id] Resource ID.
   * @property {string} protocol The reference to the transport protocol used
   * by the load balancing rule. Possible values include: 'Udp', 'Tcp', 'All'
   * @property {string} [loadDistribution] The load distribution policy for
   * this rule. Possible values are 'Default', 'SourceIP', and
   * 'SourceIPProtocol'. Possible values include: 'Default', 'SourceIP',
   * 'SourceIPProtocol'
   * @property {number} frontendPort The port for the external endpoint. Port
   * numbers for each rule must be unique within the Load Balancer. Acceptable
   * values are between 0 and 65534. Note that value 0 enables "Any Port"
   * @property {number} [backendPort] The port used for internal connections on
   * the endpoint. Acceptable values are between 0 and 65535. Note that value 0
   * enables "Any Port"
   * @property {number} [idleTimeoutInMinutes] The timeout for the TCP idle
   * connection. The value can be set between 4 and 30 minutes. The default
   * value is 4 minutes. This element is only used when the protocol is set to
   * TCP.
   * @property {boolean} [enableFloatingIP] Configures a virtual machine's
   * endpoint for the floating IP capability required to configure a SQL
   * AlwaysOn Availability Group. This setting is required when using the SQL
   * AlwaysOn Availability Groups in SQL server. This setting can't be changed
   * after you create the endpoint.
   * @property {boolean} [enableTcpReset] Receive bidirectional TCP Reset on
   * TCP flow idle timeout or unexpected connection termination. This element
   * is only used when the protocol is set to TCP.
   * @property {boolean} [disableOutboundSnat] Configures SNAT for the VMs in
   * the backend pool to use the publicIP address specified in the frontend of
   * the load balancing rule.
   * @property {string} [provisioningState] Gets the provisioning state of the
   * PublicIP resource. Possible values are: 'Updating', 'Deleting', and
   * 'Failed'.
   * @property {string} [name] The name of the resource that is unique within a
   * resource group. This name can be used to access the resource.
   * @property {string} [etag] A unique read-only string that changes whenever
   * the resource is updated.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of LoadBalancingRule
   *
   * @returns {object} metadata of LoadBalancingRule
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'LoadBalancingRule',
      type: {
        name: 'Composite',
        className: 'LoadBalancingRule',
        modelProperties: {
          id: {
            required: false,
            serializedName: 'id',
            type: {
              name: 'String'
            }
          },
          frontendIPConfiguration: {
            required: false,
            serializedName: 'properties.frontendIPConfiguration',
            type: {
              name: 'Composite',
              className: 'SubResource'
            }
          },
          backendAddressPool: {
            required: false,
            serializedName: 'properties.backendAddressPool',
            type: {
              name: 'Composite',
              className: 'SubResource'
            }
          },
          probe: {
            required: false,
            serializedName: 'properties.probe',
            type: {
              name: 'Composite',
              className: 'SubResource'
            }
          },
          protocol: {
            required: true,
            serializedName: 'properties.protocol',
            type: {
              name: 'String'
            }
          },
          loadDistribution: {
            required: false,
            serializedName: 'properties.loadDistribution',
            type: {
              name: 'String'
            }
          },
          frontendPort: {
            required: true,
            serializedName: 'properties.frontendPort',
            type: {
              name: 'Number'
            }
          },
          backendPort: {
            required: false,
            serializedName: 'properties.backendPort',
            type: {
              name: 'Number'
            }
          },
          idleTimeoutInMinutes: {
            required: false,
            serializedName: 'properties.idleTimeoutInMinutes',
            type: {
              name: 'Number'
            }
          },
          enableFloatingIP: {
            required: false,
            serializedName: 'properties.enableFloatingIP',
            type: {
              name: 'Boolean'
            }
          },
          enableTcpReset: {
            required: false,
            serializedName: 'properties.enableTcpReset',
            type: {
              name: 'Boolean'
            }
          },
          disableOutboundSnat: {
            required: false,
            serializedName: 'properties.disableOutboundSnat',
            type: {
              name: 'Boolean'
            }
          },
          provisioningState: {
            required: false,
            serializedName: 'properties.provisioningState',
            type: {
              name: 'String'
            }
          },
          name: {
            required: false,
            serializedName: 'name',
            type: {
              name: 'String'
            }
          },
          etag: {
            required: false,
            serializedName: 'etag',
            type: {
              name: 'String'
            }
          }
        }
      }
    };
  }
}

module.exports = LoadBalancingRule;
