This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_tagging.go
896 lines (779 loc) · 33.9 KB
/
api_tagging.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
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
/*
* IONOS S3 Object Storage API for contract-owned buckets
*
* ## Overview The IONOS S3 Object Storage API for contract-owned buckets is a REST-based API that allows developers and applications to interact directly with IONOS' scalable storage solution, leveraging the S3 protocol for object storage operations. Its design ensures seamless compatibility with existing tools and libraries tailored for S3 systems. ### API References - [S3 API Reference for contract-owned buckets](https://api.ionos.com/docs/s3-contract-owned-buckets/v2/) ### User documentation [IONOS S3 Object Storage User Guide](https://docs.ionos.com/cloud/managed-services/s3-object-storage) * [Documentation on user-owned and contract-owned buckets](https://docs.ionos.com/cloud/managed-services/s3-object-storage/concepts/buckets) * [Documentation on S3 API Compatibility](https://docs.ionos.com/cloud/managed-services/s3-object-storage/concepts/s3-api-compatibility) * [S3 Tools](https://docs.ionos.com/cloud/managed-services/s3-object-storage/s3-tools) ## Endpoints for contract-owned buckets | Location | Region Name | Bucket Type | Endpoint | | --- | --- | --- | --- | | **Berlin, Germany** | **eu-central-3** | Contract-owned | `https://s3.eu-central-3.ionoscloud.com` | ## Changelog - 30.05.2024 Initial version
*
* API version: 2.0.2
* Contact: [email protected]
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package ionoscloud
import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"net/url"
"strings"
)
// TaggingApiService TaggingApi service
type TaggingApiService service
type ApiDeleteBucketTaggingRequest struct {
ctx context.Context
ApiService *TaggingApiService
bucket string
}
func (r ApiDeleteBucketTaggingRequest) Execute() (*APIResponse, error) {
return r.ApiService.DeleteBucketTaggingExecute(r)
}
/*
DeleteBucketTagging DeleteBucketTagging
<p>Deletes the tags from the bucket.</p> <p>To use this operation, you must have permission to perform the `PutBucketTagging` operation. By default, the bucket owner has this permission and can grant this permission to others.</p>
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bucket
@return ApiDeleteBucketTaggingRequest
*/
func (a *TaggingApiService) DeleteBucketTagging(ctx context.Context, bucket string) ApiDeleteBucketTaggingRequest {
return ApiDeleteBucketTaggingRequest{
ApiService: a,
ctx: ctx,
bucket: bucket,
}
}
// Execute executes the request
func (a *TaggingApiService) DeleteBucketTaggingExecute(r ApiDeleteBucketTaggingRequest) (*APIResponse, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaggingApiService.DeleteBucketTagging")
if err != nil {
gerr := GenericOpenAPIError{}
gerr.SetError(err.Error())
return nil, gerr
}
localVarPath := localBasePath + "/{Bucket}?tagging"
localVarPath = strings.Replace(localVarPath, "{"+"Bucket"+"}", parameterValueToString(r.bucket, "bucket"), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if Strlen(r.bucket) < 3 {
return nil, reportError("bucket must have at least 3 elements")
}
if Strlen(r.bucket) > 63 {
return nil, reportError("bucket must have less than 63 elements")
}
// 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{}
// 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["hmac"]; 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 nil, err
}
localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req)
localVarAPIResponse := &APIResponse{
Response: localVarHTTPResponse,
Method: localVarHTTPMethod,
RequestTime: httpRequestTime,
RequestURL: localVarPath,
Operation: "DeleteBucketTagging",
}
if err != nil || localVarHTTPResponse == nil {
return localVarAPIResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarAPIResponse.Payload = localVarBody
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarAPIResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)))
return localVarAPIResponse, newErr
}
return localVarAPIResponse, nil
}
type ApiDeleteObjectTaggingRequest struct {
ctx context.Context
ApiService *TaggingApiService
bucket string
key string
versionId *string
}
// The versionId of the object that the tag-set will be removed from.
func (r ApiDeleteObjectTaggingRequest) VersionId(versionId string) ApiDeleteObjectTaggingRequest {
r.versionId = &versionId
return r
}
func (r ApiDeleteObjectTaggingRequest) Execute() (map[string]interface{}, *APIResponse, error) {
return r.ApiService.DeleteObjectTaggingExecute(r)
}
/*
DeleteObjectTagging DeleteObjectTagging
<p>Removes the entire tag set from the specified object.</p> <p>To use this operation, you must have permission to perform the `DeleteObjectTagging` operation.</p> <p>To delete tags of a specific object version, add the `versionId` query parameter in the request. You will need permission for the `DeleteObjectVersionTagging` operation.</p>
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bucket
@param key The key that identifies the object in the bucket from which to remove all tags.
@return ApiDeleteObjectTaggingRequest
*/
func (a *TaggingApiService) DeleteObjectTagging(ctx context.Context, bucket string, key string) ApiDeleteObjectTaggingRequest {
return ApiDeleteObjectTaggingRequest{
ApiService: a,
ctx: ctx,
bucket: bucket,
key: key,
}
}
// Execute executes the request
//
// @return map[string]interface{}
func (a *TaggingApiService) DeleteObjectTaggingExecute(r ApiDeleteObjectTaggingRequest) (map[string]interface{}, *APIResponse, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue map[string]interface{}
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaggingApiService.DeleteObjectTagging")
if err != nil {
gerr := GenericOpenAPIError{}
gerr.SetError(err.Error())
return localVarReturnValue, nil, gerr
}
localVarPath := localBasePath + "/{Bucket}/{Key}?tagging"
localVarPath = strings.Replace(localVarPath, "{"+"Bucket"+"}", parameterValueToString(r.bucket, "bucket"), -1)
localVarPath = strings.Replace(localVarPath, "{"+"Key"+"}", parameterValueToString(r.key, "key"), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if Strlen(r.bucket) < 3 {
return localVarReturnValue, nil, reportError("bucket must have at least 3 elements")
}
if Strlen(r.bucket) > 63 {
return localVarReturnValue, nil, reportError("bucket must have less than 63 elements")
}
if Strlen(r.key) < 1 {
return localVarReturnValue, nil, reportError("key must have at least 1 elements")
}
if r.versionId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "versionId", r.versionId, "")
}
// 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/xml"}
// 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["hmac"]; 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, httpRequestTime, err := a.client.callAPI(req)
localVarAPIResponse := &APIResponse{
Response: localVarHTTPResponse,
Method: localVarHTTPMethod,
RequestTime: httpRequestTime,
RequestURL: localVarPath,
Operation: "DeleteObjectTagging",
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarAPIResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarAPIResponse.Payload = localVarBody
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarAPIResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)))
return localVarReturnValue, localVarAPIResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(err.Error())
return localVarReturnValue, localVarAPIResponse, newErr
}
return localVarReturnValue, localVarAPIResponse, nil
}
type ApiGetBucketTaggingRequest struct {
ctx context.Context
ApiService *TaggingApiService
bucket string
}
func (r ApiGetBucketTaggingRequest) Execute() (*GetBucketTaggingOutput, *APIResponse, error) {
return r.ApiService.GetBucketTaggingExecute(r)
}
/*
GetBucketTagging GetBucketTagging
<p>Returns the tag set associated with the bucket.</p> <p>To use this operation, you must have permission to perform the `GetBucketTagging` operation. By default, the bucket owner has this permission and can grant this permission to others.</p> <p> `GetBucketTagging` has the following special error:</p> <ul> <li> <p>Error code: `NoSuchTagSetError` </p> <ul> <li> <p>Description: There is no tag set associated with the bucket.</p> </li> </ul> </li> </ul>
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bucket
@return ApiGetBucketTaggingRequest
*/
func (a *TaggingApiService) GetBucketTagging(ctx context.Context, bucket string) ApiGetBucketTaggingRequest {
return ApiGetBucketTaggingRequest{
ApiService: a,
ctx: ctx,
bucket: bucket,
}
}
// Execute executes the request
//
// @return GetBucketTaggingOutput
func (a *TaggingApiService) GetBucketTaggingExecute(r ApiGetBucketTaggingRequest) (*GetBucketTaggingOutput, *APIResponse, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *GetBucketTaggingOutput
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaggingApiService.GetBucketTagging")
if err != nil {
gerr := GenericOpenAPIError{}
gerr.SetError(err.Error())
return localVarReturnValue, nil, gerr
}
localVarPath := localBasePath + "/{Bucket}?tagging"
localVarPath = strings.Replace(localVarPath, "{"+"Bucket"+"}", parameterValueToString(r.bucket, "bucket"), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if Strlen(r.bucket) < 3 {
return localVarReturnValue, nil, reportError("bucket must have at least 3 elements")
}
if Strlen(r.bucket) > 63 {
return localVarReturnValue, nil, reportError("bucket must have less than 63 elements")
}
// 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/xml"}
// 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["hmac"]; 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, httpRequestTime, err := a.client.callAPI(req)
localVarAPIResponse := &APIResponse{
Response: localVarHTTPResponse,
Method: localVarHTTPMethod,
RequestTime: httpRequestTime,
RequestURL: localVarPath,
Operation: "GetBucketTagging",
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarAPIResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarAPIResponse.Payload = localVarBody
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarAPIResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)))
return localVarReturnValue, localVarAPIResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(err.Error())
return localVarReturnValue, localVarAPIResponse, newErr
}
return localVarReturnValue, localVarAPIResponse, nil
}
type ApiGetObjectTaggingRequest struct {
ctx context.Context
ApiService *TaggingApiService
bucket string
key string
versionId *string
}
// The versionId of the object for which to get the tagging information.
func (r ApiGetObjectTaggingRequest) VersionId(versionId string) ApiGetObjectTaggingRequest {
r.versionId = &versionId
return r
}
func (r ApiGetObjectTaggingRequest) Execute() (*GetObjectTaggingOutput, *APIResponse, error) {
return r.ApiService.GetObjectTaggingExecute(r)
}
/*
GetObjectTagging GetObjectTagging
<p>Returns the tag-set of an object. You send the GET request against the tagging subresource associated with the object.</p> <p>To use this operation, you must have permission to perform the `GetObjectTagging` operation. By default, the GET operation returns information about current version of an object. For a versioned bucket, you can have multiple versions of an object in your bucket. To retrieve tags of any other version, use the versionId query parameter. You also need permission for the `GetObjectVersionTagging` operation.</p> <p> By default, the bucket owner has this permission and can grant this permission to others.</p>
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bucket
@param key Object key for which to get the tagging information.
@return ApiGetObjectTaggingRequest
*/
func (a *TaggingApiService) GetObjectTagging(ctx context.Context, bucket string, key string) ApiGetObjectTaggingRequest {
return ApiGetObjectTaggingRequest{
ApiService: a,
ctx: ctx,
bucket: bucket,
key: key,
}
}
// Execute executes the request
//
// @return GetObjectTaggingOutput
func (a *TaggingApiService) GetObjectTaggingExecute(r ApiGetObjectTaggingRequest) (*GetObjectTaggingOutput, *APIResponse, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *GetObjectTaggingOutput
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaggingApiService.GetObjectTagging")
if err != nil {
gerr := GenericOpenAPIError{}
gerr.SetError(err.Error())
return localVarReturnValue, nil, gerr
}
localVarPath := localBasePath + "/{Bucket}/{Key}?tagging"
localVarPath = strings.Replace(localVarPath, "{"+"Bucket"+"}", parameterValueToString(r.bucket, "bucket"), -1)
localVarPath = strings.Replace(localVarPath, "{"+"Key"+"}", parameterValueToString(r.key, "key"), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if Strlen(r.bucket) < 3 {
return localVarReturnValue, nil, reportError("bucket must have at least 3 elements")
}
if Strlen(r.bucket) > 63 {
return localVarReturnValue, nil, reportError("bucket must have less than 63 elements")
}
if Strlen(r.key) < 1 {
return localVarReturnValue, nil, reportError("key must have at least 1 elements")
}
if r.versionId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "versionId", r.versionId, "")
}
// 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/xml"}
// 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["hmac"]; 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, httpRequestTime, err := a.client.callAPI(req)
localVarAPIResponse := &APIResponse{
Response: localVarHTTPResponse,
Method: localVarHTTPMethod,
RequestTime: httpRequestTime,
RequestURL: localVarPath,
Operation: "GetObjectTagging",
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarAPIResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarAPIResponse.Payload = localVarBody
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarAPIResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)))
return localVarReturnValue, localVarAPIResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(err.Error())
return localVarReturnValue, localVarAPIResponse, newErr
}
return localVarReturnValue, localVarAPIResponse, nil
}
type ApiPutBucketTaggingRequest struct {
ctx context.Context
ApiService *TaggingApiService
bucket string
putBucketTaggingRequest *PutBucketTaggingRequest
contentMD5 *string
}
func (r ApiPutBucketTaggingRequest) PutBucketTaggingRequest(putBucketTaggingRequest PutBucketTaggingRequest) ApiPutBucketTaggingRequest {
r.putBucketTaggingRequest = &putBucketTaggingRequest
return r
}
func (r ApiPutBucketTaggingRequest) ContentMD5(contentMD5 string) ApiPutBucketTaggingRequest {
r.contentMD5 = &contentMD5
return r
}
func (r ApiPutBucketTaggingRequest) Execute() (*APIResponse, error) {
return r.ApiService.PutBucketTaggingExecute(r)
}
/*
PutBucketTagging PutBucketTagging
<p>Sets the tags for a bucket.</p> <note> <p> When this operation sets the tags for a bucket, it will overwrite any current tags the bucket already has. You cannot use this operation to add tags to an existing list of tags.</p> </note> <p>To use this operation, you must have permissions to perform the `PutBucketTagging` operation. The bucket owner has this permission by default and can grant this permission to others. </p> <p> `PutBucketTagging` has the following special errors:</p> <ul> <li> <p>Error code: `InvalidTagError` </p> <ul> <li> <p>Description: The tag provided was not a valid tag. This error can occur if the tag did not pass input validation. </p> </li> </ul> </li> <li> <p>Error code: `MalformedXMLError` </p> <ul> <li> <p>Description: The XML provided does not match the schema.</p> </li> </ul> </li> <li> <p>Error code: `OperationAbortedError ` </p> <ul> <li> <p>Description: A conflicting conditional operation is currently in progress against this resource. Please try again.</p> </li> </ul> </li> <li> <p>Error code: `InternalError` </p> <ul> <li> <p>Description: The service was unable to apply the provided tag to the bucket.</p> </li> </ul> </li> </ul>
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bucket
@return ApiPutBucketTaggingRequest
*/
func (a *TaggingApiService) PutBucketTagging(ctx context.Context, bucket string) ApiPutBucketTaggingRequest {
return ApiPutBucketTaggingRequest{
ApiService: a,
ctx: ctx,
bucket: bucket,
}
}
// Execute executes the request
func (a *TaggingApiService) PutBucketTaggingExecute(r ApiPutBucketTaggingRequest) (*APIResponse, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaggingApiService.PutBucketTagging")
if err != nil {
gerr := GenericOpenAPIError{}
gerr.SetError(err.Error())
return nil, gerr
}
localVarPath := localBasePath + "/{Bucket}?tagging"
localVarPath = strings.Replace(localVarPath, "{"+"Bucket"+"}", parameterValueToString(r.bucket, "bucket"), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if Strlen(r.bucket) < 3 {
return nil, reportError("bucket must have at least 3 elements")
}
if Strlen(r.bucket) > 63 {
return nil, reportError("bucket must have less than 63 elements")
}
if r.putBucketTaggingRequest == nil {
return nil, reportError("putBucketTaggingRequest is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/xml"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.contentMD5 != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "Content-MD5", r.contentMD5, "")
}
// body params
localVarPostBody = r.putBucketTaggingRequest
if r.ctx != nil {
// API Key Authentication
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
if apiKey, ok := auth["hmac"]; 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 nil, err
}
localVarHTTPResponse, httpRequestTime, err := a.client.callAPI(req)
localVarAPIResponse := &APIResponse{
Response: localVarHTTPResponse,
Method: localVarHTTPMethod,
RequestTime: httpRequestTime,
RequestURL: localVarPath,
Operation: "PutBucketTagging",
}
if err != nil || localVarHTTPResponse == nil {
return localVarAPIResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarAPIResponse.Payload = localVarBody
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarAPIResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)))
return localVarAPIResponse, newErr
}
return localVarAPIResponse, nil
}
type ApiPutObjectTaggingRequest struct {
ctx context.Context
ApiService *TaggingApiService
bucket string
key string
putObjectTaggingRequest *PutObjectTaggingRequest
versionId *string
contentMD5 *string
}
func (r ApiPutObjectTaggingRequest) PutObjectTaggingRequest(putObjectTaggingRequest PutObjectTaggingRequest) ApiPutObjectTaggingRequest {
r.putObjectTaggingRequest = &putObjectTaggingRequest
return r
}
// The versionId of the object that the tag-set will be added to.
func (r ApiPutObjectTaggingRequest) VersionId(versionId string) ApiPutObjectTaggingRequest {
r.versionId = &versionId
return r
}
func (r ApiPutObjectTaggingRequest) ContentMD5(contentMD5 string) ApiPutObjectTaggingRequest {
r.contentMD5 = &contentMD5
return r
}
func (r ApiPutObjectTaggingRequest) Execute() (map[string]interface{}, *APIResponse, error) {
return r.ApiService.PutObjectTaggingExecute(r)
}
/*
PutObjectTagging PutObjectTagging
<p>Sets the supplied tag-set to an object that already exists in a bucket.</p> <p>A tag is a key-value pair. You can associate tags with an object by sending a PUT request against the tagging subresource that is associated with the object. You can retrieve tags by sending a GET request.</p> <p>Note that IONOS S3 Object Storage limits the maximum number of tags to 10 tags per object.</p> <p>To use this operation, you must have permission to perform the `PutObjectTagging` operation. By default, the bucket owner has this permission and can grant this permission to others.</p> <p>To put tags of any other version, use the `versionId` query parameter. You also need permission for the `PutObjectVersionTagging` operation.</p> <p class="title"> <b>Special Errors</b> </p> <ul> <li> <ul> <li> <p> <i>Code: InvalidTagError </i> </p> </li> <li> <p> <i>Cause: The tag provided was not a valid tag. This error can occur if the tag did not pass input validation.</i> </p> </li> </ul> </li> <li> <ul> <li> <p> <i>Code: MalformedXMLError </i> </p> </li> <li> <p> <i>Cause: The XML provided does not match the schema.</i> </p> </li> </ul> </li> <li> <ul> <li> <p> <i>Code: OperationAbortedError </i> </p> </li> <li> <p> <i>Cause: A conflicting conditional operation is currently in progress against this resource. Please try again.</i> </p> </li> </ul> </li> <li> <ul> <li> <p> <i>Code: InternalError</i> </p> </li> <li> <p> <i>Cause: The service was unable to apply the provided tag to the object.</i> </p> </li> </ul> </li> </ul>
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param bucket
@param key Name of the object key.
@return ApiPutObjectTaggingRequest
*/
func (a *TaggingApiService) PutObjectTagging(ctx context.Context, bucket string, key string) ApiPutObjectTaggingRequest {
return ApiPutObjectTaggingRequest{
ApiService: a,
ctx: ctx,
bucket: bucket,
key: key,
}
}
// Execute executes the request
//
// @return map[string]interface{}
func (a *TaggingApiService) PutObjectTaggingExecute(r ApiPutObjectTaggingRequest) (map[string]interface{}, *APIResponse, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue map[string]interface{}
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaggingApiService.PutObjectTagging")
if err != nil {
gerr := GenericOpenAPIError{}
gerr.SetError(err.Error())
return localVarReturnValue, nil, gerr
}
localVarPath := localBasePath + "/{Bucket}/{Key}?tagging"
localVarPath = strings.Replace(localVarPath, "{"+"Bucket"+"}", parameterValueToString(r.bucket, "bucket"), -1)
localVarPath = strings.Replace(localVarPath, "{"+"Key"+"}", parameterValueToString(r.key, "key"), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if Strlen(r.bucket) < 3 {
return localVarReturnValue, nil, reportError("bucket must have at least 3 elements")
}
if Strlen(r.bucket) > 63 {
return localVarReturnValue, nil, reportError("bucket must have less than 63 elements")
}
if Strlen(r.key) < 1 {
return localVarReturnValue, nil, reportError("key must have at least 1 elements")
}
if r.putObjectTaggingRequest == nil {
return localVarReturnValue, nil, reportError("putObjectTaggingRequest is required and must be specified")
}
if r.versionId != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "versionId", r.versionId, "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/xml"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/xml"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.contentMD5 != nil {
parameterAddToHeaderOrQuery(localVarHeaderParams, "Content-MD5", r.contentMD5, "")
}
// body params
localVarPostBody = r.putObjectTaggingRequest
if r.ctx != nil {
// API Key Authentication
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
if apiKey, ok := auth["hmac"]; 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, httpRequestTime, err := a.client.callAPI(req)
localVarAPIResponse := &APIResponse{
Response: localVarHTTPResponse,
Method: localVarHTTPMethod,
RequestTime: httpRequestTime,
RequestURL: localVarPath,
Operation: "PutObjectTagging",
}
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarAPIResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarAPIResponse.Payload = localVarBody
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarAPIResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(fmt.Sprintf("%s: %s", localVarHTTPResponse.Status, string(localVarBody)))
return localVarReturnValue, localVarAPIResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{}
newErr.SetStatusCode(localVarHTTPResponse.StatusCode)
newErr.SetBody(localVarBody)
newErr.SetError(err.Error())
return localVarReturnValue, localVarAPIResponse, newErr
}
return localVarReturnValue, localVarAPIResponse, nil
}