/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type GetRepositoriesRequest = {
  /**
   * If set to any value, the endpoint returns repositories with associated branch data
   */
  withBranches?: string | undefined;
  /**
   * If set to any value, the endpoint returns repositories with associated branch data, as well as code references for the default git branch
   */
  withReferencesForDefaultBranch?: string | undefined;
  /**
   * A LaunchDarkly project key. If provided, this filters code reference results to the specified project.
   */
  projKey?: string | undefined;
  /**
   * If set to any value, the endpoint returns repositories with associated branch data, as well as code references for the default git branch
   */
  flagKey?: string | undefined;
};

/** @internal */
export const GetRepositoriesRequest$inboundSchema: z.ZodType<
  GetRepositoriesRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  withBranches: z.string().optional(),
  withReferencesForDefaultBranch: z.string().optional(),
  projKey: z.string().optional(),
  flagKey: z.string().optional(),
});
/** @internal */
export type GetRepositoriesRequest$Outbound = {
  withBranches?: string | undefined;
  withReferencesForDefaultBranch?: string | undefined;
  projKey?: string | undefined;
  flagKey?: string | undefined;
};

/** @internal */
export const GetRepositoriesRequest$outboundSchema: z.ZodType<
  GetRepositoriesRequest$Outbound,
  z.ZodTypeDef,
  GetRepositoriesRequest
> = z.object({
  withBranches: z.string().optional(),
  withReferencesForDefaultBranch: z.string().optional(),
  projKey: z.string().optional(),
  flagKey: z.string().optional(),
});

export function getRepositoriesRequestToJSON(
  getRepositoriesRequest: GetRepositoriesRequest,
): string {
  return JSON.stringify(
    GetRepositoriesRequest$outboundSchema.parse(getRepositoriesRequest),
  );
}
export function getRepositoriesRequestFromJSON(
  jsonString: string,
): SafeParseResult<GetRepositoriesRequest, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => GetRepositoriesRequest$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'GetRepositoriesRequest' from JSON`,
  );
}
