/* 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 MetricDefinition type satisfies the MappedNullable interface at compile time var _ MappedNullable = &MetricDefinition{} // MetricDefinition Provides the details of how to compute a scalar metric over the aggregation `field`, the counterpart of `bucketDefinition` for metric aggregations. When set on an `aggregationOption`, `size` is ignored, and the corresponding `searchAggregation` in the response carries a `@libre.graph.metric` rather than `buckets`. Libregraph extension not present in MS Graph. type MetricDefinition struct { // The reducer applied to the field values of all matches. Required. `avg` is not a simple reducer (averages of averages are not averages): the backend carries `(sum, count)` internally and emits only the final value on the outermost merge. Kind string `json:"kind"` } type _MetricDefinition MetricDefinition // NewMetricDefinition instantiates a new MetricDefinition 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 NewMetricDefinition(kind string) *MetricDefinition { this := MetricDefinition{} this.Kind = kind return &this } // NewMetricDefinitionWithDefaults instantiates a new MetricDefinition 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 NewMetricDefinitionWithDefaults() *MetricDefinition { this := MetricDefinition{} return &this } // GetKind returns the Kind field value func (o *MetricDefinition) GetKind() string { if o == nil { var ret string return ret } return o.Kind } // GetKindOk returns a tuple with the Kind field value // and a boolean to check if the value has been set. func (o *MetricDefinition) GetKindOk() (*string, bool) { if o == nil { return nil, false } return &o.Kind, true } // SetKind sets field value func (o *MetricDefinition) SetKind(v string) { o.Kind = v } func (o MetricDefinition) MarshalJSON() ([]byte, error) { toSerialize,err := o.ToMap() if err != nil { return []byte{}, err } return json.Marshal(toSerialize) } func (o MetricDefinition) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} toSerialize["kind"] = o.Kind return toSerialize, nil } func (o *MetricDefinition) 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{ "kind", } 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) } } varMetricDefinition := _MetricDefinition{} decoder := json.NewDecoder(bytes.NewReader(data)) decoder.DisallowUnknownFields() err = decoder.Decode(&varMetricDefinition) if err != nil { return err } *o = MetricDefinition(varMetricDefinition) return err } type NullableMetricDefinition struct { value *MetricDefinition isSet bool } func (v NullableMetricDefinition) Get() *MetricDefinition { return v.value } func (v *NullableMetricDefinition) Set(val *MetricDefinition) { v.value = val v.isSet = true } func (v NullableMetricDefinition) IsSet() bool { return v.isSet } func (v *NullableMetricDefinition) Unset() { v.value = nil v.isSet = false } func NewNullableMetricDefinition(val *MetricDefinition) *NullableMetricDefinition { return &NullableMetricDefinition{value: val, isSet: true} } func (v NullableMetricDefinition) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableMetricDefinition) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }