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

/**
 * Defines a health policy used to evaluate the health of an application or one
 * of its children entities.
 *
 */
class ApplicationHealthPolicy {
  /**
   * Create a ApplicationHealthPolicy.
   * @property {boolean} [considerWarningAsError] Indicates whether warnings
   * are treated with the same severity as errors. Default value: false .
   * @property {number} [maxPercentUnhealthyDeployedApplications] The maximum
   * allowed percentage of unhealthy deployed applications. Allowed values are
   * Byte values from zero to 100.
   * The percentage represents the maximum tolerated percentage of deployed
   * applications that can be unhealthy before the application is considered in
   * error.
   * This is calculated by dividing the number of unhealthy deployed
   * applications over the number of nodes where the application is currently
   * deployed on in the cluster.
   * The computation rounds up to tolerate one failure on small numbers of
   * nodes. Default percentage is zero. Default value: 0 .
   * @property {object} [defaultServiceTypeHealthPolicy] The health policy used
   * by default to evaluate the health of a service type.
   * @property {number}
   * [defaultServiceTypeHealthPolicy.maxPercentUnhealthyPartitionsPerService]
   * The maximum allowed percentage of unhealthy partitions per service.
   * Allowed values are Byte values from zero to 100
   *
   * The percentage represents the maximum tolerated percentage of partitions
   * that can be unhealthy before the service is considered in error.
   * If the percentage is respected but there is at least one unhealthy
   * partition, the health is evaluated as Warning.
   * The percentage is calculated by dividing the number of unhealthy
   * partitions over the total number of partitions in the service.
   * The computation rounds up to tolerate one failure on small numbers of
   * partitions. Default percentage is zero.
   * @property {number}
   * [defaultServiceTypeHealthPolicy.maxPercentUnhealthyReplicasPerPartition]
   * The maximum allowed percentage of unhealthy replicas per partition.
   * Allowed values are Byte values from zero to 100.
   *
   * The percentage represents the maximum tolerated percentage of replicas
   * that can be unhealthy before the partition is considered in error.
   * If the percentage is respected but there is at least one unhealthy
   * replica, the health is evaluated as Warning.
   * The percentage is calculated by dividing the number of unhealthy replicas
   * over the total number of replicas in the partition.
   * The computation rounds up to tolerate one failure on small numbers of
   * replicas. Default percentage is zero.
   * @property {number}
   * [defaultServiceTypeHealthPolicy.maxPercentUnhealthyServices] The maximum
   * allowed percentage of unhealthy services. Allowed values are Byte values
   * from zero to 100.
   *
   * The percentage represents the maximum tolerated percentage of services
   * that can be unhealthy before the application is considered in error.
   * If the percentage is respected but there is at least one unhealthy
   * service, the health is evaluated as Warning.
   * This is calculated by dividing the number of unhealthy services of the
   * specific service type over the total number of services of the specific
   * service type.
   * The computation rounds up to tolerate one failure on small numbers of
   * services. Default percentage is zero.
   * @property {array} [serviceTypeHealthPolicyMap] The map with service type
   * health policy per service type name. The map is empty by default.
   */
  constructor() {
  }

  /**
   * Defines the metadata of ApplicationHealthPolicy
   *
   * @returns {object} metadata of ApplicationHealthPolicy
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'ApplicationHealthPolicy',
      type: {
        name: 'Composite',
        className: 'ApplicationHealthPolicy',
        modelProperties: {
          considerWarningAsError: {
            required: false,
            serializedName: 'ConsiderWarningAsError',
            defaultValue: false,
            type: {
              name: 'Boolean'
            }
          },
          maxPercentUnhealthyDeployedApplications: {
            required: false,
            serializedName: 'MaxPercentUnhealthyDeployedApplications',
            defaultValue: 0,
            type: {
              name: 'Number'
            }
          },
          defaultServiceTypeHealthPolicy: {
            required: false,
            serializedName: 'DefaultServiceTypeHealthPolicy',
            type: {
              name: 'Composite',
              className: 'ServiceTypeHealthPolicy'
            }
          },
          serviceTypeHealthPolicyMap: {
            required: false,
            serializedName: 'ServiceTypeHealthPolicyMap',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'ServiceTypeHealthPolicyMapItemElementType',
                  type: {
                    name: 'Composite',
                    className: 'ServiceTypeHealthPolicyMapItem'
                  }
              }
            }
          }
        }
      }
    };
  }
}

module.exports = ApplicationHealthPolicy;
