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

/**
 * Describes the parameters for an application upgrade.
 *
 */
class ApplicationUpgradeProgressInfo {
  /**
   * Create a ApplicationUpgradeProgressInfo.
   * @property {string} [name] The name of the target application, including
   * the 'fabric:' URI scheme.
   * @property {string} [typeName] The application type name as defined in the
   * application manifest.
   * @property {string} [targetApplicationTypeVersion] The target application
   * type version (found in the application manifest) for the application
   * upgrade.
   * @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] Describes the parameters for an
   * application upgrade. Note that upgrade description replaces the existing
   * application description. This means that if the parameters are not
   * specified, the existing parameters on the applications will be overwritten
   * with the empty parameters list. This would result in the application using
   * the default value of the parameters from the application manifest. If you
   * do not want to change any existing parameter values, please get the
   * application parameters first using the GetApplicationInfo query and then
   * supply those values as Parameters in this ApplicationUpgradeDescription.
   * @property {string} [upgradeDescription.name] The name of the target
   * application, including the 'fabric:' URI scheme.
   * @property {string} [upgradeDescription.targetApplicationTypeVersion] The
   * target application type version (found in the application manifest) for
   * the application upgrade.
   * @property {array} [upgradeDescription.parameters] List of application
   * parameters with overridden values from their default values specified in
   * the application manifest.
   * @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 {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.applicationHealthPolicy] Defines a
   * health policy used to evaluate the health of an application or one of its
   * children entities.
   * @property {boolean}
   * [upgradeDescription.applicationHealthPolicy.considerWarningAsError]
   * Indicates whether warnings are treated with the same severity as errors.
   * @property {number}
   * [upgradeDescription.applicationHealthPolicy.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.
   * @property {object}
   * [upgradeDescription.applicationHealthPolicy.defaultServiceTypeHealthPolicy]
   * The health policy used by default to evaluate the health of a service
   * type.
   * @property {number}
   * [upgradeDescription.applicationHealthPolicy.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}
   * [upgradeDescription.applicationHealthPolicy.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}
   * [upgradeDescription.applicationHealthPolicy.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}
   * [upgradeDescription.applicationHealthPolicy.serviceTypeHealthPolicyMap]
   * The map with service type health policy per service type name. The map is
   * empty by default.
   * @property {string} [upgradeDurationInMilliseconds] The estimated total
   * amount of time spent processing the overall upgrade.
   * @property {string} [upgradeDomainDurationInMilliseconds] The estimated
   * total amount of 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 estimated UTC datetime when the
   * upgrade started.
   * @property {string} [failureTimestampUtc] The estimated UTC datetime when
   * the upgrade failed and FailureAction was executed.
   * @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] Information about the
   * upgrade domain progress at the time of upgrade failure.
   * @property {string} [upgradeDomainProgressAtFailure.domainName] The name of
   * the upgrade domain
   * @property {array} [upgradeDomainProgressAtFailure.nodeUpgradeProgressList]
   * List of upgrading nodes and their statuses
   * @property {string} [upgradeStatusDetails] Additional detailed information
   * about the status of the pending upgrade.
   */
  constructor() {
  }

  /**
   * Defines the metadata of ApplicationUpgradeProgressInfo
   *
   * @returns {object} metadata of ApplicationUpgradeProgressInfo
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'ApplicationUpgradeProgressInfo',
      type: {
        name: 'Composite',
        className: 'ApplicationUpgradeProgressInfo',
        modelProperties: {
          name: {
            required: false,
            serializedName: 'Name',
            type: {
              name: 'String'
            }
          },
          typeName: {
            required: false,
            serializedName: 'TypeName',
            type: {
              name: 'String'
            }
          },
          targetApplicationTypeVersion: {
            required: false,
            serializedName: 'TargetApplicationTypeVersion',
            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: 'ApplicationUpgradeDescription'
            }
          },
          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: 'FailureUpgradeDomainProgressInfo'
            }
          },
          upgradeStatusDetails: {
            required: false,
            serializedName: 'UpgradeStatusDetails',
            type: {
              name: 'String'
            }
          }
        }
      }
    };
  }
}

module.exports = ApplicationUpgradeProgressInfo;
