/
zz_generated_openshiftclusterdocument.go
313 lines (252 loc) · 10.4 KB
/
zz_generated_openshiftclusterdocument.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
// Code generated by github.com/jewzaam/go-cosmosdb, DO NOT EDIT.
package cosmosdb
import (
"context"
"net/http"
"strconv"
"strings"
pkg "github.com/Azure/ARO-RP/pkg/api"
)
type openShiftClusterDocumentClient struct {
*databaseClient
path string
}
// OpenShiftClusterDocumentClient is a openShiftClusterDocument client
type OpenShiftClusterDocumentClient interface {
Create(context.Context, string, *pkg.OpenShiftClusterDocument, *Options) (*pkg.OpenShiftClusterDocument, error)
List(*Options) OpenShiftClusterDocumentIterator
ListAll(context.Context, *Options) (*pkg.OpenShiftClusterDocuments, error)
Get(context.Context, string, string, *Options) (*pkg.OpenShiftClusterDocument, error)
Replace(context.Context, string, *pkg.OpenShiftClusterDocument, *Options) (*pkg.OpenShiftClusterDocument, error)
Delete(context.Context, string, *pkg.OpenShiftClusterDocument, *Options) error
Query(string, *Query, *Options) OpenShiftClusterDocumentRawIterator
QueryAll(context.Context, string, *Query, *Options) (*pkg.OpenShiftClusterDocuments, error)
ChangeFeed(*Options) OpenShiftClusterDocumentIterator
}
type openShiftClusterDocumentChangeFeedIterator struct {
*openShiftClusterDocumentClient
continuation string
options *Options
}
type openShiftClusterDocumentListIterator struct {
*openShiftClusterDocumentClient
continuation string
done bool
options *Options
}
type openShiftClusterDocumentQueryIterator struct {
*openShiftClusterDocumentClient
partitionkey string
query *Query
continuation string
done bool
options *Options
}
// OpenShiftClusterDocumentIterator is a openShiftClusterDocument iterator
type OpenShiftClusterDocumentIterator interface {
Next(context.Context, int) (*pkg.OpenShiftClusterDocuments, error)
Continuation() string
}
// OpenShiftClusterDocumentRawIterator is a openShiftClusterDocument raw iterator
type OpenShiftClusterDocumentRawIterator interface {
OpenShiftClusterDocumentIterator
NextRaw(context.Context, int, interface{}) error
}
// NewOpenShiftClusterDocumentClient returns a new openShiftClusterDocument client
func NewOpenShiftClusterDocumentClient(collc CollectionClient, collid string) OpenShiftClusterDocumentClient {
return &openShiftClusterDocumentClient{
databaseClient: collc.(*collectionClient).databaseClient,
path: collc.(*collectionClient).path + "/colls/" + collid,
}
}
func (c *openShiftClusterDocumentClient) all(ctx context.Context, i OpenShiftClusterDocumentIterator) (*pkg.OpenShiftClusterDocuments, error) {
allopenShiftClusterDocuments := &pkg.OpenShiftClusterDocuments{}
for {
openShiftClusterDocuments, err := i.Next(ctx, -1)
if err != nil {
return nil, err
}
if openShiftClusterDocuments == nil {
break
}
allopenShiftClusterDocuments.Count += openShiftClusterDocuments.Count
allopenShiftClusterDocuments.ResourceID = openShiftClusterDocuments.ResourceID
allopenShiftClusterDocuments.OpenShiftClusterDocuments = append(allopenShiftClusterDocuments.OpenShiftClusterDocuments, openShiftClusterDocuments.OpenShiftClusterDocuments...)
}
return allopenShiftClusterDocuments, nil
}
func (c *openShiftClusterDocumentClient) Create(ctx context.Context, partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
headers := http.Header{}
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
if options == nil {
options = &Options{}
}
options.NoETag = true
err = c.setOptions(options, newopenShiftClusterDocument, headers)
if err != nil {
return
}
err = c.do(ctx, http.MethodPost, c.path+"/docs", "docs", c.path, http.StatusCreated, &newopenShiftClusterDocument, &openShiftClusterDocument, headers)
return
}
func (c *openShiftClusterDocumentClient) List(options *Options) OpenShiftClusterDocumentIterator {
continuation := ""
if options != nil {
continuation = options.Continuation
}
return &openShiftClusterDocumentListIterator{openShiftClusterDocumentClient: c, options: options, continuation: continuation}
}
func (c *openShiftClusterDocumentClient) ListAll(ctx context.Context, options *Options) (*pkg.OpenShiftClusterDocuments, error) {
return c.all(ctx, c.List(options))
}
func (c *openShiftClusterDocumentClient) Get(ctx context.Context, partitionkey, openShiftClusterDocumentid string, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
headers := http.Header{}
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
err = c.setOptions(options, nil, headers)
if err != nil {
return
}
err = c.do(ctx, http.MethodGet, c.path+"/docs/"+openShiftClusterDocumentid, "docs", c.path+"/docs/"+openShiftClusterDocumentid, http.StatusOK, nil, &openShiftClusterDocument, headers)
return
}
func (c *openShiftClusterDocumentClient) Replace(ctx context.Context, partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
headers := http.Header{}
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
err = c.setOptions(options, newopenShiftClusterDocument, headers)
if err != nil {
return
}
err = c.do(ctx, http.MethodPut, c.path+"/docs/"+newopenShiftClusterDocument.ID, "docs", c.path+"/docs/"+newopenShiftClusterDocument.ID, http.StatusOK, &newopenShiftClusterDocument, &openShiftClusterDocument, headers)
return
}
func (c *openShiftClusterDocumentClient) Delete(ctx context.Context, partitionkey string, openShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (err error) {
headers := http.Header{}
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
err = c.setOptions(options, openShiftClusterDocument, headers)
if err != nil {
return
}
err = c.do(ctx, http.MethodDelete, c.path+"/docs/"+openShiftClusterDocument.ID, "docs", c.path+"/docs/"+openShiftClusterDocument.ID, http.StatusNoContent, nil, nil, headers)
return
}
func (c *openShiftClusterDocumentClient) Query(partitionkey string, query *Query, options *Options) OpenShiftClusterDocumentRawIterator {
continuation := ""
if options != nil {
continuation = options.Continuation
}
return &openShiftClusterDocumentQueryIterator{openShiftClusterDocumentClient: c, partitionkey: partitionkey, query: query, options: options, continuation: continuation}
}
func (c *openShiftClusterDocumentClient) QueryAll(ctx context.Context, partitionkey string, query *Query, options *Options) (*pkg.OpenShiftClusterDocuments, error) {
return c.all(ctx, c.Query(partitionkey, query, options))
}
func (c *openShiftClusterDocumentClient) ChangeFeed(options *Options) OpenShiftClusterDocumentIterator {
continuation := ""
if options != nil {
continuation = options.Continuation
}
return &openShiftClusterDocumentChangeFeedIterator{openShiftClusterDocumentClient: c, options: options, continuation: continuation}
}
func (c *openShiftClusterDocumentClient) setOptions(options *Options, openShiftClusterDocument *pkg.OpenShiftClusterDocument, headers http.Header) error {
if options == nil {
return nil
}
if openShiftClusterDocument != nil && !options.NoETag {
if openShiftClusterDocument.ETag == "" {
return ErrETagRequired
}
headers.Set("If-Match", openShiftClusterDocument.ETag)
}
if len(options.PreTriggers) > 0 {
headers.Set("X-Ms-Documentdb-Pre-Trigger-Include", strings.Join(options.PreTriggers, ","))
}
if len(options.PostTriggers) > 0 {
headers.Set("X-Ms-Documentdb-Post-Trigger-Include", strings.Join(options.PostTriggers, ","))
}
if len(options.PartitionKeyRangeID) > 0 {
headers.Set("X-Ms-Documentdb-PartitionKeyRangeID", options.PartitionKeyRangeID)
}
return nil
}
func (i *openShiftClusterDocumentChangeFeedIterator) Next(ctx context.Context, maxItemCount int) (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) {
headers := http.Header{}
headers.Set("A-IM", "Incremental feed")
headers.Set("X-Ms-Max-Item-Count", strconv.Itoa(maxItemCount))
if i.continuation != "" {
headers.Set("If-None-Match", i.continuation)
}
err = i.setOptions(i.options, nil, headers)
if err != nil {
return
}
err = i.do(ctx, http.MethodGet, i.path+"/docs", "docs", i.path, http.StatusOK, nil, &openShiftClusterDocuments, headers)
if IsErrorStatusCode(err, http.StatusNotModified) {
err = nil
}
if err != nil {
return
}
i.continuation = headers.Get("Etag")
return
}
func (i *openShiftClusterDocumentChangeFeedIterator) Continuation() string {
return i.continuation
}
func (i *openShiftClusterDocumentListIterator) Next(ctx context.Context, maxItemCount int) (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) {
if i.done {
return
}
headers := http.Header{}
headers.Set("X-Ms-Max-Item-Count", strconv.Itoa(maxItemCount))
if i.continuation != "" {
headers.Set("X-Ms-Continuation", i.continuation)
}
err = i.setOptions(i.options, nil, headers)
if err != nil {
return
}
err = i.do(ctx, http.MethodGet, i.path+"/docs", "docs", i.path, http.StatusOK, nil, &openShiftClusterDocuments, headers)
if err != nil {
return
}
i.continuation = headers.Get("X-Ms-Continuation")
i.done = i.continuation == ""
return
}
func (i *openShiftClusterDocumentListIterator) Continuation() string {
return i.continuation
}
func (i *openShiftClusterDocumentQueryIterator) Next(ctx context.Context, maxItemCount int) (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) {
err = i.NextRaw(ctx, maxItemCount, &openShiftClusterDocuments)
return
}
func (i *openShiftClusterDocumentQueryIterator) NextRaw(ctx context.Context, maxItemCount int, raw interface{}) (err error) {
if i.done {
return
}
headers := http.Header{}
headers.Set("X-Ms-Max-Item-Count", strconv.Itoa(maxItemCount))
headers.Set("X-Ms-Documentdb-Isquery", "True")
headers.Set("Content-Type", "application/query+json")
if i.partitionkey != "" {
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+i.partitionkey+`"]`)
} else {
headers.Set("X-Ms-Documentdb-Query-Enablecrosspartition", "True")
}
if i.continuation != "" {
headers.Set("X-Ms-Continuation", i.continuation)
}
err = i.setOptions(i.options, nil, headers)
if err != nil {
return
}
err = i.do(ctx, http.MethodPost, i.path+"/docs", "docs", i.path, http.StatusOK, &i.query, &raw, headers)
if err != nil {
return
}
i.continuation = headers.Get("X-Ms-Continuation")
i.done = i.continuation == ""
return
}
func (i *openShiftClusterDocumentQueryIterator) Continuation() string {
return i.continuation
}