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

import * as z from "zod/v3";
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";
import * as shared from "../shared/index.js";

export type GetPlaylistGeneratorGlobals = {
  /**
   * Indicates the client accepts the indicated media types
   */
  accepts?: shared.Accepts | undefined;
  /**
   * An opaque identifier unique to the client
   */
  clientIdentifier?: string | undefined;
  /**
   * The name of the client product
   */
  product?: string | undefined;
  /**
   * The version of the client application
   */
  version?: string | undefined;
  /**
   * The platform of the client
   */
  platform?: string | undefined;
  /**
   * The version of the platform
   */
  platformVersion?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  device?: string | undefined;
  /**
   * A potentially less friendly identifier for the device model
   */
  model?: string | undefined;
  /**
   * The device vendor
   */
  deviceVendor?: string | undefined;
  /**
   * A friendly name for the client
   */
  deviceName?: string | undefined;
  /**
   * The marketplace on which the client application is distributed
   */
  marketplace?: string | undefined;
};

export type GetPlaylistGeneratorRequest = {
  /**
   * Indicates the client accepts the indicated media types
   */
  accepts?: shared.Accepts | undefined;
  /**
   * An opaque identifier unique to the client
   */
  clientIdentifier?: string | undefined;
  /**
   * The name of the client product
   */
  product?: string | undefined;
  /**
   * The version of the client application
   */
  version?: string | undefined;
  /**
   * The platform of the client
   */
  platform?: string | undefined;
  /**
   * The version of the platform
   */
  platformVersion?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  device?: string | undefined;
  /**
   * A potentially less friendly identifier for the device model
   */
  model?: string | undefined;
  /**
   * The device vendor
   */
  deviceVendor?: string | undefined;
  /**
   * A friendly name for the client
   */
  deviceName?: string | undefined;
  /**
   * The marketplace on which the client application is distributed
   */
  marketplace?: string | undefined;
  /**
   * The ID of the playlist
   */
  playlistId: number;
  /**
   * The generator item ID to delete.
   */
  generatorId: number;
};

export type GetPlaylistGeneratorDevice = {
  profile?: string | undefined;
};

export type GetPlaylistGeneratorLocation = {
  librarySectionID?: number | undefined;
  uri?: string | undefined;
};

export enum AdvancedSubtitles {
  Auto = "auto",
  Burn = "burn",
  None = "none",
  Sidecar = "sidecar",
  Embedded = "embedded",
  Segmented = "segmented",
}

export enum GetPlaylistGeneratorSubtitles {
  Auto = "auto",
  Burn = "burn",
  None = "none",
  Sidecar = "sidecar",
  Embedded = "embedded",
  Segmented = "segmented",
}

export type MediaSettings = {
  advancedSubtitles?: AdvancedSubtitles | undefined;
  audioBoost?: number | undefined;
  audioChannelCount?: number | undefined;
  autoAdjustQuality?: boolean | undefined;
  autoAdjustSubtitle?: boolean | undefined;
  directPlay?: boolean | undefined;
  directStream?: boolean | undefined;
  directStreamAudio?: boolean | undefined;
  disableResolutionRotation?: boolean | undefined;
  maxVideoBitrate?: number | undefined;
  musicBitrate?: number | undefined;
  peakBitrate?: number | undefined;
  photoQuality?: number | undefined;
  photoResolution?: string | undefined;
  secondsPerSegment?: number | undefined;
  subtitles?: GetPlaylistGeneratorSubtitles | undefined;
  subtitleSize?: number | undefined;
  videoBitrate?: number | undefined;
  videoQuality?: number | undefined;
  videoResolution?: string | undefined;
};

export enum GetPlaylistGeneratorScope {
  All = "all",
  Count = "count",
}

export type GetPlaylistGeneratorPolicy = {
  scope?: GetPlaylistGeneratorScope | undefined;
  /**
   * True if only unwatched items are optimized
   */
  unwatched?: boolean | undefined;
  /**
   * If the scope is count, the number of items to optimize
   */
  value?: number | undefined;
};

export enum GetPlaylistGeneratorState {
  Pending = "pending",
  Complete = "complete",
  Failed = "failed",
}

export type GetPlaylistGeneratorStatus = {
  itemsCompleteCount?: number | undefined;
  itemsCount?: number | undefined;
  itemsSuccessfulCount?: number | undefined;
  state?: GetPlaylistGeneratorState | undefined;
  totalSize?: number | undefined;
};

