/**
 * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
 * This product includes software developed at Datadog (https://www.datadoghq.com/).
 * Copyright 2020-Present Datadog, Inc.
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import { LogContent } from "./LogContent";
import { ObjectSerializer } from "./ObjectSerializer";

/**
 * Object describing a log after being processed and stored by Datadog.
 */

export class Log {
  "content"?: LogContent;
  /**
   * Unique ID of the Log.
   */
  "id"?: string;

  "unparsedObject"?: any;

  static readonly discriminator: string | undefined = undefined;

  static readonly attributeTypeMap: {
    [key: string]: { baseName: string; type: string; format: string };
  } = {
    content: {
      baseName: "content",
      type: "LogContent",
      format: "",
    },
    id: {
      baseName: "id",
      type: "string",
      format: "",
    },
  };

  static getAttributeTypeMap() {
    return Log.attributeTypeMap;
  }

  static deserialize(data: { [key: string]: any }): Log {
    const res = new Log();

    res.content = ObjectSerializer.deserialize(data.content, "LogContent", "");

    res.id = ObjectSerializer.deserialize(data.id, "string", "");

    return res;
  }

  static serialize(data: Log): { [key: string]: any } {
    const attributeTypes = Log.getAttributeTypeMap();
    const res: { [index: string]: any } = {};
    for (const [key, value] of Object.entries(data)) {
      if (!(key in attributeTypes)) {
        throw new TypeError(`${key} attribute not in schema`);
      }
    }
    if (data?.unparsedObject !== undefined) {
      return data.unparsedObject;
    }
    res.content = ObjectSerializer.serialize(data.content, "LogContent", "");

    res.id = ObjectSerializer.serialize(data.id, "string", "");

    return res;
  }

  public constructor() {}
}
