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

/**
 * The cluster health chunk query description, which can specify the health
 * policies to evaluate cluster health and very expressive filters to select
 * which cluster entities to include in response.
 *
 */
class ClusterHealthChunkQueryDescription {
  /**
   * Create a ClusterHealthChunkQueryDescription.
   * @property {array} [nodeFilters] Defines a list of filters that specify
   * which nodes to be included in the returned cluster health chunk.
   * If no filters are specified, no nodes are returned. All the nodes are used
   * to evaluate the cluster's aggregated health state, regardless of the input
   * filters.
   * The cluster health chunk query may specify multiple node filters.
   * For example, it can specify a filter to return all nodes with health state
   * Error and another filter to always include a node identified by its
   * NodeName.
   * @property {array} [applicationFilters] Defines a list of filters that
   * specify which applications to be included in the returned cluster health
   * chunk.
   * If no filters are specified, no applications are returned. All the
   * applications are used to evaluate the cluster's aggregated health state,
   * regardless of the input filters.
   * The cluster health chunk query may specify multiple application filters.
   * For example, it can specify a filter to return all applications with
   * health state Error and another filter to always include applications of a
   * specified application type.
   * @property {object} [clusterHealthPolicy] Defines a health policy used to
   * evaluate the health of the cluster or of a cluster node.
   * @property {boolean} [clusterHealthPolicy.considerWarningAsError] Indicates
   * whether warnings are treated with the same severity as errors.
   * @property {number} [clusterHealthPolicy.maxPercentUnhealthyNodes] The
   * maximum allowed percentage of unhealthy nodes before reporting an error.
   * For example, to allow 10% of nodes to be unhealthy, this value would be
   * 10.
   *
   * The percentage represents the maximum tolerated percentage of nodes that
   * can be unhealthy before the cluster is considered in error.
   * If the percentage is respected but there is at least one unhealthy node,
   * the health is evaluated as Warning.
   * The percentage is calculated by dividing the number of unhealthy nodes
   * over the total number of nodes in the cluster.
   * The computation rounds up to tolerate one failure on small numbers of
   * nodes. Default percentage is zero.
   *
   * In large clusters, some nodes will always be down or out for repairs, so
   * this percentage should be configured to tolerate that.
   * @property {number} [clusterHealthPolicy.maxPercentUnhealthyApplications]
   * The maximum allowed percentage of unhealthy applications before reporting
   * an error. For example, to allow 10% of applications to be unhealthy, this
   * value would be 10.
   *
   * The percentage represents the maximum tolerated percentage of applications
   * that can be unhealthy before the cluster is considered in error.
   * If the percentage is respected but there is at least one unhealthy
   * application, the health is evaluated as Warning.
   * This is calculated by dividing the number of unhealthy applications over
   * the total number of application instances in the cluster, excluding
   * applications of application types that are included in the
   * ApplicationTypeHealthPolicyMap.
   * The computation rounds up to tolerate one failure on small numbers of
   * applications. Default percentage is zero.
   * @property {array} [clusterHealthPolicy.applicationTypeHealthPolicyMap]
   * Defines a map with max percentage unhealthy applications for specific
   * application types.
   * Each entry specifies as key the application type name and as value an
   * integer that represents the MaxPercentUnhealthyApplications percentage
   * used to evaluate the applications of the specified application type.
   *
   * The application type health policy map can be used during cluster health
   * evaluation to describe special application types.
   * The application types included in the map are evaluated against the
   * percentage specified in the map, and not with the global
   * MaxPercentUnhealthyApplications defined in the cluster health policy.
   * The applications of application types specified in the map are not counted
   * against the global pool of applications.
   * For example, if some applications of a type are critical, the cluster
   * administrator can add an entry to the map for that application type
   * and assign it a value of 0% (that is, do not tolerate any failures).
   * All other applications can be evaluated with
   * MaxPercentUnhealthyApplications set to 20% to tolerate some failures out
   * of the thousands of application instances.
   * The application type health policy map is used only if the cluster
   * manifest enables application type health evaluation using the
   * configuration entry for
   * HealthManager/EnableApplicationTypeHealthEvaluation.
   * @property {object} [applicationHealthPolicies] Defines the application
   * health policy map used to evaluate the health of an application or one of
   * its children entities.
   * @property {array} [applicationHealthPolicies.applicationHealthPolicyMap]
   * The wrapper that contains the map with application health policies used to
   * evaluate specific applications in the cluster.
   */
  constructor() {
  }

  /**
   * Defines the metadata of ClusterHealthChunkQueryDescription
   *
   * @returns {object} metadata of ClusterHealthChunkQueryDescription
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'ClusterHealthChunkQueryDescription',
      type: {
        name: 'Composite',
        className: 'ClusterHealthChunkQueryDescription',
        modelProperties: {
          nodeFilters: {
            required: false,
            serializedName: 'NodeFilters',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'NodeHealthStateFilterElementType',
                  type: {
                    name: 'Composite',
                    className: 'NodeHealthStateFilter'
                  }
              }
            }
          },
          applicationFilters: {
            required: false,
            serializedName: 'ApplicationFilters',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'ApplicationHealthStateFilterElementType',
                  type: {
                    name: 'Composite',
                    className: 'ApplicationHealthStateFilter'
                  }
              }
            }
          },
          clusterHealthPolicy: {
            required: false,
            serializedName: 'ClusterHealthPolicy',
            type: {
              name: 'Composite',
              className: 'ClusterHealthPolicy'
            }
          },
          applicationHealthPolicies: {
            required: false,
            serializedName: 'ApplicationHealthPolicies',
            type: {
              name: 'Composite',
              className: 'ApplicationHealthPolicies'
            }
          }
        }
      }
    };
  }
}

module.exports = ClusterHealthChunkQueryDescription;
