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