/* Model Registry REST API REST API for Model Registry to create and manage ML model metadata API version: 1.0.0 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package openapi import ( "encoding/json" "fmt" ) // Artifact - A metadata Artifact Entity. type Artifact struct { ModelArtifact *ModelArtifact } // ModelArtifactAsArtifact is a convenience function that returns ModelArtifact wrapped in Artifact func ModelArtifactAsArtifact(v *ModelArtifact) Artifact { return Artifact{ ModelArtifact: v, } } // Unmarshal JSON data into one of the pointers in the struct func (dst *Artifact) 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 'ModelArtifact' if jsonDict["artifactType"] == "ModelArtifact" { // try to unmarshal JSON data into ModelArtifact err = json.Unmarshal(data, &dst.ModelArtifact) if err == nil { return nil // data stored in dst.ModelArtifact, return on the first match } else { dst.ModelArtifact = nil return fmt.Errorf("failed to unmarshal Artifact as ModelArtifact: %s", err.Error()) } } // check if the discriminator value is 'model-artifact' if jsonDict["artifactType"] == "model-artifact" { // try to unmarshal JSON data into ModelArtifact err = json.Unmarshal(data, &dst.ModelArtifact) if err == nil { return nil // data stored in dst.ModelArtifact, return on the first match } else { dst.ModelArtifact = nil return fmt.Errorf("failed to unmarshal Artifact as ModelArtifact: %s", err.Error()) } } return nil } // Marshal data from the first non-nil pointers in the struct to JSON func (src Artifact) MarshalJSON() ([]byte, error) { if src.ModelArtifact != nil { return json.Marshal(&src.ModelArtifact) } return nil, nil // no data in oneOf schemas } // Get the actual instance func (obj *Artifact) GetActualInstance() interface{} { if obj == nil { return nil } if obj.ModelArtifact != nil { return obj.ModelArtifact } // all schemas are nil return nil } type NullableArtifact struct { value *Artifact isSet bool } func (v NullableArtifact) Get() *Artifact { return v.value } func (v *NullableArtifact) Set(val *Artifact) { v.value = val v.isSet = true } func (v NullableArtifact) IsSet() bool { return v.isSet } func (v *NullableArtifact) Unset() { v.value = nil v.isSet = false } func NewNullableArtifact(val *Artifact) *NullableArtifact { return &NullableArtifact{value: val, isSet: true} } func (v NullableArtifact) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } func (v *NullableArtifact) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) }