// 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 (
	sessionsGetRequestFieldSessionID = big.NewInt(1 << 0)
)

type SessionsGetRequest struct {
	// The unique id of a session
	SessionID string `json:"-" url:"-"`

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

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

// SetSessionID sets the SessionID field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *SessionsGetRequest) SetSessionID(sessionID string) {
	s.SessionID = sessionID
	s.require(sessionsGetRequestFieldSessionID)
}

var (
	sessionsListRequestFieldPage          = big.NewInt(1 << 0)
	sessionsListRequestFieldLimit         = big.NewInt(1 << 1)
	sessionsListRequestFieldFromTimestamp = big.NewInt(1 << 2)
	sessionsListRequestFieldToTimestamp   = big.NewInt(1 << 3)
	sessionsListRequestFieldEnvironment   = big.NewInt(1 << 4)
)

type SessionsListRequest 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"`
	// Optional filter to only include sessions created on or after a certain datetime (ISO 8601)
	FromTimestamp *time.Time `json:"-" url:"fromTimestamp,omitempty"`
	// Optional filter to only include sessions created before a certain datetime (ISO 8601)
	ToTimestamp *time.Time `json:"-" url:"toTimestamp,omitempty"`
	// Optional filter for sessions where the environment is one of the provided values.
	Environment []*string `json:"-" url:"environment,omitempty"`

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

func (s *SessionsListRequest) require(field *big.Int) {
	if s.explicitFields == nil {
		s.explicitFields = big.NewInt(0)
	}
	s.explicitFields.Or(s.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 (s *SessionsListRequest) SetPage(page *int) {
	s.Page = page
	s.require(sessionsListRequestFieldPage)
}

// 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 (s *SessionsListRequest) SetLimit(limit *int) {
	s.Limit = limit
	s.require(sessionsListRequestFieldLimit)
}

// SetFromTimestamp sets the FromTimestamp field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *SessionsListRequest) SetFromTimestamp(fromTimestamp *time.Time) {
	s.FromTimestamp = fromTimestamp
	s.require(sessionsListRequestFieldFromTimestamp)
}

// SetToTimestamp sets the ToTimestamp field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *SessionsListRequest) SetToTimestamp(toTimestamp *time.Time) {
	s.ToTimestamp = toTimestamp
	s.require(sessionsListRequestFieldToTimestamp)
}

// 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 (s *SessionsListRequest) SetEnvironment(environment []*string) {
	s.Environment = environment
	s.require(sessionsListRequestFieldEnvironment)
}

var (
	paginatedSessionsFieldData = big.NewInt(1 << 0)
	paginatedSessionsFieldMeta = big.NewInt(1 << 1)
)

