144 lines
4.2 KiB
Go
144 lines
4.2 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"
|
|
)
|
|
|
|
// ServerNetworking - The initial networking setup for the server creation. A network, a nic or nothing can be given.
|
|
type ServerNetworking struct {
|
|
CreateServerNetworking *CreateServerNetworking
|
|
CreateServerNetworkingWithNics *CreateServerNetworkingWithNics
|
|
}
|
|
|
|
// CreateServerNetworkingAsServerNetworking is a convenience function that returns CreateServerNetworking wrapped in ServerNetworking
|
|
func CreateServerNetworkingAsServerNetworking(v *CreateServerNetworking) ServerNetworking {
|
|
return ServerNetworking{
|
|
CreateServerNetworking: v,
|
|
}
|
|
}
|
|
|
|
// CreateServerNetworkingWithNicsAsServerNetworking is a convenience function that returns CreateServerNetworkingWithNics wrapped in ServerNetworking
|
|
func CreateServerNetworkingWithNicsAsServerNetworking(v *CreateServerNetworkingWithNics) ServerNetworking {
|
|
return ServerNetworking{
|
|
CreateServerNetworkingWithNics: v,
|
|
}
|
|
}
|
|
|
|
// Unmarshal JSON data into one of the pointers in the struct
|
|
func (dst *ServerNetworking) UnmarshalJSON(data []byte) error {
|
|
var err error
|
|
match := 0
|
|
// Workaround until upstream issue is fixed:
|
|
// https://github.com/OpenAPITools/openapi-generator/issues/21751
|
|
// Tracking issue on our side: https://jira.schwarz/browse/STACKITSDK-226
|
|
// try to unmarshal data into CreateServerNetworking
|
|
dstServerNetworking1 := &ServerNetworking{}
|
|
err = json.Unmarshal(data, &dstServerNetworking1.CreateServerNetworking)
|
|
if err == nil {
|
|
jsonCreateServerNetworking, _ := json.Marshal(&dstServerNetworking1.CreateServerNetworking)
|
|
if string(jsonCreateServerNetworking) != "{}" { // empty struct
|
|
dst.CreateServerNetworking = dstServerNetworking1.CreateServerNetworking
|
|
match++
|
|
}
|
|
}
|
|
|
|
// try to unmarshal data into CreateServerNetworkingWithNics
|
|
dstServerNetworking2 := &ServerNetworking{}
|
|
err = json.Unmarshal(data, &dstServerNetworking2.CreateServerNetworkingWithNics)
|
|
if err == nil {
|
|
jsonCreateServerNetworkingWithNics, _ := json.Marshal(&dstServerNetworking2.CreateServerNetworkingWithNics)
|
|
if string(jsonCreateServerNetworkingWithNics) != "{}" { // empty struct
|
|
dst.CreateServerNetworkingWithNics = dstServerNetworking2.CreateServerNetworkingWithNics
|
|
match++
|
|
}
|
|
}
|
|
|
|
if match > 1 { // more than 1 match
|
|
// reset to nil
|
|
dst.CreateServerNetworking = nil
|
|
dst.CreateServerNetworkingWithNics = nil
|
|
|
|
return fmt.Errorf("data matches more than one schema in oneOf(ServerNetworking)")
|
|
} else if match == 1 {
|
|
return nil // exactly one match
|
|
} else { // no match
|
|
return fmt.Errorf("data failed to match schemas in oneOf(ServerNetworking)")
|
|
}
|
|
}
|
|
|
|
// Marshal data from the first non-nil pointers in the struct to JSON
|
|
func (src ServerNetworking) MarshalJSON() ([]byte, error) {
|
|
if src.CreateServerNetworking != nil {
|
|
return json.Marshal(&src.CreateServerNetworking)
|
|
}
|
|
|
|
if src.CreateServerNetworkingWithNics != nil {
|
|
return json.Marshal(&src.CreateServerNetworkingWithNics)
|
|
}
|
|
|
|
return []byte("{}"), nil // no data in oneOf schemas => empty JSON object
|
|
}
|
|
|
|
// Get the actual instance
|
|
func (obj *ServerNetworking) GetActualInstance() interface{} {
|
|
if obj == nil {
|
|
return nil
|
|
}
|
|
if obj.CreateServerNetworking != nil {
|
|
return obj.CreateServerNetworking
|
|
}
|
|
|
|
if obj.CreateServerNetworkingWithNics != nil {
|
|
return obj.CreateServerNetworkingWithNics
|
|
}
|
|
|
|
// all schemas are nil
|
|
return nil
|
|
}
|
|
|
|
type NullableServerNetworking struct {
|
|
value *ServerNetworking
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableServerNetworking) Get() *ServerNetworking {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableServerNetworking) Set(val *ServerNetworking) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableServerNetworking) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableServerNetworking) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableServerNetworking(val *ServerNetworking) *NullableServerNetworking {
|
|
return &NullableServerNetworking{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableServerNetworking) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableServerNetworking) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|