bunnyshell.com/sdk@v0.16.0/model_container_config_item_profile.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 // ContainerConfigItemProfile - A profile config or a profile name for local usage with rdev.yaml 20 type ContainerConfigItemProfile struct { 21 ProfileItem *ProfileItem 22 String *string 23 } 24 25 // ProfileItemAsContainerConfigItemProfile is a convenience function that returns ProfileItem wrapped in ContainerConfigItemProfile 26 func ProfileItemAsContainerConfigItemProfile(v *ProfileItem) ContainerConfigItemProfile { 27 return ContainerConfigItemProfile{ 28 ProfileItem: v, 29 } 30 } 31 32 // stringAsContainerConfigItemProfile is a convenience function that returns string wrapped in ContainerConfigItemProfile 33 func StringAsContainerConfigItemProfile(v *string) ContainerConfigItemProfile { 34 return ContainerConfigItemProfile{ 35 String: v, 36 } 37 } 38 39 // Unmarshal JSON data into one of the pointers in the struct 40 func (dst *ContainerConfigItemProfile) UnmarshalJSON(data []byte) error { 41 var err error 42 match := 0 43 // try to unmarshal data into ProfileItem 44 err = json.Unmarshal(data, &dst.ProfileItem) 45 if err == nil { 46 jsonProfileItem, _ := json.Marshal(dst.ProfileItem) 47 if string(jsonProfileItem) == "{}" { // empty struct 48 dst.ProfileItem = nil 49 } else { 50 match++ 51 } 52 } else { 53 dst.ProfileItem = nil 54 } 55 56 // try to unmarshal data into String 57 err = json.Unmarshal(data, &dst.String) 58 if err == nil { 59 jsonString, _ := json.Marshal(dst.String) 60 if string(jsonString) == "{}" { // empty struct 61 dst.String = nil 62 } else { 63 match++ 64 } 65 } else { 66 dst.String = nil 67 } 68 69 if match > 1 { // more than 1 match 70 // reset to nil 71 dst.ProfileItem = nil 72 dst.String = nil 73 74 return fmt.Errorf("data matches more than one schema in oneOf(ContainerConfigItemProfile)") 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(ContainerConfigItemProfile)") 79 } 80 } 81 82 // Marshal data from the first non-nil pointers in the struct to JSON 83 func (src ContainerConfigItemProfile) MarshalJSON() ([]byte, error) { 84 if src.ProfileItem != nil { 85 return json.Marshal(&src.ProfileItem) 86 } 87 88 if src.String != nil { 89 return json.Marshal(&src.String) 90 } 91 92 return nil, nil // no data in oneOf schemas 93 } 94 95 // Get the actual instance 96 func (obj *ContainerConfigItemProfile) GetActualInstance() interface{} { 97 if obj == nil { 98 return nil 99 } 100 if obj.ProfileItem != nil { 101 return obj.ProfileItem 102 } 103 104 if obj.String != nil { 105 return obj.String 106 } 107 108 // all schemas are nil 109 return nil 110 } 111 112 type NullableContainerConfigItemProfile struct { 113 value *ContainerConfigItemProfile 114 isSet bool 115 } 116 117 func (v NullableContainerConfigItemProfile) Get() *ContainerConfigItemProfile { 118 return v.value 119 } 120 121 func (v *NullableContainerConfigItemProfile) Set(val *ContainerConfigItemProfile) { 122 v.value = val 123 v.isSet = true 124 } 125 126 func (v NullableContainerConfigItemProfile) IsSet() bool { 127 return v.isSet 128 } 129 130 func (v *NullableContainerConfigItemProfile) Unset() { 131 v.value = nil 132 v.isSet = false 133 } 134 135 func NewNullableContainerConfigItemProfile(val *ContainerConfigItemProfile) *NullableContainerConfigItemProfile { 136 return &NullableContainerConfigItemProfile{value: val, isSet: true} 137 } 138 139 func (v NullableContainerConfigItemProfile) MarshalJSON() ([]byte, error) { 140 return json.Marshal(v.value) 141 } 142 143 func (v *NullableContainerConfigItemProfile) UnmarshalJSON(src []byte) error { 144 v.isSet = true 145 return json.Unmarshal(src, &v.value) 146 }