bunnyshell.com/sdk@v0.16.0/model_environment_edit_components_action_filter.go (about) 1 /* 2 API Bunnyshell Environments 3 4 Interact with Bunnyshell Platform 5 6 API version: 1.1.0 7 Contact: osi+support@bunnyshell.com 8 */ 9 10 // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 11 12 package sdk 13 14 import ( 15 "encoding/json" 16 "fmt" 17 ) 18 19 // EnvironmentEditComponentsActionFilter - struct for EnvironmentEditComponentsActionFilter 20 type EnvironmentEditComponentsActionFilter struct { 21 FilterGit *FilterGit 22 FilterName *FilterName 23 } 24 25 // FilterGitAsEnvironmentEditComponentsActionFilter is a convenience function that returns FilterGit wrapped in EnvironmentEditComponentsActionFilter 26 func FilterGitAsEnvironmentEditComponentsActionFilter(v *FilterGit) EnvironmentEditComponentsActionFilter { 27 return EnvironmentEditComponentsActionFilter{ 28 FilterGit: v, 29 } 30 } 31 32 // FilterNameAsEnvironmentEditComponentsActionFilter is a convenience function that returns FilterName wrapped in EnvironmentEditComponentsActionFilter 33 func FilterNameAsEnvironmentEditComponentsActionFilter(v *FilterName) EnvironmentEditComponentsActionFilter { 34 return EnvironmentEditComponentsActionFilter{ 35 FilterName: v, 36 } 37 } 38 39 // Unmarshal JSON data into one of the pointers in the struct 40 func (dst *EnvironmentEditComponentsActionFilter) UnmarshalJSON(data []byte) error { 41 var err error 42 match := 0 43 // try to unmarshal data into FilterGit 44 err = json.Unmarshal(data, &dst.FilterGit) 45 if err == nil { 46 jsonFilterGit, _ := json.Marshal(dst.FilterGit) 47 if string(jsonFilterGit) == "{}" { // empty struct 48 dst.FilterGit = nil 49 } else { 50 match++ 51 } 52 } else { 53 dst.FilterGit = nil 54 } 55 56 // try to unmarshal data into FilterName 57 err = json.Unmarshal(data, &dst.FilterName) 58 if err == nil { 59 jsonFilterName, _ := json.Marshal(dst.FilterName) 60 if string(jsonFilterName) == "{}" { // empty struct 61 dst.FilterName = nil 62 } else { 63 match++ 64 } 65 } else { 66 dst.FilterName = nil 67 } 68 69 if match > 1 { // more than 1 match 70 // reset to nil 71 dst.FilterGit = nil 72 dst.FilterName = nil 73 74 return fmt.Errorf("data matches more than one schema in oneOf(EnvironmentEditComponentsActionFilter)") 75 } else if match == 1 { 76 return nil // exactly one match 77 } else { // no match 78 return fmt.Errorf("data failed to match schemas in oneOf(EnvironmentEditComponentsActionFilter)") 79 } 80 } 81 82 // Marshal data from the first non-nil pointers in the struct to JSON 83 func (src EnvironmentEditComponentsActionFilter) MarshalJSON() ([]byte, error) { 84 if src.FilterGit != nil { 85 return json.Marshal(&src.FilterGit) 86 } 87 88 if src.FilterName != nil { 89 return json.Marshal(&src.FilterName) 90 } 91 92 return nil, nil // no data in oneOf schemas 93 } 94 95 // Get the actual instance 96 func (obj *EnvironmentEditComponentsActionFilter) GetActualInstance() interface{} { 97 if obj == nil { 98 return nil 99 } 100 if obj.FilterGit != nil { 101 return obj.FilterGit 102 } 103 104 if obj.FilterName != nil { 105 return obj.FilterName 106 } 107 108 // all schemas are nil 109 return nil 110 } 111 112 type NullableEnvironmentEditComponentsActionFilter struct { 113 value *EnvironmentEditComponentsActionFilter 114 isSet bool 115 } 116 117 func (v NullableEnvironmentEditComponentsActionFilter) Get() *EnvironmentEditComponentsActionFilter { 118 return v.value 119 } 120 121 func (v *NullableEnvironmentEditComponentsActionFilter) Set(val *EnvironmentEditComponentsActionFilter) { 122 v.value = val 123 v.isSet = true 124 } 125 126 func (v NullableEnvironmentEditComponentsActionFilter) IsSet() bool { 127 return v.isSet 128 } 129 130 func (v *NullableEnvironmentEditComponentsActionFilter) Unset() { 131 v.value = nil 132 v.isSet = false 133 } 134 135 func NewNullableEnvironmentEditComponentsActionFilter(val *EnvironmentEditComponentsActionFilter) *NullableEnvironmentEditComponentsActionFilter { 136 return &NullableEnvironmentEditComponentsActionFilter{value: val, isSet: true} 137 } 138 139 func (v NullableEnvironmentEditComponentsActionFilter) MarshalJSON() ([]byte, error) { 140 return json.Marshal(v.value) 141 } 142 143 func (v *NullableEnvironmentEditComponentsActionFilter) UnmarshalJSON(src []byte) error { 144 v.isSet = true 145 return json.Unmarshal(src, &v.value) 146 }