From 41b15b7e399369b41a705f1915f721539d0cd24b Mon Sep 17 00:00:00 2001 From: nick Date: Thu, 18 Apr 2024 20:57:52 +0700 Subject: [PATCH] Implemented string filter comparators --- .openapi-generator/FILES | 2 + README.md | 1 + docs/RangeFilter.md | 34 ++++---- docs/RangeFilterLte.md | 30 +++++++ docs/ReplaceDocumentRequest.md | 51 +++++++++++ model_range_filter.go | 48 +++++----- model_range_filter_lte.go | 154 +++++++++++++++++++++++++++++++++ 7 files changed, 278 insertions(+), 42 deletions(-) create mode 100644 docs/RangeFilterLte.md create mode 100644 docs/ReplaceDocumentRequest.md create mode 100644 model_range_filter_lte.go diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 488780c..898b626 100755 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -42,6 +42,8 @@ docs/PercolateRequest.md docs/PercolateRequestQuery.md docs/QueryFilter.md docs/RangeFilter.md +docs/RangeFilterLte.md +docs/ReplaceDocumentRequest.md docs/SearchAPI.md docs/SearchRequest.md docs/SearchResponse.md diff --git a/README.md b/README.md index 130f0aa..a82c9de 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,7 @@ Class | Method | HTTP request | Description - [PercolateRequestQuery](docs/PercolateRequestQuery.md) - [QueryFilter](docs/QueryFilter.md) - [RangeFilter](docs/RangeFilter.md) + - [RangeFilterLte](docs/RangeFilterLte.md) - [ReplaceDocumentRequest](docs/ReplaceDocumentRequest.md) - [SearchRequest](docs/SearchRequest.md) - [SearchResponse](docs/SearchResponse.md) diff --git a/docs/RangeFilter.md b/docs/RangeFilter.md index 0d1dcd0..7536ec4 100755 --- a/docs/RangeFilter.md +++ b/docs/RangeFilter.md @@ -1,16 +1,14 @@ # RangeFilter -Range attribute filter - ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Field** | **string** | | -**Lte** | Pointer to **NullableFloat32** | | [optional] -**Gte** | Pointer to **NullableFloat32** | | [optional] -**Lt** | Pointer to **NullableFloat32** | | [optional] -**Gt** | Pointer to **NullableFloat32** | | [optional] +**Lte** | Pointer to [**NullableRangeFilterLte**](RangeFilterLte.md) | | [optional] +**Gte** | Pointer to [**NullableRangeFilterLte**](RangeFilterLte.md) | | [optional] +**Lt** | Pointer to [**NullableRangeFilterLte**](RangeFilterLte.md) | | [optional] +**Gt** | Pointer to [**NullableRangeFilterLte**](RangeFilterLte.md) | | [optional] ## Methods @@ -53,20 +51,20 @@ SetField sets Field field to given value. ### GetLte -`func (o *RangeFilter) GetLte() float32` +`func (o *RangeFilter) GetLte() RangeFilterLte` GetLte returns the Lte field if non-nil, zero value otherwise. ### GetLteOk -`func (o *RangeFilter) GetLteOk() (*float32, bool)` +`func (o *RangeFilter) GetLteOk() (*RangeFilterLte, bool)` GetLteOk returns a tuple with the Lte field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetLte -`func (o *RangeFilter) SetLte(v float32)` +`func (o *RangeFilter) SetLte(v RangeFilterLte)` SetLte sets Lte field to given value. @@ -88,20 +86,20 @@ HasLte returns a boolean if a field has been set. UnsetLte ensures that no value is present for Lte, not even an explicit nil ### GetGte -`func (o *RangeFilter) GetGte() float32` +`func (o *RangeFilter) GetGte() RangeFilterLte` GetGte returns the Gte field if non-nil, zero value otherwise. ### GetGteOk -`func (o *RangeFilter) GetGteOk() (*float32, bool)` +`func (o *RangeFilter) GetGteOk() (*RangeFilterLte, bool)` GetGteOk returns a tuple with the Gte field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetGte -`func (o *RangeFilter) SetGte(v float32)` +`func (o *RangeFilter) SetGte(v RangeFilterLte)` SetGte sets Gte field to given value. @@ -123,20 +121,20 @@ HasGte returns a boolean if a field has been set. UnsetGte ensures that no value is present for Gte, not even an explicit nil ### GetLt -`func (o *RangeFilter) GetLt() float32` +`func (o *RangeFilter) GetLt() RangeFilterLte` GetLt returns the Lt field if non-nil, zero value otherwise. ### GetLtOk -`func (o *RangeFilter) GetLtOk() (*float32, bool)` +`func (o *RangeFilter) GetLtOk() (*RangeFilterLte, bool)` GetLtOk returns a tuple with the Lt field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetLt -`func (o *RangeFilter) SetLt(v float32)` +`func (o *RangeFilter) SetLt(v RangeFilterLte)` SetLt sets Lt field to given value. @@ -158,20 +156,20 @@ HasLt returns a boolean if a field has been set. UnsetLt ensures that no value is present for Lt, not even an explicit nil ### GetGt -`func (o *RangeFilter) GetGt() float32` +`func (o *RangeFilter) GetGt() RangeFilterLte` GetGt returns the Gt field if non-nil, zero value otherwise. ### GetGtOk -`func (o *RangeFilter) GetGtOk() (*float32, bool)` +`func (o *RangeFilter) GetGtOk() (*RangeFilterLte, bool)` GetGtOk returns a tuple with the Gt field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetGt -`func (o *RangeFilter) SetGt(v float32)` +`func (o *RangeFilter) SetGt(v RangeFilterLte)` SetGt sets Gt field to given value. diff --git a/docs/RangeFilterLte.md b/docs/RangeFilterLte.md new file mode 100644 index 0000000..0308189 --- /dev/null +++ b/docs/RangeFilterLte.md @@ -0,0 +1,30 @@ +# RangeFilterLte + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Methods + +### NewRangeFilterLte + +`func NewRangeFilterLte() *RangeFilterLte` + +NewRangeFilterLte instantiates a new RangeFilterLte 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 + +### NewRangeFilterLteWithDefaults + +`func NewRangeFilterLteWithDefaults() *RangeFilterLte` + +NewRangeFilterLteWithDefaults instantiates a new RangeFilterLte 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 + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/ReplaceDocumentRequest.md b/docs/ReplaceDocumentRequest.md new file mode 100644 index 0000000..822ae32 --- /dev/null +++ b/docs/ReplaceDocumentRequest.md @@ -0,0 +1,51 @@ +# ReplaceDocumentRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Doc** | **map[string]interface{}** | Object with document data | + +## Methods + +### NewReplaceDocumentRequest + +`func NewReplaceDocumentRequest(doc map[string]interface{}, ) *ReplaceDocumentRequest` + +NewReplaceDocumentRequest instantiates a new ReplaceDocumentRequest 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 + +### NewReplaceDocumentRequestWithDefaults + +`func NewReplaceDocumentRequestWithDefaults() *ReplaceDocumentRequest` + +NewReplaceDocumentRequestWithDefaults instantiates a new ReplaceDocumentRequest 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 + +### GetDoc + +`func (o *ReplaceDocumentRequest) GetDoc() map[string]interface{}` + +GetDoc returns the Doc field if non-nil, zero value otherwise. + +### GetDocOk + +`func (o *ReplaceDocumentRequest) GetDocOk() (*map[string]interface{}, bool)` + +GetDocOk returns a tuple with the Doc field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDoc + +`func (o *ReplaceDocumentRequest) SetDoc(v map[string]interface{})` + +SetDoc sets Doc field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/model_range_filter.go b/model_range_filter.go index 718102a..3b8e06d 100755 --- a/model_range_filter.go +++ b/model_range_filter.go @@ -23,10 +23,10 @@ var _ MappedNullable = &RangeFilter{} // RangeFilter Range attribute filter type RangeFilter struct { Field string `json:"field"` - Lte NullableFloat32 `json:"lte,omitempty"` - Gte NullableFloat32 `json:"gte,omitempty"` - Lt NullableFloat32 `json:"lt,omitempty"` - Gt NullableFloat32 `json:"gt,omitempty"` + Lte NullableRangeFilterLte `json:"lte,omitempty"` + Gte NullableRangeFilterLte `json:"gte,omitempty"` + Lt NullableRangeFilterLte `json:"lt,omitempty"` + Gt NullableRangeFilterLte `json:"gt,omitempty"` } type _RangeFilter RangeFilter @@ -74,9 +74,9 @@ func (o *RangeFilter) SetField(v string) { } // GetLte returns the Lte field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *RangeFilter) GetLte() float32 { +func (o *RangeFilter) GetLte() RangeFilterLte { if o == nil || IsNil(o.Lte.Get()) { - var ret float32 + var ret RangeFilterLte return ret } return *o.Lte.Get() @@ -85,7 +85,7 @@ func (o *RangeFilter) GetLte() float32 { // GetLteOk returns a tuple with the Lte 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 *RangeFilter) GetLteOk() (*float32, bool) { +func (o *RangeFilter) GetLteOk() (*RangeFilterLte, bool) { if o == nil { return nil, false } @@ -101,8 +101,8 @@ func (o *RangeFilter) HasLte() bool { return false } -// SetLte gets a reference to the given NullableFloat32 and assigns it to the Lte field. -func (o *RangeFilter) SetLte(v float32) { +// SetLte gets a reference to the given NullableRangeFilterLte and assigns it to the Lte field. +func (o *RangeFilter) SetLte(v RangeFilterLte) { o.Lte.Set(&v) } // SetLteNil sets the value for Lte to be an explicit nil @@ -116,9 +116,9 @@ func (o *RangeFilter) UnsetLte() { } // GetGte returns the Gte field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *RangeFilter) GetGte() float32 { +func (o *RangeFilter) GetGte() RangeFilterLte { if o == nil || IsNil(o.Gte.Get()) { - var ret float32 + var ret RangeFilterLte return ret } return *o.Gte.Get() @@ -127,7 +127,7 @@ func (o *RangeFilter) GetGte() float32 { // GetGteOk returns a tuple with the Gte 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 *RangeFilter) GetGteOk() (*float32, bool) { +func (o *RangeFilter) GetGteOk() (*RangeFilterLte, bool) { if o == nil { return nil, false } @@ -143,8 +143,8 @@ func (o *RangeFilter) HasGte() bool { return false } -// SetGte gets a reference to the given NullableFloat32 and assigns it to the Gte field. -func (o *RangeFilter) SetGte(v float32) { +// SetGte gets a reference to the given NullableRangeFilterLte and assigns it to the Gte field. +func (o *RangeFilter) SetGte(v RangeFilterLte) { o.Gte.Set(&v) } // SetGteNil sets the value for Gte to be an explicit nil @@ -158,9 +158,9 @@ func (o *RangeFilter) UnsetGte() { } // GetLt returns the Lt field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *RangeFilter) GetLt() float32 { +func (o *RangeFilter) GetLt() RangeFilterLte { if o == nil || IsNil(o.Lt.Get()) { - var ret float32 + var ret RangeFilterLte return ret } return *o.Lt.Get() @@ -169,7 +169,7 @@ func (o *RangeFilter) GetLt() float32 { // GetLtOk returns a tuple with the Lt 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 *RangeFilter) GetLtOk() (*float32, bool) { +func (o *RangeFilter) GetLtOk() (*RangeFilterLte, bool) { if o == nil { return nil, false } @@ -185,8 +185,8 @@ func (o *RangeFilter) HasLt() bool { return false } -// SetLt gets a reference to the given NullableFloat32 and assigns it to the Lt field. -func (o *RangeFilter) SetLt(v float32) { +// SetLt gets a reference to the given NullableRangeFilterLte and assigns it to the Lt field. +func (o *RangeFilter) SetLt(v RangeFilterLte) { o.Lt.Set(&v) } // SetLtNil sets the value for Lt to be an explicit nil @@ -200,9 +200,9 @@ func (o *RangeFilter) UnsetLt() { } // GetGt returns the Gt field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *RangeFilter) GetGt() float32 { +func (o *RangeFilter) GetGt() RangeFilterLte { if o == nil || IsNil(o.Gt.Get()) { - var ret float32 + var ret RangeFilterLte return ret } return *o.Gt.Get() @@ -211,7 +211,7 @@ func (o *RangeFilter) GetGt() float32 { // GetGtOk returns a tuple with the Gt 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 *RangeFilter) GetGtOk() (*float32, bool) { +func (o *RangeFilter) GetGtOk() (*RangeFilterLte, bool) { if o == nil { return nil, false } @@ -227,8 +227,8 @@ func (o *RangeFilter) HasGt() bool { return false } -// SetGt gets a reference to the given NullableFloat32 and assigns it to the Gt field. -func (o *RangeFilter) SetGt(v float32) { +// SetGt gets a reference to the given NullableRangeFilterLte and assigns it to the Gt field. +func (o *RangeFilter) SetGt(v RangeFilterLte) { o.Gt.Set(&v) } // SetGtNil sets the value for Gt to be an explicit nil diff --git a/model_range_filter_lte.go b/model_range_filter_lte.go new file mode 100644 index 0000000..15d67c5 --- /dev/null +++ b/model_range_filter_lte.go @@ -0,0 +1,154 @@ +/* +Manticore Search Client + +Сlient for Manticore Search. + +API version: 3.3.1 +Contact: info@manticoresearch.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package openapi + +import ( + "encoding/json" + "fmt" +) + +// RangeFilterLte - struct for RangeFilterLte +type RangeFilterLte struct { + Float32 *float32 + String *string +} + +// float32AsRangeFilterLte is a convenience function that returns float32 wrapped in RangeFilterLte +func Float32AsRangeFilterLte(v *float32) RangeFilterLte { + return RangeFilterLte{ + Float32: v, + } +} + +// stringAsRangeFilterLte is a convenience function that returns string wrapped in RangeFilterLte +func StringAsRangeFilterLte(v *string) RangeFilterLte { + return RangeFilterLte{ + String: v, + } +} + + +// Unmarshal JSON data into one of the pointers in the struct +func (dst *RangeFilterLte) UnmarshalJSON(data []byte) error { + var err error + // this object is nullable so check if the payload is null or empty string + if string(data) == "" || string(data) == "{}" { + return nil + } + + match := 0 + // try to unmarshal data into Float32 + err = newStrictDecoder(data).Decode(&dst.Float32) + if err == nil { + jsonFloat32, _ := json.Marshal(dst.Float32) + if string(jsonFloat32) == "{}" { // empty struct + dst.Float32 = nil + } else { + match++ + } + } else { + dst.Float32 = nil + } + + // try to unmarshal data into String + err = newStrictDecoder(data).Decode(&dst.String) + if err == nil { + jsonString, _ := json.Marshal(dst.String) + if string(jsonString) == "{}" { // empty struct + dst.String = nil + } else { + match++ + } + } else { + dst.String = nil + } + + if match > 1 { // more than 1 match + // reset to nil + dst.Float32 = nil + dst.String = nil + + return fmt.Errorf("data matches more than one schema in oneOf(RangeFilterLte)") + } else if match == 1 { + return nil // exactly one match + } else { // no match + return fmt.Errorf("data failed to match schemas in oneOf(RangeFilterLte)") + } +} + +// Marshal data from the first non-nil pointers in the struct to JSON +func (src RangeFilterLte) MarshalJSON() ([]byte, error) { + if src.Float32 != nil { + return json.Marshal(&src.Float32) + } + + if src.String != nil { + return json.Marshal(&src.String) + } + + return nil, nil // no data in oneOf schemas +} + +// Get the actual instance +func (obj *RangeFilterLte) GetActualInstance() (interface{}) { + if obj == nil { + return nil + } + if obj.Float32 != nil { + return obj.Float32 + } + + if obj.String != nil { + return obj.String + } + + // all schemas are nil + return nil +} + +type NullableRangeFilterLte struct { + value *RangeFilterLte + isSet bool +} + +func (v NullableRangeFilterLte) Get() *RangeFilterLte { + return v.value +} + +func (v *NullableRangeFilterLte) Set(val *RangeFilterLte) { + v.value = val + v.isSet = true +} + +func (v NullableRangeFilterLte) IsSet() bool { + return v.isSet +} + +func (v *NullableRangeFilterLte) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRangeFilterLte(val *RangeFilterLte) *NullableRangeFilterLte { + return &NullableRangeFilterLte{value: val, isSet: true} +} + +func (v NullableRangeFilterLte) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRangeFilterLte) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +