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

/**
 * Information about a cluster upgrade.
 *
 */
class ClusterUpgradeProgressObject {
  /**
   * Create a ClusterUpgradeProgressObject.
   * @property {string} [codeVersion] The ServiceFabric code version of the
   * cluster.
   * @property {string} [configVersion] The cluster configuration version
   * (specified in the cluster manifest).
   * @property {array} [upgradeDomains] List of upgrade domains and their
   * statuses.
   * @property {string} [upgradeState] The state of the upgrade domain.
   * Possible values include: 'Invalid', 'RollingBackInProgress',
   * 'RollingBackCompleted', 'RollingForwardPending',
   * 'RollingForwardInProgress', 'RollingForwardCompleted', 'Failed'
   * @property {string} [nextUpgradeDomain] The name of the next upgrade domain
   * to be processed.
   * @property {string} [rollingUpgradeMode] The mode used to monitor health
   * during a rolling upgrade. The values are UnmonitoredAuto,
   * UnmonitoredManual, and Monitored. Possible values include: 'Invalid',
   * 'UnmonitoredAuto', 'UnmonitoredManual', 'Monitored'. Default value:
   * 'UnmonitoredAuto' .
   * @property {object} [upgradeDescription] Represents a ServiceFabric cluster
   * upgrade
   * @property {string} [upgradeDescription.configVersion] The cluster
   * configuration version (specified in the cluster manifest).
   * @property {string} [upgradeDescription.codeVersion] The ServiceFabric code
   * version of the cluster.
   * @property {string} [upgradeDescription.upgradeKind] The kind of upgrade
   * out of the following possible values. Possible values include: 'Invalid',
   * 'Rolling'
   * @property {string} [upgradeDescription.rollingUpgradeMode] The mode used
   * to monitor health during a rolling upgrade. The values are
   * UnmonitoredAuto, UnmonitoredManual, and Monitored. Possible values
   * include: 'Invalid', 'UnmonitoredAuto', 'UnmonitoredManual', 'Monitored'
   * @property {number}
   * [upgradeDescription.upgradeReplicaSetCheckTimeoutInSeconds] The maximum
   * amount of time to block processing of an upgrade domain and prevent loss
   * of availability when there are unexpected issues. When this timeout
   * expires, processing of the upgrade domain will proceed regardless of
   * availability loss issues. The timeout is reset at the start of each
   * upgrade domain. Valid values are between 0 and 42949672925 inclusive.
   * (unsigned 32-bit integer).
   * @property {boolean} [upgradeDescription.forceRestart] If true, then
   * processes are forcefully restarted during upgrade even when the code
   * version has not changed (the upgrade only changes configuration or data).
   * @property {boolean} [upgradeDescription.enableDeltaHealthEvaluation] When
   * true, enables delta health evaluation rather than absolute health
   * evaluation after completion of each upgrade domain.
   * @property {object} [upgradeDescription.monitoringPolicy] Describes the
   * parameters for monitoring an upgrade in Monitored mode.
   * @property {string} [upgradeDescription.monitoringPolicy.failureAction] The
   * compensating action to perform when a Monitored upgrade encounters
   * monitoring policy or health policy violations.
   * Invalid indicates the failure action is invalid. Rollback specifies that
   * the upgrade will start rolling back automatically.
   * Manual indicates that the upgrade will switch to UnmonitoredManual upgrade
   * mode. Possible values include: 'Invalid', 'Rollback', 'Manual'
   * @property {string}
   * [upgradeDescription.monitoringPolicy.healthCheckWaitDurationInMilliseconds]
   * The amount of time to wait after completing an upgrade domain before
   * applying health policies. It is first interpreted as a string representing
   * an ISO 8601 duration. If that fails, then it is interpreted as a number
   * representing the total number of milliseconds.
   * @property {string}
   * [upgradeDescription.monitoringPolicy.healthCheckStableDurationInMilliseconds]
   * The amount of time that the application or cluster must remain healthy
   * before the upgrade proceeds to the next upgrade domain. It is first
   * interpreted as a string representing an ISO 8601 duration. If that fails,
   * then it is interpreted as a number representing the total number of
   * milliseconds.
   * @property {string}
   * [upgradeDescription.monitoringPolicy.healthCheckRetryTimeoutInMilliseconds]
   * The amount of time to retry health evaluation when the application or
   * cluster is unhealthy before FailureAction is executed. It is first
   * interpreted as a string representing an ISO 8601 duration. If that fails,
   * then it is interpreted as a number representing the total number of
   * milliseconds.
   * @property {string}
   * [upgradeDescription.monitoringPolicy.upgradeTimeoutInMilliseconds] The
   * amount of time the overall upgrade has to complete before FailureAction is
   * executed. It is first interpreted as a string representing an ISO 8601
   * duration. If that fails, then it is interpreted as a number representing
   * the total number of milliseconds.
   * @property {string}
   * [upgradeDescription.monitoringPolicy.upgradeDomainTimeoutInMilliseconds]
   * The amount of time each upgrade domain has to complete before
   * FailureAction is executed. It is first interpreted as a string
   * representing an ISO 8601 duration. If that fails, then it is interpreted
   * as a number representing the total number of milliseconds.
   * @property {object} [upgradeDescription.clusterHealthPolicy] Defines a
   * health policy used to evaluate the health of the cluster or of a cluster
   * node.
   * @property {boolean}
   * [upgradeDescription.clusterHealthPolicy.considerWarningAsError] Indicates
   * whether warnings are treated with the same severity as errors.
   * @property {number}
   * [upgradeDescription.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}
   * [upgradeDescription.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}
   * [upgradeDescription.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} [upgradeDescription.clusterUpgradeHealthPolicy] Defines
   * a health policy used to evaluate the health of the cluster during a
   * cluster upgrade.
   * @property {number}
   * [upgradeDescription.clusterUpgradeHealthPolicy.maxPercentDeltaUnhealthyNodes]
   * The maximum allowed percentage of nodes health degradation allowed during
   * cluster upgrades. The delta is measured between the state of the nodes at
   * the beginning of upgrade and the state of the nodes at the time of the
   * health evaluation. The check is performed after every upgrade domain
   * upgrade completion to make sure the global state of the cluster is within
   * tolerated limits. The default value is 10%.
   * @property {number}
   * [upgradeDescription.clusterUpgradeHealthPolicy.maxPercentUpgradeDomainDeltaUnhealthyNodes]
   * The maximum allowed percentage of upgrade domain nodes health degradation
   * allowed during cluster upgrades. The delta is measured between the state
   * of the upgrade domain nodes at the beginning of upgrade and the state of
   * the upgrade domain nodes at the time of the health evaluation. The check
   * is performed after every upgrade domain upgrade completion for all
   * completed upgrade domains to make sure the state of the upgrade domains is
   * within tolerated limits. The default value is 15%.
   * @property {array} [upgradeDescription.applicationHealthPolicyMap] Defines
   * a map that contains specific application health policies for different
   * applications.
   * Each entry specifies as key the application name and as value an
   * ApplicationHealthPolicy used to evaluate the application health.
   * If an application is not specified in the map, the application health
   * evaluation uses the ApplicationHealthPolicy found in its application
   * manifest or the default application health policy (if no health policy is
   * defined in the manifest).
   * The map is empty by default.
   * @property {string} [upgradeDurationInMilliseconds] The estimated elapsed
   * time spent processing the current overall upgrade.
   * @property {string} [upgradeDomainDurationInMilliseconds] The estimated
   * elapsed time spent processing the current upgrade domain.
   * @property {array} [unhealthyEvaluations] List of health evaluations that
   * resulted in the current aggregated health state.
   * @property {object} [currentUpgradeDomainProgress] Information about the
   * current in-progress upgrade domain.
   * @property {string} [currentUpgradeDomainProgress.domainName] The name of
   * the upgrade domain
   * @property {array} [currentUpgradeDomainProgress.nodeUpgradeProgressList]
   * List of upgrading nodes and their statuses
   * @property {string} [startTimestampUtc] The start time of the upgrade in
   * UTC.
   * @property {string} [failureTimestampUtc] The failure time of the upgrade
   * in UTC.
   * @property {string} [failureReason] The cause of an upgrade failure that
   * resulted in FailureAction being executed. Possible values include: 'None',
   * 'Interrupted', 'HealthCheck', 'UpgradeDomainTimeout',
   * 'OverallUpgradeTimeout'
   * @property {object} [upgradeDomainProgressAtFailure] The detailed upgrade
   * progress for nodes in the current upgrade domain at the point of failure.
   * @property {string} [upgradeDomainProgressAtFailure.domainName] The name of
   * the upgrade domain
   * @property {array} [upgradeDomainProgressAtFailure.nodeUpgradeProgressList]
   * List of upgrading nodes and their statuses
   */
  constructor() {
  }

