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

/**
 * Represents the health of the stateful service replica.
 * Contains the replica aggregated health state, the health events and the
 * unhealthy evaluations.
 *
 * @extends models['ReplicaHealth']
 */
class StatefulServiceReplicaHealth extends models['ReplicaHealth'] {
  /**
   * Create a StatefulServiceReplicaHealth.
   * @property {string} [replicaId] Id of a stateful service replica. ReplicaId
   * is used by Service Fabric to uniquely identify a replica of a partition.
   * It is unique within a partition and does not change for the lifetime of
   * the replica. If a replica gets dropped and another replica gets created on
   * the same node for the same partition, it will get a different value for
   * the id. Sometimes the id of a stateless service instance is also referred
   * as a replica id.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of StatefulServiceReplicaHealth
   *
   * @returns {object} metadata of StatefulServiceReplicaHealth
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'Stateful',
      type: {
        name: 'Composite',
        polymorphicDiscriminator: {
          serializedName: 'ServiceKind',
          clientName: 'serviceKind'
        },
        uberParent: 'EntityHealth',
        className: 'StatefulServiceReplicaHealth',
        modelProperties: {
          aggregatedHealthState: {
            required: false,
            serializedName: 'AggregatedHealthState',
            type: {
              name: 'String'
            }
          },
          healthEvents: {
            required: false,
            serializedName: 'HealthEvents',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'HealthEventElementType',
                  type: {
                    name: 'Composite',
                    className: 'HealthEvent'
                  }
              }
            }
          },
          unhealthyEvaluations: {
            required: false,
            serializedName: 'UnhealthyEvaluations',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'HealthEvaluationWrapperElementType',
                  type: {
                    name: 'Composite',
                    className: 'HealthEvaluationWrapper'
                  }
              }
            }
          },
          healthStatistics: {
            required: false,
            serializedName: 'HealthStatistics',
            type: {
              name: 'Composite',
              className: 'HealthStatistics'
            }
          },
          partitionId: {
            required: false,
            serializedName: 'PartitionId',
            type: {
              name: 'String'
            }
          },
          serviceKind: {
            required: true,
            serializedName: 'ServiceKind',
            isPolymorphicDiscriminator: true,
            type: {
              name: 'String'
            }
          },
          replicaId: {
            required: false,
            serializedName: 'ReplicaId',
            type: {
              name: 'String'
            }
          }
        }
      }
    };
  }
}

module.exports = StatefulServiceReplicaHealth;
