github.com/cilium/cilium@v1.16.2/api/v1/models/encryption_status.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright Authors of Cilium 4 // SPDX-License-Identifier: Apache-2.0 5 6 package models 7 8 // This file was generated by the swagger tool. 9 // Editing this file might prove futile when you re-run the swagger generate command 10 11 import ( 12 "context" 13 "encoding/json" 14 15 "github.com/go-openapi/errors" 16 "github.com/go-openapi/strfmt" 17 "github.com/go-openapi/swag" 18 "github.com/go-openapi/validate" 19 ) 20 21 // EncryptionStatus Status of transparent encryption 22 // 23 // +k8s:deepcopy-gen=true 24 // 25 // swagger:model EncryptionStatus 26 type EncryptionStatus struct { 27 28 // Status of the IPsec agent 29 Ipsec *IPsecStatus `json:"ipsec,omitempty"` 30 31 // mode 32 // Enum: [Disabled IPsec Wireguard] 33 Mode string `json:"mode,omitempty"` 34 35 // Human readable error/warning message 36 Msg string `json:"msg,omitempty"` 37 38 // Status of the WireGuard agent 39 Wireguard *WireguardStatus `json:"wireguard,omitempty"` 40 } 41 42 // Validate validates this encryption status 43 func (m *EncryptionStatus) Validate(formats strfmt.Registry) error { 44 var res []error 45 46 if err := m.validateIpsec(formats); err != nil { 47 res = append(res, err) 48 } 49 50 if err := m.validateMode(formats); err != nil { 51 res = append(res, err) 52 } 53 54 if err := m.validateWireguard(formats); err != nil { 55 res = append(res, err) 56 } 57 58 if len(res) > 0 { 59 return errors.CompositeValidationError(res...) 60 } 61 return nil 62 } 63 64 func (m *EncryptionStatus) validateIpsec(formats strfmt.Registry) error { 65 if swag.IsZero(m.Ipsec) { // not required 66 return nil 67 } 68 69 if m.Ipsec != nil { 70 if err := m.Ipsec.Validate(formats); err != nil { 71 if ve, ok := err.(*errors.Validation); ok { 72 return ve.ValidateName("ipsec") 73 } else if ce, ok := err.(*errors.CompositeError); ok { 74 return ce.ValidateName("ipsec") 75 } 76 return err 77 } 78 } 79 80 return nil 81 } 82 83 var encryptionStatusTypeModePropEnum []interface{} 84 85 func init() { 86 var res []string 87 if err := json.Unmarshal([]byte(`["Disabled","IPsec","Wireguard"]`), &res); err != nil { 88 panic(err) 89 } 90 for _, v := range res { 91 encryptionStatusTypeModePropEnum = append(encryptionStatusTypeModePropEnum, v) 92 } 93 } 94 95 const ( 96 97 // EncryptionStatusModeDisabled captures enum value "Disabled" 98 EncryptionStatusModeDisabled string = "Disabled" 99 100 // EncryptionStatusModeIPsec captures enum value "IPsec" 101 EncryptionStatusModeIPsec string = "IPsec" 102 103 // EncryptionStatusModeWireguard captures enum value "Wireguard" 104 EncryptionStatusModeWireguard string = "Wireguard" 105 ) 106 107 // prop value enum 108 func (m *EncryptionStatus) validateModeEnum(path, location string, value string) error { 109 if err := validate.EnumCase(path, location, value, encryptionStatusTypeModePropEnum, true); err != nil { 110 return err 111 } 112 return nil 113 } 114 115 func (m *EncryptionStatus) validateMode(formats strfmt.Registry) error { 116 if swag.IsZero(m.Mode) { // not required 117 return nil 118 } 119 120 // value enum 121 if err := m.validateModeEnum("mode", "body", m.Mode); err != nil { 122 return err 123 } 124 125 return nil 126 } 127 128 func (m *EncryptionStatus) validateWireguard(formats strfmt.Registry) error { 129 if swag.IsZero(m.Wireguard) { // not required 130 return nil 131 } 132 133 if m.Wireguard != nil { 134 if err := m.Wireguard.Validate(formats); err != nil { 135 if ve, ok := err.(*errors.Validation); ok { 136 return ve.ValidateName("wireguard") 137 } else if ce, ok := err.(*errors.CompositeError); ok { 138 return ce.ValidateName("wireguard") 139 } 140 return err 141 } 142 } 143 144 return nil 145 } 146 147 // ContextValidate validate this encryption status based on the context it is used 148 func (m *EncryptionStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 149 var res []error 150 151 if err := m.contextValidateIpsec(ctx, formats); err != nil { 152 res = append(res, err) 153 } 154 155 if err := m.contextValidateWireguard(ctx, formats); err != nil { 156 res = append(res, err) 157 } 158 159 if len(res) > 0 { 160 return errors.CompositeValidationError(res...) 161 } 162 return nil 163 } 164 165 func (m *EncryptionStatus) contextValidateIpsec(ctx context.Context, formats strfmt.Registry) error { 166 167 if m.Ipsec != nil { 168 169 if swag.IsZero(m.Ipsec) { // not required 170 return nil 171 } 172 173 if err := m.Ipsec.ContextValidate(ctx, formats); err != nil { 174 if ve, ok := err.(*errors.Validation); ok { 175 return ve.ValidateName("ipsec") 176 } else if ce, ok := err.(*errors.CompositeError); ok { 177 return ce.ValidateName("ipsec") 178 } 179 return err 180 } 181 } 182 183 return nil 184 } 185 186 func (m *EncryptionStatus) contextValidateWireguard(ctx context.Context, formats strfmt.Registry) error { 187 188 if m.Wireguard != nil { 189 190 if swag.IsZero(m.Wireguard) { // not required 191 return nil 192 } 193 194 if err := m.Wireguard.ContextValidate(ctx, formats); err != nil { 195 if ve, ok := err.(*errors.Validation); ok { 196 return ve.ValidateName("wireguard") 197 } else if ce, ok := err.(*errors.CompositeError); ok { 198 return ce.ValidateName("wireguard") 199 } 200 return err 201 } 202 } 203 204 return nil 205 } 206 207 // MarshalBinary interface implementation 208 func (m *EncryptionStatus) MarshalBinary() ([]byte, error) { 209 if m == nil { 210 return nil, nil 211 } 212 return swag.WriteJSON(m) 213 } 214 215 // UnmarshalBinary interface implementation 216 func (m *EncryptionStatus) UnmarshalBinary(b []byte) error { 217 var res EncryptionStatus 218 if err := swag.ReadJSON(b, &res); err != nil { 219 return err 220 } 221 *m = res 222 return nil 223 }