// Code generated by Fern. DO NOT EDIT.

package api

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

var (
	promptVersionUpdateRequestFieldName      = big.NewInt(1 << 0)
	promptVersionUpdateRequestFieldVersion   = big.NewInt(1 << 1)
	promptVersionUpdateRequestFieldNewLabels = big.NewInt(1 << 2)
)

type PromptVersionUpdateRequest struct {
	// The name of the prompt. If the prompt is in a folder (e.g., "folder/subfolder/prompt-name"),
	// the folder path must be URL encoded.
	Name string `json:"-" url:"-"`
	// Version of the prompt to update
	Version int `json:"-" url:"-"`
	// New labels for the prompt version. Labels are unique across versions. The "latest" label is reserved and managed by Langfuse.
	NewLabels []string `json:"newLabels" url:"-"`

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

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

// 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 (p *PromptVersionUpdateRequest) SetName(name string) {
	p.Name = name
	p.require(promptVersionUpdateRequestFieldName)
}

// 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 (p *PromptVersionUpdateRequest) SetVersion(version int) {
	p.Version = version
	p.require(promptVersionUpdateRequestFieldVersion)
}

// SetNewLabels sets the NewLabels field and marks it as non-optional;
// this prevents an empty or null value for this field from being omitted during serialization.
func (p *PromptVersionUpdateRequest) SetNewLabels(newLabels []string) {
	p.NewLabels = newLabels
	p.require(promptVersionUpdateRequestFieldNewLabels)
}

func (p *PromptVersionUpdateRequest) UnmarshalJSON(data []byte) error {
	type unmarshaler PromptVersionUpdateRequest
	var body unmarshaler
	if err := json.Unmarshal(data, &body); err != nil {
		return err
	}
	*p = PromptVersionUpdateRequest(body)
	return nil
}

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