From 65e18f6f0913684d747fa5a74b8daba5c791ee5c Mon Sep 17 00:00:00 2001 From: Eric Choi Date: Thu, 1 Aug 2024 18:30:26 -0700 Subject: [PATCH] Make ExceptionRule reference DimensionMatcher --- metric_ruleset/model_exception_rule.go | 13 +- .../model_exception_rule_matcher.go | 143 ------------------ metric_ruleset_test.go | 2 +- 3 files changed, 8 insertions(+), 150 deletions(-) delete mode 100644 metric_ruleset/model_exception_rule_matcher.go diff --git a/metric_ruleset/model_exception_rule.go b/metric_ruleset/model_exception_rule.go index 8286b5b..efb97c6 100644 --- a/metric_ruleset/model_exception_rule.go +++ b/metric_ruleset/model_exception_rule.go @@ -20,7 +20,8 @@ type ExceptionRule struct { Name string `json:"name"` // Whether to reroute the metric with the specified dimension. If false, the rule remains defined but will not reroute metrics. Enabled bool `json:"enabled"` - Matcher ExceptionRuleMatcher `json:"matcher"` + // Finds the metric to reroute. + Matcher DimensionMatcher `json:"matcher"` // Contains fields for the restoration job. The restoration job reroutes metrics from the archival route to the real-time route. Restoration []ExceptionRuleRestorationFields `json:"restoration,omitempty"` // Information about an exception rule. @@ -33,7 +34,7 @@ type _ExceptionRule ExceptionRule // 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 NewExceptionRule(name string, enabled bool, matcher ExceptionRuleMatcher) *ExceptionRule { +func NewExceptionRule(name string, enabled bool, matcher DimensionMatcher) *ExceptionRule { this := ExceptionRule{} this.Name = name this.Enabled = enabled @@ -98,9 +99,9 @@ func (o *ExceptionRule) SetEnabled(v bool) { } // GetMatcher returns the Matcher field value -func (o *ExceptionRule) GetMatcher() ExceptionRuleMatcher { +func (o *ExceptionRule) GetMatcher() DimensionMatcher { if o == nil { - var ret ExceptionRuleMatcher + var ret DimensionMatcher return ret } @@ -109,7 +110,7 @@ func (o *ExceptionRule) GetMatcher() ExceptionRuleMatcher { // GetMatcherOk returns a tuple with the Matcher field value // and a boolean to check if the value has been set. -func (o *ExceptionRule) GetMatcherOk() (*ExceptionRuleMatcher, bool) { +func (o *ExceptionRule) GetMatcherOk() (*DimensionMatcher, bool) { if o == nil { return nil, false } @@ -117,7 +118,7 @@ func (o *ExceptionRule) GetMatcherOk() (*ExceptionRuleMatcher, bool) { } // SetMatcher sets field value -func (o *ExceptionRule) SetMatcher(v ExceptionRuleMatcher) { +func (o *ExceptionRule) SetMatcher(v DimensionMatcher) { o.Matcher = v } diff --git a/metric_ruleset/model_exception_rule_matcher.go b/metric_ruleset/model_exception_rule_matcher.go deleted file mode 100644 index 26fd6b8..0000000 --- a/metric_ruleset/model_exception_rule_matcher.go +++ /dev/null @@ -1,143 +0,0 @@ -/* -Metric Ruleset API - - Metric ruleset API - -API version: 3.3.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package metric_ruleset - -import ( - "encoding/json" -) - -// ExceptionRuleMatcher Finds the metric to reroute. -type ExceptionRuleMatcher struct { - // Metric component to apply filters for. The only supported metric component is \"dimension\". - Type string `json:"type"` - // List of filters to apply to your metric. - Filters []PropertyFilter `json:"filters"` -} - -// NewExceptionRuleMatcher instantiates a new ExceptionRuleMatcher 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 NewExceptionRuleMatcher(type_ string, filters []PropertyFilter) *ExceptionRuleMatcher { - this := ExceptionRuleMatcher{} - this.Type = type_ - this.Filters = filters - return &this -} - -// NewExceptionRuleMatcherWithDefaults instantiates a new ExceptionRuleMatcher 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 NewExceptionRuleMatcherWithDefaults() *ExceptionRuleMatcher { - this := ExceptionRuleMatcher{} - return &this -} - -// GetType returns the Type field value -func (o *ExceptionRuleMatcher) 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 *ExceptionRuleMatcher) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *ExceptionRuleMatcher) SetType(v string) { - o.Type = v -} - -// GetFilters returns the Filters field value -func (o *ExceptionRuleMatcher) GetFilters() []PropertyFilter { - if o == nil { - var ret []PropertyFilter - return ret - } - - return o.Filters -} - -// GetFiltersOk returns a tuple with the Filters field value -// and a boolean to check if the value has been set. -func (o *ExceptionRuleMatcher) GetFiltersOk() ([]PropertyFilter, bool) { - if o == nil { - return nil, false - } - return o.Filters, true -} - -// SetFilters sets field value -func (o *ExceptionRuleMatcher) SetFilters(v []PropertyFilter) { - o.Filters = v -} - -func (o ExceptionRuleMatcher) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ExceptionRuleMatcher) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["type"] = o.Type - toSerialize["filters"] = o.Filters - return toSerialize, nil -} - -type NullableExceptionRuleMatcher struct { - value *ExceptionRuleMatcher - isSet bool -} - -func (v NullableExceptionRuleMatcher) Get() *ExceptionRuleMatcher { - return v.value -} - -func (v *NullableExceptionRuleMatcher) Set(val *ExceptionRuleMatcher) { - v.value = val - v.isSet = true -} - -func (v NullableExceptionRuleMatcher) IsSet() bool { - return v.isSet -} - -func (v *NullableExceptionRuleMatcher) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableExceptionRuleMatcher(val *ExceptionRuleMatcher) *NullableExceptionRuleMatcher { - return &NullableExceptionRuleMatcher{value: val, isSet: true} -} - -func (v NullableExceptionRuleMatcher) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableExceptionRuleMatcher) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/metric_ruleset_test.go b/metric_ruleset_test.go index a1f7bc7..42dd3af 100644 --- a/metric_ruleset_test.go +++ b/metric_ruleset_test.go @@ -26,7 +26,7 @@ func TestCreateArchivedMetricRuleset(t *testing.T) { { Name: ruleName, Enabled: true, - Matcher: metric_ruleset.ExceptionRuleMatcher{ + Matcher: metric_ruleset.DimensionMatcher{ Type: "dimension", Filters: []metric_ruleset.PropertyFilter{ {