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 // ResolverRule A rule for a resolver. Specifying both qnameCoverConditions and clientAddressConditions is not allowed.
22 // **Warning:** Oracle recommends that you avoid using any confidential information when you supply string values using the API.
23 type ResolverRule interface {
24 25 // A list of CIDR blocks. The query must come from a client within one of the blocks in order for the rule action
26 // to apply.
27 GetClientAddressConditions() []string
28 29 // A list of domain names. The query must be covered by one of the domains in order for the rule action to apply.
30 GetQnameCoverConditions() []string
31 }
32 33 type resolverrule struct {
34 JsonData []byte
35 ClientAddressConditions []string `mandatory:"true" json:"clientAddressConditions"`
36 QnameCoverConditions []string `mandatory:"true" json:"qnameCoverConditions"`
37 Action string `json:"action"`
38 }
39 40 // UnmarshalJSON unmarshals json
41 func (m *resolverrule) UnmarshalJSON(data []byte) error {
42 m.JsonData = data
43 type Unmarshalerresolverrule resolverrule
44 s := struct {
45 Model Unmarshalerresolverrule
46 }{}
47 err := json.Unmarshal(data, &s.Model)
48 if err != nil {
49 return err
50 }
51 m.ClientAddressConditions = s.Model.ClientAddressConditions
52 m.QnameCoverConditions = s.Model.QnameCoverConditions
53 m.Action = s.Model.Action
54 55 return err
56 }
57 58 // UnmarshalPolymorphicJSON unmarshals polymorphic json
59 func (m *resolverrule) UnmarshalPolymorphicJSON(data []byte) (interface{}, error) {
60 61 if data == nil || string(data) == "null" {
62 return nil, nil
63 }
64 65 var err error
66 switch m.Action {
67 case "FORWARD":
68 mm := ResolverForwardRule{}
69 err = json.Unmarshal(data, &mm)
70 return mm, err
71 default:
72 common.Logf("Received unsupported enum value for ResolverRule: %s.", m.Action)
73 return *m, nil
74 }
75 }
76 77 // GetClientAddressConditions returns ClientAddressConditions
78 func (m resolverrule) GetClientAddressConditions() []string {
79 return m.ClientAddressConditions
80 }
81 82 // GetQnameCoverConditions returns QnameCoverConditions
83 func (m resolverrule) GetQnameCoverConditions() []string {
84 return m.QnameCoverConditions
85 }
86 87 func (m resolverrule) String() string {
88 return common.PointerString(m)
89 }
90 91 // ValidateEnumValue returns an error when providing an unsupported enum value
92 // This function is being called during constructing API request process
93 // Not recommended for calling this function directly
94 func (m resolverrule) ValidateEnumValue() (bool, error) {
95 errMessage := []string{}
96 97 if len(errMessage) > 0 {
98 return true, fmt.Errorf("%s", strings.Join(errMessage, "\n"))
99 }
100 return false, nil
101 }
102 103 // ResolverRuleActionEnum Enum with underlying type: string
104 type ResolverRuleActionEnum string
105 106 // Set of constants representing the allowable values for ResolverRuleActionEnum
107 const (
108 ResolverRuleActionForward ResolverRuleActionEnum = "FORWARD"
109 )
110 111 var mappingResolverRuleActionEnum = map[string]ResolverRuleActionEnum{
112 "FORWARD": ResolverRuleActionForward,
113 }
114 115 var mappingResolverRuleActionEnumLowerCase = map[string]ResolverRuleActionEnum{
116 "forward": ResolverRuleActionForward,
117 }
118 119 // GetResolverRuleActionEnumValues Enumerates the set of values for ResolverRuleActionEnum
120 func GetResolverRuleActionEnumValues() []ResolverRuleActionEnum {
121 values := make([]ResolverRuleActionEnum, 0)
122 for _, v := range mappingResolverRuleActionEnum {
123 values = append(values, v)
124 }
125 return values
126 }
127 128 // GetResolverRuleActionEnumStringValues Enumerates the set of values in String for ResolverRuleActionEnum
129 func GetResolverRuleActionEnumStringValues() []string {
130 return []string{
131 "FORWARD",
132 }
133 }
134 135 // GetMappingResolverRuleActionEnum performs case Insensitive comparison on enum value and return the desired enum
136 func GetMappingResolverRuleActionEnum(val string) (ResolverRuleActionEnum, bool) {
137 enum, ok := mappingResolverRuleActionEnumLowerCase[strings.ToLower(val)]
138 return enum, ok
139 }
140