/*
 * 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 GetMetadataItemGlobals = {
  /**
   * 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 GetMetadataItemRequest = {
  /**
   * 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;
  ids: Array<string>;
  /**
   * Determines if file check should be performed asynchronously.  An activity is created to indicate progress.  Default is false.
   */
  asyncCheckFiles?: shared.BoolInt | undefined;
  /**
   * Determines if local media agent refresh should be performed asynchronously.  An activity is created to indicate progress.  Default is false.
   */
  asyncRefreshLocalMediaAgent?: shared.BoolInt | undefined;
  /**
   * Determines if analysis refresh should be performed asynchronously.  An activity is created to indicate progress.  Default is false.
   */
  asyncRefreshAnalysis?: shared.BoolInt | undefined;
  /**
   * Determines if file check should be performed synchronously.  Specifying `asyncCheckFiles` will cause this option to be ignored.  Default is false.
   */
  checkFiles?: shared.BoolInt | undefined;
  /**
   * Determines if synchronous local media agent and analysis refresh should be skipped.  Specifying async versions will cause synchronous versions to be skipped.  Default is false.
   */
  skipRefresh?: shared.BoolInt | undefined;
  /**
   * Determines if file existence check should be performed synchronously.  Specifying `checkFiles` will imply this option.  Default is false.
   */
  checkFileAvailability?: shared.BoolInt | undefined;
  /**
   * Add metadata augmentations.  An activity is created to indicate progress.  Option will be ignored if specified by non-admin or if multiple metadata items are requested.  Default is false.
   */
  asyncAugmentMetadata?: shared.BoolInt | undefined;
  /**
   * Number of augmentations to add.  Requires `asyncAugmentMetadata` to be specified.
   */
  augmentCount?: shared.BoolInt | undefined;
};

export type GetMetadataItemResponse = {
  /**
   * 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
   */
  mediaContainerWithMetadata?: shared.MediaContainerWithMetadata | undefined;
  headers: { [k: string]: Array<string> };
};

/** @internal */
export type GetMetadataItemRequest$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;
  ids: Array<string>;
  asyncCheckFiles: number;
  asyncRefreshLocalMediaAgent: number;
  asyncRefreshAnalysis: number;
  checkFiles: number;
  skipRefresh: number;
  checkFileAvailability: number;
  asyncAugmentMetadata: number;
  augmentCount: number;
};

/** @internal */
export const GetMetadataItemRequest$outboundSchema: z.ZodType<
  GetMetadataItemRequest$Outbound,
  z.ZodTypeDef,
  GetMetadataItemRequest
> = 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(),
  ids: z.array(z.string()),
  asyncCheckFiles: shared.BoolInt$outboundSchema.default(shared.BoolInt.False),
  asyncRefreshLocalMediaAgent: shared.BoolInt$outboundSchema.default(
    shared.BoolInt.False,
  ),
  asyncRefreshAnalysis: shared.BoolInt$outboundSchema.default(
    shared.BoolInt.False,
  ),
  checkFiles: shared.BoolInt$outboundSchema.default(shared.BoolInt.False),
  skipRefresh: shared.BoolInt$outboundSchema.default(shared.BoolInt.False),
  checkFileAvailability: shared.BoolInt$outboundSchema.default(
    shared.BoolInt.False,
  ),
  asyncAugmentMetadata: shared.BoolInt$outboundSchema.default(
    shared.BoolInt.False,
  ),
  augmentCount: shared.BoolInt$outboundSchema.default(shared.BoolInt.False),
}).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 getMetadataItemRequestToJSON(
  getMetadataItemRequest: GetMetadataItemRequest,
): string {
  return JSON.stringify(
    GetMetadataItemRequest$outboundSchema.parse(getMetadataItemRequest),
  );
}

/** @internal */
export const GetMetadataItemResponse$inboundSchema: z.ZodType<
  GetMetadataItemResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  ContentType: z.string(),
  StatusCode: z.number().int(),
  RawResponse: z.instanceof(Response),
  MediaContainerWithMetadata: shared.MediaContainerWithMetadata$inboundSchema
    .optional(),
  Headers: z.record(z.array(z.string())).default({}),
}).transform((v) => {
  return remap$(v, {
    "ContentType": "contentType",
    "StatusCode": "statusCode",
    "RawResponse": "rawResponse",
    "MediaContainerWithMetadata": "mediaContainerWithMetadata",
    "Headers": "headers",
  });
});

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