243 lines
6.6 KiB
Go
243 lines
6.6 KiB
Go
/*
|
|
STACKIT IaaS API
|
|
|
|
This API allows you to create and modify IaaS resources.
|
|
|
|
API version: 2beta1
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package iaasbeta
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// RouteNexthop - struct for RouteNexthop
|
|
type RouteNexthop struct {
|
|
NexthopBlackhole *NexthopBlackhole
|
|
NexthopIPv4 *NexthopIPv4
|
|
NexthopIPv6 *NexthopIPv6
|
|
NexthopInternet *NexthopInternet
|
|
}
|
|
|
|
// NexthopBlackholeAsRouteNexthop is a convenience function that returns NexthopBlackhole wrapped in RouteNexthop
|
|
func NexthopBlackholeAsRouteNexthop(v *NexthopBlackhole) RouteNexthop {
|
|
return RouteNexthop{
|
|
NexthopBlackhole: v,
|
|
}
|
|
}
|
|
|
|
// NexthopIPv4AsRouteNexthop is a convenience function that returns NexthopIPv4 wrapped in RouteNexthop
|
|
func NexthopIPv4AsRouteNexthop(v *NexthopIPv4) RouteNexthop {
|
|
return RouteNexthop{
|
|
NexthopIPv4: v,
|
|
}
|
|
}
|
|
|
|
// NexthopIPv6AsRouteNexthop is a convenience function that returns NexthopIPv6 wrapped in RouteNexthop
|
|
func NexthopIPv6AsRouteNexthop(v *NexthopIPv6) RouteNexthop {
|
|
return RouteNexthop{
|
|
NexthopIPv6: v,
|
|
}
|
|
}
|
|
|
|
// NexthopInternetAsRouteNexthop is a convenience function that returns NexthopInternet wrapped in RouteNexthop
|
|
func NexthopInternetAsRouteNexthop(v *NexthopInternet) RouteNexthop {
|
|
return RouteNexthop{
|
|
NexthopInternet: v,
|
|
}
|
|
}
|
|
|
|
// Unmarshal JSON data into one of the pointers in the struct
|
|
func (dst *RouteNexthop) 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 'NexthopBlackhole'
|
|
if jsonDict["type"] == "NexthopBlackhole" {
|
|
// try to unmarshal JSON data into NexthopBlackhole
|
|
err = json.Unmarshal(data, &dst.NexthopBlackhole)
|
|
if err == nil {
|
|
return nil // data stored in dst.NexthopBlackhole, return on the first match
|
|
} else {
|
|
dst.NexthopBlackhole = nil
|
|
return fmt.Errorf("failed to unmarshal RouteNexthop as NexthopBlackhole: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'NexthopIPv4'
|
|
if jsonDict["type"] == "NexthopIPv4" {
|
|
// try to unmarshal JSON data into NexthopIPv4
|
|
err = json.Unmarshal(data, &dst.NexthopIPv4)
|
|
if err == nil {
|
|
return nil // data stored in dst.NexthopIPv4, return on the first match
|
|
} else {
|
|
dst.NexthopIPv4 = nil
|
|
return fmt.Errorf("failed to unmarshal RouteNexthop as NexthopIPv4: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'NexthopIPv6'
|
|
if jsonDict["type"] == "NexthopIPv6" {
|
|
// try to unmarshal JSON data into NexthopIPv6
|
|
err = json.Unmarshal(data, &dst.NexthopIPv6)
|
|
if err == nil {
|
|
return nil // data stored in dst.NexthopIPv6, return on the first match
|
|
} else {
|
|
dst.NexthopIPv6 = nil
|
|
return fmt.Errorf("failed to unmarshal RouteNexthop as NexthopIPv6: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'NexthopInternet'
|
|
if jsonDict["type"] == "NexthopInternet" {
|
|
// try to unmarshal JSON data into NexthopInternet
|
|
err = json.Unmarshal(data, &dst.NexthopInternet)
|
|
if err == nil {
|
|
return nil // data stored in dst.NexthopInternet, return on the first match
|
|
} else {
|
|
dst.NexthopInternet = nil
|
|
return fmt.Errorf("failed to unmarshal RouteNexthop as NexthopInternet: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'blackhole'
|
|
if jsonDict["type"] == "blackhole" {
|
|
// try to unmarshal JSON data into NexthopBlackhole
|
|
err = json.Unmarshal(data, &dst.NexthopBlackhole)
|
|
if err == nil {
|
|
return nil // data stored in dst.NexthopBlackhole, return on the first match
|
|
} else {
|
|
dst.NexthopBlackhole = nil
|
|
return fmt.Errorf("failed to unmarshal RouteNexthop as NexthopBlackhole: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'internet'
|
|
if jsonDict["type"] == "internet" {
|
|
// try to unmarshal JSON data into NexthopInternet
|
|
err = json.Unmarshal(data, &dst.NexthopInternet)
|
|
if err == nil {
|
|
return nil // data stored in dst.NexthopInternet, return on the first match
|
|
} else {
|
|
dst.NexthopInternet = nil
|
|
return fmt.Errorf("failed to unmarshal RouteNexthop as NexthopInternet: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'ipv4'
|
|
if jsonDict["type"] == "ipv4" {
|
|
// try to unmarshal JSON data into NexthopIPv4
|
|
err = json.Unmarshal(data, &dst.NexthopIPv4)
|
|
if err == nil {
|
|
return nil // data stored in dst.NexthopIPv4, return on the first match
|
|
} else {
|
|
dst.NexthopIPv4 = nil
|
|
return fmt.Errorf("failed to unmarshal RouteNexthop as NexthopIPv4: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'ipv6'
|
|
if jsonDict["type"] == "ipv6" {
|
|
// try to unmarshal JSON data into NexthopIPv6
|
|
err = json.Unmarshal(data, &dst.NexthopIPv6)
|
|
if err == nil {
|
|
return nil // data stored in dst.NexthopIPv6, return on the first match
|
|
} else {
|
|
dst.NexthopIPv6 = nil
|
|
return fmt.Errorf("failed to unmarshal RouteNexthop as NexthopIPv6: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// Marshal data from the first non-nil pointers in the struct to JSON
|
|
func (src RouteNexthop) MarshalJSON() ([]byte, error) {
|
|
if src.NexthopBlackhole != nil {
|
|
return json.Marshal(&src.NexthopBlackhole)
|
|
}
|
|
|
|
if src.NexthopIPv4 != nil {
|
|
return json.Marshal(&src.NexthopIPv4)
|
|
}
|
|
|
|
if src.NexthopIPv6 != nil {
|
|
return json.Marshal(&src.NexthopIPv6)
|
|
}
|
|
|
|
if src.NexthopInternet != nil {
|
|
return json.Marshal(&src.NexthopInternet)
|
|
}
|
|
|
|
return []byte("{}"), nil // no data in oneOf schemas => empty JSON object
|
|
}
|
|
|
|
// Get the actual instance
|
|
func (obj *RouteNexthop) GetActualInstance() interface{} {
|
|
if obj == nil {
|
|
return nil
|
|
}
|
|
if obj.NexthopBlackhole != nil {
|
|
return obj.NexthopBlackhole
|
|
}
|
|
|
|
if obj.NexthopIPv4 != nil {
|
|
return obj.NexthopIPv4
|
|
}
|
|
|
|
if obj.NexthopIPv6 != nil {
|
|
return obj.NexthopIPv6
|
|
}
|
|
|
|
if obj.NexthopInternet != nil {
|
|
return obj.NexthopInternet
|
|
}
|
|
|
|
// all schemas are nil
|
|
return nil
|
|
}
|
|
|
|
type NullableRouteNexthop struct {
|
|
value *RouteNexthop
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableRouteNexthop) Get() *RouteNexthop {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableRouteNexthop) Set(val *RouteNexthop) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableRouteNexthop) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableRouteNexthop) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableRouteNexthop(val *RouteNexthop) *NullableRouteNexthop {
|
|
return &NullableRouteNexthop{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableRouteNexthop) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableRouteNexthop) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|