  /**
   * Defines the metadata of ClusterUpgradeProgressObject
   *
   * @returns {object} metadata of ClusterUpgradeProgressObject
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'ClusterUpgradeProgressObject',
      type: {
        name: 'Composite',
        className: 'ClusterUpgradeProgressObject',
        modelProperties: {
          codeVersion: {
            required: false,
            serializedName: 'CodeVersion',
            type: {
              name: 'String'
            }
          },
          configVersion: {
            required: false,
            serializedName: 'ConfigVersion',
            type: {
              name: 'String'
            }
          },
          upgradeDomains: {
            required: false,
            serializedName: 'UpgradeDomains',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'UpgradeDomainInfoElementType',
                  type: {
                    name: 'Composite',
                    className: 'UpgradeDomainInfo'
                  }
              }
            }
          },
          upgradeState: {
            required: false,
            serializedName: 'UpgradeState',
            type: {
              name: 'String'
            }
          },
          nextUpgradeDomain: {
            required: false,
            serializedName: 'NextUpgradeDomain',
            type: {
              name: 'String'
            }
          },
          rollingUpgradeMode: {
            required: false,
            serializedName: 'RollingUpgradeMode',
            defaultValue: 'UnmonitoredAuto',
            type: {
              name: 'String'
            }
          },
          upgradeDescription: {
            required: false,
            serializedName: 'UpgradeDescription',
            type: {
              name: 'Composite',
              className: 'ClusterUpgradeDescriptionObject'
            }
          },
          upgradeDurationInMilliseconds: {
            required: false,
            serializedName: 'UpgradeDurationInMilliseconds',
            type: {
              name: 'String'
            }
          },
          upgradeDomainDurationInMilliseconds: {
            required: false,
            serializedName: 'UpgradeDomainDurationInMilliseconds',
            type: {
              name: 'String'
            }
          },
          unhealthyEvaluations: {
            required: false,
            serializedName: 'UnhealthyEvaluations',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'HealthEvaluationWrapperElementType',
                  type: {
                    name: 'Composite',
                    className: 'HealthEvaluationWrapper'
                  }
              }
            }
          },
          currentUpgradeDomainProgress: {
            required: false,
            serializedName: 'CurrentUpgradeDomainProgress',
            type: {
              name: 'Composite',
              className: 'CurrentUpgradeDomainProgressInfo'
            }
          },
          startTimestampUtc: {
            required: false,
            serializedName: 'StartTimestampUtc',
            type: {
              name: 'String'
            }
          },
          failureTimestampUtc: {
            required: false,
            serializedName: 'FailureTimestampUtc',
            type: {
              name: 'String'
            }
          },
          failureReason: {
            required: false,
            serializedName: 'FailureReason',
            type: {
              name: 'String'
            }
          },
          upgradeDomainProgressAtFailure: {
            required: false,
            serializedName: 'UpgradeDomainProgressAtFailure',
            type: {
              name: 'Composite',
              className: 'FailedUpgradeDomainProgressObject'
            }
          }
        }
      }
    };
  }
}

module.exports = ClusterUpgradeProgressObject;
