1 // Copyright (c) 2016, 2018, 2025, Oracle and/or its affiliates. All rights reserved.
2 // 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.
3 // Code generated. DO NOT EDIT.
4 5 // DNS API
6 //
7 // API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
8 // For more information, see Overview of the DNS Service (https://docs.oracle.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
9 //
10 11 package dns
12 13 import (
14 "encoding/json"
15 "fmt"
16 "strings"
17 18 "github.com/nrdcg/oci-go-sdk/common/v1065"
19 )
20 21 // SteeringPolicyRule The configuration of the sorting and filtering behaviors in a steering policy. Rules can
22 // filter and sort answers based on weight, priority, endpoint health, and other data.
23 //
24 // A rule may optionally include a sequence of cases, each with an optional `caseCondition`
25 // expression. Cases allow a sequence of conditions to be defined that will apply different
26 // parameters to the rule when the conditions are met. For more information about cases,
27 // see Traffic Management API Guide (https://docs.oracle.com/iaas/Content/TrafficManagement/Concepts/trafficmanagementapi.htm).
28 //
29 // **Warning:** Oracle recommends that you avoid using any confidential information when you supply string values using the API.
30 type SteeringPolicyRule interface {
31 32 // A user-defined description of the rule's purpose or behavior.
33 GetDescription() *string
34 }
35 36 type steeringpolicyrule struct {
37 JsonData []byte
38 Description *string `mandatory:"false" json:"description"`
39 RuleType string `json:"ruleType"`
40 }
41 42 // UnmarshalJSON unmarshals json
43 func (m *steeringpolicyrule) UnmarshalJSON(data []byte) error {
44 m.JsonData = data
45 type Unmarshalersteeringpolicyrule steeringpolicyrule
46 s := struct {
47 Model Unmarshalersteeringpolicyrule
48 }{}
49 err := json.Unmarshal(data, &s.Model)
50 if err != nil {
51 return err
52 }
53 m.Description = s.Model.Description
54 m.RuleType = s.Model.RuleType
55 56 return err
57 }
58 59 // UnmarshalPolymorphicJSON unmarshals polymorphic json
60 func (m *steeringpolicyrule) UnmarshalPolymorphicJSON(data []byte) (interface{}, error) {
61 62 if data == nil || string(data) == "null" {
63 return nil, nil
64 }
65 66 var err error
67 switch m.RuleType {
68 case "FILTER":
69 mm := SteeringPolicyFilterRule{}
70 err = json.Unmarshal(data, &mm)
71 return mm, err
72 case "WEIGHTED":
73 mm := SteeringPolicyWeightedRule{}
74 err = json.Unmarshal(data, &mm)
75 return mm, err
76 case "LIMIT":
77 mm := SteeringPolicyLimitRule{}
78 err = json.Unmarshal(data, &mm)
79 return mm, err
80 case "HEALTH":
81 mm := SteeringPolicyHealthRule{}
82 err = json.Unmarshal(data, &mm)
83 return mm, err
84 case "PRIORITY":
85 mm := SteeringPolicyPriorityRule{}
86 err = json.Unmarshal(data, &mm)
87 return mm, err
88 default:
89 common.Logf("Received unsupported enum value for SteeringPolicyRule: %s.", m.RuleType)
90 return *m, nil
91 }
92 }
93 94 // GetDescription returns Description
95 func (m steeringpolicyrule) GetDescription() *string {
96 return m.Description
97 }
98 99 func (m steeringpolicyrule) String() string {
100 return common.PointerString(m)
101 }
102 103 // ValidateEnumValue returns an error when providing an unsupported enum value
104 // This function is being called during constructing API request process
105 // Not recommended for calling this function directly
106 func (m steeringpolicyrule) ValidateEnumValue() (bool, error) {
107 errMessage := []string{}
108 109 if len(errMessage) > 0 {
110 return true, fmt.Errorf("%s", strings.Join(errMessage, "\n"))
111 }
112 return false, nil
113 }
114 115 // SteeringPolicyRuleRuleTypeEnum Enum with underlying type: string
116 type SteeringPolicyRuleRuleTypeEnum string
117 118 // Set of constants representing the allowable values for SteeringPolicyRuleRuleTypeEnum
119 const (
120 SteeringPolicyRuleRuleTypeFilter SteeringPolicyRuleRuleTypeEnum = "FILTER"
121 SteeringPolicyRuleRuleTypeHealth SteeringPolicyRuleRuleTypeEnum = "HEALTH"
122 SteeringPolicyRuleRuleTypeWeighted SteeringPolicyRuleRuleTypeEnum = "WEIGHTED"
123 SteeringPolicyRuleRuleTypePriority SteeringPolicyRuleRuleTypeEnum = "PRIORITY"
124 SteeringPolicyRuleRuleTypeLimit SteeringPolicyRuleRuleTypeEnum = "LIMIT"
125 )
126 127 var mappingSteeringPolicyRuleRuleTypeEnum = map[string]SteeringPolicyRuleRuleTypeEnum{
128 "FILTER": SteeringPolicyRuleRuleTypeFilter,
129 "HEALTH": SteeringPolicyRuleRuleTypeHealth,
130 "WEIGHTED": SteeringPolicyRuleRuleTypeWeighted,
131 "PRIORITY": SteeringPolicyRuleRuleTypePriority,
132 "LIMIT": SteeringPolicyRuleRuleTypeLimit,
133 }
134 135 var mappingSteeringPolicyRuleRuleTypeEnumLowerCase = map[string]SteeringPolicyRuleRuleTypeEnum{
136 "filter": SteeringPolicyRuleRuleTypeFilter,
137 "health": SteeringPolicyRuleRuleTypeHealth,
138 "weighted": SteeringPolicyRuleRuleTypeWeighted,
139 "priority": SteeringPolicyRuleRuleTypePriority,
140 "limit": SteeringPolicyRuleRuleTypeLimit,
141 }
142 143 // GetSteeringPolicyRuleRuleTypeEnumValues Enumerates the set of values for SteeringPolicyRuleRuleTypeEnum
144 func GetSteeringPolicyRuleRuleTypeEnumValues() []SteeringPolicyRuleRuleTypeEnum {
145 values := make([]SteeringPolicyRuleRuleTypeEnum, 0)
146 for _, v := range mappingSteeringPolicyRuleRuleTypeEnum {
147 values = append(values, v)
148 }
149 return values
150 }
151 152 // GetSteeringPolicyRuleRuleTypeEnumStringValues Enumerates the set of values in String for SteeringPolicyRuleRuleTypeEnum
153 func GetSteeringPolicyRuleRuleTypeEnumStringValues() []string {
154 return []string{
155 "FILTER",
156 "HEALTH",
157 "WEIGHTED",
158 "PRIORITY",
159 "LIMIT",
160 }
161 }
162 163 // GetMappingSteeringPolicyRuleRuleTypeEnum performs case Insensitive comparison on enum value and return the desired enum
164 func GetMappingSteeringPolicyRuleRuleTypeEnum(val string) (SteeringPolicyRuleRuleTypeEnum, bool) {
165 enum, ok := mappingSteeringPolicyRuleRuleTypeEnumLowerCase[strings.ToLower(val)]
166 return enum, ok
167 }
168