terraform-provider-stackitp.../pkg/iaasbeta/model_route_destination.go
Marcel S. Henselin 9f41c4da7f
Some checks failed
Publish / Check GoReleaser config (push) Successful in 4s
Release / goreleaser (push) Failing after 29s
Publish / Publish provider (push) Failing after 4m24s
feat: auto generated files and new structure (#4)
## 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>
2026-01-29 14:10:25 +00:00

163 lines
4.5 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"
)
// RouteDestination - struct for RouteDestination
type RouteDestination struct {
DestinationCIDRv4 *DestinationCIDRv4
DestinationCIDRv6 *DestinationCIDRv6
}
// DestinationCIDRv4AsRouteDestination is a convenience function that returns DestinationCIDRv4 wrapped in RouteDestination
func DestinationCIDRv4AsRouteDestination(v *DestinationCIDRv4) RouteDestination {
return RouteDestination{
DestinationCIDRv4: v,
}
}
// DestinationCIDRv6AsRouteDestination is a convenience function that returns DestinationCIDRv6 wrapped in RouteDestination
func DestinationCIDRv6AsRouteDestination(v *DestinationCIDRv6) RouteDestination {
return RouteDestination{
DestinationCIDRv6: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *RouteDestination) 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 'DestinationCIDRv4'
if jsonDict["type"] == "DestinationCIDRv4" {
// try to unmarshal JSON data into DestinationCIDRv4
err = json.Unmarshal(data, &dst.DestinationCIDRv4)
if err == nil {
return nil // data stored in dst.DestinationCIDRv4, return on the first match
} else {
dst.DestinationCIDRv4 = nil
return fmt.Errorf("failed to unmarshal RouteDestination as DestinationCIDRv4: %s", err.Error())
}
}
// check if the discriminator value is 'DestinationCIDRv6'
if jsonDict["type"] == "DestinationCIDRv6" {
// try to unmarshal JSON data into DestinationCIDRv6
err = json.Unmarshal(data, &dst.DestinationCIDRv6)
if err == nil {
return nil // data stored in dst.DestinationCIDRv6, return on the first match
} else {
dst.DestinationCIDRv6 = nil
return fmt.Errorf("failed to unmarshal RouteDestination as DestinationCIDRv6: %s", err.Error())
}
}
// check if the discriminator value is 'cidrv4'
if jsonDict["type"] == "cidrv4" {
// try to unmarshal JSON data into DestinationCIDRv4
err = json.Unmarshal(data, &dst.DestinationCIDRv4)
if err == nil {
return nil // data stored in dst.DestinationCIDRv4, return on the first match
} else {
dst.DestinationCIDRv4 = nil
return fmt.Errorf("failed to unmarshal RouteDestination as DestinationCIDRv4: %s", err.Error())
}
}
// check if the discriminator value is 'cidrv6'
if jsonDict["type"] == "cidrv6" {
// try to unmarshal JSON data into DestinationCIDRv6
err = json.Unmarshal(data, &dst.DestinationCIDRv6)
if err == nil {
return nil // data stored in dst.DestinationCIDRv6, return on the first match
} else {
dst.DestinationCIDRv6 = nil
return fmt.Errorf("failed to unmarshal RouteDestination as DestinationCIDRv6: %s", err.Error())
}
}
return nil
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src RouteDestination) MarshalJSON() ([]byte, error) {
if src.DestinationCIDRv4 != nil {
return json.Marshal(&src.DestinationCIDRv4)
}
if src.DestinationCIDRv6 != nil {
return json.Marshal(&src.DestinationCIDRv6)
}
return []byte("{}"), nil // no data in oneOf schemas => empty JSON object
}
// Get the actual instance
func (obj *RouteDestination) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.DestinationCIDRv4 != nil {
return obj.DestinationCIDRv4
}
if obj.DestinationCIDRv6 != nil {
return obj.DestinationCIDRv6
}
// all schemas are nil
return nil
}
type NullableRouteDestination struct {
value *RouteDestination
isSet bool
}
func (v NullableRouteDestination) Get() *RouteDestination {
return v.value
}
func (v *NullableRouteDestination) Set(val *RouteDestination) {
v.value = val
v.isSet = true
}
func (v NullableRouteDestination) IsSet() bool {
return v.isSet
}
func (v *NullableRouteDestination) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableRouteDestination(val *RouteDestination) *NullableRouteDestination {
return &NullableRouteDestination{value: val, isSet: true}
}
func (v NullableRouteDestination) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableRouteDestination) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}