// Code generated by Fern. DO NOT EDIT.

package api

import (
	json "encoding/json"
	fmt "fmt"
	big "math/big"
	internal "pentagi/pkg/observability/langfuse/api/internal"
	time "time"
)

var (
	observationsGetRequestFieldObservationID = big.NewInt(1 << 0)
)

type ObservationsGetRequest struct {
	// The unique langfuse identifier of an observation, can be an event, span or generation
	ObservationID string `json:"-" url:"-"`

	// Private bitmask of fields set to an explicit value and therefore not to be omitted
	explicitFields *big.Int `json:"-" url:"-"`
}

func (o *ObservationsGetRequest) require(field *big.Int) {
	if o.explicitFields == nil {
		o.explicitFields = big.NewInt(0)
	}
	o.explicitFields.Or(o.explicitFields, field)
}

// SetObservationID sets the ObservationID field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetRequest) SetObservationID(observationID string) {
	o.ObservationID = observationID
	o.require(observationsGetRequestFieldObservationID)
}

var (
	observationsGetManyRequestFieldPage                = big.NewInt(1 << 0)
	observationsGetManyRequestFieldLimit               = big.NewInt(1 << 1)
	observationsGetManyRequestFieldName                = big.NewInt(1 << 2)
	observationsGetManyRequestFieldUserID              = big.NewInt(1 << 3)
	observationsGetManyRequestFieldType                = big.NewInt(1 << 4)
	observationsGetManyRequestFieldTraceID             = big.NewInt(1 << 5)
	observationsGetManyRequestFieldLevel               = big.NewInt(1 << 6)
	observationsGetManyRequestFieldParentObservationID = big.NewInt(1 << 7)
	observationsGetManyRequestFieldEnvironment         = big.NewInt(1 << 8)
	observationsGetManyRequestFieldFromStartTime       = big.NewInt(1 << 9)
	observationsGetManyRequestFieldToStartTime         = big.NewInt(1 << 10)
	observationsGetManyRequestFieldVersion             = big.NewInt(1 << 11)
	observationsGetManyRequestFieldFilter              = big.NewInt(1 << 12)
)

