/*
 * 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";

export type DirectoryResponse = {
  count?: number | undefined;
  /**
   * The key where this directory is found
   */
  key?: string | undefined;
  title?: string | 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 LibrarySectionsMediaContainer = {
  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;
  allowCameraUpload?: boolean | undefined;
  allowChannelAccess?: boolean | undefined;
  allowMediaDeletion?: boolean | undefined;
  allowSharing?: boolean | undefined;
  allowSync?: boolean | undefined;
  allowTuners?: boolean | undefined;
  backgroundProcessing?: boolean | undefined;
  certificate?: boolean | undefined;
  companionProxy?: boolean | undefined;
  countryCode?: string | undefined;
  diagnostics?: string | undefined;
  eventStream?: boolean | undefined;
  friendlyName?: string | undefined;
  hubSearch?: boolean | undefined;
  itemClusters?: boolean | undefined;
  livetv?: number | undefined;
  machineIdentifier?: any | undefined;
  mediaProviders?: boolean | undefined;
  multiuser?: boolean | undefined;
  musicAnalysis?: number | undefined;
  myPlex?: boolean | undefined;
  myPlexMappingState?: any | undefined;
  myPlexSigninState?: any | undefined;
  myPlexSubscription?: boolean | undefined;
  myPlexUsername?: string | undefined;
  offlineTranscode?: any | undefined;
  /**
   * A comma-separated list of features which are enabled for the server owner
   */
  ownerFeatures?: string | undefined;
  platform?: string | undefined;
  platformVersion?: string | undefined;
  pluginHost?: boolean | undefined;
  pushNotifications?: boolean | undefined;
  readOnlyLibraries?: boolean | undefined;
  streamingBrainABRVersion?: number | undefined;
  streamingBrainVersion?: number | undefined;
  sync?: boolean | undefined;
  transcoderActiveVideoSessions?: number | undefined;
  transcoderAudio?: boolean | undefined;
  transcoderLyrics?: boolean | undefined;
  transcoderPhoto?: boolean | undefined;
  transcoderSubtitles?: boolean | undefined;
  transcoderVideo?: boolean | undefined;
  /**
   * The suggested video quality bitrates to present to the user
   */
  transcoderVideoBitrates?: any | undefined;
  transcoderVideoQualities?: string | undefined;
  /**
   * The suggested video resolutions to the above quality bitrates
   */
  transcoderVideoResolutions?: any | undefined;
  updatedAt?: number | undefined;
  updater?: boolean | undefined;
  version?: string | undefined;
  voiceSearch?: boolean | undefined;
  directory?: Array<DirectoryResponse> | undefined;
};

/**
 * OK
 */
export type LibrarySections = {
  mediaContainer?: LibrarySectionsMediaContainer | undefined;
};

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

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

/** @internal */
export const LibrarySectionsMediaContainer$inboundSchema: z.ZodType<
  LibrarySectionsMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  identifier: z.string().optional(),
  offset: z.number().int().optional(),
  size: z.number().int().optional(),
  totalSize: z.number().int().optional(),
  allowCameraUpload: z.boolean().optional(),
  allowChannelAccess: z.boolean().optional(),
  allowMediaDeletion: z.boolean().optional(),
  allowSharing: z.boolean().optional(),
  allowSync: z.boolean().optional(),
  allowTuners: z.boolean().optional(),
  backgroundProcessing: z.boolean().optional(),
  certificate: z.boolean().optional(),
  companionProxy: z.boolean().optional(),
  countryCode: z.string().optional(),
  diagnostics: z.string().optional(),
  eventStream: z.boolean().optional(),
  friendlyName: z.string().optional(),
  hubSearch: z.boolean().optional(),
  itemClusters: z.boolean().optional(),
  livetv: z.number().int().optional(),
  machineIdentifier: z.any().optional(),
  mediaProviders: z.boolean().optional(),
  multiuser: z.boolean().optional(),
  musicAnalysis: z.number().int().optional(),
  myPlex: z.boolean().optional(),
  myPlexMappingState: z.any().optional(),
  myPlexSigninState: z.any().optional(),
  myPlexSubscription: z.boolean().optional(),
  myPlexUsername: z.string().optional(),
  offlineTranscode: z.any().optional(),
  ownerFeatures: z.string().optional(),
  platform: z.string().optional(),
  platformVersion: z.string().optional(),
  pluginHost: z.boolean().optional(),
  pushNotifications: z.boolean().optional(),
  readOnlyLibraries: z.boolean().optional(),
  streamingBrainABRVersion: z.number().int().optional(),
  streamingBrainVersion: z.number().int().optional(),
  sync: z.boolean().optional(),
  transcoderActiveVideoSessions: z.number().int().optional(),
  transcoderAudio: z.boolean().optional(),
  transcoderLyrics: z.boolean().optional(),
  transcoderPhoto: z.boolean().optional(),
  transcoderSubtitles: z.boolean().optional(),
  transcoderVideo: z.boolean().optional(),
  transcoderVideoBitrates: z.any().optional(),
  transcoderVideoQualities: z.string().optional(),
  transcoderVideoResolutions: z.any().optional(),
  updatedAt: z.number().int().optional(),
  updater: z.boolean().optional(),
  version: z.string().optional(),
  voiceSearch: z.boolean().optional(),
  Directory: z.array(z.lazy(() => DirectoryResponse$inboundSchema)).optional(),
}).transform((v) => {
  return remap$(v, {
    "Directory": "directory",
  });
});

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

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

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