-
Notifications
You must be signed in to change notification settings - Fork 1
/
JsonPatch.go
207 lines (174 loc) · 4.15 KB
/
JsonPatch.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package cdk8s
import (
_jsii_ "github.com/aws/jsii-runtime-go/runtime"
_init_ "github.com/cdk8s-team/cdk8s-core-go/cdk8s/jsii"
)
// Utility for applying RFC-6902 JSON-Patch to a document.
//
// Use the the `JsonPatch.apply(doc, ...ops)` function to apply a set of
// operations to a JSON document and return the result.
//
// Operations can be created using the factory methods `JsonPatch.add()`,
// `JsonPatch.remove()`, etc.
//
// Example:
// const output = JsonPatch.apply(input,
// JsonPatch.replace('/world/hi/there', 'goodbye'),
// JsonPatch.add('/world/foo/', 'boom'),
// JsonPatch.remove('/hello'));
//
type JsonPatch interface {
}
// The jsii proxy struct for JsonPatch
type jsiiProxy_JsonPatch struct {
_ byte // padding
}
// Adds a value to an object or inserts it into an array.
//
// In the case of an
// array, the value is inserted before the given index. The - character can be
// used instead of an index to insert at the end of an array.
//
// Example:
// JsonPatch.add('/biscuits/1', { "name": "Ginger Nut" })
//
func JsonPatch_Add(path *string, value interface{}) JsonPatch {
_init_.Initialize()
if err := validateJsonPatch_AddParameters(path, value); err != nil {
panic(err)
}
var returns JsonPatch
_jsii_.StaticInvoke(
"cdk8s.JsonPatch",
"add",
[]interface{}{path, value},
&returns,
)
return returns
}
// Applies a set of JSON-Patch (RFC-6902) operations to `document` and returns the result.
//
// Returns: The result document.
func JsonPatch_Apply(document interface{}, ops ...JsonPatch) interface{} {
_init_.Initialize()
if err := validateJsonPatch_ApplyParameters(document); err != nil {
panic(err)
}
args := []interface{}{document}
for _, a := range ops {
args = append(args, a)
}
var returns interface{}
_jsii_.StaticInvoke(
"cdk8s.JsonPatch",
"apply",
args,
&returns,
)
return returns
}
// Copies a value from one location to another within the JSON document.
//
// Both
// from and path are JSON Pointers.
//
// Example:
// JsonPatch.copy('/biscuits/0', '/best_biscuit')
//
func JsonPatch_Copy(from *string, path *string) JsonPatch {
_init_.Initialize()
if err := validateJsonPatch_CopyParameters(from, path); err != nil {
panic(err)
}
var returns JsonPatch
_jsii_.StaticInvoke(
"cdk8s.JsonPatch",
"copy",
[]interface{}{from, path},
&returns,
)
return returns
}
// Moves a value from one location to the other.
//
// Both from and path are JSON Pointers.
//
// Example:
// JsonPatch.move('/biscuits', '/cookies')
//
func JsonPatch_Move(from *string, path *string) JsonPatch {
_init_.Initialize()
if err := validateJsonPatch_MoveParameters(from, path); err != nil {
panic(err)
}
var returns JsonPatch
_jsii_.StaticInvoke(
"cdk8s.JsonPatch",
"move",
[]interface{}{from, path},
&returns,
)
return returns
}
// Removes a value from an object or array.
//
// Example:
// JsonPatch.remove('/biscuits/0')
//
func JsonPatch_Remove(path *string) JsonPatch {
_init_.Initialize()
if err := validateJsonPatch_RemoveParameters(path); err != nil {
panic(err)
}
var returns JsonPatch
_jsii_.StaticInvoke(
"cdk8s.JsonPatch",
"remove",
[]interface{}{path},
&returns,
)
return returns
}
// Replaces a value.
//
// Equivalent to a “remove” followed by an “add”.
//
// Example:
// JsonPatch.replace('/biscuits/0/name', 'Chocolate Digestive')
//
func JsonPatch_Replace(path *string, value interface{}) JsonPatch {
_init_.Initialize()
if err := validateJsonPatch_ReplaceParameters(path, value); err != nil {
panic(err)
}
var returns JsonPatch
_jsii_.StaticInvoke(
"cdk8s.JsonPatch",
"replace",
[]interface{}{path, value},
&returns,
)
return returns
}
// Tests that the specified value is set in the document.
//
// If the test fails,
// then the patch as a whole should not apply.
//
// Example:
// JsonPatch.test('/best_biscuit/name', 'Choco Leibniz')
//
func JsonPatch_Test(path *string, value interface{}) JsonPatch {
_init_.Initialize()
if err := validateJsonPatch_TestParameters(path, value); err != nil {
panic(err)
}
var returns JsonPatch
_jsii_.StaticInvoke(
"cdk8s.JsonPatch",
"test",
[]interface{}{path, value},
&returns,
)
return returns
}