144 lines
4.4 KiB
Go
144 lines
4.4 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"
|
|
)
|
|
|
|
// CreateNetworkIPv4 - The create request for an IPv4 network.
|
|
type CreateNetworkIPv4 struct {
|
|
CreateNetworkIPv4WithPrefix *CreateNetworkIPv4WithPrefix
|
|
CreateNetworkIPv4WithPrefixLength *CreateNetworkIPv4WithPrefixLength
|
|
}
|
|
|
|
// CreateNetworkIPv4WithPrefixAsCreateNetworkIPv4 is a convenience function that returns CreateNetworkIPv4WithPrefix wrapped in CreateNetworkIPv4
|
|
func CreateNetworkIPv4WithPrefixAsCreateNetworkIPv4(v *CreateNetworkIPv4WithPrefix) CreateNetworkIPv4 {
|
|
return CreateNetworkIPv4{
|
|
CreateNetworkIPv4WithPrefix: v,
|
|
}
|
|
}
|
|
|
|
// CreateNetworkIPv4WithPrefixLengthAsCreateNetworkIPv4 is a convenience function that returns CreateNetworkIPv4WithPrefixLength wrapped in CreateNetworkIPv4
|
|
func CreateNetworkIPv4WithPrefixLengthAsCreateNetworkIPv4(v *CreateNetworkIPv4WithPrefixLength) CreateNetworkIPv4 {
|
|
return CreateNetworkIPv4{
|
|
CreateNetworkIPv4WithPrefixLength: v,
|
|
}
|
|
}
|
|
|
|
// Unmarshal JSON data into one of the pointers in the struct
|
|
func (dst *CreateNetworkIPv4) 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 CreateNetworkIPv4WithPrefix
|
|
dstCreateNetworkIPv41 := &CreateNetworkIPv4{}
|
|
err = json.Unmarshal(data, &dstCreateNetworkIPv41.CreateNetworkIPv4WithPrefix)
|
|
if err == nil {
|
|
jsonCreateNetworkIPv4WithPrefix, _ := json.Marshal(&dstCreateNetworkIPv41.CreateNetworkIPv4WithPrefix)
|
|
if string(jsonCreateNetworkIPv4WithPrefix) != "{}" { // empty struct
|
|
dst.CreateNetworkIPv4WithPrefix = dstCreateNetworkIPv41.CreateNetworkIPv4WithPrefix
|
|
match++
|
|
}
|
|
}
|
|
|
|
// try to unmarshal data into CreateNetworkIPv4WithPrefixLength
|
|
dstCreateNetworkIPv42 := &CreateNetworkIPv4{}
|
|
err = json.Unmarshal(data, &dstCreateNetworkIPv42.CreateNetworkIPv4WithPrefixLength)
|
|
if err == nil {
|
|
jsonCreateNetworkIPv4WithPrefixLength, _ := json.Marshal(&dstCreateNetworkIPv42.CreateNetworkIPv4WithPrefixLength)
|
|
if string(jsonCreateNetworkIPv4WithPrefixLength) != "{}" { // empty struct
|
|
dst.CreateNetworkIPv4WithPrefixLength = dstCreateNetworkIPv42.CreateNetworkIPv4WithPrefixLength
|
|
match++
|
|
}
|
|
}
|
|
|
|
if match > 1 { // more than 1 match
|
|
// reset to nil
|
|
dst.CreateNetworkIPv4WithPrefix = nil
|
|
dst.CreateNetworkIPv4WithPrefixLength = nil
|
|
|
|
return fmt.Errorf("data matches more than one schema in oneOf(CreateNetworkIPv4)")
|
|
} else if match == 1 {
|
|
return nil // exactly one match
|
|
} else { // no match
|
|
return fmt.Errorf("data failed to match schemas in oneOf(CreateNetworkIPv4)")
|
|
}
|
|
}
|
|
|
|
// Marshal data from the first non-nil pointers in the struct to JSON
|
|
func (src CreateNetworkIPv4) MarshalJSON() ([]byte, error) {
|
|
if src.CreateNetworkIPv4WithPrefix != nil {
|
|
return json.Marshal(&src.CreateNetworkIPv4WithPrefix)
|
|
}
|
|
|
|
if src.CreateNetworkIPv4WithPrefixLength != nil {
|
|
return json.Marshal(&src.CreateNetworkIPv4WithPrefixLength)
|
|
}
|
|
|
|
return []byte("{}"), nil // no data in oneOf schemas => empty JSON object
|
|
}
|
|
|
|
// Get the actual instance
|
|
func (obj *CreateNetworkIPv4) GetActualInstance() interface{} {
|
|
if obj == nil {
|
|
return nil
|
|
}
|
|
if obj.CreateNetworkIPv4WithPrefix != nil {
|
|
return obj.CreateNetworkIPv4WithPrefix
|
|
}
|
|
|
|
if obj.CreateNetworkIPv4WithPrefixLength != nil {
|
|
return obj.CreateNetworkIPv4WithPrefixLength
|
|
}
|
|
|
|
// all schemas are nil
|
|
return nil
|
|
}
|
|
|
|
type NullableCreateNetworkIPv4 struct {
|
|
value *CreateNetworkIPv4
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableCreateNetworkIPv4) Get() *CreateNetworkIPv4 {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableCreateNetworkIPv4) Set(val *CreateNetworkIPv4) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableCreateNetworkIPv4) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableCreateNetworkIPv4) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableCreateNetworkIPv4(val *CreateNetworkIPv4) *NullableCreateNetworkIPv4 {
|
|
return &NullableCreateNetworkIPv4{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableCreateNetworkIPv4) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableCreateNetworkIPv4) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|