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

/**
 * A team's access grant to a Vercel Container Registry repository.
 */
export type VcrRepositoryPermission = {
  /**
   * Identifier of the repository the permission grants access to.
   */
  repositoryId: string;
  /**
   * Identifier of the team that is granted access to the repository.
   */
  teamId: string;
  /**
   * Slug of the team that is granted access to the repository.
   */
  teamSlug: string;
  /**
   * ISO 8601 timestamp of when the permission was created.
   */
  createdAt: string;
};

/** @internal */
export const VcrRepositoryPermission$inboundSchema: z.ZodType<
  VcrRepositoryPermission,
  z.ZodTypeDef,
  unknown
> = z.object({
  repositoryId: types.string(),
  teamId: types.string(),
  teamSlug: types.string(),
  createdAt: types.string(),
});

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