github.com/akamai/AkamaiOPEN-edgegrid-golang/v8@v8.1.0/pkg/gtm/common.go (about)

     1  package gtm
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  )
     7  
     8  // default schema version
     9  var schemaVersion = "1.6"
    10  
    11  // internal method to set version. passed in as string
    12  func setVersionHeader(req *http.Request, version string) {
    13  
    14  	req.Header.Set("Accept", fmt.Sprintf("application/vnd.config-gtm.v%s+json", version))
    15  
    16  	if req.Method != "GET" {
    17  		req.Header.Set("Content-Type", fmt.Sprintf("application/vnd.config-gtm.v%s+json", version))
    18  	}
    19  
    20  	return
    21  
    22  }
    23  
    24  // ResponseStatus is returned on Create, Update or Delete operations for all entity types
    25  type ResponseStatus struct {
    26  	ChangeID              string  `json:"changeId,omitempty"`
    27  	Links                 *[]Link `json:"links,omitempty"`
    28  	Message               string  `json:"message,omitempty"`
    29  	PassingValidation     bool    `json:"passingValidation,omitempty"`
    30  	PropagationStatus     string  `json:"propagationStatus,omitempty"`
    31  	PropagationStatusDate string  `json:"propagationStatusDate,omitempty"`
    32  }
    33  
    34  // ResponseBody is a generic response struct
    35  type ResponseBody struct {
    36  	Resource interface{}     `json:"resource"`
    37  	Status   *ResponseStatus `json:"status"`
    38  }
    39  
    40  // DomainResponse contains a response after creating or updating Domain
    41  type DomainResponse struct {
    42  	Resource *Domain         `json:"resource"`
    43  	Status   *ResponseStatus `json:"status"`
    44  }
    45  
    46  // DatacenterResponse contains a response after creating or updating Datacenter
    47  type DatacenterResponse struct {
    48  	Status   *ResponseStatus `json:"status"`
    49  	Resource *Datacenter     `json:"resource"`
    50  }
    51  
    52  // PropertyResponse contains a response after creating or updating Property
    53  type PropertyResponse struct {
    54  	Resource *Property       `json:"resource"`
    55  	Status   *ResponseStatus `json:"status"`
    56  }
    57  
    58  // ResourceResponse contains a response after creating or updating Resource
    59  type ResourceResponse struct {
    60  	Resource *Resource       `json:"resource"`
    61  	Status   *ResponseStatus `json:"status"`
    62  }
    63  
    64  // CIDRMapResponse contains a response after creating or updating CIDRMap
    65  type CIDRMapResponse struct {
    66  	Resource *CIDRMap        `json:"resource"`
    67  	Status   *ResponseStatus `json:"status"`
    68  }
    69  
    70  // GeoMapResponse contains a response after creating or updating GeoMap
    71  type GeoMapResponse struct {
    72  	Resource *GeoMap         `json:"resource"`
    73  	Status   *ResponseStatus `json:"status"`
    74  }
    75  
    76  // ASMapResponse contains a response after creating or updating ASMap
    77  type ASMapResponse struct {
    78  	Resource *ASMap          `json:"resource"`
    79  	Status   *ResponseStatus `json:"status"`
    80  }
    81  
    82  // Link is Probably THE most common type
    83  type Link struct {
    84  	Rel  string `json:"rel"`
    85  	Href string `json:"href"`
    86  }
    87  
    88  // LoadObject contains information about the load reporting interface
    89  type LoadObject struct {
    90  	LoadObject     string   `json:"loadObject,omitempty"`
    91  	LoadObjectPort int      `json:"loadObjectPort,omitempty"`
    92  	LoadServers    []string `json:"loadServers,omitempty"`
    93  }
    94  
    95  // DatacenterBase is a placeholder for default Datacenter
    96  type DatacenterBase struct {
    97  	Nickname     string `json:"nickname,omitempty"`
    98  	DatacenterID int    `json:"datacenterId"`
    99  }