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

/**
 * Describes a stateful service.
 *
 * @extends models['ServiceDescription']
 */
class StatefulServiceDescription extends models['ServiceDescription'] {
  /**
   * Create a StatefulServiceDescription.
   * @property {number} targetReplicaSetSize The target replica set size as a
   * number.
   * @property {number} minReplicaSetSize The minimum replica set size as a
   * number.
   * @property {boolean} hasPersistedState A flag indicating whether this is a
   * persistent service which stores states on the local disk. If it is then
   * the value of this property is true, if not it is false.
   * @property {number} [flags] Flags indicating whether other properties are
   * set. Each of the associated properties corresponds to a flag, specified
   * below, which, if set, indicate that the property is specified.
   * This property can be a combination of those flags obtained using bitwise
   * 'OR' operator.
   * For example, if the provided value is 6 then the flags for
   * QuorumLossWaitDuration (2) and StandByReplicaKeepDuration(4) are set.
   *
   * - None - Does not indicate any other properties are set. The value is
   * zero.
   * - ReplicaRestartWaitDuration - Indicates the ReplicaRestartWaitDuration
   * property is set. The value is 1.
   * - QuorumLossWaitDuration - Indicates the QuorumLossWaitDuration property
   * is set. The value is 2.
   * - StandByReplicaKeepDuration - Indicates the StandByReplicaKeepDuration
   * property is set. The value is 4.
   * @property {number} [replicaRestartWaitDurationSeconds] The duration, in
   * seconds, between when a replica goes down and when a new replica is
   * created.
   * @property {number} [quorumLossWaitDurationSeconds] The maximum duration,
   * in seconds, for which a partition is allowed to be in a state of quorum
   * loss.
   * @property {number} [standByReplicaKeepDurationSeconds] The definition on
   * how long StandBy replicas should be maintained before being removed.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of StatefulServiceDescription
   *
   * @returns {object} metadata of StatefulServiceDescription
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'Stateful',
      type: {
        name: 'Composite',
        polymorphicDiscriminator: {
          serializedName: 'ServiceKind',
          clientName: 'serviceKind'
        },
        uberParent: 'ServiceDescription',
        className: 'StatefulServiceDescription',
        modelProperties: {
          applicationName: {
            required: false,
            serializedName: 'ApplicationName',
            type: {
              name: 'String'
            }
          },
          serviceName: {
            required: true,
            serializedName: 'ServiceName',
            type: {
              name: 'String'
            }
          },
          serviceTypeName: {
            required: true,
            serializedName: 'ServiceTypeName',
            type: {
              name: 'String'
            }
          },
          initializationData: {
            required: false,
            serializedName: 'InitializationData',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'NumberElementType',
                  type: {
                    name: 'Number'
                  }
              }
            }
          },
          partitionDescription: {
            required: true,
            serializedName: 'PartitionDescription',
            type: {
              name: 'Composite',
              polymorphicDiscriminator: {
                serializedName: 'PartitionScheme',
                clientName: 'partitionScheme'
              },
              uberParent: 'PartitionSchemeDescription',
              className: 'PartitionSchemeDescription'
            }
          },
          placementConstraints: {
            required: false,
            serializedName: 'PlacementConstraints',
            type: {
              name: 'String'
            }
          },
          correlationScheme: {
            required: false,
            serializedName: 'CorrelationScheme',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'ServiceCorrelationDescriptionElementType',
                  type: {
                    name: 'Composite',
                    className: 'ServiceCorrelationDescription'
                  }
              }
            }
          },
          serviceLoadMetrics: {
            required: false,
            serializedName: 'ServiceLoadMetrics',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'ServiceLoadMetricDescriptionElementType',
                  type: {
                    name: 'Composite',
                    className: 'ServiceLoadMetricDescription'
                  }
              }
            }
          },
          servicePlacementPolicies: {
            required: false,
            serializedName: 'ServicePlacementPolicies',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'ServicePlacementPolicyDescriptionElementType',
                  type: {
                    name: 'Composite',
                    polymorphicDiscriminator: {
                      serializedName: 'Type',
                      clientName: 'type'
                    },
                    uberParent: 'ServicePlacementPolicyDescription',
                    className: 'ServicePlacementPolicyDescription'
                  }
              }
            }
          },
          defaultMoveCost: {
            required: false,
            serializedName: 'DefaultMoveCost',
            type: {
              name: 'String'
            }
          },
          isDefaultMoveCostSpecified: {
            required: false,
            serializedName: 'IsDefaultMoveCostSpecified',
            type: {
              name: 'Boolean'
            }
          },
          servicePackageActivationMode: {
            required: false,
            serializedName: 'ServicePackageActivationMode',
            type: {
              name: 'String'
            }
          },
          serviceDnsName: {
            required: false,
            serializedName: 'ServiceDnsName',
            type: {
              name: 'String'
            }
          },
          scalingPolicies: {
            required: false,
            serializedName: 'ScalingPolicies',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'ScalingPolicyDescriptionElementType',
                  type: {
                    name: 'Composite',
                    className: 'ScalingPolicyDescription'
                  }
              }
            }
          },
          serviceKind: {
            required: true,
            serializedName: 'ServiceKind',
            isPolymorphicDiscriminator: true,
            type: {
              name: 'String'
            }
          },
          targetReplicaSetSize: {
            required: true,
            serializedName: 'TargetReplicaSetSize',
            constraints: {
              InclusiveMinimum: 1
            },
            type: {
              name: 'Number'
            }
          },
          minReplicaSetSize: {
            required: true,
            serializedName: 'MinReplicaSetSize',
            constraints: {
              InclusiveMinimum: 1
            },
            type: {
              name: 'Number'
            }
          },
          hasPersistedState: {
            required: true,
            serializedName: 'HasPersistedState',
            type: {
              name: 'Boolean'
            }
          },
          flags: {
            required: false,
            serializedName: 'Flags',
            type: {
              name: 'Number'
            }
          },
          replicaRestartWaitDurationSeconds: {
            required: false,
            serializedName: 'ReplicaRestartWaitDurationSeconds',
            constraints: {
              InclusiveMaximum: 4294967295,
              InclusiveMinimum: 0
            },
            type: {
              name: 'Number'
            }
          },
          quorumLossWaitDurationSeconds: {
            required: false,
            serializedName: 'QuorumLossWaitDurationSeconds',
            constraints: {
              InclusiveMaximum: 4294967295,
              InclusiveMinimum: 0
            },
            type: {
              name: 'Number'
            }
          },
          standByReplicaKeepDurationSeconds: {
            required: false,
            serializedName: 'StandByReplicaKeepDurationSeconds',
            constraints: {
              InclusiveMaximum: 4294967295,
              InclusiveMinimum: 0
            },
            type: {
              name: 'Number'
            }
          }
        }
      }
    };
  }
}

module.exports = StatefulServiceDescription;
