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

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

export type WorkspaceRoleSummary = {
  /**
   * The ID of the role
   */
  roleId?: string | undefined;
  /**
   * The name of the role
   */
  name?: string | null | undefined;
  /**
   * If this role is applicable to any participant of a workspace including those outside the account. If false, this role may only be assigned to internal users of the same account
   */
  isExternal?: boolean | null | undefined;
  /**
   * The date the role was created
   */
  createdDate?: Date | null | undefined;
};

/** @internal */
export const WorkspaceRoleSummary$inboundSchema: z.ZodType<
  WorkspaceRoleSummary,
  z.ZodTypeDef,
  unknown
> = z.object({
  role_id: types.optional(types.string()),
  name: z.nullable(types.string()).optional(),
  is_external: z.nullable(types.boolean()).optional(),
  created_date: z.nullable(types.date()).optional(),
}).transform((v) => {
  return remap$(v, {
    "role_id": "roleId",
    "is_external": "isExternal",
    "created_date": "createdDate",
  });
});

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