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

import { betaObservabilityTracesFetchOptions } from "../funcs/betaObservabilityTracesFetchOptions.js";
import { betaObservabilityTracesGetSpanById } from "../funcs/betaObservabilityTracesGetSpanById.js";
import { betaObservabilityTracesGetTraceById } from "../funcs/betaObservabilityTracesGetTraceById.js";
import { betaObservabilityTracesGetTraceFields } from "../funcs/betaObservabilityTracesGetTraceFields.js";
import { betaObservabilityTracesGetTraceSpans } from "../funcs/betaObservabilityTracesGetTraceSpans.js";
import { betaObservabilityTracesSearch } from "../funcs/betaObservabilityTracesSearch.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import * as components from "../models/components/index.js";
import * as operations from "../models/operations/index.js";
import { unwrapAsync } from "../types/fp.js";

export class Traces extends ClientSDK {
  /**
   * Search traces
   */
  async search(
    request: operations.SearchTracesV1ObservabilityTracesSearchPostRequest,
    options?: RequestOptions,
  ): Promise<components.GetTraces> {
    return unwrapAsync(betaObservabilityTracesSearch(
      this,
      request,
      options,
    ));
  }

  /**
   * Get trace field definitions
   */
  async getTraceFields(
    options?: RequestOptions,
  ): Promise<components.GetTraceFields> {
    return unwrapAsync(betaObservabilityTracesGetTraceFields(
      this,
      options,
    ));
  }

  /**
   * Get trace by id
   */
  async getTraceById(
    request: operations.GetTraceByIdV1ObservabilityTracesTraceIdGetRequest,
    options?: RequestOptions,
  ): Promise<components.GetTrace> {
    return unwrapAsync(betaObservabilityTracesGetTraceById(
      this,
      request,
      options,
    ));
  }

  /**
   * Get trace spans
   */
  async getTraceSpans(
    request:
      operations.GetTraceSpansV1ObservabilityTracesTraceIdSpansGetRequest,
    options?: RequestOptions,
  ): Promise<components.GetSpans> {
    return unwrapAsync(betaObservabilityTracesGetTraceSpans(
      this,
      request,
      options,
    ));
  }

  /**
   * Get options for a trace field
   */
  async fetchOptions(
    request:
      operations.GetTraceFieldOptionsV1ObservabilityTracesFieldsFieldNameOptionsGetRequest,
    options?: RequestOptions,
  ): Promise<components.GetTraceFieldOptions> {
    return unwrapAsync(betaObservabilityTracesFetchOptions(
      this,
      request,
      options,
    ));
  }

  /**
   * Get span by id
   */
  async getSpanById(
    request:
      operations.GetSpanByIdV1ObservabilityTracesTraceIdSpansSpanIdGetRequest,
    options?: RequestOptions,
  ): Promise<components.GetSpan> {
    return unwrapAsync(betaObservabilityTracesGetSpanById(
      this,
      request,
      options,
    ));
  }
}
