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

/**
 * A failover group.
 *
 * @extends models['ProxyResource']
 */
class FailoverGroup extends models['ProxyResource'] {
  /**
   * Create a FailoverGroup.
   * @property {string} [location] Resource location.
   * @property {object} [tags] Resource tags.
   * @property {object} readWriteEndpoint Read-write endpoint of the failover
   * group instance.
   * @property {string} [readWriteEndpoint.failoverPolicy] Failover policy of
   * the read-write endpoint for the failover group. If failoverPolicy is
   * Automatic then failoverWithDataLossGracePeriodMinutes is required.
   * Possible values include: 'Manual', 'Automatic'
   * @property {number}
   * [readWriteEndpoint.failoverWithDataLossGracePeriodMinutes] Grace period
   * before failover with data loss is attempted for the read-write endpoint.
   * If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes
   * is required.
   * @property {object} [readOnlyEndpoint] Read-only endpoint of the failover
   * group instance.
   * @property {string} [readOnlyEndpoint.failoverPolicy] Failover policy of
   * the read-only endpoint for the failover group. Possible values include:
   * 'Disabled', 'Enabled'
   * @property {string} [replicationRole] Local replication role of the
   * failover group instance. Possible values include: 'Primary', 'Secondary'
   * @property {string} [replicationState] Replication state of the failover
   * group instance.
   * @property {array} partnerServers List of partner server information for
   * the failover group.
   * @property {array} [databases] List of databases in the failover group.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of FailoverGroup
   *
   * @returns {object} metadata of FailoverGroup
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'FailoverGroup',
      type: {
        name: 'Composite',
        className: 'FailoverGroup',
        modelProperties: {
          id: {
            required: false,
            readOnly: true,
            serializedName: 'id',
            type: {
              name: 'String'
            }
          },
          name: {
            required: false,
            readOnly: true,
            serializedName: 'name',
            type: {
              name: 'String'
            }
          },
          type: {
            required: false,
            readOnly: true,
            serializedName: 'type',
            type: {
              name: 'String'
            }
          },
          location: {
            required: false,
            readOnly: true,
            serializedName: 'location',
            type: {
              name: 'String'
            }
          },
          tags: {
            required: false,
            serializedName: 'tags',
            type: {
              name: 'Dictionary',
              value: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          readWriteEndpoint: {
            required: true,
            serializedName: 'properties.readWriteEndpoint',
            type: {
              name: 'Composite',
              className: 'FailoverGroupReadWriteEndpoint'
            }
          },
          readOnlyEndpoint: {
            required: false,
            serializedName: 'properties.readOnlyEndpoint',
            type: {
              name: 'Composite',
              className: 'FailoverGroupReadOnlyEndpoint'
            }
          },
          replicationRole: {
            required: false,
            readOnly: true,
            serializedName: 'properties.replicationRole',
            type: {
              name: 'String'
            }
          },
          replicationState: {
            required: false,
            readOnly: true,
            serializedName: 'properties.replicationState',
            type: {
              name: 'String'
            }
          },
          partnerServers: {
            required: true,
            serializedName: 'properties.partnerServers',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'PartnerInfoElementType',
                  type: {
                    name: 'Composite',
                    className: 'PartnerInfo'
                  }
              }
            }
          },
          databases: {
            required: false,
            serializedName: 'properties.databases',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          }
        }
      }
    };
  }
}

module.exports = FailoverGroup;
