-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_branching_model.go
696 lines (615 loc) · 23.8 KB
/
api_branching_model.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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
/*
Bitbucket API
Code against the Bitbucket API to automate simple tasks, embed Bitbucket data into your own site, build mobile or desktop apps, or even add custom UI add-ons into Bitbucket itself using the Connect framework.
API version: 2.0
Contact: [email protected]
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package bitbucket
import (
"bytes"
"context"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
// BranchingModelApiService BranchingModelApi service
type BranchingModelApiService service
type BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelGetRequest struct {
ctx context.Context
ApiService *BranchingModelApiService
repoSlug string
workspace string
}
func (r BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelGetRequest) Execute() (*BranchingModel, *http.Response, error) {
return r.ApiService.RepositoriesWorkspaceRepoSlugBranchingModelGetExecute(r)
}
/*
RepositoriesWorkspaceRepoSlugBranchingModelGet Get the branching model for a repository
Return the branching model as applied to the repository. This view is
read-only. The branching model settings can be changed using the
[settings](branching-model/settings#get) API.
The returned object:
1. Always has a `development` property. `development.branch` contains
the actual repository branch object that is considered to be the
`development` branch. `development.branch` will not be present
if it does not exist.
2. Might have a `production` property. `production` will not
be present when `production` is disabled.
`production.branch` contains the actual branch object that is
considered to be the `production` branch. `production.branch` will
not be present if it does not exist.
3. Always has a `branch_types` array which contains all enabled branch
types.
Example body:
```
{
"development": {
"name": "master",
"branch": {
"type": "branch",
"name": "master",
"target": {
"hash": "16dffcb0de1b22e249db6799532074cf32efe80f"
}
},
"use_mainbranch": true
},
"production": {
"name": "production",
"branch": {
"type": "branch",
"name": "production",
"target": {
"hash": "16dffcb0de1b22e249db6799532074cf32efe80f"
}
},
"use_mainbranch": false
},
"branch_types": [
{
"kind": "release",
"prefix": "release/"
},
{
"kind": "hotfix",
"prefix": "hotfix/"
},
{
"kind": "feature",
"prefix": "feature/"
},
{
"kind": "bugfix",
"prefix": "bugfix/"
}
],
"type": "branching_model",
"links": {
"self": {
"href": "https://api.bitbucket.org/.../branching-model"
}
}
}
```
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param repoSlug This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`.
@param workspace This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`.
@return BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelGetRequest
*/
func (a *BranchingModelApiService) RepositoriesWorkspaceRepoSlugBranchingModelGet(ctx context.Context, repoSlug string, workspace string) BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelGetRequest {
return BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelGetRequest{
ApiService: a,
ctx: ctx,
repoSlug: repoSlug,
workspace: workspace,
}
}
// Execute executes the request
// @return BranchingModel
func (a *BranchingModelApiService) RepositoriesWorkspaceRepoSlugBranchingModelGetExecute(r BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelGetRequest) (*BranchingModel, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BranchingModel
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchingModelApiService.RepositoriesWorkspaceRepoSlugBranchingModelGet")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/repositories/{workspace}/{repo_slug}/branching-model"
localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", url.PathEscape(parameterToString(r.repoSlug, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"workspace"+"}", url.PathEscape(parameterToString(r.workspace, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.ctx != nil {
// API Key Authentication
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
if apiKey, ok := auth["api_key"]; ok {
var key string
if apiKey.Prefix != "" {
key = apiKey.Prefix + " " + apiKey.Key
} else {
key = apiKey.Key
}
localVarHeaderParams["Authorization"] = key
}
}
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsGetRequest struct {
ctx context.Context
ApiService *BranchingModelApiService
repoSlug string
workspace string
}
func (r BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsGetRequest) Execute() (*BranchingModelSettings, *http.Response, error) {
return r.ApiService.RepositoriesWorkspaceRepoSlugBranchingModelSettingsGetExecute(r)
}
/*
RepositoriesWorkspaceRepoSlugBranchingModelSettingsGet Get the branching model config for a repository
Return the branching model configuration for a repository. The returned
object:
1. Always has a `development` property for the development branch.
2. Always a `production` property for the production branch. The
production branch can be disabled.
3. The `branch_types` contains all the branch types.
This is the raw configuration for the branching model. A client
wishing to see the branching model with its actual current branches may
find the [active model API](/cloud/bitbucket/rest/api-group-branching-model/#api-repositories-workspace-repo-slug-branching-model-get) more useful.
Example body:
```
{
"development": {
"is_valid": true,
"name": null,
"use_mainbranch": true
},
"production": {
"is_valid": true,
"name": "production",
"use_mainbranch": false,
"enabled": false
},
"branch_types": [
{
"kind": "release",
"enabled": true,
"prefix": "release/"
},
{
"kind": "hotfix",
"enabled": true,
"prefix": "hotfix/"
},
{
"kind": "feature",
"enabled": true,
"prefix": "feature/"
},
{
"kind": "bugfix",
"enabled": false,
"prefix": "bugfix/"
}
],
"type": "branching_model_settings",
"links": {
"self": {
"href": "https://api.bitbucket.org/.../branching-model/settings"
}
}
}
```
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param repoSlug This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`.
@param workspace This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`.
@return BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsGetRequest
*/
func (a *BranchingModelApiService) RepositoriesWorkspaceRepoSlugBranchingModelSettingsGet(ctx context.Context, repoSlug string, workspace string) BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsGetRequest {
return BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsGetRequest{
ApiService: a,
ctx: ctx,
repoSlug: repoSlug,
workspace: workspace,
}
}
// Execute executes the request
// @return BranchingModelSettings
func (a *BranchingModelApiService) RepositoriesWorkspaceRepoSlugBranchingModelSettingsGetExecute(r BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsGetRequest) (*BranchingModelSettings, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BranchingModelSettings
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchingModelApiService.RepositoriesWorkspaceRepoSlugBranchingModelSettingsGet")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/repositories/{workspace}/{repo_slug}/branching-model/settings"
localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", url.PathEscape(parameterToString(r.repoSlug, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"workspace"+"}", url.PathEscape(parameterToString(r.workspace, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.ctx != nil {
// API Key Authentication
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
if apiKey, ok := auth["api_key"]; ok {
var key string
if apiKey.Prefix != "" {
key = apiKey.Prefix + " " + apiKey.Key
} else {
key = apiKey.Key
}
localVarHeaderParams["Authorization"] = key
}
}
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 401 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsPutRequest struct {
ctx context.Context
ApiService *BranchingModelApiService
repoSlug string
workspace string
}
func (r BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsPutRequest) Execute() (*BranchingModelSettings, *http.Response, error) {
return r.ApiService.RepositoriesWorkspaceRepoSlugBranchingModelSettingsPutExecute(r)
}
/*
RepositoriesWorkspaceRepoSlugBranchingModelSettingsPut Update the branching model config for a repository
Update the branching model configuration for a repository.
The `development` branch can be configured to a specific branch or to
track the main branch. When set to a specific branch it must
currently exist. Only the passed properties will be updated. The
properties not passed will be left unchanged. A request without a
`development` property will leave the development branch unchanged.
It is possible for the `development` branch to be invalid. This
happens when it points at a specific branch that has been
deleted. This is indicated in the `is_valid` field for the branch. It is
not possible to update the settings for `development` if that
would leave the branch in an invalid state. Such a request will be
rejected.
The `production` branch can be a specific branch, the main
branch or disabled. When set to a specific branch it must currently
exist. The `enabled` property can be used to enable (`true`) or
disable (`false`) it. Only the passed properties will be updated. The
properties not passed will be left unchanged. A request without a
`production` property will leave the production branch unchanged.
It is possible for the `production` branch to be invalid. This
happens when it points at a specific branch that has been
deleted. This is indicated in the `is_valid` field for the branch. A
request that would leave `production` enabled and invalid will be
rejected. It is possible to update `production` and make it invalid if
it would also be left disabled.
The `branch_types` property contains the branch types to be updated.
Only the branch types passed will be updated. All updates will be
rejected if it would leave the branching model in an invalid state.
For branch types this means that:
1. The prefixes for all enabled branch types are valid. For example,
it is not possible to use '*' inside a Git prefix.
2. A prefix of an enabled branch type must not be a prefix of another
enabled branch type. This is to ensure that a branch can be easily
classified by its prefix unambiguously.
It is possible to store an invalid prefix if that branch type would be
left disabled. Only the passed properties will be updated. The
properties not passed will be left unchanged. Each branch type must
have a `kind` property to identify it.
Example Body:
```
{
"development": {
"use_mainbranch": true
},
"production": {
"enabled": true,
"use_mainbranch": false,
"name": "production"
},
"branch_types": [
{
"kind": "bugfix",
"enabled": true,
"prefix": "bugfix/"
},
{
"kind": "feature",
"enabled": true,
"prefix": "feature/"
},
{
"kind": "hotfix",
"prefix": "hotfix/"
},
{
"kind": "release",
"enabled": false,
}
]
}
```
There is currently a side effect when using this API endpoint. If the
repository is inheriting branching model settings from its project,
updating the branching model for this repository will disable the
project setting inheritance.
We have deprecated this side effect and will remove it on 1 August 2022.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param repoSlug This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: `{repository UUID}`.
@param workspace This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: `{workspace UUID}`.
@return BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsPutRequest
*/
func (a *BranchingModelApiService) RepositoriesWorkspaceRepoSlugBranchingModelSettingsPut(ctx context.Context, repoSlug string, workspace string) BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsPutRequest {
return BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsPutRequest{
ApiService: a,
ctx: ctx,
repoSlug: repoSlug,
workspace: workspace,
}
}
// Execute executes the request
// @return BranchingModelSettings
func (a *BranchingModelApiService) RepositoriesWorkspaceRepoSlugBranchingModelSettingsPutExecute(r BranchingModelApiRepositoriesWorkspaceRepoSlugBranchingModelSettingsPutRequest) (*BranchingModelSettings, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *BranchingModelSettings
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "BranchingModelApiService.RepositoriesWorkspaceRepoSlugBranchingModelSettingsPut")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/repositories/{workspace}/{repo_slug}/branching-model/settings"
localVarPath = strings.Replace(localVarPath, "{"+"repo_slug"+"}", url.PathEscape(parameterToString(r.repoSlug, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"workspace"+"}", url.PathEscape(parameterToString(r.workspace, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.ctx != nil {
// API Key Authentication
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
if apiKey, ok := auth["api_key"]; ok {
var key string
if apiKey.Prefix != "" {
key = apiKey.Prefix + " " + apiKey.Key
} else {
key = apiKey.Key
}
localVarHeaderParams["Authorization"] = key
}
}
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 404 {
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}