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