/*
 * 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 Feature = {
  directory?: Array<shared.Directory> | undefined;
  key?: string | undefined;
  type?: 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 ListProvidersMediaContainer = {
  /**
   * A unique identifier for the provider, e.g. `com.plexapp.plugins.library`.
   */
  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;
  feature?: Array<Feature> | undefined;
  /**
   * A comma-separated list of default protocols for the provider, which can be:
   *
   * @remarks
   * - `stream`: The provider allows streaming media directly from the provider (e.g. for Vimeo). - `download`: The provider allows downloading media for offline storage, sync, etc. (e.g. Podcasts). - `livetv`: The provider provides live content which is only available on a schedule basis.
   */
  protocols?: string | undefined;
  /**
   * The title of the provider.
   */
  title?: string | undefined;
  /**
   * This attribute contains a comma-separated list of the media types exposed by the provider (e.g. `video, audio`).
   */
  types?: string | undefined;
};

/**
 * OK
 */
export type ListProvidersResponseBody = {
  mediaContainer?: ListProvidersMediaContainer | undefined;
};

export type ListProvidersResponse = {
  /**
   * 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?: ListProvidersResponseBody | undefined;
};

/** @internal */
export const Feature$inboundSchema: z.ZodType<Feature, z.ZodTypeDef, unknown> =
  z.object({
    Directory: z.array(shared.Directory$inboundSchema).optional(),
    key: z.string().optional(),
    type: z.string().optional(),
  }).transform((v) => {
    return remap$(v, {
      "Directory": "directory",
    });
  });

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

/** @internal */
export const ListProvidersMediaContainer$inboundSchema: z.ZodType<
  ListProvidersMediaContainer,
  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(),
  Feature: z.array(z.lazy(() => Feature$inboundSchema)).optional(),
  protocols: z.string().optional(),
  title: z.string().optional(),
  types: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    "Feature": "feature",
  });
});

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

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

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

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

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