148 lines
3.8 KiB
Go
148 lines
3.8 KiB
Go
/*
|
|
Garage Administration API v0+garage-v0.9.0
|
|
|
|
Administrate your Garage cluster programatically, including status, layout, keys, buckets, and maintainance tasks. *Disclaimer: The API is not stable yet, hence its v0 tag. The API can change at any time, and changes can include breaking backward compatibility. Read the changelog and upgrade your scripts before upgrading. Additionnaly, this specification is very early stage and can contain bugs, especially on error return codes/types that are not tested yet. Do not expect a well finished and polished product!*
|
|
|
|
API version: v0.9.0
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package garage
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// NodeRoleChange - struct for NodeRoleChange
|
|
type NodeRoleChange struct {
|
|
NodeRoleRemove *NodeRoleRemove
|
|
NodeRoleUpdate *NodeRoleUpdate
|
|
}
|
|
|
|
// NodeRoleRemoveAsNodeRoleChange is a convenience function that returns NodeRoleRemove wrapped in NodeRoleChange
|
|
func NodeRoleRemoveAsNodeRoleChange(v *NodeRoleRemove) NodeRoleChange {
|
|
return NodeRoleChange{
|
|
NodeRoleRemove: v,
|
|
}
|
|
}
|
|
|
|
// NodeRoleUpdateAsNodeRoleChange is a convenience function that returns NodeRoleUpdate wrapped in NodeRoleChange
|
|
func NodeRoleUpdateAsNodeRoleChange(v *NodeRoleUpdate) NodeRoleChange {
|
|
return NodeRoleChange{
|
|
NodeRoleUpdate: v,
|
|
}
|
|
}
|
|
|
|
|
|
// Unmarshal JSON data into one of the pointers in the struct
|
|
func (dst *NodeRoleChange) UnmarshalJSON(data []byte) error {
|
|
var err error
|
|
match := 0
|
|
// try to unmarshal data into NodeRoleRemove
|
|
err = newStrictDecoder(data).Decode(&dst.NodeRoleRemove)
|
|
if err == nil {
|
|
jsonNodeRoleRemove, _ := json.Marshal(dst.NodeRoleRemove)
|
|
if string(jsonNodeRoleRemove) == "{}" { // empty struct
|
|
dst.NodeRoleRemove = nil
|
|
} else {
|
|
match++
|
|
}
|
|
} else {
|
|
dst.NodeRoleRemove = nil
|
|
}
|
|
|
|
// try to unmarshal data into NodeRoleUpdate
|
|
err = newStrictDecoder(data).Decode(&dst.NodeRoleUpdate)
|
|
if err == nil {
|
|
jsonNodeRoleUpdate, _ := json.Marshal(dst.NodeRoleUpdate)
|
|
if string(jsonNodeRoleUpdate) == "{}" { // empty struct
|
|
dst.NodeRoleUpdate = nil
|
|
} else {
|
|
match++
|
|
}
|
|
} else {
|
|
dst.NodeRoleUpdate = nil
|
|
}
|
|
|
|
if match > 1 { // more than 1 match
|
|
// reset to nil
|
|
dst.NodeRoleRemove = nil
|
|
dst.NodeRoleUpdate = nil
|
|
|
|
return fmt.Errorf("Data matches more than one schema in oneOf(NodeRoleChange)")
|
|
} else if match == 1 {
|
|
return nil // exactly one match
|
|
} else { // no match
|
|
return fmt.Errorf("Data failed to match schemas in oneOf(NodeRoleChange)")
|
|
}
|
|
}
|
|
|
|
// Marshal data from the first non-nil pointers in the struct to JSON
|
|
func (src NodeRoleChange) MarshalJSON() ([]byte, error) {
|
|
if src.NodeRoleRemove != nil {
|
|
return json.Marshal(&src.NodeRoleRemove)
|
|
}
|
|
|
|
if src.NodeRoleUpdate != nil {
|
|
return json.Marshal(&src.NodeRoleUpdate)
|
|
}
|
|
|
|
return nil, nil // no data in oneOf schemas
|
|
}
|
|
|
|
// Get the actual instance
|
|
func (obj *NodeRoleChange) GetActualInstance() (interface{}) {
|
|
if obj == nil {
|
|
return nil
|
|
}
|
|
if obj.NodeRoleRemove != nil {
|
|
return obj.NodeRoleRemove
|
|
}
|
|
|
|
if obj.NodeRoleUpdate != nil {
|
|
return obj.NodeRoleUpdate
|
|
}
|
|
|
|
// all schemas are nil
|
|
return nil
|
|
}
|
|
|
|
type NullableNodeRoleChange struct {
|
|
value *NodeRoleChange
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableNodeRoleChange) Get() *NodeRoleChange {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableNodeRoleChange) Set(val *NodeRoleChange) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableNodeRoleChange) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableNodeRoleChange) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableNodeRoleChange(val *NodeRoleChange) *NullableNodeRoleChange {
|
|
return &NullableNodeRoleChange{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableNodeRoleChange) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableNodeRoleChange) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|
|
|
|
|