-
Notifications
You must be signed in to change notification settings - Fork 80
/
auto_scale_policy_details.go
254 lines (216 loc) · 11.5 KB
/
auto_scale_policy_details.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// Copyright (c) 2016, 2018, 2023, Oracle and/or its affiliates. All rights reserved.
// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
// Code generated. DO NOT EDIT.
// Big Data Service API
//
// REST API for Oracle Big Data Service. Use this API to build, deploy, and manage fully elastic Big Data Service clusters. Build on Hadoop, Spark and Data Science distributions, which can be fully integrated with existing enterprise data in Oracle Database and Oracle applications.
//
package bds
import (
"encoding/json"
"fmt"
"github.com/oracle/oci-go-sdk/v65/common"
"strings"
)
// AutoScalePolicyDetails Details of an autoscale policy.
// You can create following types of autoscaling policies:
// - **MetricBasedVerticalScalingPolicy:** Vertical autoscaling action is triggered when a performance metric exceeds a threshold
// - **MetricBasedHorizontalScalingPolicy:** Horizontal autoscaling action is triggered when a performance metric exceeds a threshold
// - **ScheduleBasedVerticalScalingPolicy:** Vertical autoscaling action is triggered at the specific times that you schedule.
// - **ScheduleBasedHorizontalScalingPolicy:** Horizontal autoscaling action is triggered at the specific times that you schedule.
type AutoScalePolicyDetails interface {
// The type of autoscaling trigger.
GetTriggerType() AutoScalePolicyDetailsTriggerTypeEnum
// The type of autoscaling action to take.
GetActionType() AutoScalePolicyDetailsActionTypeEnum
}
type autoscalepolicydetails struct {
JsonData []byte
TriggerType AutoScalePolicyDetailsTriggerTypeEnum `mandatory:"true" json:"triggerType"`
ActionType AutoScalePolicyDetailsActionTypeEnum `mandatory:"true" json:"actionType"`
PolicyType string `json:"policyType"`
}
// UnmarshalJSON unmarshals json
func (m *autoscalepolicydetails) UnmarshalJSON(data []byte) error {
m.JsonData = data
type Unmarshalerautoscalepolicydetails autoscalepolicydetails
s := struct {
Model Unmarshalerautoscalepolicydetails
}{}
err := json.Unmarshal(data, &s.Model)
if err != nil {
return err
}
m.TriggerType = s.Model.TriggerType
m.ActionType = s.Model.ActionType
m.PolicyType = s.Model.PolicyType
return err
}
// UnmarshalPolymorphicJSON unmarshals polymorphic json
func (m *autoscalepolicydetails) UnmarshalPolymorphicJSON(data []byte) (interface{}, error) {
if data == nil || string(data) == "null" {
return nil, nil
}
var err error
switch m.PolicyType {
case "METRIC_BASED_VERTICAL_SCALING_POLICY":
mm := MetricBasedVerticalScalingPolicyDetails{}
err = json.Unmarshal(data, &mm)
return mm, err
case "SCHEDULE_BASED_VERTICAL_SCALING_POLICY":
mm := ScheduleBasedVerticalScalingPolicyDetails{}
err = json.Unmarshal(data, &mm)
return mm, err
case "SCHEDULE_BASED_HORIZONTAL_SCALING_POLICY":
mm := ScheduleBasedHorizontalScalingPolicyDetails{}
err = json.Unmarshal(data, &mm)
return mm, err
case "METRIC_BASED_HORIZONTAL_SCALING_POLICY":
mm := MetricBasedHorizontalScalingPolicyDetails{}
err = json.Unmarshal(data, &mm)
return mm, err
default:
common.Logf("Recieved unsupported enum value for AutoScalePolicyDetails: %s.", m.PolicyType)
return *m, nil
}
}
//GetTriggerType returns TriggerType
func (m autoscalepolicydetails) GetTriggerType() AutoScalePolicyDetailsTriggerTypeEnum {
return m.TriggerType
}
//GetActionType returns ActionType
func (m autoscalepolicydetails) GetActionType() AutoScalePolicyDetailsActionTypeEnum {
return m.ActionType
}
func (m autoscalepolicydetails) String() string {
return common.PointerString(m)
}
// ValidateEnumValue returns an error when providing an unsupported enum value
// This function is being called during constructing API request process
// Not recommended for calling this function directly
func (m autoscalepolicydetails) ValidateEnumValue() (bool, error) {
errMessage := []string{}
if _, ok := GetMappingAutoScalePolicyDetailsTriggerTypeEnum(string(m.TriggerType)); !ok && m.TriggerType != "" {
errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for TriggerType: %s. Supported values are: %s.", m.TriggerType, strings.Join(GetAutoScalePolicyDetailsTriggerTypeEnumStringValues(), ",")))
}
if _, ok := GetMappingAutoScalePolicyDetailsActionTypeEnum(string(m.ActionType)); !ok && m.ActionType != "" {
errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for ActionType: %s. Supported values are: %s.", m.ActionType, strings.Join(GetAutoScalePolicyDetailsActionTypeEnumStringValues(), ",")))
}
if len(errMessage) > 0 {
return true, fmt.Errorf(strings.Join(errMessage, "\n"))
}
return false, nil
}
// AutoScalePolicyDetailsTriggerTypeEnum Enum with underlying type: string
type AutoScalePolicyDetailsTriggerTypeEnum string
// Set of constants representing the allowable values for AutoScalePolicyDetailsTriggerTypeEnum
const (
AutoScalePolicyDetailsTriggerTypeMetricBased AutoScalePolicyDetailsTriggerTypeEnum = "METRIC_BASED"
AutoScalePolicyDetailsTriggerTypeScheduleBased AutoScalePolicyDetailsTriggerTypeEnum = "SCHEDULE_BASED"
)
var mappingAutoScalePolicyDetailsTriggerTypeEnum = map[string]AutoScalePolicyDetailsTriggerTypeEnum{
"METRIC_BASED": AutoScalePolicyDetailsTriggerTypeMetricBased,
"SCHEDULE_BASED": AutoScalePolicyDetailsTriggerTypeScheduleBased,
}
var mappingAutoScalePolicyDetailsTriggerTypeEnumLowerCase = map[string]AutoScalePolicyDetailsTriggerTypeEnum{
"metric_based": AutoScalePolicyDetailsTriggerTypeMetricBased,
"schedule_based": AutoScalePolicyDetailsTriggerTypeScheduleBased,
}
// GetAutoScalePolicyDetailsTriggerTypeEnumValues Enumerates the set of values for AutoScalePolicyDetailsTriggerTypeEnum
func GetAutoScalePolicyDetailsTriggerTypeEnumValues() []AutoScalePolicyDetailsTriggerTypeEnum {
values := make([]AutoScalePolicyDetailsTriggerTypeEnum, 0)
for _, v := range mappingAutoScalePolicyDetailsTriggerTypeEnum {
values = append(values, v)
}
return values
}
// GetAutoScalePolicyDetailsTriggerTypeEnumStringValues Enumerates the set of values in String for AutoScalePolicyDetailsTriggerTypeEnum
func GetAutoScalePolicyDetailsTriggerTypeEnumStringValues() []string {
return []string{
"METRIC_BASED",
"SCHEDULE_BASED",
}
}
// GetMappingAutoScalePolicyDetailsTriggerTypeEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingAutoScalePolicyDetailsTriggerTypeEnum(val string) (AutoScalePolicyDetailsTriggerTypeEnum, bool) {
enum, ok := mappingAutoScalePolicyDetailsTriggerTypeEnumLowerCase[strings.ToLower(val)]
return enum, ok
}
// AutoScalePolicyDetailsActionTypeEnum Enum with underlying type: string
type AutoScalePolicyDetailsActionTypeEnum string
// Set of constants representing the allowable values for AutoScalePolicyDetailsActionTypeEnum
const (
AutoScalePolicyDetailsActionTypeVerticalScaling AutoScalePolicyDetailsActionTypeEnum = "VERTICAL_SCALING"
AutoScalePolicyDetailsActionTypeHorizontalScaling AutoScalePolicyDetailsActionTypeEnum = "HORIZONTAL_SCALING"
)
var mappingAutoScalePolicyDetailsActionTypeEnum = map[string]AutoScalePolicyDetailsActionTypeEnum{
"VERTICAL_SCALING": AutoScalePolicyDetailsActionTypeVerticalScaling,
"HORIZONTAL_SCALING": AutoScalePolicyDetailsActionTypeHorizontalScaling,
}
var mappingAutoScalePolicyDetailsActionTypeEnumLowerCase = map[string]AutoScalePolicyDetailsActionTypeEnum{
"vertical_scaling": AutoScalePolicyDetailsActionTypeVerticalScaling,
"horizontal_scaling": AutoScalePolicyDetailsActionTypeHorizontalScaling,
}
// GetAutoScalePolicyDetailsActionTypeEnumValues Enumerates the set of values for AutoScalePolicyDetailsActionTypeEnum
func GetAutoScalePolicyDetailsActionTypeEnumValues() []AutoScalePolicyDetailsActionTypeEnum {
values := make([]AutoScalePolicyDetailsActionTypeEnum, 0)
for _, v := range mappingAutoScalePolicyDetailsActionTypeEnum {
values = append(values, v)
}
return values
}
// GetAutoScalePolicyDetailsActionTypeEnumStringValues Enumerates the set of values in String for AutoScalePolicyDetailsActionTypeEnum
func GetAutoScalePolicyDetailsActionTypeEnumStringValues() []string {
return []string{
"VERTICAL_SCALING",
"HORIZONTAL_SCALING",
}
}
// GetMappingAutoScalePolicyDetailsActionTypeEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingAutoScalePolicyDetailsActionTypeEnum(val string) (AutoScalePolicyDetailsActionTypeEnum, bool) {
enum, ok := mappingAutoScalePolicyDetailsActionTypeEnumLowerCase[strings.ToLower(val)]
return enum, ok
}
// AutoScalePolicyDetailsPolicyTypeEnum Enum with underlying type: string
type AutoScalePolicyDetailsPolicyTypeEnum string
// Set of constants representing the allowable values for AutoScalePolicyDetailsPolicyTypeEnum
const (
AutoScalePolicyDetailsPolicyTypeMetricBasedVerticalScalingPolicy AutoScalePolicyDetailsPolicyTypeEnum = "METRIC_BASED_VERTICAL_SCALING_POLICY"
AutoScalePolicyDetailsPolicyTypeMetricBasedHorizontalScalingPolicy AutoScalePolicyDetailsPolicyTypeEnum = "METRIC_BASED_HORIZONTAL_SCALING_POLICY"
AutoScalePolicyDetailsPolicyTypeScheduleBasedVerticalScalingPolicy AutoScalePolicyDetailsPolicyTypeEnum = "SCHEDULE_BASED_VERTICAL_SCALING_POLICY"
AutoScalePolicyDetailsPolicyTypeScheduleBasedHorizontalScalingPolicy AutoScalePolicyDetailsPolicyTypeEnum = "SCHEDULE_BASED_HORIZONTAL_SCALING_POLICY"
)
var mappingAutoScalePolicyDetailsPolicyTypeEnum = map[string]AutoScalePolicyDetailsPolicyTypeEnum{
"METRIC_BASED_VERTICAL_SCALING_POLICY": AutoScalePolicyDetailsPolicyTypeMetricBasedVerticalScalingPolicy,
"METRIC_BASED_HORIZONTAL_SCALING_POLICY": AutoScalePolicyDetailsPolicyTypeMetricBasedHorizontalScalingPolicy,
"SCHEDULE_BASED_VERTICAL_SCALING_POLICY": AutoScalePolicyDetailsPolicyTypeScheduleBasedVerticalScalingPolicy,
"SCHEDULE_BASED_HORIZONTAL_SCALING_POLICY": AutoScalePolicyDetailsPolicyTypeScheduleBasedHorizontalScalingPolicy,
}
var mappingAutoScalePolicyDetailsPolicyTypeEnumLowerCase = map[string]AutoScalePolicyDetailsPolicyTypeEnum{
"metric_based_vertical_scaling_policy": AutoScalePolicyDetailsPolicyTypeMetricBasedVerticalScalingPolicy,
"metric_based_horizontal_scaling_policy": AutoScalePolicyDetailsPolicyTypeMetricBasedHorizontalScalingPolicy,
"schedule_based_vertical_scaling_policy": AutoScalePolicyDetailsPolicyTypeScheduleBasedVerticalScalingPolicy,
"schedule_based_horizontal_scaling_policy": AutoScalePolicyDetailsPolicyTypeScheduleBasedHorizontalScalingPolicy,
}
// GetAutoScalePolicyDetailsPolicyTypeEnumValues Enumerates the set of values for AutoScalePolicyDetailsPolicyTypeEnum
func GetAutoScalePolicyDetailsPolicyTypeEnumValues() []AutoScalePolicyDetailsPolicyTypeEnum {
values := make([]AutoScalePolicyDetailsPolicyTypeEnum, 0)
for _, v := range mappingAutoScalePolicyDetailsPolicyTypeEnum {
values = append(values, v)
}
return values
}
// GetAutoScalePolicyDetailsPolicyTypeEnumStringValues Enumerates the set of values in String for AutoScalePolicyDetailsPolicyTypeEnum
func GetAutoScalePolicyDetailsPolicyTypeEnumStringValues() []string {
return []string{
"METRIC_BASED_VERTICAL_SCALING_POLICY",
"METRIC_BASED_HORIZONTAL_SCALING_POLICY",
"SCHEDULE_BASED_VERTICAL_SCALING_POLICY",
"SCHEDULE_BASED_HORIZONTAL_SCALING_POLICY",
}
}
// GetMappingAutoScalePolicyDetailsPolicyTypeEnum performs case Insensitive comparison on enum value and return the desired enum
func GetMappingAutoScalePolicyDetailsPolicyTypeEnum(val string) (AutoScalePolicyDetailsPolicyTypeEnum, bool) {
enum, ok := mappingAutoScalePolicyDetailsPolicyTypeEnumLowerCase[strings.ToLower(val)]
return enum, ok
}