## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
relates to #1234
## Checklist
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)
Reviewed-on: #4
Reviewed-by: Andre_Harms <andre.harms@stackit.cloud>
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-committed-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
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)
|
|
}
|