model_timeseries_specifier.go•13.8 kB
/*
Metoro Alerts API
API for managing alerts in the Metoro observability platform.
API version: 1.0.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package model
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the TimeseriesSpecifier type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &TimeseriesSpecifier{}
// TimeseriesSpecifier Specification for a timeseries
type TimeseriesSpecifier struct {
// Type of timeseries
Type string `json:"type"`
Metric *TimeseriesSpecifierMetric `json:"metric,omitempty"`
KubernetesResource *TimeseriesSpecifierKubernetesResource `json:"kubernetes_resource,omitempty"`
Logs *TimeseriesSpecifierLogs `json:"logs,omitempty"`
Traces *TimeseriesSpecifierTraces `json:"traces,omitempty"`
// Filters to apply to the timeseries
Filters []TimeseriesSpecifierFiltersInner `json:"filters,omitempty"`
// Aggregation function to apply
Aggregation *string `json:"aggregation,omitempty"`
// Size of buckets in seconds for data aggregation
BucketSize *int64 `json:"bucketSize,omitempty"`
// Fields to split the results by
Splits []string `json:"splits,omitempty"`
// Functions to apply to the timeseries
Functions []TimeseriesSpecifierFunction `json:"functions,omitempty"`
}
type _TimeseriesSpecifier TimeseriesSpecifier
// NewTimeseriesSpecifier instantiates a new TimeseriesSpecifier 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 NewTimeseriesSpecifier(type_ string) *TimeseriesSpecifier {
this := TimeseriesSpecifier{}
this.Type = type_
return &this
}
// NewTimeseriesSpecifierWithDefaults instantiates a new TimeseriesSpecifier 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 NewTimeseriesSpecifierWithDefaults() *TimeseriesSpecifier {
this := TimeseriesSpecifier{}
return &this
}
// GetType returns the Type field value
func (o *TimeseriesSpecifier) GetType() string {
if o == nil {
var ret string
return ret
}
return o.Type
}
// GetTypeOk returns a tuple with the Type field value
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetTypeOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Type, true
}
// SetType sets field value
func (o *TimeseriesSpecifier) SetType(v string) {
o.Type = v
}
// GetMetric returns the Metric field value if set, zero value otherwise.
func (o *TimeseriesSpecifier) GetMetric() TimeseriesSpecifierMetric {
if o == nil || IsNil(o.Metric) {
var ret TimeseriesSpecifierMetric
return ret
}
return *o.Metric
}
// GetMetricOk returns a tuple with the Metric field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetMetricOk() (*TimeseriesSpecifierMetric, bool) {
if o == nil || IsNil(o.Metric) {
return nil, false
}
return o.Metric, true
}
// HasMetric returns a boolean if a field has been set.
func (o *TimeseriesSpecifier) HasMetric() bool {
if o != nil && !IsNil(o.Metric) {
return true
}
return false
}
// SetMetric gets a reference to the given TimeseriesSpecifierMetric and assigns it to the Metric field.
func (o *TimeseriesSpecifier) SetMetric(v TimeseriesSpecifierMetric) {
o.Metric = &v
}
// GetKubernetesResource returns the KubernetesResource field value if set, zero value otherwise.
func (o *TimeseriesSpecifier) GetKubernetesResource() TimeseriesSpecifierKubernetesResource {
if o == nil || IsNil(o.KubernetesResource) {
var ret TimeseriesSpecifierKubernetesResource
return ret
}
return *o.KubernetesResource
}
// GetKubernetesResourceOk returns a tuple with the KubernetesResource field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetKubernetesResourceOk() (*TimeseriesSpecifierKubernetesResource, bool) {
if o == nil || IsNil(o.KubernetesResource) {
return nil, false
}
return o.KubernetesResource, true
}
// HasKubernetesResource returns a boolean if a field has been set.
func (o *TimeseriesSpecifier) HasKubernetesResource() bool {
if o != nil && !IsNil(o.KubernetesResource) {
return true
}
return false
}
// SetKubernetesResource gets a reference to the given TimeseriesSpecifierKubernetesResource and assigns it to the KubernetesResource field.
func (o *TimeseriesSpecifier) SetKubernetesResource(v TimeseriesSpecifierKubernetesResource) {
o.KubernetesResource = &v
}
// GetLogs returns the Logs field value if set, zero value otherwise.
func (o *TimeseriesSpecifier) GetLogs() TimeseriesSpecifierLogs {
if o == nil || IsNil(o.Logs) {
var ret TimeseriesSpecifierLogs
return ret
}
return *o.Logs
}
// GetLogsOk returns a tuple with the Logs field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetLogsOk() (*TimeseriesSpecifierLogs, bool) {
if o == nil || IsNil(o.Logs) {
return nil, false
}
return o.Logs, true
}
// HasLogs returns a boolean if a field has been set.
func (o *TimeseriesSpecifier) HasLogs() bool {
if o != nil && !IsNil(o.Logs) {
return true
}
return false
}
// SetLogs gets a reference to the given TimeseriesSpecifierLogs and assigns it to the Logs field.
func (o *TimeseriesSpecifier) SetLogs(v TimeseriesSpecifierLogs) {
o.Logs = &v
}
// GetTraces returns the Traces field value if set, zero value otherwise.
func (o *TimeseriesSpecifier) GetTraces() TimeseriesSpecifierTraces {
if o == nil || IsNil(o.Traces) {
var ret TimeseriesSpecifierTraces
return ret
}
return *o.Traces
}
// GetTracesOk returns a tuple with the Traces field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetTracesOk() (*TimeseriesSpecifierTraces, bool) {
if o == nil || IsNil(o.Traces) {
return nil, false
}
return o.Traces, true
}
// HasTraces returns a boolean if a field has been set.
func (o *TimeseriesSpecifier) HasTraces() bool {
if o != nil && !IsNil(o.Traces) {
return true
}
return false
}
// SetTraces gets a reference to the given TimeseriesSpecifierTraces and assigns it to the Traces field.
func (o *TimeseriesSpecifier) SetTraces(v TimeseriesSpecifierTraces) {
o.Traces = &v
}
// GetFilters returns the Filters field value if set, zero value otherwise.
func (o *TimeseriesSpecifier) GetFilters() []TimeseriesSpecifierFiltersInner {
if o == nil || IsNil(o.Filters) {
var ret []TimeseriesSpecifierFiltersInner
return ret
}
return o.Filters
}
// GetFiltersOk returns a tuple with the Filters field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetFiltersOk() ([]TimeseriesSpecifierFiltersInner, bool) {
if o == nil || IsNil(o.Filters) {
return nil, false
}
return o.Filters, true
}
// HasFilters returns a boolean if a field has been set.
func (o *TimeseriesSpecifier) HasFilters() bool {
if o != nil && !IsNil(o.Filters) {
return true
}
return false
}
// SetFilters gets a reference to the given []TimeseriesSpecifierFiltersInner and assigns it to the Filters field.
func (o *TimeseriesSpecifier) SetFilters(v []TimeseriesSpecifierFiltersInner) {
o.Filters = v
}
// GetAggregation returns the Aggregation field value if set, zero value otherwise.
func (o *TimeseriesSpecifier) GetAggregation() string {
if o == nil || IsNil(o.Aggregation) {
var ret string
return ret
}
return *o.Aggregation
}
// GetAggregationOk returns a tuple with the Aggregation field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetAggregationOk() (*string, bool) {
if o == nil || IsNil(o.Aggregation) {
return nil, false
}
return o.Aggregation, true
}
// HasAggregation returns a boolean if a field has been set.
func (o *TimeseriesSpecifier) HasAggregation() bool {
if o != nil && !IsNil(o.Aggregation) {
return true
}
return false
}
// SetAggregation gets a reference to the given string and assigns it to the Aggregation field.
func (o *TimeseriesSpecifier) SetAggregation(v string) {
o.Aggregation = &v
}
// GetBucketSize returns the BucketSize field value if set, zero value otherwise.
func (o *TimeseriesSpecifier) GetBucketSize() int64 {
if o == nil || IsNil(o.BucketSize) {
var ret int64
return ret
}
return *o.BucketSize
}
// GetBucketSizeOk returns a tuple with the BucketSize field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetBucketSizeOk() (*int64, bool) {
if o == nil || IsNil(o.BucketSize) {
return nil, false
}
return o.BucketSize, true
}
// HasBucketSize returns a boolean if a field has been set.
func (o *TimeseriesSpecifier) HasBucketSize() bool {
if o != nil && !IsNil(o.BucketSize) {
return true
}
return false
}
// SetBucketSize gets a reference to the given int64 and assigns it to the BucketSize field.
func (o *TimeseriesSpecifier) SetBucketSize(v int64) {
o.BucketSize = &v
}
// GetSplits returns the Splits field value if set, zero value otherwise.
func (o *TimeseriesSpecifier) GetSplits() []string {
if o == nil || IsNil(o.Splits) {
var ret []string
return ret
}
return o.Splits
}
// GetSplitsOk returns a tuple with the Splits field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetSplitsOk() ([]string, bool) {
if o == nil || IsNil(o.Splits) {
return nil, false
}
return o.Splits, true
}
// HasSplits returns a boolean if a field has been set.
func (o *TimeseriesSpecifier) HasSplits() bool {
if o != nil && !IsNil(o.Splits) {
return true
}
return false
}
// SetSplits gets a reference to the given []string and assigns it to the Splits field.
func (o *TimeseriesSpecifier) SetSplits(v []string) {
o.Splits = v
}
// GetFunctions returns the Functions field value if set, zero value otherwise.
func (o *TimeseriesSpecifier) GetFunctions() []TimeseriesSpecifierFunction {
if o == nil || IsNil(o.Functions) {
var ret []TimeseriesSpecifierFunction
return ret
}
return o.Functions
}
// GetFunctionsOk returns a tuple with the Functions field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifier) GetFunctionsOk() ([]TimeseriesSpecifierFunction, bool) {
if o == nil || IsNil(o.Functions) {
return nil, false
}
return o.Functions, true
}
// HasFunctions returns a boolean if a field has been set.
func (o *TimeseriesSpecifier) HasFunctions() bool {
if o != nil && !IsNil(o.Functions) {
return true
}
return false
}
// SetFunctions gets a reference to the given []TimeseriesSpecifierFunction and assigns it to the Functions field.
func (o *TimeseriesSpecifier) SetFunctions(v []TimeseriesSpecifierFunction) {
o.Functions = v
}
func (o TimeseriesSpecifier) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o TimeseriesSpecifier) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["type"] = o.Type
if !IsNil(o.Metric) {
toSerialize["metric"] = o.Metric
}
if !IsNil(o.KubernetesResource) {
toSerialize["kubernetes_resource"] = o.KubernetesResource
}
if !IsNil(o.Logs) {
toSerialize["logs"] = o.Logs
}
if !IsNil(o.Traces) {
toSerialize["traces"] = o.Traces
}
if !IsNil(o.Filters) {
toSerialize["filters"] = o.Filters
}
if !IsNil(o.Aggregation) {
toSerialize["aggregation"] = o.Aggregation
}
if !IsNil(o.BucketSize) {
toSerialize["bucketSize"] = o.BucketSize
}
if !IsNil(o.Splits) {
toSerialize["splits"] = o.Splits
}
if !IsNil(o.Functions) {
toSerialize["functions"] = o.Functions
}
return toSerialize, nil
}
func (o *TimeseriesSpecifier) 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{
"type",
}
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)
}
}
varTimeseriesSpecifier := _TimeseriesSpecifier{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varTimeseriesSpecifier)
if err != nil {
return err
}
*o = TimeseriesSpecifier(varTimeseriesSpecifier)
return err
}
type NullableTimeseriesSpecifier struct {
value *TimeseriesSpecifier
isSet bool
}
func (v NullableTimeseriesSpecifier) Get() *TimeseriesSpecifier {
return v.value
}
func (v *NullableTimeseriesSpecifier) Set(val *TimeseriesSpecifier) {
v.value = val
v.isSet = true
}
func (v NullableTimeseriesSpecifier) IsSet() bool {
return v.isSet
}
func (v *NullableTimeseriesSpecifier) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTimeseriesSpecifier(val *TimeseriesSpecifier) *NullableTimeseriesSpecifier {
return &NullableTimeseriesSpecifier{value: val, isSet: true}
}
func (v NullableTimeseriesSpecifier) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTimeseriesSpecifier) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}