mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-10-03 01:15:11 -04:00
First tagged release carrying the merged search spec: the search query endpoint with aggregations (metricDefinition/searchMetric, geohashDefinition, aggregationFilterToken), sortProperty and the auth-guest additions.
381 lines
11 KiB
Go
381 lines
11 KiB
Go
/*
|
|
Libre Graph API
|
|
|
|
Libre Graph is a free API for cloud collaboration inspired by the MS Graph API.
|
|
|
|
API version: v1.0.8
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package libregraph
|
|
|
|
import (
|
|
"encoding/json"
|
|
"bytes"
|
|
"fmt"
|
|
)
|
|
|
|
// checks if the SearchRequest type satisfies the MappedNullable interface at compile time
|
|
var _ MappedNullable = &SearchRequest{}
|
|
|
|
// SearchRequest Represents an individual search request within a search query. Follows the [MS Graph searchRequest](https://learn.microsoft.com/en-us/graph/api/resources/searchrequest) resource type.
|
|
type SearchRequest struct {
|
|
// One or more types of resources expected in the response. Currently only `driveItem` is supported.
|
|
EntityTypes []string `json:"entityTypes"`
|
|
Query SearchQuery `json:"query"`
|
|
// Specifies the offset for the search results. Offset 0 returns the very first result. Used together with the `size` property for pagination.
|
|
From *int32 `json:"from,omitempty"`
|
|
// The size of the page to be retrieved. The maximum value is 500. Set to 0 to return only aggregations without any hits.
|
|
Size *int32 `json:"size,omitempty"`
|
|
// Specifies aggregations (also known as refiners or facets) to be returned alongside the search results. Optional.
|
|
Aggregations []AggregationOption `json:"aggregations,omitempty"`
|
|
// Contains one or more filters to narrow search results to specific buckets of a prior aggregation. Build each filter from the response of a prior search that aggregated on the same field: take the `aggregationFilterToken` of the wanted `searchBucket` and combine it with the field as `{field}:{aggregationFilterToken}`, e.g. `audio.artist:\"ǂǂ5361786f6e\"` for a terms bucket or `audio.year:range(1980, 1990)` for a range bucket. Several buckets of the same field are combined with `{field}:or({aggregationFilterToken},{aggregationFilterToken})`. Whitespace after the commas of `range(...)` and `or(...)` is optional. Multiple filters can be provided as separate array items. This results in a logical AND between the filters. Filters that are not built from server-issued tokens are rejected with `invalidRequest`.
|
|
AggregationFilters []string `json:"aggregationFilters,omitempty"`
|
|
// Contains the ordered collection of fields to sort the results on, primary sort key first. At most 5 sort properties. If absent, the results are sorted by relevance. See `sortProperty.name` for the set of sortable fields. Ties are broken by relevance, and results missing the sort property are placed last. Optional.
|
|
SortProperties []SortProperty `json:"sortProperties,omitempty"`
|
|
}
|
|
|
|
type _SearchRequest SearchRequest
|
|
|
|
// NewSearchRequest instantiates a new SearchRequest 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 NewSearchRequest(entityTypes []string, query SearchQuery) *SearchRequest {
|
|
this := SearchRequest{}
|
|
this.EntityTypes = entityTypes
|
|
this.Query = query
|
|
var from int32 = 0
|
|
this.From = &from
|
|
var size int32 = 25
|
|
this.Size = &size
|
|
return &this
|
|
}
|
|
|
|
// NewSearchRequestWithDefaults instantiates a new SearchRequest 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 NewSearchRequestWithDefaults() *SearchRequest {
|
|
this := SearchRequest{}
|
|
var from int32 = 0
|
|
this.From = &from
|
|
var size int32 = 25
|
|
this.Size = &size
|
|
return &this
|
|
}
|
|
|
|
// GetEntityTypes returns the EntityTypes field value
|
|
func (o *SearchRequest) GetEntityTypes() []string {
|
|
if o == nil {
|
|
var ret []string
|
|
return ret
|
|
}
|
|
|
|
return o.EntityTypes
|
|
}
|
|
|
|
// GetEntityTypesOk returns a tuple with the EntityTypes field value
|
|
// and a boolean to check if the value has been set.
|
|
func (o *SearchRequest) GetEntityTypesOk() ([]string, bool) {
|
|
if o == nil {
|
|
return nil, false
|
|
}
|
|
return o.EntityTypes, true
|
|
}
|
|
|
|
// SetEntityTypes sets field value
|
|
func (o *SearchRequest) SetEntityTypes(v []string) {
|
|
o.EntityTypes = v
|
|
}
|
|
|
|
// GetQuery returns the Query field value
|
|
func (o *SearchRequest) GetQuery() SearchQuery {
|
|
if o == nil {
|
|
var ret SearchQuery
|
|
return ret
|
|
}
|
|
|
|
return o.Query
|
|
}
|
|
|
|
// GetQueryOk returns a tuple with the Query field value
|
|
// and a boolean to check if the value has been set.
|
|
func (o *SearchRequest) GetQueryOk() (*SearchQuery, bool) {
|
|
if o == nil {
|
|
return nil, false
|
|
}
|
|
return &o.Query, true
|
|
}
|
|
|
|
// SetQuery sets field value
|
|
func (o *SearchRequest) SetQuery(v SearchQuery) {
|
|
o.Query = v
|
|
}
|
|
|
|
// GetFrom returns the From field value if set, zero value otherwise.
|
|
func (o *SearchRequest) GetFrom() int32 {
|
|
if o == nil || IsNil(o.From) {
|
|
var ret int32
|
|
return ret
|
|
}
|
|
return *o.From
|
|
}
|
|
|
|
// GetFromOk returns a tuple with the From field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *SearchRequest) GetFromOk() (*int32, bool) {
|
|
if o == nil || IsNil(o.From) {
|
|
return nil, false
|
|
}
|
|
return o.From, true
|
|
}
|
|
|
|
// HasFrom returns a boolean if a field has been set.
|
|
func (o *SearchRequest) HasFrom() bool {
|
|
if o != nil && !IsNil(o.From) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetFrom gets a reference to the given int32 and assigns it to the From field.
|
|
func (o *SearchRequest) SetFrom(v int32) {
|
|
o.From = &v
|
|
}
|
|
|
|
// GetSize returns the Size field value if set, zero value otherwise.
|
|
func (o *SearchRequest) GetSize() int32 {
|
|
if o == nil || IsNil(o.Size) {
|
|
var ret int32
|
|
return ret
|
|
}
|
|
return *o.Size
|
|
}
|
|
|
|
// GetSizeOk returns a tuple with the Size field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *SearchRequest) GetSizeOk() (*int32, bool) {
|
|
if o == nil || IsNil(o.Size) {
|
|
return nil, false
|
|
}
|
|
return o.Size, true
|
|
}
|
|
|
|
// HasSize returns a boolean if a field has been set.
|
|
func (o *SearchRequest) HasSize() bool {
|
|
if o != nil && !IsNil(o.Size) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetSize gets a reference to the given int32 and assigns it to the Size field.
|
|
func (o *SearchRequest) SetSize(v int32) {
|
|
o.Size = &v
|
|
}
|
|
|
|
// GetAggregations returns the Aggregations field value if set, zero value otherwise.
|
|
func (o *SearchRequest) GetAggregations() []AggregationOption {
|
|
if o == nil || IsNil(o.Aggregations) {
|
|
var ret []AggregationOption
|
|
return ret
|
|
}
|
|
return o.Aggregations
|
|
}
|
|
|
|
// GetAggregationsOk returns a tuple with the Aggregations field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *SearchRequest) GetAggregationsOk() ([]AggregationOption, bool) {
|
|
if o == nil || IsNil(o.Aggregations) {
|
|
return nil, false
|
|
}
|
|
return o.Aggregations, true
|
|
}
|
|
|
|
// HasAggregations returns a boolean if a field has been set.
|
|
func (o *SearchRequest) HasAggregations() bool {
|
|
if o != nil && !IsNil(o.Aggregations) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetAggregations gets a reference to the given []AggregationOption and assigns it to the Aggregations field.
|
|
func (o *SearchRequest) SetAggregations(v []AggregationOption) {
|
|
o.Aggregations = v
|
|
}
|
|
|
|
// GetAggregationFilters returns the AggregationFilters field value if set, zero value otherwise.
|
|
func (o *SearchRequest) GetAggregationFilters() []string {
|
|
if o == nil || IsNil(o.AggregationFilters) {
|
|
var ret []string
|
|
return ret
|
|
}
|
|
return o.AggregationFilters
|
|
}
|
|
|
|
// GetAggregationFiltersOk returns a tuple with the AggregationFilters field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *SearchRequest) GetAggregationFiltersOk() ([]string, bool) {
|
|
if o == nil || IsNil(o.AggregationFilters) {
|
|
return nil, false
|
|
}
|
|
return o.AggregationFilters, true
|
|
}
|
|
|
|
// HasAggregationFilters returns a boolean if a field has been set.
|
|
func (o *SearchRequest) HasAggregationFilters() bool {
|
|
if o != nil && !IsNil(o.AggregationFilters) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetAggregationFilters gets a reference to the given []string and assigns it to the AggregationFilters field.
|
|
func (o *SearchRequest) SetAggregationFilters(v []string) {
|
|
o.AggregationFilters = v
|
|
}
|
|
|
|
// GetSortProperties returns the SortProperties field value if set, zero value otherwise.
|
|
func (o *SearchRequest) GetSortProperties() []SortProperty {
|
|
if o == nil || IsNil(o.SortProperties) {
|
|
var ret []SortProperty
|
|
return ret
|
|
}
|
|
return o.SortProperties
|
|
}
|
|
|
|
// GetSortPropertiesOk returns a tuple with the SortProperties field value if set, nil otherwise
|
|
// and a boolean to check if the value has been set.
|
|
func (o *SearchRequest) GetSortPropertiesOk() ([]SortProperty, bool) {
|
|
if o == nil || IsNil(o.SortProperties) {
|
|
return nil, false
|
|
}
|
|
return o.SortProperties, true
|
|
}
|
|
|
|
// HasSortProperties returns a boolean if a field has been set.
|
|
func (o *SearchRequest) HasSortProperties() bool {
|
|
if o != nil && !IsNil(o.SortProperties) {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SetSortProperties gets a reference to the given []SortProperty and assigns it to the SortProperties field.
|
|
func (o *SearchRequest) SetSortProperties(v []SortProperty) {
|
|
o.SortProperties = v
|
|
}
|
|
|
|
func (o SearchRequest) MarshalJSON() ([]byte, error) {
|
|
toSerialize,err := o.ToMap()
|
|
if err != nil {
|
|
return []byte{}, err
|
|
}
|
|
return json.Marshal(toSerialize)
|
|
}
|
|
|
|
func (o SearchRequest) ToMap() (map[string]interface{}, error) {
|
|
toSerialize := map[string]interface{}{}
|
|
toSerialize["entityTypes"] = o.EntityTypes
|
|
toSerialize["query"] = o.Query
|
|
if !IsNil(o.From) {
|
|
toSerialize["from"] = o.From
|
|
}
|
|
if !IsNil(o.Size) {
|
|
toSerialize["size"] = o.Size
|
|
}
|
|
if !IsNil(o.Aggregations) {
|
|
toSerialize["aggregations"] = o.Aggregations
|
|
}
|
|
if !IsNil(o.AggregationFilters) {
|
|
toSerialize["aggregationFilters"] = o.AggregationFilters
|
|
}
|
|
if !IsNil(o.SortProperties) {
|
|
toSerialize["sortProperties"] = o.SortProperties
|
|
}
|
|
return toSerialize, nil
|
|
}
|
|
|
|
func (o *SearchRequest) 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{
|
|
"entityTypes",
|
|
"query",
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
varSearchRequest := _SearchRequest{}
|
|
|
|
decoder := json.NewDecoder(bytes.NewReader(data))
|
|
decoder.DisallowUnknownFields()
|
|
err = decoder.Decode(&varSearchRequest)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
*o = SearchRequest(varSearchRequest)
|
|
|
|
return err
|
|
}
|
|
|
|
type NullableSearchRequest struct {
|
|
value *SearchRequest
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableSearchRequest) Get() *SearchRequest {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableSearchRequest) Set(val *SearchRequest) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableSearchRequest) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableSearchRequest) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableSearchRequest(val *SearchRequest) *NullableSearchRequest {
|
|
return &NullableSearchRequest{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableSearchRequest) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableSearchRequest) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|
|
|
|
|