252 lines
7.2 KiB
Go
252 lines
7.2 KiB
Go
/*
|
|
Model Registry REST API
|
|
|
|
REST API for Model Registry to create and manage ML model metadata
|
|
|
|
API version: v1alpha3
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package openapi
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// MetadataValue - A value in properties.
|
|
type MetadataValue struct {
|
|
MetadataBoolValue *MetadataBoolValue
|
|
MetadataDoubleValue *MetadataDoubleValue
|
|
MetadataIntValue *MetadataIntValue
|
|
MetadataProtoValue *MetadataProtoValue
|
|
MetadataStringValue *MetadataStringValue
|
|
MetadataStructValue *MetadataStructValue
|
|
}
|
|
|
|
// MetadataBoolValueAsMetadataValue is a convenience function that returns MetadataBoolValue wrapped in MetadataValue
|
|
func MetadataBoolValueAsMetadataValue(v *MetadataBoolValue) MetadataValue {
|
|
return MetadataValue{
|
|
MetadataBoolValue: v,
|
|
}
|
|
}
|
|
|
|
// MetadataDoubleValueAsMetadataValue is a convenience function that returns MetadataDoubleValue wrapped in MetadataValue
|
|
func MetadataDoubleValueAsMetadataValue(v *MetadataDoubleValue) MetadataValue {
|
|
return MetadataValue{
|
|
MetadataDoubleValue: v,
|
|
}
|
|
}
|
|
|
|
// MetadataIntValueAsMetadataValue is a convenience function that returns MetadataIntValue wrapped in MetadataValue
|
|
func MetadataIntValueAsMetadataValue(v *MetadataIntValue) MetadataValue {
|
|
return MetadataValue{
|
|
MetadataIntValue: v,
|
|
}
|
|
}
|
|
|
|
// MetadataProtoValueAsMetadataValue is a convenience function that returns MetadataProtoValue wrapped in MetadataValue
|
|
func MetadataProtoValueAsMetadataValue(v *MetadataProtoValue) MetadataValue {
|
|
return MetadataValue{
|
|
MetadataProtoValue: v,
|
|
}
|
|
}
|
|
|
|
// MetadataStringValueAsMetadataValue is a convenience function that returns MetadataStringValue wrapped in MetadataValue
|
|
func MetadataStringValueAsMetadataValue(v *MetadataStringValue) MetadataValue {
|
|
return MetadataValue{
|
|
MetadataStringValue: v,
|
|
}
|
|
}
|
|
|
|
// MetadataStructValueAsMetadataValue is a convenience function that returns MetadataStructValue wrapped in MetadataValue
|
|
func MetadataStructValueAsMetadataValue(v *MetadataStructValue) MetadataValue {
|
|
return MetadataValue{
|
|
MetadataStructValue: v,
|
|
}
|
|
}
|
|
|
|
// Unmarshal JSON data into one of the pointers in the struct
|
|
func (dst *MetadataValue) 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 'MetadataBoolValue'
|
|
if jsonDict["metadataType"] == "MetadataBoolValue" {
|
|
// try to unmarshal JSON data into MetadataBoolValue
|
|
err = json.Unmarshal(data, &dst.MetadataBoolValue)
|
|
if err == nil {
|
|
return nil // data stored in dst.MetadataBoolValue, return on the first match
|
|
} else {
|
|
dst.MetadataBoolValue = nil
|
|
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataBoolValue: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'MetadataDoubleValue'
|
|
if jsonDict["metadataType"] == "MetadataDoubleValue" {
|
|
// try to unmarshal JSON data into MetadataDoubleValue
|
|
err = json.Unmarshal(data, &dst.MetadataDoubleValue)
|
|
if err == nil {
|
|
return nil // data stored in dst.MetadataDoubleValue, return on the first match
|
|
} else {
|
|
dst.MetadataDoubleValue = nil
|
|
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataDoubleValue: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'MetadataIntValue'
|
|
if jsonDict["metadataType"] == "MetadataIntValue" {
|
|
// try to unmarshal JSON data into MetadataIntValue
|
|
err = json.Unmarshal(data, &dst.MetadataIntValue)
|
|
if err == nil {
|
|
return nil // data stored in dst.MetadataIntValue, return on the first match
|
|
} else {
|
|
dst.MetadataIntValue = nil
|
|
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataIntValue: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'MetadataProtoValue'
|
|
if jsonDict["metadataType"] == "MetadataProtoValue" {
|
|
// try to unmarshal JSON data into MetadataProtoValue
|
|
err = json.Unmarshal(data, &dst.MetadataProtoValue)
|
|
if err == nil {
|
|
return nil // data stored in dst.MetadataProtoValue, return on the first match
|
|
} else {
|
|
dst.MetadataProtoValue = nil
|
|
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataProtoValue: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'MetadataStringValue'
|
|
if jsonDict["metadataType"] == "MetadataStringValue" {
|
|
// try to unmarshal JSON data into MetadataStringValue
|
|
err = json.Unmarshal(data, &dst.MetadataStringValue)
|
|
if err == nil {
|
|
return nil // data stored in dst.MetadataStringValue, return on the first match
|
|
} else {
|
|
dst.MetadataStringValue = nil
|
|
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataStringValue: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
// check if the discriminator value is 'MetadataStructValue'
|
|
if jsonDict["metadataType"] == "MetadataStructValue" {
|
|
// try to unmarshal JSON data into MetadataStructValue
|
|
err = json.Unmarshal(data, &dst.MetadataStructValue)
|
|
if err == nil {
|
|
return nil // data stored in dst.MetadataStructValue, return on the first match
|
|
} else {
|
|
dst.MetadataStructValue = nil
|
|
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataStructValue: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// Marshal data from the first non-nil pointers in the struct to JSON
|
|
func (src MetadataValue) MarshalJSON() ([]byte, error) {
|
|
if src.MetadataBoolValue != nil {
|
|
return json.Marshal(&src.MetadataBoolValue)
|
|
}
|
|
|
|
if src.MetadataDoubleValue != nil {
|
|
return json.Marshal(&src.MetadataDoubleValue)
|
|
}
|
|
|
|
if src.MetadataIntValue != nil {
|
|
return json.Marshal(&src.MetadataIntValue)
|
|
}
|
|
|
|
if src.MetadataProtoValue != nil {
|
|
return json.Marshal(&src.MetadataProtoValue)
|
|
}
|
|
|
|
if src.MetadataStringValue != nil {
|
|
return json.Marshal(&src.MetadataStringValue)
|
|
}
|
|
|
|
if src.MetadataStructValue != nil {
|
|
return json.Marshal(&src.MetadataStructValue)
|
|
}
|
|
|
|
return nil, nil // no data in oneOf schemas
|
|
}
|
|
|
|
// Get the actual instance
|
|
func (obj *MetadataValue) GetActualInstance() interface{} {
|
|
if obj == nil {
|
|
return nil
|
|
}
|
|
if obj.MetadataBoolValue != nil {
|
|
return obj.MetadataBoolValue
|
|
}
|
|
|
|
if obj.MetadataDoubleValue != nil {
|
|
return obj.MetadataDoubleValue
|
|
}
|
|
|
|
if obj.MetadataIntValue != nil {
|
|
return obj.MetadataIntValue
|
|
}
|
|
|
|
if obj.MetadataProtoValue != nil {
|
|
return obj.MetadataProtoValue
|
|
}
|
|
|
|
if obj.MetadataStringValue != nil {
|
|
return obj.MetadataStringValue
|
|
}
|
|
|
|
if obj.MetadataStructValue != nil {
|
|
return obj.MetadataStructValue
|
|
}
|
|
|
|
// all schemas are nil
|
|
return nil
|
|
}
|
|
|
|
type NullableMetadataValue struct {
|
|
value *MetadataValue
|
|
isSet bool
|
|
}
|
|
|
|
func (v NullableMetadataValue) Get() *MetadataValue {
|
|
return v.value
|
|
}
|
|
|
|
func (v *NullableMetadataValue) Set(val *MetadataValue) {
|
|
v.value = val
|
|
v.isSet = true
|
|
}
|
|
|
|
func (v NullableMetadataValue) IsSet() bool {
|
|
return v.isSet
|
|
}
|
|
|
|
func (v *NullableMetadataValue) Unset() {
|
|
v.value = nil
|
|
v.isSet = false
|
|
}
|
|
|
|
func NewNullableMetadataValue(val *MetadataValue) *NullableMetadataValue {
|
|
return &NullableMetadataValue{value: val, isSet: true}
|
|
}
|
|
|
|
func (v NullableMetadataValue) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(v.value)
|
|
}
|
|
|
|
func (v *NullableMetadataValue) UnmarshalJSON(src []byte) error {
|
|
v.isSet = true
|
|
return json.Unmarshal(src, &v.value)
|
|
}
|