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

/**
 * Network security rule.
 *
 * @extends models['SubResource']
 */
class SecurityRule extends models['SubResource'] {
  /**
   * Create a SecurityRule.
   * @property {string} [description] A description for this rule. Restricted
   * to 140 chars.
   * @property {string} protocol Network protocol this rule applies to.
   * Possible values are 'Tcp', 'Udp', 'Icmp', 'Esp', and '*'. Possible values
   * include: 'Tcp', 'Udp', 'Icmp', 'Esp', '*'
   * @property {string} [sourcePortRange] The source port or range. Integer or
   * range between 0 and 65535. Asterisk '*' can also be used to match all
   * ports.
   * @property {string} [destinationPortRange] The destination port or range.
   * Integer or range between 0 and 65535. Asterisk '*' can also be used to
   * match all ports.
   * @property {string} [sourceAddressPrefix] The CIDR or source IP range.
   * Asterisk '*' can also be used to match all source IPs. Default tags such
   * as 'VirtualNetwork', 'AzureLoadBalancer' and 'Internet' can also be used.
   * If this is an ingress rule, specifies where network traffic originates
   * from.
   * @property {array} [sourceAddressPrefixes] The CIDR or source IP ranges.
   * @property {array} [sourceApplicationSecurityGroups] The application
   * security group specified as source.
   * @property {string} [destinationAddressPrefix] The destination address
   * prefix. CIDR or destination IP range. Asterisk '*' can also be used to
   * match all source IPs. Default tags such as 'VirtualNetwork',
   * 'AzureLoadBalancer' and 'Internet' can also be used.
   * @property {array} [destinationAddressPrefixes] The destination address
   * prefixes. CIDR or destination IP ranges.
   * @property {array} [destinationApplicationSecurityGroups] The application
   * security group specified as destination.
   * @property {array} [sourcePortRanges] The source port ranges.
   * @property {array} [destinationPortRanges] The destination port ranges.
   * @property {string} access The network traffic is allowed or denied.
   * Possible values include: 'Allow', 'Deny'
   * @property {number} [priority] The priority of the rule. The value can be
   * between 100 and 4096. The priority number must be unique for each rule in
   * the collection. The lower the priority number, the higher the priority of
   * the rule.
   * @property {string} direction The direction of the rule. The direction
   * specifies if rule will be evaluated on incoming or outgoing traffic.
   * Possible values include: 'Inbound', 'Outbound'
   * @property {string} [provisioningState] The provisioning state of the
   * public IP 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 SecurityRule
   *
   * @returns {object} metadata of SecurityRule
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'SecurityRule',
      type: {
        name: 'Composite',
        className: 'SecurityRule',
        modelProperties: {
          id: {
            required: false,
            serializedName: 'id',
            type: {
              name: 'String'
            }
          },
          description: {
            required: false,
            serializedName: 'properties.description',
            type: {
              name: 'String'
            }
          },
          protocol: {
            required: true,
            serializedName: 'properties.protocol',
            type: {
              name: 'String'
            }
          },
          sourcePortRange: {
            required: false,
            serializedName: 'properties.sourcePortRange',
            type: {
              name: 'String'
            }
          },
          destinationPortRange: {
            required: false,
            serializedName: 'properties.destinationPortRange',
            type: {
              name: 'String'
            }
          },
          sourceAddressPrefix: {
            required: false,
            serializedName: 'properties.sourceAddressPrefix',
            type: {
              name: 'String'
            }
          },
          sourceAddressPrefixes: {
            required: false,
            serializedName: 'properties.sourceAddressPrefixes',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          sourceApplicationSecurityGroups: {
            required: false,
            serializedName: 'properties.sourceApplicationSecurityGroups',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'ApplicationSecurityGroupElementType',
                  type: {
                    name: 'Composite',
                    className: 'ApplicationSecurityGroup'
                  }
              }
            }
          },
          destinationAddressPrefix: {
            required: false,
            serializedName: 'properties.destinationAddressPrefix',
            type: {
              name: 'String'
            }
          },
          destinationAddressPrefixes: {
            required: false,
            serializedName: 'properties.destinationAddressPrefixes',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          destinationApplicationSecurityGroups: {
            required: false,
            serializedName: 'properties.destinationApplicationSecurityGroups',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'ApplicationSecurityGroupElementType',
                  type: {
                    name: 'Composite',
                    className: 'ApplicationSecurityGroup'
                  }
              }
            }
          },
          sourcePortRanges: {
            required: false,
            serializedName: 'properties.sourcePortRanges',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          destinationPortRanges: {
            required: false,
            serializedName: 'properties.destinationPortRanges',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          access: {
            required: true,
            serializedName: 'properties.access',
            type: {
              name: 'String'
            }
          },
          priority: {
            required: false,
            serializedName: 'properties.priority',
            type: {
              name: 'Number'
            }
          },
          direction: {
            required: true,
            serializedName: 'properties.direction',
            type: {
              name: 'String'
            }
          },
          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 = SecurityRule;
