Files
plexjs/src/sdk/models/errors/getsourceconnectioninformation.ts

377 lines
12 KiB
TypeScript

/*
* 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 { PlexAPIError } from "./plexapierror.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
export type GetSourceConnectionInformationAuthenticationErrors = {
code?: number | undefined;
message?: string | undefined;
status?: number | undefined;
};
/**
* Unauthorized - Returned if the X-Plex-Token is missing from the header or query.
*/
export type GetSourceConnectionInformationUnauthorizedData = {
errors?:
| Array<GetSourceConnectionInformationAuthenticationErrors>
| undefined;
/**
* Raw HTTP response; suitable for custom response parsing
*/
rawResponse?: Response | undefined;
};
/**
* Unauthorized - Returned if the X-Plex-Token is missing from the header or query.
*/
export class GetSourceConnectionInformationUnauthorized extends PlexAPIError {
errors?:
| Array<GetSourceConnectionInformationAuthenticationErrors>
| undefined;
/** The original data that was passed to this error instance. */
data$: GetSourceConnectionInformationUnauthorizedData;
constructor(
err: GetSourceConnectionInformationUnauthorizedData,
httpMeta: { response: Response; request: Request; body: string },
) {
const message = "message" in err && typeof err.message === "string"
? err.message
: `API error occurred: ${JSON.stringify(err)}`;
super(message, httpMeta);
this.data$ = err;
if (err.errors != null) this.errors = err.errors;
this.name = "GetSourceConnectionInformationUnauthorized";
}
}
export type GetSourceConnectionInformationErrors = {
code?: number | undefined;
message?: string | undefined;
status?: number | undefined;
};
/**
* Bad Request - A parameter was not specified, or was specified incorrectly.
*/
export type GetSourceConnectionInformationBadRequestData = {
errors?: Array<GetSourceConnectionInformationErrors> | undefined;
/**
* Raw HTTP response; suitable for custom response parsing
*/
rawResponse?: Response | undefined;
};
/**
* Bad Request - A parameter was not specified, or was specified incorrectly.
*/
export class GetSourceConnectionInformationBadRequest extends PlexAPIError {
errors?: Array<GetSourceConnectionInformationErrors> | undefined;
/** The original data that was passed to this error instance. */
data$: GetSourceConnectionInformationBadRequestData;
constructor(
err: GetSourceConnectionInformationBadRequestData,
httpMeta: { response: Response; request: Request; body: string },
) {
const message = "message" in err && typeof err.message === "string"
? err.message
: `API error occurred: ${JSON.stringify(err)}`;
super(message, httpMeta);
this.data$ = err;
if (err.errors != null) this.errors = err.errors;
this.name = "GetSourceConnectionInformationBadRequest";
}
}
/** @internal */
export const GetSourceConnectionInformationAuthenticationErrors$inboundSchema:
z.ZodType<
GetSourceConnectionInformationAuthenticationErrors,
z.ZodTypeDef,
unknown
> = z.object({
code: z.number().int().optional(),
message: z.string().optional(),
status: z.number().int().optional(),
});
/** @internal */
export type GetSourceConnectionInformationAuthenticationErrors$Outbound = {
code?: number | undefined;
message?: string | undefined;
status?: number | undefined;
};
/** @internal */
export const GetSourceConnectionInformationAuthenticationErrors$outboundSchema:
z.ZodType<
GetSourceConnectionInformationAuthenticationErrors$Outbound,
z.ZodTypeDef,
GetSourceConnectionInformationAuthenticationErrors
> = z.object({
code: z.number().int().optional(),
message: z.string().optional(),
status: 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 GetSourceConnectionInformationAuthenticationErrors$ {
/** @deprecated use `GetSourceConnectionInformationAuthenticationErrors$inboundSchema` instead. */
export const inboundSchema =
GetSourceConnectionInformationAuthenticationErrors$inboundSchema;
/** @deprecated use `GetSourceConnectionInformationAuthenticationErrors$outboundSchema` instead. */
export const outboundSchema =
GetSourceConnectionInformationAuthenticationErrors$outboundSchema;
/** @deprecated use `GetSourceConnectionInformationAuthenticationErrors$Outbound` instead. */
export type Outbound =
GetSourceConnectionInformationAuthenticationErrors$Outbound;
}
export function getSourceConnectionInformationAuthenticationErrorsToJSON(
getSourceConnectionInformationAuthenticationErrors:
GetSourceConnectionInformationAuthenticationErrors,
): string {
return JSON.stringify(
GetSourceConnectionInformationAuthenticationErrors$outboundSchema.parse(
getSourceConnectionInformationAuthenticationErrors,
),
);
}
export function getSourceConnectionInformationAuthenticationErrorsFromJSON(
jsonString: string,
): SafeParseResult<
GetSourceConnectionInformationAuthenticationErrors,
SDKValidationError
> {
return safeParse(
jsonString,
(x) =>
GetSourceConnectionInformationAuthenticationErrors$inboundSchema.parse(
JSON.parse(x),
),
`Failed to parse 'GetSourceConnectionInformationAuthenticationErrors' from JSON`,
);
}
/** @internal */
export const GetSourceConnectionInformationUnauthorized$inboundSchema:
z.ZodType<GetSourceConnectionInformationUnauthorized, z.ZodTypeDef, unknown> =
z.object({
errors: z.array(
z.lazy(() =>
GetSourceConnectionInformationAuthenticationErrors$inboundSchema
),
).optional(),
RawResponse: z.instanceof(Response).optional(),
request$: z.instanceof(Request),
response$: z.instanceof(Response),
body$: z.string(),
})
.transform((v) => {
const remapped = remap$(v, {
"RawResponse": "rawResponse",
});
return new GetSourceConnectionInformationUnauthorized(remapped, {
request: v.request$,
response: v.response$,
body: v.body$,
});
});
/** @internal */
export type GetSourceConnectionInformationUnauthorized$Outbound = {
errors?:
| Array<GetSourceConnectionInformationAuthenticationErrors$Outbound>
| undefined;
RawResponse?: never | undefined;
};
/** @internal */
export const GetSourceConnectionInformationUnauthorized$outboundSchema:
z.ZodType<
GetSourceConnectionInformationUnauthorized$Outbound,
z.ZodTypeDef,
GetSourceConnectionInformationUnauthorized
> = z.instanceof(GetSourceConnectionInformationUnauthorized)
.transform(v => v.data$)
.pipe(
z.object({
errors: z.array(z.lazy(() =>
GetSourceConnectionInformationAuthenticationErrors$outboundSchema
)).optional(),
rawResponse: z.instanceof(Response).transform(() => {
throw new Error("Response cannot be serialized");
}).optional(),
}).transform((v) => {
return remap$(v, {
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 GetSourceConnectionInformationUnauthorized$ {
/** @deprecated use `GetSourceConnectionInformationUnauthorized$inboundSchema` instead. */
export const inboundSchema =
GetSourceConnectionInformationUnauthorized$inboundSchema;
/** @deprecated use `GetSourceConnectionInformationUnauthorized$outboundSchema` instead. */
export const outboundSchema =
GetSourceConnectionInformationUnauthorized$outboundSchema;
/** @deprecated use `GetSourceConnectionInformationUnauthorized$Outbound` instead. */
export type Outbound = GetSourceConnectionInformationUnauthorized$Outbound;
}
/** @internal */
export const GetSourceConnectionInformationErrors$inboundSchema: z.ZodType<
GetSourceConnectionInformationErrors,
z.ZodTypeDef,
unknown
> = z.object({
code: z.number().int().optional(),
message: z.string().optional(),
status: z.number().int().optional(),
});
/** @internal */
export type GetSourceConnectionInformationErrors$Outbound = {
code?: number | undefined;
message?: string | undefined;
status?: number | undefined;
};
/** @internal */
export const GetSourceConnectionInformationErrors$outboundSchema: z.ZodType<
GetSourceConnectionInformationErrors$Outbound,
z.ZodTypeDef,
GetSourceConnectionInformationErrors
> = z.object({
code: z.number().int().optional(),
message: z.string().optional(),
status: 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 GetSourceConnectionInformationErrors$ {
/** @deprecated use `GetSourceConnectionInformationErrors$inboundSchema` instead. */
export const inboundSchema =
GetSourceConnectionInformationErrors$inboundSchema;
/** @deprecated use `GetSourceConnectionInformationErrors$outboundSchema` instead. */
export const outboundSchema =
GetSourceConnectionInformationErrors$outboundSchema;
/** @deprecated use `GetSourceConnectionInformationErrors$Outbound` instead. */
export type Outbound = GetSourceConnectionInformationErrors$Outbound;
}
export function getSourceConnectionInformationErrorsToJSON(
getSourceConnectionInformationErrors: GetSourceConnectionInformationErrors,
): string {
return JSON.stringify(
GetSourceConnectionInformationErrors$outboundSchema.parse(
getSourceConnectionInformationErrors,
),
);
}
export function getSourceConnectionInformationErrorsFromJSON(
jsonString: string,
): SafeParseResult<GetSourceConnectionInformationErrors, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
GetSourceConnectionInformationErrors$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetSourceConnectionInformationErrors' from JSON`,
);
}
/** @internal */
export const GetSourceConnectionInformationBadRequest$inboundSchema: z.ZodType<
GetSourceConnectionInformationBadRequest,
z.ZodTypeDef,
unknown
> = z.object({
errors: z.array(
z.lazy(() => GetSourceConnectionInformationErrors$inboundSchema),
).optional(),
RawResponse: z.instanceof(Response).optional(),
request$: z.instanceof(Request),
response$: z.instanceof(Response),
body$: z.string(),
})
.transform((v) => {
const remapped = remap$(v, {
"RawResponse": "rawResponse",
});
return new GetSourceConnectionInformationBadRequest(remapped, {
request: v.request$,
response: v.response$,
body: v.body$,
});
});
/** @internal */
export type GetSourceConnectionInformationBadRequest$Outbound = {
errors?: Array<GetSourceConnectionInformationErrors$Outbound> | undefined;
RawResponse?: never | undefined;
};
/** @internal */
export const GetSourceConnectionInformationBadRequest$outboundSchema: z.ZodType<
GetSourceConnectionInformationBadRequest$Outbound,
z.ZodTypeDef,
GetSourceConnectionInformationBadRequest
> = z.instanceof(GetSourceConnectionInformationBadRequest)
.transform(v => v.data$)
.pipe(
z.object({
errors: z.array(
z.lazy(() => GetSourceConnectionInformationErrors$outboundSchema),
).optional(),
rawResponse: z.instanceof(Response).transform(() => {
throw new Error("Response cannot be serialized");
}).optional(),
}).transform((v) => {
return remap$(v, {
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 GetSourceConnectionInformationBadRequest$ {
/** @deprecated use `GetSourceConnectionInformationBadRequest$inboundSchema` instead. */
export const inboundSchema =
GetSourceConnectionInformationBadRequest$inboundSchema;
/** @deprecated use `GetSourceConnectionInformationBadRequest$outboundSchema` instead. */
export const outboundSchema =
GetSourceConnectionInformationBadRequest$outboundSchema;
/** @deprecated use `GetSourceConnectionInformationBadRequest$Outbound` instead. */
export type Outbound = GetSourceConnectionInformationBadRequest$Outbound;
}