type ObservationsGetManyRequest struct {
	// Page number, starts at 1.
	Page *int `json:"-" url:"page,omitempty"`
	// Limit of items per page. If you encounter api issues due to too large page sizes, try to reduce the limit.
	Limit   *int    `json:"-" url:"limit,omitempty"`
	Name    *string `json:"-" url:"name,omitempty"`
	UserID  *string `json:"-" url:"userId,omitempty"`
	Type    *string `json:"-" url:"type,omitempty"`
	TraceID *string `json:"-" url:"traceId,omitempty"`
	// Optional filter for observations with a specific level (e.g. "DEBUG", "DEFAULT", "WARNING", "ERROR").
	Level               *ObservationLevel `json:"-" url:"level,omitempty"`
	ParentObservationID *string           `json:"-" url:"parentObservationId,omitempty"`
	// Optional filter for observations where the environment is one of the provided values.
	Environment []*string `json:"-" url:"environment,omitempty"`
	// Retrieve only observations with a start_time on or after this datetime (ISO 8601).
	FromStartTime *time.Time `json:"-" url:"fromStartTime,omitempty"`
	// Retrieve only observations with a start_time before this datetime (ISO 8601).
	ToStartTime *time.Time `json:"-" url:"toStartTime,omitempty"`
	// Optional filter to only include observations with a certain version.
	Version *string `json:"-" url:"version,omitempty"`
	// JSON string containing an array of filter conditions. When provided, this takes precedence over query parameter filters (userId, name, type, level, environment, fromStartTime, ...).
	//
	// ## Filter Structure
	// Each filter condition has the following structure:
	// ```json
	// [
	//
	//	{
	//	  "type": string,           // Required. One of: "datetime", "string", "number", "stringOptions", "categoryOptions", "arrayOptions", "stringObject", "numberObject", "boolean", "null"
	//	  "column": string,         // Required. Column to filter on (see available columns below)
	//	  "operator": string,       // Required. Operator based on type:
	//	                            // - datetime: ">", "<", ">=", "<="
	//	                            // - string: "=", "contains", "does not contain", "starts with", "ends with"
	//	                            // - stringOptions: "any of", "none of"
	//	                            // - categoryOptions: "any of", "none of"
	//	                            // - arrayOptions: "any of", "none of", "all of"
	//	                            // - number: "=", ">", "<", ">=", "<="
	//	                            // - stringObject: "=", "contains", "does not contain", "starts with", "ends with"
	//	                            // - numberObject: "=", ">", "<", ">=", "<="
	//	                            // - boolean: "=", "<>"
	//	                            // - null: "is null", "is not null"
	//	  "value": any,             // Required (except for null type). Value to compare against. Type depends on filter type
	//	  "key": string             // Required only for stringObject, numberObject, and categoryOptions types when filtering on nested fields like metadata
	//	}
	//
	// ]
	// ```
	//
	// ## Available Columns
	//
	// ### Core Observation Fields
	// - `id` (string) - Observation ID
	// - `type` (string) - Observation type (SPAN, GENERATION, EVENT)
	// - `name` (string) - Observation name
	// - `traceId` (string) - Associated trace ID
	// - `startTime` (datetime) - Observation start time
	// - `endTime` (datetime) - Observation end time
	// - `environment` (string) - Environment tag
	// - `level` (string) - Log level (DEBUG, DEFAULT, WARNING, ERROR)
	// - `statusMessage` (string) - Status message
	// - `version` (string) - Version tag
	//
	// ### Performance Metrics
	// - `latency` (number) - Latency in seconds (calculated: end_time - start_time)
	// - `timeToFirstToken` (number) - Time to first token in seconds
	// - `tokensPerSecond` (number) - Output tokens per second
	//
	// ### Token Usage
	// - `inputTokens` (number) - Number of input tokens
	// - `outputTokens` (number) - Number of output tokens
	// - `totalTokens` (number) - Total tokens (alias: `tokens`)
	//
	// ### Cost Metrics
	// - `inputCost` (number) - Input cost in USD
	// - `outputCost` (number) - Output cost in USD
	// - `totalCost` (number) - Total cost in USD
	//
	// ### Model Information
	// - `model` (string) - Provided model name
	// - `promptName` (string) - Associated prompt name
	// - `promptVersion` (number) - Associated prompt version
	//
	// ### Structured Data
	// - `metadata` (stringObject/numberObject/categoryOptions) - Metadata key-value pairs. Use `key` parameter to filter on specific metadata keys.
	//
	// ### Associated Trace Fields (requires join with traces table)
	// - `userId` (string) - User ID from associated trace
	// - `traceName` (string) - Name from associated trace
	// - `traceEnvironment` (string) - Environment from associated trace
	// - `traceTags` (arrayOptions) - Tags from associated trace
	//
	// ## Filter Examples
	// ```json
	// [
	//
	//	{
	//	  "type": "string",
	//	  "column": "type",
	//	  "operator": "=",
	//	  "value": "GENERATION"
	//	},
	//	{
	//	  "type": "number",
	//	  "column": "latency",
	//	  "operator": ">=",
	//	  "value": 2.5
	//	},
	//	{
	//	  "type": "stringObject",
	//	  "column": "metadata",
	//	  "key": "environment",
	//	  "operator": "=",
	//	  "value": "production"
	//	}
	//
	// ]
	// ```
	Filter *string `json:"-" url:"filter,omitempty"`

	// Private bitmask of fields set to an explicit value and therefore not to be omitted
	explicitFields *big.Int `json:"-" url:"-"`
}

func (o *ObservationsGetManyRequest) require(field *big.Int) {
	if o.explicitFields == nil {
		o.explicitFields = big.NewInt(0)
	}
	o.explicitFields.Or(o.explicitFields, field)
}

// SetPage sets the Page field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetPage(page *int) {
	o.Page = page
	o.require(observationsGetManyRequestFieldPage)
}

// SetLimit sets the Limit field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetLimit(limit *int) {
	o.Limit = limit
	o.require(observationsGetManyRequestFieldLimit)
}

// SetName sets the Name field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetName(name *string) {
	o.Name = name
	o.require(observationsGetManyRequestFieldName)
}

// SetUserID sets the UserID field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetUserID(userID *string) {
	o.UserID = userID
	o.require(observationsGetManyRequestFieldUserID)
}