/**
 * The type of this generator
 */
export enum GetPlaylistGeneratorType {
  Minus1 = -1,
  FortyTwo = 42,
}

export type GetPlaylistGeneratorItem = {
  /**
   * The composite thumbnail image path
   */
  composite?: string | undefined;
  device?: GetPlaylistGeneratorDevice | undefined;
  id?: number | undefined;
  location?: GetPlaylistGeneratorLocation | undefined;
  mediaSettings?: MediaSettings | undefined;
  policy?: GetPlaylistGeneratorPolicy | undefined;
  status?: GetPlaylistGeneratorStatus | undefined;
  target?: string | undefined;
  /**
   * The tag of this generator's settings
   */
  targetTagID?: number | undefined;
  title?: string | undefined;
  /**
   * The type of this generator
   */
  type?: GetPlaylistGeneratorType | undefined;
};

/**
 * `MediaContainer` is the root element of most Plex API responses. It serves as a generic container for various types of content (Metadata, Hubs, Directories, etc.) and includes pagination information (offset, size, totalSize) when applicable.
 *
 * @remarks
 * Common attributes: - identifier: Unique identifier for this container - size: Number of items in this response page - totalSize: Total number of items available (for pagination) - offset: Starting index of this page (for pagination)
 * The container often "hoists" common attributes from its children. For example, if all tracks in a container share the same album title, the `parentTitle` attribute may appear on the MediaContainer rather than being repeated on each track.
 */
export type GetPlaylistGeneratorMediaContainer = {
  identifier?: string | undefined;
  /**
   * The offset of where this container page starts among the total objects available. Also provided in the `X-Plex-Container-Start` header.
   *
   * @remarks
   */
  offset?: number | undefined;
  size?: number | undefined;
  /**
   * The total size of objects available. Also provided in the `X-Plex-Container-Total-Size` header.
   *
   * @remarks
   */
  totalSize?: number | undefined;
  item?: Array<GetPlaylistGeneratorItem> | undefined;
};

/**
 * OK
 */
export type GetPlaylistGeneratorResponseBody = {
  mediaContainer?: GetPlaylistGeneratorMediaContainer | undefined;
};

export type GetPlaylistGeneratorResponse = {
  /**
   * 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;
  /**
   * OK
   */
  object?: GetPlaylistGeneratorResponseBody | undefined;
};

/** @internal */
export type GetPlaylistGeneratorRequest$Outbound = {
  accepts: string;
  "Client-Identifier"?: string | undefined;
  Product?: string | undefined;
  Version?: string | undefined;
  Platform?: string | undefined;
  "Platform-Version"?: string | undefined;
  Device?: string | undefined;
  Model?: string | undefined;
  "Device-Vendor"?: string | undefined;
  "Device-Name"?: string | undefined;
  Marketplace?: string | undefined;
  playlistId: number;
  generatorId: number;
};

/** @internal */
export const GetPlaylistGeneratorRequest$outboundSchema: z.ZodType<
  GetPlaylistGeneratorRequest$Outbound,
  z.ZodTypeDef,
  GetPlaylistGeneratorRequest
> = z.object({
  accepts: shared.Accepts$outboundSchema.default(shared.Accepts.ApplicationXml),
  clientIdentifier: z.string().optional(),
  product: z.string().optional(),
  version: z.string().optional(),
  platform: z.string().optional(),
  platformVersion: z.string().optional(),
  device: z.string().optional(),
  model: z.string().optional(),
  deviceVendor: z.string().optional(),
  deviceName: z.string().optional(),
  marketplace: z.string().optional(),
  playlistId: z.number().int(),
  generatorId: z.number().int(),
}).transform((v) => {
  return remap$(v, {
    clientIdentifier: "Client-Identifier",
    product: "Product",
    version: "Version",
    platform: "Platform",
    platformVersion: "Platform-Version",
    device: "Device",
    model: "Model",
    deviceVendor: "Device-Vendor",
    deviceName: "Device-Name",
    marketplace: "Marketplace",
  });
});

export function getPlaylistGeneratorRequestToJSON(
  getPlaylistGeneratorRequest: GetPlaylistGeneratorRequest,
): string {
  return JSON.stringify(
    GetPlaylistGeneratorRequest$outboundSchema.parse(
      getPlaylistGeneratorRequest,
    ),
  );
}

/** @internal */
export const GetPlaylistGeneratorDevice$inboundSchema: z.ZodType<
  GetPlaylistGeneratorDevice,
  z.ZodTypeDef,
  unknown
