/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod";
import { remap as remap$ } from "../../../lib/primitives.js";
import { safeParse } from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * An integer log level to write to the PMS log with.
 *
 * @remarks
 * 0: Error
 * 1: Warning
 * 2: Info
 * 3: Debug
 * 4: Verbose
 */
export enum Level {
  Zero = 0,
  One = 1,
  Two = 2,
  Three = 3,
  Four = 4,
}

export type LogLineRequest = {
  /**
   * An integer log level to write to the PMS log with.
   *
   * @remarks
   * 0: Error
   * 1: Warning
   * 2: Info
   * 3: Debug
   * 4: Verbose
   */
  level: Level;
  /**
   * The text of the message to write to the log.
   */
  message: string;
  /**
   * a string indicating the source of the message.
   */
  source: string;
};

export type LogLineResponse = {
  /**
   * HTTP response content type for this operation
   */
  contentType: string;
  /**
   * HTTP response status code for this operation
   */
  statusCode: number;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse: Response;
};

/** @internal */
export const Level$inboundSchema: z.ZodNativeEnum<typeof Level> = z.nativeEnum(
  Level,
);

/** @internal */
export const Level$outboundSchema: z.ZodNativeEnum<typeof Level> =
  Level$inboundSchema;

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace Level$ {
  /** @deprecated use `Level$inboundSchema` instead. */
  export const inboundSchema = Level$inboundSchema;
  /** @deprecated use `Level$outboundSchema` instead. */
  export const outboundSchema = Level$outboundSchema;
}

/** @internal */
export const LogLineRequest$inboundSchema: z.ZodType<
  LogLineRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  level: Level$inboundSchema,
  message: z.string(),
  source: z.string(),
});

/** @internal */
export type LogLineRequest$Outbound = {
  level: number;
  message: string;
  source: string;
};

/** @internal */
export const LogLineRequest$outboundSchema: z.ZodType<
  LogLineRequest$Outbound,
  z.ZodTypeDef,
  LogLineRequest
> = z.object({
  level: Level$outboundSchema,
  message: z.string(),
  source: z.string(),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace LogLineRequest$ {
  /** @deprecated use `LogLineRequest$inboundSchema` instead. */
  export const inboundSchema = LogLineRequest$inboundSchema;
  /** @deprecated use `LogLineRequest$outboundSchema` instead. */
  export const outboundSchema = LogLineRequest$outboundSchema;
  /** @deprecated use `LogLineRequest$Outbound` instead. */
  export type Outbound = LogLineRequest$Outbound;
}

export function logLineRequestToJSON(logLineRequest: LogLineRequest): string {
  return JSON.stringify(LogLineRequest$outboundSchema.parse(logLineRequest));
}

export function logLineRequestFromJSON(
  jsonString: string,
): SafeParseResult<LogLineRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => LogLineRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'LogLineRequest' from JSON`,
  );
}

/** @internal */
export const LogLineResponse$inboundSchema: z.ZodType<
  LogLineResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  ContentType: z.string(),
  StatusCode: z.number().int(),
  RawResponse: z.instanceof(Response),
}).transform((v) => {
  return remap$(v, {
    "ContentType": "contentType",
    "StatusCode": "statusCode",
    "RawResponse": "rawResponse",
  });
});

/** @internal */
export type LogLineResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
};

/** @internal */
export const LogLineResponse$outboundSchema: z.ZodType<
  LogLineResponse$Outbound,
  z.ZodTypeDef,
  LogLineResponse
> = z.object({
  contentType: z.string(),
  statusCode: z.number().int(),
  rawResponse: z.instanceof(Response).transform(() => {
    throw new Error("Response cannot be serialized");
  }),
}).transform((v) => {
  return remap$(v, {
    contentType: "ContentType",
    statusCode: "StatusCode",
    rawResponse: "RawResponse",
  });
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace LogLineResponse$ {
  /** @deprecated use `LogLineResponse$inboundSchema` instead. */
  export const inboundSchema = LogLineResponse$inboundSchema;
  /** @deprecated use `LogLineResponse$outboundSchema` instead. */
  export const outboundSchema = LogLineResponse$outboundSchema;
  /** @deprecated use `LogLineResponse$Outbound` instead. */
  export type Outbound = LogLineResponse$Outbound;
}

export function logLineResponseToJSON(
  logLineResponse: LogLineResponse,
): string {
  return JSON.stringify(LogLineResponse$outboundSchema.parse(logLineResponse));
}

export function logLineResponseFromJSON(
  jsonString: string,
): SafeParseResult<LogLineResponse, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => LogLineResponse$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'LogLineResponse' from JSON`,
  );
}
