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

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

export type GetLog = {
  customerId: string;
  organizationId: string;
  workspaceId: string;
  userId: string;
  timestamp: Date;
  traceId: string;
  spanId: string;
  traceFlags: number;
  severityText: string;
  severityNumber: number;
  serviceName: string;
  body: string;
  eventName: string;
  resourceSchemaUrl: string;
  resourceAttributes: { [k: string]: string };
  scopeSchemaUrl: string;
  scopeName: string;
  scopeVersion: string;
  scopeAttributes: { [k: string]: string };
  logAttributes: { [k: string]: string };
};

/** @internal */
export const GetLog$inboundSchema: z.ZodType<GetLog, unknown> = z.object({
  customer_id: z.string(),
  organization_id: z.string(),
  workspace_id: z.string(),
  user_id: z.string(),
  timestamp: z.iso.datetime({ offset: true }).transform(v => new Date(v)),
  trace_id: z.string(),
  span_id: z.string(),
  trace_flags: z.int(),
  severity_text: z.string(),
  severity_number: z.int(),
  service_name: z.string(),
  body: z.string(),
  event_name: z.string(),
  resource_schema_url: z.string(),
  resource_attributes: z.record(z.string(), z.string()),
  scope_schema_url: z.string(),
  scope_name: z.string(),
  scope_version: z.string(),
  scope_attributes: z.record(z.string(), z.string()),
  log_attributes: z.record(z.string(), z.string()),
}).transform((v) => {
  return remap$(v, {
    "customer_id": "customerId",
    "organization_id": "organizationId",
    "workspace_id": "workspaceId",
    "user_id": "userId",
    "trace_id": "traceId",
    "span_id": "spanId",
    "trace_flags": "traceFlags",
    "severity_text": "severityText",
    "severity_number": "severityNumber",
    "service_name": "serviceName",
    "event_name": "eventName",
    "resource_schema_url": "resourceSchemaUrl",
    "resource_attributes": "resourceAttributes",
    "scope_schema_url": "scopeSchemaUrl",
    "scope_name": "scopeName",
    "scope_version": "scopeVersion",
    "scope_attributes": "scopeAttributes",
    "log_attributes": "logAttributes",
  });
});

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