Files
sdk/model_post_event_request.go

245 lines
5.9 KiB
Go

/*
Hanzo Cloud API
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
API version: v1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hanzoai
import (
"encoding/json"
"fmt"
"gopkg.in/validator.v2"
)
// PostEventRequest - struct for PostEventRequest
type PostEventRequest struct {
CaptureBatch *CaptureBatch
CaptureEvent *CaptureEvent
InsightsBody *InsightsBody
ArrayOfCaptureEvent *[]CaptureEvent
}
// CaptureBatchAsPostEventRequest is a convenience function that returns CaptureBatch wrapped in PostEventRequest
func CaptureBatchAsPostEventRequest(v *CaptureBatch) PostEventRequest {
return PostEventRequest{
CaptureBatch: v,
}
}
// CaptureEventAsPostEventRequest is a convenience function that returns CaptureEvent wrapped in PostEventRequest
func CaptureEventAsPostEventRequest(v *CaptureEvent) PostEventRequest {
return PostEventRequest{
CaptureEvent: v,
}
}
// InsightsBodyAsPostEventRequest is a convenience function that returns InsightsBody wrapped in PostEventRequest
func InsightsBodyAsPostEventRequest(v *InsightsBody) PostEventRequest {
return PostEventRequest{
InsightsBody: v,
}
}
// []CaptureEventAsPostEventRequest is a convenience function that returns []CaptureEvent wrapped in PostEventRequest
func ArrayOfCaptureEventAsPostEventRequest(v *[]CaptureEvent) PostEventRequest {
return PostEventRequest{
ArrayOfCaptureEvent: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *PostEventRequest) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into CaptureBatch
err = newStrictDecoder(data).Decode(&dst.CaptureBatch)
if err == nil {
jsonCaptureBatch, _ := json.Marshal(dst.CaptureBatch)
if string(jsonCaptureBatch) == "{}" { // empty struct
dst.CaptureBatch = nil
} else {
if err = validator.Validate(dst.CaptureBatch); err != nil {
dst.CaptureBatch = nil
} else {
match++
}
}
} else {
dst.CaptureBatch = nil
}
// try to unmarshal data into CaptureEvent
err = newStrictDecoder(data).Decode(&dst.CaptureEvent)
if err == nil {
jsonCaptureEvent, _ := json.Marshal(dst.CaptureEvent)
if string(jsonCaptureEvent) == "{}" { // empty struct
dst.CaptureEvent = nil
} else {
if err = validator.Validate(dst.CaptureEvent); err != nil {
dst.CaptureEvent = nil
} else {
match++
}
}
} else {
dst.CaptureEvent = nil
}
// try to unmarshal data into InsightsBody
err = newStrictDecoder(data).Decode(&dst.InsightsBody)
if err == nil {
jsonInsightsBody, _ := json.Marshal(dst.InsightsBody)
if string(jsonInsightsBody) == "{}" { // empty struct
dst.InsightsBody = nil
} else {
if err = validator.Validate(dst.InsightsBody); err != nil {
dst.InsightsBody = nil
} else {
match++
}
}
} else {
dst.InsightsBody = nil
}
// try to unmarshal data into ArrayOfCaptureEvent
err = newStrictDecoder(data).Decode(&dst.ArrayOfCaptureEvent)
if err == nil {
jsonArrayOfCaptureEvent, _ := json.Marshal(dst.ArrayOfCaptureEvent)
if string(jsonArrayOfCaptureEvent) == "{}" { // empty struct
dst.ArrayOfCaptureEvent = nil
} else {
if err = validator.Validate(dst.ArrayOfCaptureEvent); err != nil {
dst.ArrayOfCaptureEvent = nil
} else {
match++
}
}
} else {
dst.ArrayOfCaptureEvent = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.CaptureBatch = nil
dst.CaptureEvent = nil
dst.InsightsBody = nil
dst.ArrayOfCaptureEvent = nil
return fmt.Errorf("data matches more than one schema in oneOf(PostEventRequest)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("data failed to match schemas in oneOf(PostEventRequest)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src PostEventRequest) MarshalJSON() ([]byte, error) {
if src.CaptureBatch != nil {
return json.Marshal(&src.CaptureBatch)
}
if src.CaptureEvent != nil {
return json.Marshal(&src.CaptureEvent)
}
if src.InsightsBody != nil {
return json.Marshal(&src.InsightsBody)
}
if src.ArrayOfCaptureEvent != nil {
return json.Marshal(&src.ArrayOfCaptureEvent)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *PostEventRequest) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.CaptureBatch != nil {
return obj.CaptureBatch
}
if obj.CaptureEvent != nil {
return obj.CaptureEvent
}
if obj.InsightsBody != nil {
return obj.InsightsBody
}
if obj.ArrayOfCaptureEvent != nil {
return obj.ArrayOfCaptureEvent
}
// all schemas are nil
return nil
}
// Get the actual instance value
func (obj PostEventRequest) GetActualInstanceValue() interface{} {
if obj.CaptureBatch != nil {
return *obj.CaptureBatch
}
if obj.CaptureEvent != nil {
return *obj.CaptureEvent
}
if obj.InsightsBody != nil {
return *obj.InsightsBody
}
if obj.ArrayOfCaptureEvent != nil {
return *obj.ArrayOfCaptureEvent
}
// all schemas are nil
return nil
}
type NullablePostEventRequest struct {
value *PostEventRequest
isSet bool
}
func (v NullablePostEventRequest) Get() *PostEventRequest {
return v.value
}
func (v *NullablePostEventRequest) Set(val *PostEventRequest) {
v.value = val
v.isSet = true
}
func (v NullablePostEventRequest) IsSet() bool {
return v.isSet
}
func (v *NullablePostEventRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullablePostEventRequest(val *PostEventRequest) *NullablePostEventRequest {
return &NullablePostEventRequest{value: val, isSet: true}
}
func (v NullablePostEventRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullablePostEventRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}