update_steering_policy_details.go raw

   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  // UpdateSteeringPolicyDetails The body for updating a steering policy. New rules and answers provided in the request will
  22  // replace the existing rules and answers in the policy.
  23  //
  24  // **Warning:** Oracle recommends that you avoid using any confidential information when you supply string values using the API.
  25  type UpdateSteeringPolicyDetails struct {
  26  
  27  	// A user-friendly name for the steering policy. Does not have to be unique and can be changed.
  28  	// Avoid entering confidential information.
  29  	DisplayName *string `mandatory:"false" json:"displayName"`
  30  
  31  	// The Time To Live (TTL) for responses from the steering policy, in seconds.
  32  	// If not specified during creation, a value of 30 seconds will be used.
  33  	Ttl *int `mandatory:"false" json:"ttl"`
  34  
  35  	// The OCID of the health check monitor providing health data about the answers of the
  36  	// steering policy. A steering policy answer with `rdata` matching a monitored endpoint
  37  	// will use the health data of that endpoint. A steering policy answer with `rdata` not
  38  	// matching any monitored endpoint will be assumed healthy.
  39  	//
  40  	// **Note:** To use the Health Check monitoring feature in a steering policy, a monitor
  41  	// must be created using the Health Checks service first. For more information on how to
  42  	// create a monitor, please see Managing Health Checks (https://docs.oracle.com/iaas/Content/HealthChecks/Tasks/managinghealthchecks.htm).
  43  	HealthCheckMonitorId *string `mandatory:"false" json:"healthCheckMonitorId"`
  44  
  45  	// A set of predefined rules based on the desired purpose of the steering policy. Each
  46  	// template utilizes Traffic Management's rules in a different order to produce the desired
  47  	// results when answering DNS queries.
  48  	//
  49  	// **Example:** The `FAILOVER` template determines answers by filtering the policy's answers
  50  	// using the `FILTER` rule first, then the following rules in succession: `HEALTH`, `PRIORITY`,
  51  	// and `LIMIT`. This gives the domain dynamic failover capability.
  52  	//
  53  	// It is **strongly recommended** to use a template other than `CUSTOM` when creating
  54  	// a steering policy.
  55  	//
  56  	// All templates require the rule order to begin with an unconditional `FILTER` rule that keeps
  57  	// answers contingent upon `answer.isDisabled != true`, except for `CUSTOM`. A defined
  58  	// `HEALTH` rule must follow the `FILTER` rule if the policy references a `healthCheckMonitorId`.
  59  	// The last rule of a template must must be a `LIMIT` rule. For more information about templates
  60  	// and code examples, see Traffic Management API Guide (https://docs.oracle.com/iaas/Content/TrafficManagement/Concepts/trafficmanagementapi.htm).
  61  	// **Template Types**
  62  	// * `FAILOVER` - Uses health check information on your endpoints to determine which DNS answers
  63  	// to serve. If an endpoint fails a health check, the answer for that endpoint will be removed
  64  	// from the list of available answers until the endpoint is detected as healthy.
  65  	//
  66  	// * `LOAD_BALANCE` - Distributes web traffic to specified endpoints based on defined weights.
  67  	//
  68  	// * `ROUTE_BY_GEO` - Answers DNS queries based on the query's geographic location. For a list of geographic
  69  	// locations to route by, see Traffic Management Geographic Locations (https://docs.oracle.com/iaas/Content/TrafficManagement/Reference/trafficmanagementgeo.htm).
  70  	//
  71  	// * `ROUTE_BY_ASN` - Answers DNS queries based on the query's originating ASN.
  72  	//
  73  	// * `ROUTE_BY_IP` - Answers DNS queries based on the query's IP address.
  74  	//
  75  	// * `CUSTOM` - Allows a customized configuration of rules.
  76  	Template UpdateSteeringPolicyDetailsTemplateEnum `mandatory:"false" json:"template,omitempty"`
  77  
  78  	// Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace.
  79  	// For more information, see Resource Tags (https://docs.oracle.com/iaas/Content/General/Concepts/resourcetags.htm).
  80  	//
  81  	// **Example:** `{"Department": "Finance"}`
  82  	FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
  83  
  84  	// Defined tags for this resource. Each key is predefined and scoped to a namespace.
  85  	// For more information, see Resource Tags (https://docs.oracle.com/iaas/Content/General/Concepts/resourcetags.htm).
  86  	//
  87  	// **Example:** `{"Operations": {"CostCenter": "42"}}`
  88  	DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
  89  
  90  	// The set of all answers that can potentially issue from the steering policy.
  91  	Answers []SteeringPolicyAnswer `mandatory:"false" json:"answers"`
  92  
  93  	// The series of rules that will be processed in sequence to reduce the pool of answers
  94  	// to a response for any given request.
  95  	//
  96  	// The first rule receives a shuffled list of all answers, and every other rule receives
  97  	// the list of answers emitted by the one preceding it. The last rule populates the
  98  	// response.
  99  	Rules []SteeringPolicyRule `mandatory:"false" json:"rules"`
 100  }
 101  
 102  func (m UpdateSteeringPolicyDetails) String() string {
 103  	return common.PointerString(m)
 104  }
 105  
 106  // ValidateEnumValue returns an error when providing an unsupported enum value
 107  // This function is being called during constructing API request process
 108  // Not recommended for calling this function directly
 109  func (m UpdateSteeringPolicyDetails) ValidateEnumValue() (bool, error) {
 110  	errMessage := []string{}
 111  
 112  	if _, ok := GetMappingUpdateSteeringPolicyDetailsTemplateEnum(string(m.Template)); !ok && m.Template != "" {
 113  		errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Template: %s. Supported values are: %s.", m.Template, strings.Join(GetUpdateSteeringPolicyDetailsTemplateEnumStringValues(), ",")))
 114  	}
 115  	if len(errMessage) > 0 {
 116  		return true, fmt.Errorf("%s", strings.Join(errMessage, "\n"))
 117  	}
 118  	return false, nil
 119  }
 120  
 121  // UnmarshalJSON unmarshals from json
 122  func (m *UpdateSteeringPolicyDetails) UnmarshalJSON(data []byte) (e error) {
 123  	model := struct {
 124  		DisplayName          *string                                 `json:"displayName"`
 125  		Ttl                  *int                                    `json:"ttl"`
 126  		HealthCheckMonitorId *string                                 `json:"healthCheckMonitorId"`
 127  		Template             UpdateSteeringPolicyDetailsTemplateEnum `json:"template"`
 128  		FreeformTags         map[string]string                       `json:"freeformTags"`
 129  		DefinedTags          map[string]map[string]interface{}       `json:"definedTags"`
 130  		Answers              []SteeringPolicyAnswer                  `json:"answers"`
 131  		Rules                []steeringpolicyrule                    `json:"rules"`
 132  	}{}
 133  
 134  	e = json.Unmarshal(data, &model)
 135  	if e != nil {
 136  		return
 137  	}
 138  	var nn interface{}
 139  	m.DisplayName = model.DisplayName
 140  
 141  	m.Ttl = model.Ttl
 142  
 143  	m.HealthCheckMonitorId = model.HealthCheckMonitorId
 144  
 145  	m.Template = model.Template
 146  
 147  	m.FreeformTags = model.FreeformTags
 148  
 149  	m.DefinedTags = model.DefinedTags
 150  
 151  	m.Answers = make([]SteeringPolicyAnswer, len(model.Answers))
 152  	copy(m.Answers, model.Answers)
 153  	m.Rules = make([]SteeringPolicyRule, len(model.Rules))
 154  	for i, n := range model.Rules {
 155  		nn, e = n.UnmarshalPolymorphicJSON(n.JsonData)
 156  		if e != nil {
 157  			return e
 158  		}
 159  		if nn != nil {
 160  			m.Rules[i] = nn.(SteeringPolicyRule)
 161  		} else {
 162  			m.Rules[i] = nil
 163  		}
 164  	}
 165  	return
 166  }
 167  
 168  // UpdateSteeringPolicyDetailsTemplateEnum Enum with underlying type: string
 169  type UpdateSteeringPolicyDetailsTemplateEnum string
 170  
 171  // Set of constants representing the allowable values for UpdateSteeringPolicyDetailsTemplateEnum
 172  const (
 173  	UpdateSteeringPolicyDetailsTemplateFailover    UpdateSteeringPolicyDetailsTemplateEnum = "FAILOVER"
 174  	UpdateSteeringPolicyDetailsTemplateLoadBalance UpdateSteeringPolicyDetailsTemplateEnum = "LOAD_BALANCE"
 175  	UpdateSteeringPolicyDetailsTemplateRouteByGeo  UpdateSteeringPolicyDetailsTemplateEnum = "ROUTE_BY_GEO"
 176  	UpdateSteeringPolicyDetailsTemplateRouteByAsn  UpdateSteeringPolicyDetailsTemplateEnum = "ROUTE_BY_ASN"
 177  	UpdateSteeringPolicyDetailsTemplateRouteByIp   UpdateSteeringPolicyDetailsTemplateEnum = "ROUTE_BY_IP"
 178  	UpdateSteeringPolicyDetailsTemplateCustom      UpdateSteeringPolicyDetailsTemplateEnum = "CUSTOM"
 179  )
 180  
 181  var mappingUpdateSteeringPolicyDetailsTemplateEnum = map[string]UpdateSteeringPolicyDetailsTemplateEnum{
 182  	"FAILOVER":     UpdateSteeringPolicyDetailsTemplateFailover,
 183  	"LOAD_BALANCE": UpdateSteeringPolicyDetailsTemplateLoadBalance,
 184  	"ROUTE_BY_GEO": UpdateSteeringPolicyDetailsTemplateRouteByGeo,
 185  	"ROUTE_BY_ASN": UpdateSteeringPolicyDetailsTemplateRouteByAsn,
 186  	"ROUTE_BY_IP":  UpdateSteeringPolicyDetailsTemplateRouteByIp,
 187  	"CUSTOM":       UpdateSteeringPolicyDetailsTemplateCustom,
 188  }
 189  
 190  var mappingUpdateSteeringPolicyDetailsTemplateEnumLowerCase = map[string]UpdateSteeringPolicyDetailsTemplateEnum{
 191  	"failover":     UpdateSteeringPolicyDetailsTemplateFailover,
 192  	"load_balance": UpdateSteeringPolicyDetailsTemplateLoadBalance,
 193  	"route_by_geo": UpdateSteeringPolicyDetailsTemplateRouteByGeo,
 194  	"route_by_asn": UpdateSteeringPolicyDetailsTemplateRouteByAsn,
 195  	"route_by_ip":  UpdateSteeringPolicyDetailsTemplateRouteByIp,
 196  	"custom":       UpdateSteeringPolicyDetailsTemplateCustom,
 197  }
 198  
 199  // GetUpdateSteeringPolicyDetailsTemplateEnumValues Enumerates the set of values for UpdateSteeringPolicyDetailsTemplateEnum
 200  func GetUpdateSteeringPolicyDetailsTemplateEnumValues() []UpdateSteeringPolicyDetailsTemplateEnum {
 201  	values := make([]UpdateSteeringPolicyDetailsTemplateEnum, 0)
 202  	for _, v := range mappingUpdateSteeringPolicyDetailsTemplateEnum {
 203  		values = append(values, v)
 204  	}
 205  	return values
 206  }
 207  
 208  // GetUpdateSteeringPolicyDetailsTemplateEnumStringValues Enumerates the set of values in String for UpdateSteeringPolicyDetailsTemplateEnum
 209  func GetUpdateSteeringPolicyDetailsTemplateEnumStringValues() []string {
 210  	return []string{
 211  		"FAILOVER",
 212  		"LOAD_BALANCE",
 213  		"ROUTE_BY_GEO",
 214  		"ROUTE_BY_ASN",
 215  		"ROUTE_BY_IP",
 216  		"CUSTOM",
 217  	}
 218  }
 219  
 220  // GetMappingUpdateSteeringPolicyDetailsTemplateEnum performs case Insensitive comparison on enum value and return the desired enum
 221  func GetMappingUpdateSteeringPolicyDetailsTemplateEnum(val string) (UpdateSteeringPolicyDetailsTemplateEnum, bool) {
 222  	enum, ok := mappingUpdateSteeringPolicyDetailsTemplateEnumLowerCase[strings.ToLower(val)]
 223  	return enum, ok
 224  }
 225