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

/**
 * The details of a single workspace
 */
export type GetWorkspaceResponse = {
  /**
   * The ID of the workspace
   */
  workspaceId: string;
  /**
   * The name of the workspace
   */
  name?: string | null | undefined;
  /**
   * The date the workspace was created
   */
  createdDate?: Date | null | undefined;
  /**
   * The ID of the user who created the workspace
   */
  createdByUserId?: string | null | undefined;
  /**
   * The list of user IDs of the workspace owners
   */
  workspaceOwnerIds?: Array<string> | null | undefined;
};

/** @internal */
export const GetWorkspaceResponse$inboundSchema: z.ZodType<
  GetWorkspaceResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  workspace_id: types.string(),
  name: z.nullable(types.string()).optional(),
  created_date: z.nullable(types.date()).optional(),
  created_by_user_id: z.nullable(types.string()).optional(),
  workspace_owner_ids: z.nullable(z.array(types.string())).optional(),
}).transform((v) => {
  return remap$(v, {
    "workspace_id": "workspaceId",
    "created_date": "createdDate",
    "created_by_user_id": "createdByUserId",
    "workspace_owner_ids": "workspaceOwnerIds",
  });
});

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