type PaginatedSessions struct {
	Data []*Session         `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 (p *PaginatedSessions) GetData() []*Session {
	if p == nil {
		return nil
	}
	return p.Data
}

func (p *PaginatedSessions) GetMeta() *UtilsMetaResponse {
	if p == nil {
		return nil
	}
	return p.Meta
}

func (p *PaginatedSessions) GetExtraProperties() map[string]interface{} {
	return p.extraProperties
}

func (p *PaginatedSessions) require(field *big.Int) {
	if p.explicitFields == nil {
		p.explicitFields = big.NewInt(0)
	}
	p.explicitFields.Or(p.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 (p *PaginatedSessions) SetData(data []*Session) {
	p.Data = data
	p.require(paginatedSessionsFieldData)
}

// 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 (p *PaginatedSessions) SetMeta(meta *UtilsMetaResponse) {
	p.Meta = meta
	p.require(paginatedSessionsFieldMeta)
}

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

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

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

var (
	sessionFieldID          = big.NewInt(1 << 0)
	sessionFieldCreatedAt   = big.NewInt(1 << 1)
	sessionFieldProjectID   = big.NewInt(1 << 2)
	sessionFieldEnvironment = big.NewInt(1 << 3)
)

type Session struct {
	ID        string    `json:"id" url:"id"`
	CreatedAt time.Time `json:"createdAt" url:"createdAt"`
	ProjectID string    `json:"projectId" url:"projectId"`
	// The environment from which this session originated.
	Environment string `json:"environment" url:"environment"`

	// 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 (s *Session) GetID() string {
	if s == nil {
		return ""
	}
	return s.ID
}

func (s *Session) GetCreatedAt() time.Time {
	if s == nil {
		return time.Time{}
	}
	return s.CreatedAt
}

func (s *Session) GetProjectID() string {
	if s == nil {
		return ""
	}
	return s.ProjectID
}

func (s *Session) GetEnvironment() string {
	if s == nil {
		return ""
	}
	return s.Environment
}

func (s *Session) GetExtraProperties() map[string]interface{} {
	return s.extraProperties
}

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

// SetID sets the ID field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *Session) SetID(id string) {
	s.ID = id
	s.require(sessionFieldID)
}

// SetCreatedAt sets the CreatedAt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *Session) SetCreatedAt(createdAt time.Time) {
	s.CreatedAt = createdAt
	s.require(sessionFieldCreatedAt)
}

// SetProjectID sets the ProjectID field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *Session) SetProjectID(projectID string) {
	s.ProjectID = projectID
	s.require(sessionFieldProjectID)
}

// 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 (s *Session) SetEnvironment(environment string) {
	s.Environment = environment
	s.require(sessionFieldEnvironment)
}

func (s *Session) UnmarshalJSON(data []byte) error {
	type embed Session
	var unmarshaler = struct {
		embed
		CreatedAt *internal.DateTime `json:"createdAt"`
	}{
		embed: embed(*s),
	}
	if err := json.Unmarshal(data, &unmarshaler); err != nil {
		return err
	}
	*s = Session(unmarshaler.embed)
	s.CreatedAt = unmarshaler.CreatedAt.Time()
	extraProperties, err := internal.ExtractExtraProperties(data, *s)
	if err != nil {
		return err
	}
	s.extraProperties = extraProperties
	s.rawJSON = json.RawMessage(data)
	return nil
}

func (s *Session) MarshalJSON() ([]byte, error) {
	type embed Session
	var marshaler = struct {
		embed
		CreatedAt *internal.DateTime `json:"createdAt"`
	}{
		embed:     embed(*s),
		CreatedAt: internal.NewDateTime(s.CreatedAt),
	}
	explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields)
	return json.Marshal(explicitMarshaler)
}

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

var (
	sessionWithTracesFieldID          = big.NewInt(1 << 0)
	sessionWithTracesFieldCreatedAt   = big.NewInt(1 << 1)
	sessionWithTracesFieldProjectID   = big.NewInt(1 << 2)
	sessionWithTracesFieldEnvironment = big.NewInt(1 << 3)
	sessionWithTracesFieldTraces      = big.NewInt(1 << 4)
)

type SessionWithTraces struct {
	ID        string    `json:"id" url:"id"`
	CreatedAt time.Time `json:"createdAt" url:"createdAt"`
	ProjectID string    `json:"projectId" url:"projectId"`
	// The environment from which this session originated.
	Environment string   `json:"environment" url:"environment"`
	Traces      []*Trace `json:"traces" url:"traces"`

	// 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 (s *SessionWithTraces) GetID() string {
	if s == nil {
		return ""
	}
	return s.ID
}

func (s *SessionWithTraces) GetCreatedAt() time.Time {
	if s == nil {
		return time.Time{}
	}
	return s.CreatedAt
}

func (s *SessionWithTraces) GetProjectID() string {
	if s == nil {
		return ""
	}
	return s.ProjectID
}

func (s *SessionWithTraces) GetEnvironment() string {
	if s == nil {
		return ""
	}
	return s.Environment
}

func (s *SessionWithTraces) GetTraces() []*Trace {
	if s == nil {
		return nil
	}
	return s.Traces
}

func (s *SessionWithTraces) GetExtraProperties() map[string]interface{} {
	return s.extraProperties
}

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

// SetID sets the ID field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *SessionWithTraces) SetID(id string) {
	s.ID = id
	s.require(sessionWithTracesFieldID)
}

// SetCreatedAt sets the CreatedAt field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *SessionWithTraces) SetCreatedAt(createdAt time.Time) {
	s.CreatedAt = createdAt
	s.require(sessionWithTracesFieldCreatedAt)
}

// SetProjectID sets the ProjectID field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *SessionWithTraces) SetProjectID(projectID string) {
	s.ProjectID = projectID
	s.require(sessionWithTracesFieldProjectID)
}

// 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 (s *SessionWithTraces) SetEnvironment(environment string) {
	s.Environment = environment
	s.require(sessionWithTracesFieldEnvironment)
}

// SetTraces sets the Traces field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (s *SessionWithTraces) SetTraces(traces []*Trace) {
	s.Traces = traces
	s.require(sessionWithTracesFieldTraces)
}

func (s *SessionWithTraces) UnmarshalJSON(data []byte) error {
	type embed SessionWithTraces
	var unmarshaler = struct {
		embed
		CreatedAt *internal.DateTime `json:"createdAt"`
	}{
		embed: embed(*s),
	}
	if err := json.Unmarshal(data, &unmarshaler); err != nil {
		return err
	}
	*s = SessionWithTraces(unmarshaler.embed)
	s.CreatedAt = unmarshaler.CreatedAt.Time()
	extraProperties, err := internal.ExtractExtraProperties(data, *s)
	if err != nil {
		return err
	}
	s.extraProperties = extraProperties
	s.rawJSON = json.RawMessage(data)
	return nil
}

func (s *SessionWithTraces) MarshalJSON() ([]byte, error) {
	type embed SessionWithTraces
	var marshaler = struct {
		embed
		CreatedAt *internal.DateTime `json:"createdAt"`
	}{
		embed:     embed(*s),
		CreatedAt: internal.NewDateTime(s.CreatedAt),
	}
	explicitMarshaler := internal.HandleExplicitFields(marshaler, s.explicitFields)
	return json.Marshal(explicitMarshaler)
}

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