resolver.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  // Resolver An OCI DNS resolver. If the resolver has an attached VCN, the VCN will attempt to answer queries based on the
  22  // attached views in priority order. If the query does not match any of the attached views, the query will be
  23  // evaluated against the default view. If the default view does not match, the rules will be evaluated in
  24  // priority order. If no rules match the query, answers come from Internet DNS. A resolver may have a maximum of 10
  25  // resolver endpoints.
  26  // **Warning:** Oracle recommends that you avoid using any confidential information when you supply string values using the API.
  27  type Resolver struct {
  28  
  29  	// The OCID of the owning compartment.
  30  	CompartmentId *string `mandatory:"true" json:"compartmentId"`
  31  
  32  	// The display name of the resolver.
  33  	DisplayName *string `mandatory:"true" json:"displayName"`
  34  
  35  	// Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace.
  36  	// For more information, see Resource Tags (https://docs.oracle.com/iaas/Content/General/Concepts/resourcetags.htm).
  37  	//
  38  	// **Example:** `{"Department": "Finance"}`
  39  	FreeformTags map[string]string `mandatory:"true" json:"freeformTags"`
  40  
  41  	// Defined tags for this resource. Each key is predefined and scoped to a namespace.
  42  	// For more information, see Resource Tags (https://docs.oracle.com/iaas/Content/General/Concepts/resourcetags.htm).
  43  	//
  44  	// **Example:** `{"Operations": {"CostCenter": "42"}}`
  45  	DefinedTags map[string]map[string]interface{} `mandatory:"true" json:"definedTags"`
  46  
  47  	// The OCID of the resolver.
  48  	Id *string `mandatory:"true" json:"id"`
  49  
  50  	// The date and time the resource was created in "YYYY-MM-ddThh:mm:ssZ" format
  51  	// with a Z offset, as defined by RFC 3339.
  52  	// **Example:** `2016-07-22T17:23:59:60Z`
  53  	TimeCreated *common.SDKTime `mandatory:"true" json:"timeCreated"`
  54  
  55  	// The date and time the resource was last updated in "YYYY-MM-ddThh:mm:ssZ"
  56  	// format with a Z offset, as defined by RFC 3339.
  57  	// **Example:** `2016-07-22T17:23:59:60Z`
  58  	TimeUpdated *common.SDKTime `mandatory:"true" json:"timeUpdated"`
  59  
  60  	// The current state of the resource.
  61  	LifecycleState ResolverLifecycleStateEnum `mandatory:"true" json:"lifecycleState"`
  62  
  63  	// The canonical absolute URL of the resource.
  64  	Self *string `mandatory:"true" json:"self"`
  65  
  66  	// A Boolean flag indicating whether or not parts of the resource are unable to be explicitly managed.
  67  	IsProtected *bool `mandatory:"true" json:"isProtected"`
  68  
  69  	// Read-only array of endpoints for the resolver.
  70  	Endpoints []ResolverEndpointSummary `mandatory:"true" json:"endpoints"`
  71  
  72  	// The attached views. Views are evaluated in order.
  73  	AttachedViews []AttachedView `mandatory:"true" json:"attachedViews"`
  74  
  75  	// The OCID of the attached VCN.
  76  	AttachedVcnId *string `mandatory:"false" json:"attachedVcnId"`
  77  
  78  	// The OCID of the default view.
  79  	DefaultViewId *string `mandatory:"false" json:"defaultViewId"`
  80  
  81  	// Rules for the resolver. Rules are evaluated in order.
  82  	Rules []ResolverRule `mandatory:"false" json:"rules"`
  83  }
  84  
  85  func (m Resolver) String() string {
  86  	return common.PointerString(m)
  87  }
  88  
  89  // ValidateEnumValue returns an error when providing an unsupported enum value
  90  // This function is being called during constructing API request process
  91  // Not recommended for calling this function directly
  92  func (m Resolver) ValidateEnumValue() (bool, error) {
  93  	errMessage := []string{}
  94  	if _, ok := GetMappingResolverLifecycleStateEnum(string(m.LifecycleState)); !ok && m.LifecycleState != "" {
  95  		errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for LifecycleState: %s. Supported values are: %s.", m.LifecycleState, strings.Join(GetResolverLifecycleStateEnumStringValues(), ",")))
  96  	}
  97  
  98  	if len(errMessage) > 0 {
  99  		return true, fmt.Errorf("%s", strings.Join(errMessage, "\n"))
 100  	}
 101  	return false, nil
 102  }
 103  
 104  // UnmarshalJSON unmarshals from json
 105  func (m *Resolver) UnmarshalJSON(data []byte) (e error) {
 106  	model := struct {
 107  		AttachedVcnId  *string                           `json:"attachedVcnId"`
 108  		DefaultViewId  *string                           `json:"defaultViewId"`
 109  		Rules          []resolverrule                    `json:"rules"`
 110  		CompartmentId  *string                           `json:"compartmentId"`
 111  		DisplayName    *string                           `json:"displayName"`
 112  		FreeformTags   map[string]string                 `json:"freeformTags"`
 113  		DefinedTags    map[string]map[string]interface{} `json:"definedTags"`
 114  		Id             *string                           `json:"id"`
 115  		TimeCreated    *common.SDKTime                   `json:"timeCreated"`
 116  		TimeUpdated    *common.SDKTime                   `json:"timeUpdated"`
 117  		LifecycleState ResolverLifecycleStateEnum        `json:"lifecycleState"`
 118  		Self           *string                           `json:"self"`
 119  		IsProtected    *bool                             `json:"isProtected"`
 120  		Endpoints      []resolverendpointsummary         `json:"endpoints"`
 121  		AttachedViews  []AttachedView                    `json:"attachedViews"`
 122  	}{}
 123  
 124  	e = json.Unmarshal(data, &model)
 125  	if e != nil {
 126  		return
 127  	}
 128  	var nn interface{}
 129  	m.AttachedVcnId = model.AttachedVcnId
 130  
 131  	m.DefaultViewId = model.DefaultViewId
 132  
 133  	m.Rules = make([]ResolverRule, len(model.Rules))
 134  	for i, n := range model.Rules {
 135  		nn, e = n.UnmarshalPolymorphicJSON(n.JsonData)
 136  		if e != nil {
 137  			return e
 138  		}
 139  		if nn != nil {
 140  			m.Rules[i] = nn.(ResolverRule)
 141  		} else {
 142  			m.Rules[i] = nil
 143  		}
 144  	}
 145  	m.CompartmentId = model.CompartmentId
 146  
 147  	m.DisplayName = model.DisplayName
 148  
 149  	m.FreeformTags = model.FreeformTags
 150  
 151  	m.DefinedTags = model.DefinedTags
 152  
 153  	m.Id = model.Id
 154  
 155  	m.TimeCreated = model.TimeCreated
 156  
 157  	m.TimeUpdated = model.TimeUpdated
 158  
 159  	m.LifecycleState = model.LifecycleState
 160  
 161  	m.Self = model.Self
 162  
 163  	m.IsProtected = model.IsProtected
 164  
 165  	m.Endpoints = make([]ResolverEndpointSummary, len(model.Endpoints))
 166  	for i, n := range model.Endpoints {
 167  		nn, e = n.UnmarshalPolymorphicJSON(n.JsonData)
 168  		if e != nil {
 169  			return e
 170  		}
 171  		if nn != nil {
 172  			m.Endpoints[i] = nn.(ResolverEndpointSummary)
 173  		} else {
 174  			m.Endpoints[i] = nil
 175  		}
 176  	}
 177  	m.AttachedViews = make([]AttachedView, len(model.AttachedViews))
 178  	copy(m.AttachedViews, model.AttachedViews)
 179  	return
 180  }
 181  
 182  // ResolverLifecycleStateEnum Enum with underlying type: string
 183  type ResolverLifecycleStateEnum string
 184  
 185  // Set of constants representing the allowable values for ResolverLifecycleStateEnum
 186  const (
 187  	ResolverLifecycleStateActive   ResolverLifecycleStateEnum = "ACTIVE"
 188  	ResolverLifecycleStateCreating ResolverLifecycleStateEnum = "CREATING"
 189  	ResolverLifecycleStateDeleted  ResolverLifecycleStateEnum = "DELETED"
 190  	ResolverLifecycleStateDeleting ResolverLifecycleStateEnum = "DELETING"
 191  	ResolverLifecycleStateFailed   ResolverLifecycleStateEnum = "FAILED"
 192  	ResolverLifecycleStateUpdating ResolverLifecycleStateEnum = "UPDATING"
 193  )
 194  
 195  var mappingResolverLifecycleStateEnum = map[string]ResolverLifecycleStateEnum{
 196  	"ACTIVE":   ResolverLifecycleStateActive,
 197  	"CREATING": ResolverLifecycleStateCreating,
 198  	"DELETED":  ResolverLifecycleStateDeleted,
 199  	"DELETING": ResolverLifecycleStateDeleting,
 200  	"FAILED":   ResolverLifecycleStateFailed,
 201  	"UPDATING": ResolverLifecycleStateUpdating,
 202  }
 203  
 204  var mappingResolverLifecycleStateEnumLowerCase = map[string]ResolverLifecycleStateEnum{
 205  	"active":   ResolverLifecycleStateActive,
 206  	"creating": ResolverLifecycleStateCreating,
 207  	"deleted":  ResolverLifecycleStateDeleted,
 208  	"deleting": ResolverLifecycleStateDeleting,
 209  	"failed":   ResolverLifecycleStateFailed,
 210  	"updating": ResolverLifecycleStateUpdating,
 211  }
 212  
 213  // GetResolverLifecycleStateEnumValues Enumerates the set of values for ResolverLifecycleStateEnum
 214  func GetResolverLifecycleStateEnumValues() []ResolverLifecycleStateEnum {
 215  	values := make([]ResolverLifecycleStateEnum, 0)
 216  	for _, v := range mappingResolverLifecycleStateEnum {
 217  		values = append(values, v)
 218  	}
 219  	return values
 220  }
 221  
 222  // GetResolverLifecycleStateEnumStringValues Enumerates the set of values in String for ResolverLifecycleStateEnum
 223  func GetResolverLifecycleStateEnumStringValues() []string {
 224  	return []string{
 225  		"ACTIVE",
 226  		"CREATING",
 227  		"DELETED",
 228  		"DELETING",
 229  		"FAILED",
 230  		"UPDATING",
 231  	}
 232  }
 233  
 234  // GetMappingResolverLifecycleStateEnum performs case Insensitive comparison on enum value and return the desired enum
 235  func GetMappingResolverLifecycleStateEnum(val string) (ResolverLifecycleStateEnum, bool) {
 236  	enum, ok := mappingResolverLifecycleStateEnumLowerCase[strings.ToLower(val)]
 237  	return enum, ok
 238  }
 239