128 lines
3.3 KiB
Go
128 lines
3.3 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"
|
|
)
|
|
|
|
// ConfigPatchLogSink - struct for ConfigPatchLogSink
|
|
type ConfigPatchLogSink struct {
|
|
LokiLogSinkPatch *LokiLogSinkPatch
|
|
}
|
|
|
|
// LokiLogSinkPatchAsConfigPatchLogSink is a convenience function that returns LokiLogSinkPatch wrapped in ConfigPatchLogSink
|
|
func LokiLogSinkPatchAsConfigPatchLogSink(v *LokiLogSinkPatch) ConfigPatchLogSink {
|
|
return ConfigPatchLogSink{
|
|
LokiLogSinkPatch: v,
|
|
}
|
|
}
|
|
|
|
// Unmarshal JSON data into one of the pointers in the struct
|
|
func (dst *ConfigPatchLogSink) UnmarshalJSON(data []byte) error {
|
|
var err error
|
|
// this object is nullable so check if the payload is null or empty string
|
|
if string(data) == "" || string(data) == "{}" {
|
|
return nil
|
|
}
|
|
|
|
// 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 'LokiLogSinkPatch'
|
|
if jsonDict["type"] == "LokiLogSinkPatch" {
|
|
// try to unmarshal JSON data into LokiLogSinkPatch
|
|
err = json.Unmarshal(data, &dst.LokiLogSinkPatch)
|
|
if err == nil {
|
|
return nil // data stored in dst.LokiLogSinkPatch, return on the first match
|
|
} else {
|
|
dst.LokiLogSinkPatch = nil
|
|
return fmt.Errorf("failed to unmarshal ConfigPatchLogSink as LokiLogSinkPatch: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'loki'
|
|
if jsonDict["type"] == "loki" {
|
|
// try to unmarshal JSON data into LokiLogSinkPatch
|
|
err = json.Unmarshal(data, &dst.LokiLogSinkPatch)
|
|
if err == nil {
|
|
return nil // data stored in dst.LokiLogSinkPatch, return on the first match
|
|
} else {
|
|
dst.LokiLogSinkPatch = nil
|
|
return fmt.Errorf("failed to unmarshal ConfigPatchLogSink as LokiLogSinkPatch: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// Marshal data from the first non-nil pointers in the struct to JSON
|
|
func (src ConfigPatchLogSink) MarshalJSON() ([]byte, error) {
|
|
if src.LokiLogSinkPatch != nil {
|
|
return json.Marshal(&src.LokiLogSinkPatch)
|
|
}
|
|
|
|
return []byte("{}"), nil // no data in oneOf schemas => empty JSON object
|
|
}
|
|
|
|
// Get the actual instance
|
|
func (obj *ConfigPatchLogSink) GetActualInstance() interface{} {
|
|
if obj == nil {
|
|
return nil
|
|
}
|
|
if obj.LokiLogSinkPatch != nil {
|
|
return obj.LokiLogSinkPatch
|
|
}
|
|
|
|
// all schemas are nil
|
|
return nil
|
|
}
|
|
|
|
type NullableConfigPatchLogSink struct {
|
|
value *ConfigPatchLogSink
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableConfigPatchLogSink) Get() *ConfigPatchLogSink {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableConfigPatchLogSink) Set(val *ConfigPatchLogSink) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableConfigPatchLogSink) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableConfigPatchLogSink) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableConfigPatchLogSink(val *ConfigPatchLogSink) *NullableConfigPatchLogSink {
|
|
return &NullableConfigPatchLogSink{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableConfigPatchLogSink) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableConfigPatchLogSink) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|