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

/**
 * This enables publishing to Event Grid using a custom input schema. This can
 * be used to map properties from a custom input JSON schema to the Event Grid
 * event schema.
 *
 * @extends models['InputSchemaMapping']
 */
class JsonInputSchemaMapping extends models['InputSchemaMapping'] {
  /**
   * Create a JsonInputSchemaMapping.
   * @property {object} [id] The mapping information for the Id property of the
   * Event Grid Event.
   * @property {string} [id.sourceField] Name of a field in the input event
   * schema that's to be used as the source of a mapping.
   * @property {object} [topic] The mapping information for the Topic property
   * of the Event Grid Event.
   * @property {string} [topic.sourceField] Name of a field in the input event
   * schema that's to be used as the source of a mapping.
   * @property {object} [eventTime] The mapping information for the EventTime
   * property of the Event Grid Event.
   * @property {string} [eventTime.sourceField] Name of a field in the input
   * event schema that's to be used as the source of a mapping.
   * @property {object} [eventType] The mapping information for the EventType
   * property of the Event Grid Event.
   * @property {string} [eventType.sourceField] Name of a field in the input
   * event schema that's to be used as the source of a mapping.
   * @property {string} [eventType.defaultValue] The default value to be used
   * for mapping when a SourceField is not provided or if there's no property
   * with the specified name in the published JSON event payload.
   * @property {object} [subject] The mapping information for the Subject
   * property of the Event Grid Event.
   * @property {string} [subject.sourceField] Name of a field in the input
   * event schema that's to be used as the source of a mapping.
   * @property {string} [subject.defaultValue] The default value to be used for
   * mapping when a SourceField is not provided or if there's no property with
   * the specified name in the published JSON event payload.
   * @property {object} [dataVersion] The mapping information for the
   * DataVersion property of the Event Grid Event.
   * @property {string} [dataVersion.sourceField] Name of a field in the input
   * event schema that's to be used as the source of a mapping.
   * @property {string} [dataVersion.defaultValue] The default value to be used
   * for mapping when a SourceField is not provided or if there's no property
   * with the specified name in the published JSON event payload.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of JsonInputSchemaMapping
   *
   * @returns {object} metadata of JsonInputSchemaMapping
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'Json',
      type: {
        name: 'Composite',
        polymorphicDiscriminator: {
          serializedName: 'inputSchemaMappingType',
          clientName: 'inputSchemaMappingType'
        },
        uberParent: 'InputSchemaMapping',
        className: 'JsonInputSchemaMapping',
        modelProperties: {
          inputSchemaMappingType: {
            required: true,
            serializedName: 'inputSchemaMappingType',
            isPolymorphicDiscriminator: true,
            type: {
              name: 'String'
            }
          },
          id: {
            required: false,
            serializedName: 'properties.id',
            type: {
              name: 'Composite',
              className: 'JsonField'
            }
          },
          topic: {
            required: false,
            serializedName: 'properties.topic',
            type: {
              name: 'Composite',
              className: 'JsonField'
            }
          },
          eventTime: {
            required: false,
            serializedName: 'properties.eventTime',
            type: {
              name: 'Composite',
              className: 'JsonField'
            }
          },
          eventType: {
            required: false,
            serializedName: 'properties.eventType',
            type: {
              name: 'Composite',
              className: 'JsonFieldWithDefault'
            }
          },
          subject: {
            required: false,
            serializedName: 'properties.subject',
            type: {
              name: 'Composite',
              className: 'JsonFieldWithDefault'
            }
          },
          dataVersion: {
            required: false,
            serializedName: 'properties.dataVersion',
            type: {
              name: 'Composite',
              className: 'JsonFieldWithDefault'
            }
          }
        }
      }
    };
  }
}

module.exports = JsonInputSchemaMapping;