> = z.object({
  profile: z.string().optional(),
});

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

/** @internal */
export const GetPlaylistGeneratorLocation$inboundSchema: z.ZodType<
  GetPlaylistGeneratorLocation,
  z.ZodTypeDef,
  unknown
> = z.object({
  librarySectionID: z.number().int().optional(),
  uri: z.string().optional(),
});

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

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

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

/** @internal */
export const MediaSettings$inboundSchema: z.ZodType<
  MediaSettings,
  z.ZodTypeDef,
  unknown
> = z.object({
  advancedSubtitles: AdvancedSubtitles$inboundSchema.optional(),
  audioBoost: z.number().int().optional(),
  audioChannelCount: z.number().int().optional(),
  autoAdjustQuality: z.boolean().optional(),
  autoAdjustSubtitle: z.boolean().optional(),
  directPlay: z.boolean().optional(),
  directStream: z.boolean().optional(),
  directStreamAudio: z.boolean().optional(),
  disableResolutionRotation: z.boolean().optional(),
  maxVideoBitrate: z.number().int().optional(),
  musicBitrate: z.number().int().optional(),
  peakBitrate: z.number().int().optional(),
  photoQuality: z.number().int().optional(),
  photoResolution: z.string().optional(),
  secondsPerSegment: z.number().int().optional(),
  subtitles: GetPlaylistGeneratorSubtitles$inboundSchema.optional(),
  subtitleSize: z.number().int().optional(),
  videoBitrate: z.number().int().optional(),
  videoQuality: z.number().int().optional(),
  videoResolution: z.string().optional(),
});

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

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

/** @internal */
export const GetPlaylistGeneratorPolicy$inboundSchema: z.ZodType<
  GetPlaylistGeneratorPolicy,
  z.ZodTypeDef,
  unknown
> = z.object({
  scope: GetPlaylistGeneratorScope$inboundSchema.optional(),
  unwatched: z.boolean().optional(),
  value: z.number().int().optional(),
});

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

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

/** @internal */
export const GetPlaylistGeneratorStatus$inboundSchema: z.ZodType<
  GetPlaylistGeneratorStatus,
  z.ZodTypeDef,
  unknown
> = z.object({
  itemsCompleteCount: z.number().int().optional(),
  itemsCount: z.number().int().optional(),
  itemsSuccessfulCount: z.number().int().optional(),
  state: GetPlaylistGeneratorState$inboundSchema.optional(),
  totalSize: z.number().int().optional(),
});

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

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

/** @internal */
export const GetPlaylistGeneratorItem$inboundSchema: z.ZodType<
  GetPlaylistGeneratorItem,
  z.ZodTypeDef,
  unknown
> = z.object({
  composite: z.string().optional(),
  Device: z.lazy(() => GetPlaylistGeneratorDevice$inboundSchema).optional(),
  id: z.number().int().optional(),
  Location: z.lazy(() => GetPlaylistGeneratorLocation$inboundSchema).optional(),
  MediaSettings: z.lazy(() => MediaSettings$inboundSchema).optional(),
  Policy: z.lazy(() => GetPlaylistGeneratorPolicy$inboundSchema).optional(),
  Status: z.lazy(() => GetPlaylistGeneratorStatus$inboundSchema).optional(),
  target: z.string().optional(),
  targetTagID: z.number().int().optional(),
  title: z.string().optional(),
  type: GetPlaylistGeneratorType$inboundSchema.optional(),
}).transform((v) => {
  return remap$(v, {
    "Device": "device",
    "Location": "location",
    "MediaSettings": "mediaSettings",
    "Policy": "policy",
    "Status": "status",
  });
});

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

/** @internal */
export const GetPlaylistGeneratorMediaContainer$inboundSchema: z.ZodType<
  GetPlaylistGeneratorMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  identifier: z.string().optional(),
  offset: z.number().int().optional(),
  size: z.number().int().optional(),
  totalSize: z.number().int().optional(),
  Item: z.array(z.lazy(() => GetPlaylistGeneratorItem$inboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "Item": "item",
  });
});

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

/** @internal */
export const GetPlaylistGeneratorResponseBody$inboundSchema: z.ZodType<
  GetPlaylistGeneratorResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  MediaContainer: z.lazy(() => GetPlaylistGeneratorMediaContainer$inboundSchema)
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "MediaContainer": "mediaContainer",
  });
});

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

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

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