## 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
4.5 KiB
Go
163 lines
4.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"
|
|
)
|
|
|
|
// ConfigPatchBackend - struct for ConfigPatchBackend
|
|
type ConfigPatchBackend struct {
|
|
BucketBackendPatch *BucketBackendPatch
|
|
HttpBackendPatch *HttpBackendPatch
|
|
}
|
|
|
|
// BucketBackendPatchAsConfigPatchBackend is a convenience function that returns BucketBackendPatch wrapped in ConfigPatchBackend
|
|
func BucketBackendPatchAsConfigPatchBackend(v *BucketBackendPatch) ConfigPatchBackend {
|
|
return ConfigPatchBackend{
|
|
BucketBackendPatch: v,
|
|
}
|
|
}
|
|
|
|
// HttpBackendPatchAsConfigPatchBackend is a convenience function that returns HttpBackendPatch wrapped in ConfigPatchBackend
|
|
func HttpBackendPatchAsConfigPatchBackend(v *HttpBackendPatch) ConfigPatchBackend {
|
|
return ConfigPatchBackend{
|
|
HttpBackendPatch: v,
|
|
}
|
|
}
|
|
|
|
// Unmarshal JSON data into one of the pointers in the struct
|
|
func (dst *ConfigPatchBackend) 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 'BucketBackendPatch'
|
|
if jsonDict["type"] == "BucketBackendPatch" {
|
|
// try to unmarshal JSON data into BucketBackendPatch
|
|
err = json.Unmarshal(data, &dst.BucketBackendPatch)
|
|
if err == nil {
|
|
return nil // data stored in dst.BucketBackendPatch, return on the first match
|
|
} else {
|
|
dst.BucketBackendPatch = nil
|
|
return fmt.Errorf("failed to unmarshal ConfigPatchBackend as BucketBackendPatch: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'HttpBackendPatch'
|
|
if jsonDict["type"] == "HttpBackendPatch" {
|
|
// try to unmarshal JSON data into HttpBackendPatch
|
|
err = json.Unmarshal(data, &dst.HttpBackendPatch)
|
|
if err == nil {
|
|
return nil // data stored in dst.HttpBackendPatch, return on the first match
|
|
} else {
|
|
dst.HttpBackendPatch = nil
|
|
return fmt.Errorf("failed to unmarshal ConfigPatchBackend as HttpBackendPatch: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'bucket'
|
|
if jsonDict["type"] == "bucket" {
|
|
// try to unmarshal JSON data into BucketBackendPatch
|
|
err = json.Unmarshal(data, &dst.BucketBackendPatch)
|
|
if err == nil {
|
|
return nil // data stored in dst.BucketBackendPatch, return on the first match
|
|
} else {
|
|
dst.BucketBackendPatch = nil
|
|
return fmt.Errorf("failed to unmarshal ConfigPatchBackend as BucketBackendPatch: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'http'
|
|
if jsonDict["type"] == "http" {
|
|
// try to unmarshal JSON data into HttpBackendPatch
|
|
err = json.Unmarshal(data, &dst.HttpBackendPatch)
|
|
if err == nil {
|
|
return nil // data stored in dst.HttpBackendPatch, return on the first match
|
|
} else {
|
|
dst.HttpBackendPatch = nil
|
|
return fmt.Errorf("failed to unmarshal ConfigPatchBackend as HttpBackendPatch: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// Marshal data from the first non-nil pointers in the struct to JSON
|
|
func (src ConfigPatchBackend) MarshalJSON() ([]byte, error) {
|
|
if src.BucketBackendPatch != nil {
|
|
return json.Marshal(&src.BucketBackendPatch)
|
|
}
|
|
|
|
if src.HttpBackendPatch != nil {
|
|
return json.Marshal(&src.HttpBackendPatch)
|
|
}
|
|
|
|
return []byte("{}"), nil // no data in oneOf schemas => empty JSON object
|
|
}
|
|
|
|
// Get the actual instance
|
|
func (obj *ConfigPatchBackend) GetActualInstance() interface{} {
|
|
if obj == nil {
|
|
return nil
|
|
}
|
|
if obj.BucketBackendPatch != nil {
|
|
return obj.BucketBackendPatch
|
|
}
|
|
|
|
if obj.HttpBackendPatch != nil {
|
|
return obj.HttpBackendPatch
|
|
}
|
|
|
|
// all schemas are nil
|
|
return nil
|
|
}
|
|
|
|
type NullableConfigPatchBackend struct {
|
|
value *ConfigPatchBackend
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableConfigPatchBackend) Get() *ConfigPatchBackend {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableConfigPatchBackend) Set(val *ConfigPatchBackend) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableConfigPatchBackend) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableConfigPatchBackend) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableConfigPatchBackend(val *ConfigPatchBackend) *NullableConfigPatchBackend {
|
|
return &NullableConfigPatchBackend{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableConfigPatchBackend) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableConfigPatchBackend) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|