-
Notifications
You must be signed in to change notification settings - Fork 2
/
rfc6902_patch_operation.go
129 lines (102 loc) · 3.7 KB
/
rfc6902_patch_operation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"encoding/json"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// Rfc6902PatchOperation rfc6902 patch operation
//
// swagger:model Rfc6902PatchOperation
type Rfc6902PatchOperation struct {
// Each operation must have at least one `op` member, which value indicates
// the actual operation to be performed against the target (current) configuration.
// For a detailed description of available operations,
// see the [Operations #4 section of the RFC6902 specification](https://datatracker.ietf.org/doc/html/rfc6902#section-4).
// Enum: [add remove replace move copy test]
Op string `json:"op,omitempty" yaml:"op,omitempty"`
// String containing a JSON-Pointer value ([RFC6901](https://datatracker.ietf.org/doc/html/rfc6901))
// that references a location within the target configuration where the operation is performed.
//
// For available paths, reference the exported configuration.
Path string `json:"path,omitempty" yaml:"path,omitempty"`
// New object value applied to the patched (target) configuration.
Value interface{} `json:"value,omitempty" yaml:"value,omitempty"`
}
// Validate validates this rfc6902 patch operation
func (m *Rfc6902PatchOperation) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateOp(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var rfc6902PatchOperationTypeOpPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["add","remove","replace","move","copy","test"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
rfc6902PatchOperationTypeOpPropEnum = append(rfc6902PatchOperationTypeOpPropEnum, v)
}
}
const (
// Rfc6902PatchOperationOpAdd captures enum value "add"
Rfc6902PatchOperationOpAdd string = "add"
// Rfc6902PatchOperationOpRemove captures enum value "remove"
Rfc6902PatchOperationOpRemove string = "remove"
// Rfc6902PatchOperationOpReplace captures enum value "replace"
Rfc6902PatchOperationOpReplace string = "replace"
// Rfc6902PatchOperationOpMove captures enum value "move"
Rfc6902PatchOperationOpMove string = "move"
// Rfc6902PatchOperationOpCopy captures enum value "copy"
Rfc6902PatchOperationOpCopy string = "copy"
// Rfc6902PatchOperationOpTest captures enum value "test"
Rfc6902PatchOperationOpTest string = "test"
)
// prop value enum
func (m *Rfc6902PatchOperation) validateOpEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, rfc6902PatchOperationTypeOpPropEnum, true); err != nil {
return err
}
return nil
}
func (m *Rfc6902PatchOperation) validateOp(formats strfmt.Registry) error {
if swag.IsZero(m.Op) { // not required
return nil
}
// value enum
if err := m.validateOpEnum("op", "body", m.Op); err != nil {
return err
}
return nil
}
// ContextValidate validates this rfc6902 patch operation based on context it is used
func (m *Rfc6902PatchOperation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *Rfc6902PatchOperation) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Rfc6902PatchOperation) UnmarshalBinary(b []byte) error {
var res Rfc6902PatchOperation
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}