terraform-provider-stackitp.../pkg/cdnbeta/model_create_distribution_payload_log_sink.go
2026-01-21 09:07:29 +01:00

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