/*
 * 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 * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

/**
 * HTTP header injection rules for outgoing requests matching specific domains.
 */
export type SandboxInjectionRule = {
  /**
   * The domain (or pattern) that this injection rule applies to. Supports wildcards like *.vercel.com.
   */
  domain: string;
  /**
   * The names of HTTP headers that have value that will be injected for requests to this domain.
   */
  headerNames?: Array<string> | undefined;
};

/** @internal */
export const SandboxInjectionRule$inboundSchema: z.ZodType<
  SandboxInjectionRule,
  z.ZodTypeDef,
  unknown
> = z.object({
  domain: types.string(),
  headerNames: types.optional(z.array(types.string())),
});

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