// SetType sets the Type field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetType(type_ *string) {
	o.Type = type_
	o.require(observationsGetManyRequestFieldType)
}

// SetTraceID sets the TraceID field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetTraceID(traceID *string) {
	o.TraceID = traceID
	o.require(observationsGetManyRequestFieldTraceID)
}

// SetLevel sets the Level field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetLevel(level *ObservationLevel) {
	o.Level = level
	o.require(observationsGetManyRequestFieldLevel)
}

// SetParentObservationID sets the ParentObservationID field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetParentObservationID(parentObservationID *string) {
	o.ParentObservationID = parentObservationID
	o.require(observationsGetManyRequestFieldParentObservationID)
}

// SetEnvironment sets the Environment field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetEnvironment(environment []*string) {
	o.Environment = environment
	o.require(observationsGetManyRequestFieldEnvironment)
}

// SetFromStartTime sets the FromStartTime field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetFromStartTime(fromStartTime *time.Time) {
	o.FromStartTime = fromStartTime
	o.require(observationsGetManyRequestFieldFromStartTime)
}

// SetToStartTime sets the ToStartTime field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetToStartTime(toStartTime *time.Time) {
	o.ToStartTime = toStartTime
	o.require(observationsGetManyRequestFieldToStartTime)
}

// SetVersion sets the Version field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetVersion(version *string) {
	o.Version = version
	o.require(observationsGetManyRequestFieldVersion)
}

// SetFilter sets the Filter field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsGetManyRequest) SetFilter(filter *string) {
	o.Filter = filter
	o.require(observationsGetManyRequestFieldFilter)
}

var (
	observationsViewsFieldData = big.NewInt(1 << 0)
	observationsViewsFieldMeta = big.NewInt(1 << 1)
)

type ObservationsViews struct {
	Data []*ObservationsView `json:"data" url:"data"`
	Meta *UtilsMetaResponse  `json:"meta" url:"meta"`

	// Private bitmask of fields set to an explicit value and therefore not to be omitted
	explicitFields *big.Int `json:"-" url:"-"`

	extraProperties map[string]interface{}
	rawJSON         json.RawMessage
}

func (o *ObservationsViews) GetData() []*ObservationsView {
	if o == nil {
		return nil
	}
	return o.Data
}

func (o *ObservationsViews) GetMeta() *UtilsMetaResponse {
	if o == nil {
		return nil
	}
	return o.Meta
}

func (o *ObservationsViews) GetExtraProperties() map[string]interface{} {
	return o.extraProperties
}

func (o *ObservationsViews) require(field *big.Int) {
	if o.explicitFields == nil {
		o.explicitFields = big.NewInt(0)
	}
	o.explicitFields.Or(o.explicitFields, field)
}

// SetData sets the Data field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsViews) SetData(data []*ObservationsView) {
	o.Data = data
	o.require(observationsViewsFieldData)
}

// SetMeta sets the Meta field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (o *ObservationsViews) SetMeta(meta *UtilsMetaResponse) {
	o.Meta = meta
	o.require(observationsViewsFieldMeta)
}

func (o *ObservationsViews) UnmarshalJSON(data []byte) error {
	type unmarshaler ObservationsViews
	var value unmarshaler
	if err := json.Unmarshal(data, &value); err != nil {
		return err
	}
	*o = ObservationsViews(value)
	extraProperties, err := internal.ExtractExtraProperties(data, *o)
	if err != nil {
		return err
	}
	o.extraProperties = extraProperties
	o.rawJSON = json.RawMessage(data)
	return nil
}

func (o *ObservationsViews) MarshalJSON() ([]byte, error) {
	type embed ObservationsViews
	var marshaler = struct {
		embed
	}{
		embed: embed(*o),
	}
	explicitMarshaler := internal.HandleExplicitFields(marshaler, o.explicitFields)
	return json.Marshal(explicitMarshaler)
}

func (o *ObservationsViews) String() string {
	if len(o.rawJSON) > 0 {
		if value, err := internal.StringifyJSON(o.rawJSON); err == nil {
			return value
		}
	}
	if value, err := internal.StringifyJSON(o); err == nil {
		return value
	}
	return fmt.Sprintf("%#v", o)
}
