fleet-memory/hindsight-clients/go/model_memory_item.go
Nicolò Boschi 6e30980add
feat: use official go generator for Go client (#377)
* ci: add Go client integration tests

Add test-go-client job to CI workflow following the same pattern as
Python, TypeScript, and Rust client tests. The job:
- Sets up Go 1.23 with dependency caching
- Starts the Hindsight API server
- Runs integration tests using the 'integration' build tag
- Displays server logs on failure

The integration tests (hindsight-clients/go/integration_test.go) cover
all core operations: retain, recall, reflect, bank management, and
end-to-end workflows.

* Move Go cookbook content to hindsight-cookbook repo

Removes Go-specific cookbook content that was added in PR #375:
- applications/go-memory-service.md
- recipes/go-quickstart.md
- recipes/go-concurrent-pipeline.md

These have been moved to the hindsight-cookbook repository where
cookbook content should live per project conventions.

* feat(go): add CI test for Go client and patch for ogen null handling

- Add test-go-client job to GitHub Actions CI workflow
- Create post-generation patch script (patch-ogen.sh) to fix ogen's
  handling of null values in optional string fields
- Patch OptString.Decode() to check jx.Next() type before decoding,
  properly handling explicit null in JSON responses

The patch ensures generated code persists across regenerations and
handles the Hindsight API's nullable optional fields correctly.

Fixes: Go client integration tests for retain and bank operations
Note: Some tests still fail for nullable arrays/objects - those
require additional patches for other Opt* types.

* feat: use official go generator for Go client

* feat: use official go generator for Go client

* ci fixes

* chore: sync Go client with latest OpenAPI spec

- Add model_child_operation_status.go (new model)
- Update model_operation_status_response.go with child operations
- Update go.mod/go.sum dependencies
- Update api/openapi.yaml
2026-02-16 14:04:12 +01:00

408 lines
11 KiB
Go

/*
Hindsight HTTP API
HTTP API for Hindsight
API version: 0.4.11
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hindsight
import (
"encoding/json"
"time"
"bytes"
"fmt"
)
// checks if the MemoryItem type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &MemoryItem{}
// MemoryItem Single memory item for retain.
type MemoryItem struct {
Content string `json:"content"`
Timestamp NullableTime `json:"timestamp,omitempty"`
Context NullableString `json:"context,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
DocumentId NullableString `json:"document_id,omitempty"`
Entities []EntityInput `json:"entities,omitempty"`
Tags []string `json:"tags,omitempty"`
}
type _MemoryItem MemoryItem
// NewMemoryItem instantiates a new MemoryItem object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewMemoryItem(content string) *MemoryItem {
this := MemoryItem{}
this.Content = content
return &this
}
// NewMemoryItemWithDefaults instantiates a new MemoryItem object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewMemoryItemWithDefaults() *MemoryItem {
this := MemoryItem{}
return &this
}
// GetContent returns the Content field value
func (o *MemoryItem) GetContent() string {
if o == nil {
var ret string
return ret
}
return o.Content
}
// GetContentOk returns a tuple with the Content field value
// and a boolean to check if the value has been set.
func (o *MemoryItem) GetContentOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Content, true
}
// SetContent sets field value
func (o *MemoryItem) SetContent(v string) {
o.Content = v
}
// GetTimestamp returns the Timestamp field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *MemoryItem) GetTimestamp() time.Time {
if o == nil || IsNil(o.Timestamp.Get()) {
var ret time.Time
return ret
}
return *o.Timestamp.Get()
}
// GetTimestampOk returns a tuple with the Timestamp field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *MemoryItem) GetTimestampOk() (*time.Time, bool) {
if o == nil {
return nil, false
}
return o.Timestamp.Get(), o.Timestamp.IsSet()
}
// HasTimestamp returns a boolean if a field has been set.
func (o *MemoryItem) HasTimestamp() bool {
if o != nil && o.Timestamp.IsSet() {
return true
}
return false
}
// SetTimestamp gets a reference to the given NullableTime and assigns it to the Timestamp field.
func (o *MemoryItem) SetTimestamp(v time.Time) {
o.Timestamp.Set(&v)
}
// SetTimestampNil sets the value for Timestamp to be an explicit nil
func (o *MemoryItem) SetTimestampNil() {
o.Timestamp.Set(nil)
}
// UnsetTimestamp ensures that no value is present for Timestamp, not even an explicit nil
func (o *MemoryItem) UnsetTimestamp() {
o.Timestamp.Unset()
}
// GetContext returns the Context field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *MemoryItem) GetContext() string {
if o == nil || IsNil(o.Context.Get()) {
var ret string
return ret
}
return *o.Context.Get()
}
// GetContextOk returns a tuple with the Context field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *MemoryItem) GetContextOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Context.Get(), o.Context.IsSet()
}
// HasContext returns a boolean if a field has been set.
func (o *MemoryItem) HasContext() bool {
if o != nil && o.Context.IsSet() {
return true
}
return false
}
// SetContext gets a reference to the given NullableString and assigns it to the Context field.
func (o *MemoryItem) SetContext(v string) {
o.Context.Set(&v)
}
// SetContextNil sets the value for Context to be an explicit nil
func (o *MemoryItem) SetContextNil() {
o.Context.Set(nil)
}
// UnsetContext ensures that no value is present for Context, not even an explicit nil
func (o *MemoryItem) UnsetContext() {
o.Context.Unset()
}
// GetMetadata returns the Metadata field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *MemoryItem) GetMetadata() map[string]string {
if o == nil {
var ret map[string]string
return ret
}
return o.Metadata
}
// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *MemoryItem) GetMetadataOk() (map[string]string, bool) {
if o == nil || IsNil(o.Metadata) {
return map[string]string{}, false
}
return o.Metadata, true
}
// HasMetadata returns a boolean if a field has been set.
func (o *MemoryItem) HasMetadata() bool {
if o != nil && !IsNil(o.Metadata) {
return true
}
return false
}
// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field.
func (o *MemoryItem) SetMetadata(v map[string]string) {
o.Metadata = v
}
// GetDocumentId returns the DocumentId field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *MemoryItem) GetDocumentId() string {
if o == nil || IsNil(o.DocumentId.Get()) {
var ret string
return ret
}
return *o.DocumentId.Get()
}
// GetDocumentIdOk returns a tuple with the DocumentId field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *MemoryItem) GetDocumentIdOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.DocumentId.Get(), o.DocumentId.IsSet()
}
// HasDocumentId returns a boolean if a field has been set.
func (o *MemoryItem) HasDocumentId() bool {
if o != nil && o.DocumentId.IsSet() {
return true
}
return false
}
// SetDocumentId gets a reference to the given NullableString and assigns it to the DocumentId field.
func (o *MemoryItem) SetDocumentId(v string) {
o.DocumentId.Set(&v)
}
// SetDocumentIdNil sets the value for DocumentId to be an explicit nil
func (o *MemoryItem) SetDocumentIdNil() {
o.DocumentId.Set(nil)
}
// UnsetDocumentId ensures that no value is present for DocumentId, not even an explicit nil
func (o *MemoryItem) UnsetDocumentId() {
o.DocumentId.Unset()
}
// GetEntities returns the Entities field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *MemoryItem) GetEntities() []EntityInput {
if o == nil {
var ret []EntityInput
return ret
}
return o.Entities
}
// GetEntitiesOk returns a tuple with the Entities field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *MemoryItem) GetEntitiesOk() ([]EntityInput, bool) {
if o == nil || IsNil(o.Entities) {
return nil, false
}
return o.Entities, true
}
// HasEntities returns a boolean if a field has been set.
func (o *MemoryItem) HasEntities() bool {
if o != nil && !IsNil(o.Entities) {
return true
}
return false
}
// SetEntities gets a reference to the given []EntityInput and assigns it to the Entities field.
func (o *MemoryItem) SetEntities(v []EntityInput) {
o.Entities = v
}
// GetTags returns the Tags field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *MemoryItem) GetTags() []string {
if o == nil {
var ret []string
return ret
}
return o.Tags
}
// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *MemoryItem) GetTagsOk() ([]string, bool) {
if o == nil || IsNil(o.Tags) {
return nil, false
}
return o.Tags, true
}
// HasTags returns a boolean if a field has been set.
func (o *MemoryItem) HasTags() bool {
if o != nil && !IsNil(o.Tags) {
return true
}
return false
}
// SetTags gets a reference to the given []string and assigns it to the Tags field.
func (o *MemoryItem) SetTags(v []string) {
o.Tags = v
}
func (o MemoryItem) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o MemoryItem) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["content"] = o.Content
if o.Timestamp.IsSet() {
toSerialize["timestamp"] = o.Timestamp.Get()
}
if o.Context.IsSet() {
toSerialize["context"] = o.Context.Get()
}
if o.Metadata != nil {
toSerialize["metadata"] = o.Metadata
}
if o.DocumentId.IsSet() {
toSerialize["document_id"] = o.DocumentId.Get()
}
if o.Entities != nil {
toSerialize["entities"] = o.Entities
}
if o.Tags != nil {
toSerialize["tags"] = o.Tags
}
return toSerialize, nil
}
func (o *MemoryItem) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"content",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err;
}
for _, requiredProperty := range(requiredProperties) {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varMemoryItem := _MemoryItem{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varMemoryItem)
if err != nil {
return err
}
*o = MemoryItem(varMemoryItem)
return err
}
type NullableMemoryItem struct {
value *MemoryItem
isSet bool
}
func (v NullableMemoryItem) Get() *MemoryItem {
return v.value
}
func (v *NullableMemoryItem) Set(val *MemoryItem) {
v.value = val
v.isSet = true
}
func (v NullableMemoryItem) IsSet() bool {
return v.isSet
}
func (v *NullableMemoryItem) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableMemoryItem(val *MemoryItem) *NullableMemoryItem {
return &NullableMemoryItem{value: val, isSet: true}
}
func (v NullableMemoryItem) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableMemoryItem) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}