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

export type GetResourcesStatisticsRequest = {
  /**
   * The timespan to retrieve statistics for
   *
   * @remarks
   * the exact meaning of this parameter is not known
   */
  timespan?: number | undefined;
};

export type StatisticsResources = {
  timespan?: number | undefined;
  at?: number | undefined;
  hostCpuUtilization?: number | undefined;
  processCpuUtilization?: number | undefined;
  hostMemoryUtilization?: number | undefined;
  processMemoryUtilization?: number | undefined;
};

export type GetResourcesStatisticsMediaContainer = {
  size?: number | undefined;
  statisticsResources?: Array<StatisticsResources> | undefined;
};

/**
 * Resource Statistics
 */
export type GetResourcesStatisticsResponseBody = {
  mediaContainer?: GetResourcesStatisticsMediaContainer | undefined;
};

export type GetResourcesStatisticsResponse = {
  /**
   * 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;
  /**
   * Resource Statistics
   */
  object?: GetResourcesStatisticsResponseBody | undefined;
};

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

/** @internal */
export type GetResourcesStatisticsRequest$Outbound = {
  timespan?: number | undefined;
};

/** @internal */
export const GetResourcesStatisticsRequest$outboundSchema: z.ZodType<
  GetResourcesStatisticsRequest$Outbound,
  z.ZodTypeDef,
  GetResourcesStatisticsRequest
> = z.object({
  timespan: z.number().int().optional(),
});

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

export function getResourcesStatisticsRequestToJSON(
  getResourcesStatisticsRequest: GetResourcesStatisticsRequest,
): string {
  return JSON.stringify(
    GetResourcesStatisticsRequest$outboundSchema.parse(
      getResourcesStatisticsRequest,
    ),
  );
}

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

/** @internal */
export const StatisticsResources$inboundSchema: z.ZodType<
  StatisticsResources,
  z.ZodTypeDef,
  unknown
> = z.object({
  timespan: z.number().int().optional(),
  at: z.number().int().optional(),
  hostCpuUtilization: z.number().optional(),
  processCpuUtilization: z.number().optional(),
  hostMemoryUtilization: z.number().optional(),
  processMemoryUtilization: z.number().optional(),
});

/** @internal */
export type StatisticsResources$Outbound = {
  timespan?: number | undefined;
  at?: number | undefined;
  hostCpuUtilization?: number | undefined;
  processCpuUtilization?: number | undefined;
  hostMemoryUtilization?: number | undefined;
  processMemoryUtilization?: number | undefined;
};

/** @internal */
export const StatisticsResources$outboundSchema: z.ZodType<
  StatisticsResources$Outbound,
  z.ZodTypeDef,
  StatisticsResources
> = z.object({
  timespan: z.number().int().optional(),
  at: z.number().int().optional(),
  hostCpuUtilization: z.number().optional(),
  processCpuUtilization: z.number().optional(),
  hostMemoryUtilization: z.number().optional(),
  processMemoryUtilization: z.number().optional(),
});

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

export function statisticsResourcesToJSON(
  statisticsResources: StatisticsResources,
): string {
  return JSON.stringify(
    StatisticsResources$outboundSchema.parse(statisticsResources),
  );
}

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

/** @internal */
export const GetResourcesStatisticsMediaContainer$inboundSchema: z.ZodType<
  GetResourcesStatisticsMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  size: z.number().int().optional(),
  StatisticsResources: z.array(z.lazy(() => StatisticsResources$inboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "StatisticsResources": "statisticsResources",
  });
});

/** @internal */
export type GetResourcesStatisticsMediaContainer$Outbound = {
  size?: number | undefined;
  StatisticsResources?: Array<StatisticsResources$Outbound> | undefined;
};

/** @internal */
export const GetResourcesStatisticsMediaContainer$outboundSchema: z.ZodType<
  GetResourcesStatisticsMediaContainer$Outbound,
  z.ZodTypeDef,
  GetResourcesStatisticsMediaContainer
> = z.object({
  size: z.number().int().optional(),
  statisticsResources: z.array(z.lazy(() => StatisticsResources$outboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    statisticsResources: "StatisticsResources",
  });
});

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

export function getResourcesStatisticsMediaContainerToJSON(
  getResourcesStatisticsMediaContainer: GetResourcesStatisticsMediaContainer,
): string {
  return JSON.stringify(
    GetResourcesStatisticsMediaContainer$outboundSchema.parse(
      getResourcesStatisticsMediaContainer,
    ),
  );
}

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

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

/** @internal */
export type GetResourcesStatisticsResponseBody$Outbound = {
  MediaContainer?: GetResourcesStatisticsMediaContainer$Outbound | undefined;
};

/** @internal */
export const GetResourcesStatisticsResponseBody$outboundSchema: z.ZodType<
  GetResourcesStatisticsResponseBody$Outbound,
  z.ZodTypeDef,
  GetResourcesStatisticsResponseBody
> = z.object({
  mediaContainer: z.lazy(() =>
    GetResourcesStatisticsMediaContainer$outboundSchema
  ).optional(),
}).transform((v) => {
  return remap$(v, {
    mediaContainer: "MediaContainer",
  });
});

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

export function getResourcesStatisticsResponseBodyToJSON(
  getResourcesStatisticsResponseBody: GetResourcesStatisticsResponseBody,
): string {
  return JSON.stringify(
    GetResourcesStatisticsResponseBody$outboundSchema.parse(
      getResourcesStatisticsResponseBody,
    ),
  );
}

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

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

/** @internal */
export type GetResourcesStatisticsResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
  object?: GetResourcesStatisticsResponseBody$Outbound | undefined;
};

/** @internal */
export const GetResourcesStatisticsResponse$outboundSchema: z.ZodType<
  GetResourcesStatisticsResponse$Outbound,
  z.ZodTypeDef,
  GetResourcesStatisticsResponse
> = z.object({
  contentType: z.string(),
  statusCode: z.number().int(),
  rawResponse: z.instanceof(Response).transform(() => {
    throw new Error("Response cannot be serialized");
  }),
  object: z.lazy(() => GetResourcesStatisticsResponseBody$outboundSchema)
    .optional(),
}).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 GetResourcesStatisticsResponse$ {
  /** @deprecated use `GetResourcesStatisticsResponse$inboundSchema` instead. */
  export const inboundSchema = GetResourcesStatisticsResponse$inboundSchema;
  /** @deprecated use `GetResourcesStatisticsResponse$outboundSchema` instead. */
  export const outboundSchema = GetResourcesStatisticsResponse$outboundSchema;
  /** @deprecated use `GetResourcesStatisticsResponse$Outbound` instead. */
  export type Outbound = GetResourcesStatisticsResponse$Outbound;
}

export function getResourcesStatisticsResponseToJSON(
  getResourcesStatisticsResponse: GetResourcesStatisticsResponse,
): string {
  return JSON.stringify(
    GetResourcesStatisticsResponse$outboundSchema.parse(
      getResourcesStatisticsResponse,
    ),
  );
}

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