/* 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" ) // PutCustomDomainResponseCertificate - Pass a custom certificate to be served by the CDN when calling the custom domain. Will use a managed certificate when omitted type PutCustomDomainResponseCertificate struct { GetCustomDomainCustomCertificate *GetCustomDomainCustomCertificate GetCustomDomainManagedCertificate *GetCustomDomainManagedCertificate } // GetCustomDomainCustomCertificateAsPutCustomDomainResponseCertificate is a convenience function that returns GetCustomDomainCustomCertificate wrapped in PutCustomDomainResponseCertificate func GetCustomDomainCustomCertificateAsPutCustomDomainResponseCertificate(v *GetCustomDomainCustomCertificate) PutCustomDomainResponseCertificate { return PutCustomDomainResponseCertificate{ GetCustomDomainCustomCertificate: v, } } // GetCustomDomainManagedCertificateAsPutCustomDomainResponseCertificate is a convenience function that returns GetCustomDomainManagedCertificate wrapped in PutCustomDomainResponseCertificate func GetCustomDomainManagedCertificateAsPutCustomDomainResponseCertificate(v *GetCustomDomainManagedCertificate) PutCustomDomainResponseCertificate { return PutCustomDomainResponseCertificate{ GetCustomDomainManagedCertificate: v, } } // Unmarshal JSON data into one of the pointers in the struct func (dst *PutCustomDomainResponseCertificate) 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 PutCustomDomainResponseCertificate 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 PutCustomDomainResponseCertificate 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 PutCustomDomainResponseCertificate 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 PutCustomDomainResponseCertificate as GetCustomDomainManagedCertificate: %s", err.Error()) } } return nil } // Marshal data from the first non-nil pointers in the struct to JSON func (src PutCustomDomainResponseCertificate) 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 *PutCustomDomainResponseCertificate) 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 NullablePutCustomDomainResponseCertificate struct { value *PutCustomDomainResponseCertificate isSet bool } func (v NullablePutCustomDomainResponseCertificate) Get() *PutCustomDomainResponseCertificate { return v.value } func (v *NullablePutCustomDomainResponseCertificate) Set(val *PutCustomDomainResponseCertificate) { v.value = val v.isSet = true } func (v NullablePutCustomDomainResponseCertificate) IsSet() bool { return v.isSet } func (v *NullablePutCustomDomainResponseCertificate) Unset() { v.value = nil v.isSet = false } func NewNullablePutCustomDomainResponseCertificate(val *PutCustomDomainResponseCertificate) *NullablePutCustomDomainResponseCertificate { return &NullablePutCustomDomainResponseCertificate{value: val, isSet: true} } func (v NullablePutCustomDomainResponseCertificate) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullablePutCustomDomainResponseCertificate) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }