163 lines
5 KiB
Go
163 lines
5 KiB
Go
/*
|
|
CDN API
|
|
|
|
API used to create and manage your CDN distributions.
|
|
|
|
API version: 1beta2.0.0
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package cdnbeta
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// CreateDistributionPayloadBackend - Configuration for the content origin backend.
|
|
type CreateDistributionPayloadBackend struct {
|
|
BucketBackendCreate *BucketBackendCreate
|
|
HttpBackendCreate *HttpBackendCreate
|
|
}
|
|
|
|
// BucketBackendCreateAsCreateDistributionPayloadBackend is a convenience function that returns BucketBackendCreate wrapped in CreateDistributionPayloadBackend
|
|
func BucketBackendCreateAsCreateDistributionPayloadBackend(v *BucketBackendCreate) CreateDistributionPayloadBackend {
|
|
return CreateDistributionPayloadBackend{
|
|
BucketBackendCreate: v,
|
|
}
|
|
}
|
|
|
|
// HttpBackendCreateAsCreateDistributionPayloadBackend is a convenience function that returns HttpBackendCreate wrapped in CreateDistributionPayloadBackend
|
|
func HttpBackendCreateAsCreateDistributionPayloadBackend(v *HttpBackendCreate) CreateDistributionPayloadBackend {
|
|
return CreateDistributionPayloadBackend{
|
|
HttpBackendCreate: v,
|
|
}
|
|
}
|
|
|
|
// Unmarshal JSON data into one of the pointers in the struct
|
|
func (dst *CreateDistributionPayloadBackend) UnmarshalJSON(data []byte) error {
|
|
var err error
|
|
// use discriminator value to speed up the lookup
|
|
var jsonDict map[string]interface{}
|
|
err = newStrictDecoder(data).Decode(&jsonDict)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup")
|
|
}
|
|
|
|
// check if the discriminator value is 'BucketBackendCreate'
|
|
if jsonDict["type"] == "BucketBackendCreate" {
|
|
// try to unmarshal JSON data into BucketBackendCreate
|
|
err = json.Unmarshal(data, &dst.BucketBackendCreate)
|
|
if err == nil {
|
|
return nil // data stored in dst.BucketBackendCreate, return on the first match
|
|
} else {
|
|
dst.BucketBackendCreate = nil
|
|
return fmt.Errorf("failed to unmarshal CreateDistributionPayloadBackend as BucketBackendCreate: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'HttpBackendCreate'
|
|
if jsonDict["type"] == "HttpBackendCreate" {
|
|
// try to unmarshal JSON data into HttpBackendCreate
|
|
err = json.Unmarshal(data, &dst.HttpBackendCreate)
|
|
if err == nil {
|
|
return nil // data stored in dst.HttpBackendCreate, return on the first match
|
|
} else {
|
|
dst.HttpBackendCreate = nil
|
|
return fmt.Errorf("failed to unmarshal CreateDistributionPayloadBackend as HttpBackendCreate: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'bucket'
|
|
if jsonDict["type"] == "bucket" {
|
|
// try to unmarshal JSON data into BucketBackendCreate
|
|
err = json.Unmarshal(data, &dst.BucketBackendCreate)
|
|
if err == nil {
|
|
return nil // data stored in dst.BucketBackendCreate, return on the first match
|
|
} else {
|
|
dst.BucketBackendCreate = nil
|
|
return fmt.Errorf("failed to unmarshal CreateDistributionPayloadBackend as BucketBackendCreate: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'http'
|
|
if jsonDict["type"] == "http" {
|
|
// try to unmarshal JSON data into HttpBackendCreate
|
|
err = json.Unmarshal(data, &dst.HttpBackendCreate)
|
|
if err == nil {
|
|
return nil // data stored in dst.HttpBackendCreate, return on the first match
|
|
} else {
|
|
dst.HttpBackendCreate = nil
|
|
return fmt.Errorf("failed to unmarshal CreateDistributionPayloadBackend as HttpBackendCreate: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// Marshal data from the first non-nil pointers in the struct to JSON
|
|
func (src CreateDistributionPayloadBackend) MarshalJSON() ([]byte, error) {
|
|
if src.BucketBackendCreate != nil {
|
|
return json.Marshal(&src.BucketBackendCreate)
|
|
}
|
|
|
|
if src.HttpBackendCreate != nil {
|
|
return json.Marshal(&src.HttpBackendCreate)
|
|
}
|
|
|
|
return []byte("{}"), nil // no data in oneOf schemas => empty JSON object
|
|
}
|
|
|
|
// Get the actual instance
|
|
func (obj *CreateDistributionPayloadBackend) GetActualInstance() interface{} {
|
|
if obj == nil {
|
|
return nil
|
|
}
|
|
if obj.BucketBackendCreate != nil {
|
|
return obj.BucketBackendCreate
|
|
}
|
|
|
|
if obj.HttpBackendCreate != nil {
|
|
return obj.HttpBackendCreate
|
|
}
|
|
|
|
// all schemas are nil
|
|
return nil
|
|
}
|
|
|
|
type NullableCreateDistributionPayloadBackend struct {
|
|
value *CreateDistributionPayloadBackend
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableCreateDistributionPayloadBackend) Get() *CreateDistributionPayloadBackend {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableCreateDistributionPayloadBackend) Set(val *CreateDistributionPayloadBackend) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableCreateDistributionPayloadBackend) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableCreateDistributionPayloadBackend) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableCreateDistributionPayloadBackend(val *CreateDistributionPayloadBackend) *NullableCreateDistributionPayloadBackend {
|
|
return &NullableCreateDistributionPayloadBackend{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableCreateDistributionPayloadBackend) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableCreateDistributionPayloadBackend) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|