## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
relates to #1234
## Checklist
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)
Reviewed-on: #4
Reviewed-by: Andre_Harms <andre.harms@stackit.cloud>
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-committed-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
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)
|
|
}
|