create_view_request_response.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  package dns
   6  
   7  import (
   8  	"fmt"
   9  	"net/http"
  10  	"strings"
  11  
  12  	"github.com/nrdcg/oci-go-sdk/common/v1065"
  13  )
  14  
  15  // CreateViewRequest wrapper for the CreateView operation
  16  //
  17  // # See also
  18  //
  19  // Click https://docs.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/dns/CreateView.go.html to see an example of how to use CreateViewRequest.
  20  type CreateViewRequest struct {
  21  
  22  	// Details for creating a new view.
  23  	CreateViewDetails `contributesTo:"body"`
  24  
  25  	// A token that uniquely identifies a request so it can be retried in case
  26  	// of a timeout or server error without risk of executing that same action
  27  	// again. Retry tokens expire after 24 hours, but can be invalidated before
  28  	// then due to conflicting operations (for example, if a resource has been
  29  	// deleted and purged from the system, then a retry of the original creation
  30  	// request may be rejected).
  31  	OpcRetryToken *string `mandatory:"false" contributesTo:"header" name:"opc-retry-token"`
  32  
  33  	// Unique Oracle-assigned identifier for the request. If you need
  34  	// to contact Oracle about a particular request, please provide
  35  	// the request ID.
  36  	OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
  37  
  38  	// Specifies to operate only on resources that have a matching DNS scope.
  39  	Scope CreateViewScopeEnum `mandatory:"false" contributesTo:"query" name:"scope" omitEmpty:"true"`
  40  
  41  	// Metadata about the request. This information will not be transmitted to the service, but
  42  	// represents information that the SDK will consume to drive retry behavior.
  43  	RequestMetadata common.RequestMetadata
  44  }
  45  
  46  func (request CreateViewRequest) String() string {
  47  	return common.PointerString(request)
  48  }
  49  
  50  // HTTPRequest implements the OCIRequest interface
  51  func (request CreateViewRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) {
  52  
  53  	_, err := request.ValidateEnumValue()
  54  	if err != nil {
  55  		return http.Request{}, err
  56  	}
  57  	return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders)
  58  }
  59  
  60  // BinaryRequestBody implements the OCIRequest interface
  61  func (request CreateViewRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) {
  62  
  63  	return nil, false
  64  
  65  }
  66  
  67  // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
  68  func (request CreateViewRequest) RetryPolicy() *common.RetryPolicy {
  69  	return request.RequestMetadata.RetryPolicy
  70  }
  71  
  72  // ValidateEnumValue returns an error when providing an unsupported enum value
  73  // This function is being called during constructing API request process
  74  // Not recommended for calling this function directly
  75  func (request CreateViewRequest) ValidateEnumValue() (bool, error) {
  76  	errMessage := []string{}
  77  	if _, ok := GetMappingCreateViewScopeEnum(string(request.Scope)); !ok && request.Scope != "" {
  78  		errMessage = append(errMessage, fmt.Sprintf("unsupported enum value for Scope: %s. Supported values are: %s.", request.Scope, strings.Join(GetCreateViewScopeEnumStringValues(), ",")))
  79  	}
  80  	if len(errMessage) > 0 {
  81  		return true, fmt.Errorf("%s", strings.Join(errMessage, "\n"))
  82  	}
  83  	return false, nil
  84  }
  85  
  86  // CreateViewResponse wrapper for the CreateView operation
  87  type CreateViewResponse struct {
  88  
  89  	// The underlying http response
  90  	RawResponse *http.Response
  91  
  92  	// The View instance
  93  	View `presentIn:"body"`
  94  
  95  	// The current version of the resource, ending with a
  96  	// representation-specific suffix. This value may be used in If-Match
  97  	// and If-None-Match headers for later requests of the same resource.
  98  	Etag *string `presentIn:"header" name:"etag"`
  99  
 100  	// The full URI of the resource related to the request.
 101  	Location *string `presentIn:"header" name:"location"`
 102  
 103  	// Unique Oracle-assigned identifier for the request. If you need to
 104  	// contact Oracle about a particular request, please provide the request ID.
 105  	OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
 106  
 107  	// Unique Oracle-assigned identifier for the asynchronous request.
 108  	// You can use this to query status of the asynchronous operation.
 109  	OpcWorkRequestId *string `presentIn:"header" name:"opc-work-request-id"`
 110  }
 111  
 112  func (response CreateViewResponse) String() string {
 113  	return common.PointerString(response)
 114  }
 115  
 116  // HTTPResponse implements the OCIResponse interface
 117  func (response CreateViewResponse) HTTPResponse() *http.Response {
 118  	return response.RawResponse
 119  }
 120  
 121  // CreateViewScopeEnum Enum with underlying type: string
 122  type CreateViewScopeEnum string
 123  
 124  // Set of constants representing the allowable values for CreateViewScopeEnum
 125  const (
 126  	CreateViewScopeGlobal  CreateViewScopeEnum = "GLOBAL"
 127  	CreateViewScopePrivate CreateViewScopeEnum = "PRIVATE"
 128  )
 129  
 130  var mappingCreateViewScopeEnum = map[string]CreateViewScopeEnum{
 131  	"GLOBAL":  CreateViewScopeGlobal,
 132  	"PRIVATE": CreateViewScopePrivate,
 133  }
 134  
 135  var mappingCreateViewScopeEnumLowerCase = map[string]CreateViewScopeEnum{
 136  	"global":  CreateViewScopeGlobal,
 137  	"private": CreateViewScopePrivate,
 138  }
 139  
 140  // GetCreateViewScopeEnumValues Enumerates the set of values for CreateViewScopeEnum
 141  func GetCreateViewScopeEnumValues() []CreateViewScopeEnum {
 142  	values := make([]CreateViewScopeEnum, 0)
 143  	for _, v := range mappingCreateViewScopeEnum {
 144  		values = append(values, v)
 145  	}
 146  	return values
 147  }
 148  
 149  // GetCreateViewScopeEnumStringValues Enumerates the set of values in String for CreateViewScopeEnum
 150  func GetCreateViewScopeEnumStringValues() []string {
 151  	return []string{
 152  		"GLOBAL",
 153  		"PRIVATE",
 154  	}
 155  }
 156  
 157  // GetMappingCreateViewScopeEnum performs case Insensitive comparison on enum value and return the desired enum
 158  func GetMappingCreateViewScopeEnum(val string) (CreateViewScopeEnum, bool) {
 159  	enum, ok := mappingCreateViewScopeEnumLowerCase[strings.ToLower(val)]
 160  	return enum, ok
 161  }
 162