|
| 1 | +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +// This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +// Copyright 2019-Present Datadog, Inc. |
| 4 | + |
| 5 | +package datadogV2 |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + |
| 10 | + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" |
| 11 | +) |
| 12 | + |
| 13 | +// CostAggregationType Controls how costs are aggregated when using `start_date`. The `cumulative` option returns month-to-date running totals. |
| 14 | +type CostAggregationType string |
| 15 | + |
| 16 | +// List of CostAggregationType. |
| 17 | +const ( |
| 18 | + COSTAGGREGATIONTYPE_CUMULATIVE CostAggregationType = "cumulative" |
| 19 | +) |
| 20 | + |
| 21 | +var allowedCostAggregationTypeEnumValues = []CostAggregationType{ |
| 22 | + COSTAGGREGATIONTYPE_CUMULATIVE, |
| 23 | +} |
| 24 | + |
| 25 | +// GetAllowedValues reeturns the list of possible values. |
| 26 | +func (v *CostAggregationType) GetAllowedValues() []CostAggregationType { |
| 27 | + return allowedCostAggregationTypeEnumValues |
| 28 | +} |
| 29 | + |
| 30 | +// UnmarshalJSON deserializes the given payload. |
| 31 | +func (v *CostAggregationType) UnmarshalJSON(src []byte) error { |
| 32 | + var value string |
| 33 | + err := datadog.Unmarshal(src, &value) |
| 34 | + if err != nil { |
| 35 | + return err |
| 36 | + } |
| 37 | + *v = CostAggregationType(value) |
| 38 | + return nil |
| 39 | +} |
| 40 | + |
| 41 | +// NewCostAggregationTypeFromValue returns a pointer to a valid CostAggregationType |
| 42 | +// for the value passed as argument, or an error if the value passed is not allowed by the enum. |
| 43 | +func NewCostAggregationTypeFromValue(v string) (*CostAggregationType, error) { |
| 44 | + ev := CostAggregationType(v) |
| 45 | + if ev.IsValid() { |
| 46 | + return &ev, nil |
| 47 | + } |
| 48 | + return nil, fmt.Errorf("invalid value '%v' for CostAggregationType: valid values are %v", v, allowedCostAggregationTypeEnumValues) |
| 49 | +} |
| 50 | + |
| 51 | +// IsValid return true if the value is valid for the enum, false otherwise. |
| 52 | +func (v CostAggregationType) IsValid() bool { |
| 53 | + for _, existing := range allowedCostAggregationTypeEnumValues { |
| 54 | + if existing == v { |
| 55 | + return true |
| 56 | + } |
| 57 | + } |
| 58 | + return false |
| 59 | +} |
| 60 | + |
| 61 | +// Ptr returns reference to CostAggregationType value. |
| 62 | +func (v CostAggregationType) Ptr() *CostAggregationType { |
| 63 | + return &v |
| 64 | +} |
0 commit comments