github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/obs/client_bucket.go (about) 1 package obs 2 3 import ( 4 "errors" 5 ) 6 7 // ListBuckets lists buckets. 8 // 9 // You can use this API to obtain the bucket list. In the list, bucket names are displayed in lexicographical order. 10 func (obsClient ObsClient) ListBuckets(input *ListBucketsInput) (output *ListBucketsOutput, err error) { 11 if input == nil { 12 input = &ListBucketsInput{} 13 } 14 output = &ListBucketsOutput{} 15 err = obsClient.doActionWithoutBucket("ListBuckets", HTTP_GET, input, output) 16 if err != nil { 17 output = nil 18 } 19 return 20 } 21 22 // CreateBucket creates a bucket. 23 // 24 // You can use this API to create a bucket and name it as you specify. The created bucket name must be unique in OBS. 25 func (obsClient ObsClient) CreateBucket(input *CreateBucketInput) (output *BaseModel, err error) { 26 if input == nil { 27 return nil, errors.New("CreateBucketInput is nil") 28 } 29 output = &BaseModel{} 30 err = obsClient.doActionWithBucket("CreateBucket", HTTP_PUT, input.Bucket, input, output) 31 if err != nil { 32 output = nil 33 } 34 return 35 } 36 37 // DeleteBucket deletes a bucket. 38 // 39 // You can use this API to delete a bucket. The bucket to be deleted must be empty 40 // (containing no objects, noncurrent object versions, or part fragments). 41 func (obsClient ObsClient) DeleteBucket(bucketName string) (output *BaseModel, err error) { 42 output = &BaseModel{} 43 err = obsClient.doActionWithBucket("DeleteBucket", HTTP_DELETE, bucketName, defaultSerializable, output) 44 if err != nil { 45 output = nil 46 } 47 return 48 } 49 50 // SetBucketStoragePolicy sets bucket storage class. 51 // 52 // You can use this API to set storage class for bucket. 53 func (obsClient ObsClient) SetBucketStoragePolicy(input *SetBucketStoragePolicyInput) (output *BaseModel, err error) { 54 if input == nil { 55 return nil, errors.New("SetBucketStoragePolicyInput is nil") 56 } 57 output = &BaseModel{} 58 err = obsClient.doActionWithBucket("SetBucketStoragePolicy", HTTP_PUT, input.Bucket, input, output) 59 if err != nil { 60 output = nil 61 } 62 return 63 } 64 65 func (obsClient ObsClient) getBucketStoragePolicyS3(bucketName string) (output *GetBucketStoragePolicyOutput, err error) { 66 output = &GetBucketStoragePolicyOutput{} 67 var outputS3 = &getBucketStoragePolicyOutputS3{} 68 err = obsClient.doActionWithBucket("GetBucketStoragePolicy", HTTP_GET, bucketName, newSubResourceSerial(SubResourceStoragePolicy), outputS3) 69 if err != nil { 70 output = nil 71 return 72 } 73 output.BaseModel = outputS3.BaseModel 74 output.StorageClass = string(outputS3.StorageClass) 75 return 76 } 77 78 func (obsClient ObsClient) getBucketStoragePolicyObs(bucketName string) (output *GetBucketStoragePolicyOutput, err error) { 79 output = &GetBucketStoragePolicyOutput{} 80 var outputObs = &getBucketStoragePolicyOutputObs{} 81 err = obsClient.doActionWithBucket("GetBucketStoragePolicy", HTTP_GET, bucketName, newSubResourceSerial(SubResourceStorageClass), outputObs) 82 if err != nil { 83 output = nil 84 return 85 } 86 output.BaseModel = outputObs.BaseModel 87 output.StorageClass = outputObs.StorageClass 88 return 89 } 90 91 // GetBucketStoragePolicy gets bucket storage class. 92 // 93 // You can use this API to obtain the storage class of a bucket. 94 func (obsClient ObsClient) GetBucketStoragePolicy(bucketName string) (output *GetBucketStoragePolicyOutput, err error) { 95 if obsClient.conf.signature == SignatureObs { 96 return obsClient.getBucketStoragePolicyObs(bucketName) 97 } 98 return obsClient.getBucketStoragePolicyS3(bucketName) 99 } 100 101 // SetBucketQuota sets the bucket quota. 102 // 103 // You can use this API to set the bucket quota. A bucket quota must be expressed in bytes and the maximum value is 2^63-1. 104 func (obsClient ObsClient) SetBucketQuota(input *SetBucketQuotaInput) (output *BaseModel, err error) { 105 if input == nil { 106 return nil, errors.New("SetBucketQuotaInput is nil") 107 } 108 output = &BaseModel{} 109 err = obsClient.doActionWithBucket("SetBucketQuota", HTTP_PUT, input.Bucket, input, output) 110 if err != nil { 111 output = nil 112 } 113 return 114 } 115 116 // GetBucketQuota gets the bucket quota. 117 // 118 // You can use this API to obtain the bucket quota. Value 0 indicates that no upper limit is set for the bucket quota. 119 func (obsClient ObsClient) GetBucketQuota(bucketName string) (output *GetBucketQuotaOutput, err error) { 120 output = &GetBucketQuotaOutput{} 121 err = obsClient.doActionWithBucket("GetBucketQuota", HTTP_GET, bucketName, newSubResourceSerial(SubResourceQuota), output) 122 if err != nil { 123 output = nil 124 } 125 return 126 } 127 128 // HeadBucket checks whether a bucket exists. 129 // 130 // You can use this API to check whether a bucket exists. 131 func (obsClient ObsClient) HeadBucket(bucketName string) (output *BaseModel, err error) { 132 output = &BaseModel{} 133 err = obsClient.doActionWithBucket("HeadBucket", HTTP_HEAD, bucketName, defaultSerializable, output) 134 if err != nil { 135 output = nil 136 } 137 return 138 } 139 140 // GetBucketMetadata gets the metadata of a bucket. 141 // 142 // You can use this API to send a HEAD request to a bucket to obtain the bucket 143 // metadata such as the storage class and CORS rules (if set). 144 func (obsClient ObsClient) GetBucketMetadata(input *GetBucketMetadataInput) (output *GetBucketMetadataOutput, err error) { 145 output = &GetBucketMetadataOutput{} 146 err = obsClient.doActionWithBucket("GetBucketMetadata", HTTP_HEAD, input.Bucket, input, output) 147 if err != nil { 148 output = nil 149 } else { 150 ParseGetBucketMetadataOutput(output) 151 } 152 return 153 } 154 155 // GetBucketStorageInfo gets storage information about a bucket. 156 // 157 // You can use this API to obtain storage information about a bucket, including the 158 // bucket size and number of objects in the bucket. 159 func (obsClient ObsClient) GetBucketStorageInfo(bucketName string) (output *GetBucketStorageInfoOutput, err error) { 160 output = &GetBucketStorageInfoOutput{} 161 err = obsClient.doActionWithBucket("GetBucketStorageInfo", HTTP_GET, bucketName, newSubResourceSerial(SubResourceStorageInfo), output) 162 if err != nil { 163 output = nil 164 } 165 return 166 } 167 168 func (obsClient ObsClient) getBucketLocationS3(bucketName string) (output *GetBucketLocationOutput, err error) { 169 output = &GetBucketLocationOutput{} 170 var outputS3 = &getBucketLocationOutputS3{} 171 err = obsClient.doActionWithBucket("GetBucketLocation", HTTP_GET, bucketName, newSubResourceSerial(SubResourceLocation), outputS3) 172 if err != nil { 173 output = nil 174 } else { 175 output.BaseModel = outputS3.BaseModel 176 output.Location = outputS3.Location 177 } 178 return 179 } 180 181 func (obsClient ObsClient) getBucketLocationObs(bucketName string) (output *GetBucketLocationOutput, err error) { 182 output = &GetBucketLocationOutput{} 183 var outputObs = &getBucketLocationOutputObs{} 184 err = obsClient.doActionWithBucket("GetBucketLocation", HTTP_GET, bucketName, newSubResourceSerial(SubResourceLocation), outputObs) 185 if err != nil { 186 output = nil 187 } else { 188 output.BaseModel = outputObs.BaseModel 189 output.Location = outputObs.Location 190 } 191 return 192 } 193 194 // GetBucketLocation gets the location of a bucket. 195 // 196 // You can use this API to obtain the bucket location. 197 func (obsClient ObsClient) GetBucketLocation(bucketName string) (output *GetBucketLocationOutput, err error) { 198 if obsClient.conf.signature == SignatureObs { 199 return obsClient.getBucketLocationObs(bucketName) 200 } 201 return obsClient.getBucketLocationS3(bucketName) 202 } 203 204 // SetBucketAcl sets the bucket ACL. 205 // 206 // You can use this API to set the ACL for a bucket. 207 func (obsClient ObsClient) SetBucketAcl(input *SetBucketAclInput) (output *BaseModel, err error) { 208 if input == nil { 209 return nil, errors.New("SetBucketAclInput is nil") 210 } 211 output = &BaseModel{} 212 err = obsClient.doActionWithBucket("SetBucketAcl", HTTP_PUT, input.Bucket, input, output) 213 if err != nil { 214 output = nil 215 } 216 return 217 } 218 219 func (obsClient ObsClient) getBucketACLObs(bucketName string) (output *GetBucketAclOutput, err error) { 220 output = &GetBucketAclOutput{} 221 var outputObs = &GetBucketAclOutput{} 222 err = obsClient.doActionWithBucket("GetBucketAcl", HTTP_GET, bucketName, newSubResourceSerial(SubResourceAcl), outputObs) 223 if err != nil { 224 output = nil 225 } else { 226 output.BaseModel = outputObs.BaseModel 227 output.Owner = outputObs.Owner 228 output.Grants = make([]Grant, 0, len(outputObs.Grants)) 229 for _, valGrant := range outputObs.Grants { 230 tempOutput := Grant{} 231 tempOutput.Delivered = valGrant.Delivered 232 tempOutput.Permission = valGrant.Permission 233 tempOutput.Grantee.DisplayName = valGrant.Grantee.DisplayName 234 tempOutput.Grantee.ID = valGrant.Grantee.ID 235 tempOutput.Grantee.Type = valGrant.Grantee.Type 236 tempOutput.Grantee.URI = GroupAllUsers 237 238 output.Grants = append(output.Grants, tempOutput) 239 } 240 } 241 return 242 } 243 244 // GetBucketAcl gets the bucket ACL. 245 // 246 // You can use this API to obtain a bucket ACL. 247 func (obsClient ObsClient) GetBucketAcl(bucketName string) (output *GetBucketAclOutput, err error) { 248 output = &GetBucketAclOutput{} 249 if obsClient.conf.signature == SignatureObs { 250 return obsClient.getBucketACLObs(bucketName) 251 } 252 err = obsClient.doActionWithBucket("GetBucketAcl", HTTP_GET, bucketName, newSubResourceSerial(SubResourceAcl), output) 253 if err != nil { 254 output = nil 255 } 256 return 257 } 258 259 // SetBucketPolicy sets the bucket policy. 260 // 261 // You can use this API to set a bucket policy. If the bucket already has a policy, the 262 // policy will be overwritten by the one specified in this request. 263 func (obsClient ObsClient) SetBucketPolicy(input *SetBucketPolicyInput) (output *BaseModel, err error) { 264 if input == nil { 265 return nil, errors.New("SetBucketPolicy is nil") 266 } 267 output = &BaseModel{} 268 err = obsClient.doActionWithBucket("SetBucketPolicy", HTTP_PUT, input.Bucket, input, output) 269 if err != nil { 270 output = nil 271 } 272 return 273 } 274 275 // GetBucketPolicy gets the bucket policy. 276 // 277 // You can use this API to obtain the policy of a bucket. 278 func (obsClient ObsClient) GetBucketPolicy(bucketName string) (output *GetBucketPolicyOutput, err error) { 279 output = &GetBucketPolicyOutput{} 280 err = obsClient.doActionWithBucketV2("GetBucketPolicy", HTTP_GET, bucketName, newSubResourceSerial(SubResourcePolicy), output) 281 if err != nil { 282 output = nil 283 } 284 return 285 } 286 287 // DeleteBucketPolicy deletes the bucket policy. 288 // 289 // You can use this API to delete the policy of a bucket. 290 func (obsClient ObsClient) DeleteBucketPolicy(bucketName string) (output *BaseModel, err error) { 291 output = &BaseModel{} 292 err = obsClient.doActionWithBucket("DeleteBucketPolicy", HTTP_DELETE, bucketName, newSubResourceSerial(SubResourcePolicy), output) 293 if err != nil { 294 output = nil 295 } 296 return 297 } 298 299 // SetBucketCors sets CORS rules for a bucket. 300 // 301 // You can use this API to set CORS rules for a bucket to allow client browsers to send cross-origin requests. 302 func (obsClient ObsClient) SetBucketCors(input *SetBucketCorsInput) (output *BaseModel, err error) { 303 if input == nil { 304 return nil, errors.New("SetBucketCorsInput is nil") 305 } 306 output = &BaseModel{} 307 err = obsClient.doActionWithBucket("SetBucketCors", HTTP_PUT, input.Bucket, input, output) 308 if err != nil { 309 output = nil 310 } 311 return 312 } 313 314 // GetBucketCors gets CORS rules of a bucket. 315 // 316 // You can use this API to obtain the CORS rules of a specified bucket. 317 func (obsClient ObsClient) GetBucketCors(bucketName string) (output *GetBucketCorsOutput, err error) { 318 output = &GetBucketCorsOutput{} 319 err = obsClient.doActionWithBucket("GetBucketCors", HTTP_GET, bucketName, newSubResourceSerial(SubResourceCors), output) 320 if err != nil { 321 output = nil 322 } 323 return 324 } 325 326 // DeleteBucketCors deletes CORS rules of a bucket. 327 // 328 // You can use this API to delete the CORS rules of a specified bucket. 329 func (obsClient ObsClient) DeleteBucketCors(bucketName string) (output *BaseModel, err error) { 330 output = &BaseModel{} 331 err = obsClient.doActionWithBucket("DeleteBucketCors", HTTP_DELETE, bucketName, newSubResourceSerial(SubResourceCors), output) 332 if err != nil { 333 output = nil 334 } 335 return 336 } 337 338 // SetBucketVersioning sets the versioning status for a bucket. 339 // 340 // You can use this API to set the versioning status for a bucket. 341 func (obsClient ObsClient) SetBucketVersioning(input *SetBucketVersioningInput) (output *BaseModel, err error) { 342 if input == nil { 343 return nil, errors.New("SetBucketVersioningInput is nil") 344 } 345 output = &BaseModel{} 346 err = obsClient.doActionWithBucket("SetBucketVersioning", HTTP_PUT, input.Bucket, input, output) 347 if err != nil { 348 output = nil 349 } 350 return 351 } 352 353 // GetBucketVersioning gets the versioning status of a bucket. 354 // 355 // You can use this API to obtain the versioning status of a bucket. 356 func (obsClient ObsClient) GetBucketVersioning(bucketName string) (output *GetBucketVersioningOutput, err error) { 357 output = &GetBucketVersioningOutput{} 358 err = obsClient.doActionWithBucket("GetBucketVersioning", HTTP_GET, bucketName, newSubResourceSerial(SubResourceVersioning), output) 359 if err != nil { 360 output = nil 361 } 362 return 363 } 364 365 // SetBucketWebsiteConfiguration sets website hosting for a bucket. 366 // 367 // You can use this API to set website hosting for a bucket. 368 func (obsClient ObsClient) SetBucketWebsiteConfiguration(input *SetBucketWebsiteConfigurationInput) (output *BaseModel, err error) { 369 if input == nil { 370 return nil, errors.New("SetBucketWebsiteConfigurationInput is nil") 371 } 372 output = &BaseModel{} 373 err = obsClient.doActionWithBucket("SetBucketWebsiteConfiguration", HTTP_PUT, input.Bucket, input, output) 374 if err != nil { 375 output = nil 376 } 377 return 378 } 379 380 // GetBucketWebsiteConfiguration gets the website hosting settings of a bucket. 381 // 382 // You can use this API to obtain the website hosting settings of a bucket. 383 func (obsClient ObsClient) GetBucketWebsiteConfiguration(bucketName string) (output *GetBucketWebsiteConfigurationOutput, err error) { 384 output = &GetBucketWebsiteConfigurationOutput{} 385 err = obsClient.doActionWithBucket("GetBucketWebsiteConfiguration", HTTP_GET, bucketName, newSubResourceSerial(SubResourceWebsite), output) 386 if err != nil { 387 output = nil 388 } 389 return 390 } 391 392 // DeleteBucketWebsiteConfiguration deletes the website hosting settings of a bucket. 393 // 394 // You can use this API to delete the website hosting settings of a bucket. 395 func (obsClient ObsClient) DeleteBucketWebsiteConfiguration(bucketName string) (output *BaseModel, err error) { 396 output = &BaseModel{} 397 err = obsClient.doActionWithBucket("DeleteBucketWebsiteConfiguration", HTTP_DELETE, bucketName, newSubResourceSerial(SubResourceWebsite), output) 398 if err != nil { 399 output = nil 400 } 401 return 402 } 403 404 // SetBucketLoggingConfiguration sets the bucket logging. 405 // 406 // You can use this API to configure access logging for a bucket. 407 func (obsClient ObsClient) SetBucketLoggingConfiguration(input *SetBucketLoggingConfigurationInput) (output *BaseModel, err error) { 408 if input == nil { 409 return nil, errors.New("SetBucketLoggingConfigurationInput is nil") 410 } 411 output = &BaseModel{} 412 err = obsClient.doActionWithBucket("SetBucketLoggingConfiguration", HTTP_PUT, input.Bucket, input, output) 413 if err != nil { 414 output = nil 415 } 416 return 417 } 418 419 // GetBucketLoggingConfiguration gets the logging settings of a bucket. 420 // 421 // You can use this API to obtain the access logging settings of a bucket. 422 func (obsClient ObsClient) GetBucketLoggingConfiguration(bucketName string) (output *GetBucketLoggingConfigurationOutput, err error) { 423 output = &GetBucketLoggingConfigurationOutput{} 424 err = obsClient.doActionWithBucket("GetBucketLoggingConfiguration", HTTP_GET, bucketName, newSubResourceSerial(SubResourceLogging), output) 425 if err != nil { 426 output = nil 427 } 428 return 429 } 430 431 // SetBucketLifecycleConfiguration sets lifecycle rules for a bucket. 432 // 433 // You can use this API to set lifecycle rules for a bucket, to periodically transit 434 // storage classes of objects and delete objects in the bucket. 435 func (obsClient ObsClient) SetBucketLifecycleConfiguration(input *SetBucketLifecycleConfigurationInput) (output *BaseModel, err error) { 436 if input == nil { 437 return nil, errors.New("SetBucketLifecycleConfigurationInput is nil") 438 } 439 output = &BaseModel{} 440 err = obsClient.doActionWithBucket("SetBucketLifecycleConfiguration", HTTP_PUT, input.Bucket, input, output) 441 if err != nil { 442 output = nil 443 } 444 return 445 } 446 447 // GetBucketLifecycleConfiguration gets lifecycle rules of a bucket. 448 // 449 // You can use this API to obtain the lifecycle rules of a bucket. 450 func (obsClient ObsClient) GetBucketLifecycleConfiguration(bucketName string) (output *GetBucketLifecycleConfigurationOutput, err error) { 451 output = &GetBucketLifecycleConfigurationOutput{} 452 err = obsClient.doActionWithBucket("GetBucketLifecycleConfiguration", HTTP_GET, bucketName, newSubResourceSerial(SubResourceLifecycle), output) 453 if err != nil { 454 output = nil 455 } 456 return 457 } 458 459 // DeleteBucketLifecycleConfiguration deletes lifecycle rules of a bucket. 460 // 461 // You can use this API to delete all lifecycle rules of a bucket. 462 func (obsClient ObsClient) DeleteBucketLifecycleConfiguration(bucketName string) (output *BaseModel, err error) { 463 output = &BaseModel{} 464 err = obsClient.doActionWithBucket("DeleteBucketLifecycleConfiguration", HTTP_DELETE, bucketName, newSubResourceSerial(SubResourceLifecycle), output) 465 if err != nil { 466 output = nil 467 } 468 return 469 } 470 471 // SetBucketEncryption sets the default server-side encryption for a bucket. 472 // 473 // You can use this API to create or update the default server-side encryption for a bucket. 474 func (obsClient ObsClient) SetBucketEncryption(input *SetBucketEncryptionInput) (output *BaseModel, err error) { 475 if input == nil { 476 return nil, errors.New("SetBucketEncryptionInput is nil") 477 } 478 output = &BaseModel{} 479 err = obsClient.doActionWithBucket("SetBucketEncryption", HTTP_PUT, input.Bucket, input, output) 480 if err != nil { 481 output = nil 482 } 483 return 484 } 485 486 // GetBucketEncryption gets the encryption configuration of a bucket. 487 // 488 // You can use this API to obtain the encryption configuration of a bucket. 489 func (obsClient ObsClient) GetBucketEncryption(bucketName string) (output *GetBucketEncryptionOutput, err error) { 490 output = &GetBucketEncryptionOutput{} 491 err = obsClient.doActionWithBucket("GetBucketEncryption", HTTP_GET, bucketName, newSubResourceSerial(SubResourceEncryption), output) 492 if err != nil { 493 output = nil 494 } 495 return 496 } 497 498 // DeleteBucketEncryption deletes the encryption configuration of a bucket. 499 // 500 // You can use this API to delete the encryption configuration of a bucket. 501 func (obsClient ObsClient) DeleteBucketEncryption(bucketName string) (output *BaseModel, err error) { 502 output = &BaseModel{} 503 err = obsClient.doActionWithBucket("DeleteBucketEncryption", HTTP_DELETE, bucketName, newSubResourceSerial(SubResourceEncryption), output) 504 if err != nil { 505 output = nil 506 } 507 return 508 } 509 510 // SetBucketTagging sets bucket tags. 511 // 512 // You can use this API to set bucket tags. 513 func (obsClient ObsClient) SetBucketTagging(input *SetBucketTaggingInput) (output *BaseModel, err error) { 514 if input == nil { 515 return nil, errors.New("SetBucketTaggingInput is nil") 516 } 517 output = &BaseModel{} 518 err = obsClient.doActionWithBucket("SetBucketTagging", HTTP_PUT, input.Bucket, input, output) 519 if err != nil { 520 output = nil 521 } 522 return 523 } 524 525 // GetBucketTagging gets bucket tags. 526 // 527 // You can use this API to obtain the tags of a specified bucket. 528 func (obsClient ObsClient) GetBucketTagging(bucketName string) (output *GetBucketTaggingOutput, err error) { 529 output = &GetBucketTaggingOutput{} 530 err = obsClient.doActionWithBucket("GetBucketTagging", HTTP_GET, bucketName, newSubResourceSerial(SubResourceTagging), output) 531 if err != nil { 532 output = nil 533 } 534 return 535 } 536 537 // DeleteBucketTagging deletes bucket tags. 538 // 539 // You can use this API to delete the tags of a specified bucket. 540 func (obsClient ObsClient) DeleteBucketTagging(bucketName string) (output *BaseModel, err error) { 541 output = &BaseModel{} 542 err = obsClient.doActionWithBucket("DeleteBucketTagging", HTTP_DELETE, bucketName, newSubResourceSerial(SubResourceTagging), output) 543 if err != nil { 544 output = nil 545 } 546 return 547 } 548 549 // SetBucketNotification sets event notification for a bucket. 550 // 551 // You can use this API to configure event notification for a bucket. You will be notified of all 552 // specified operations performed on the bucket. 553 func (obsClient ObsClient) SetBucketNotification(input *SetBucketNotificationInput) (output *BaseModel, err error) { 554 if input == nil { 555 return nil, errors.New("SetBucketNotificationInput is nil") 556 } 557 output = &BaseModel{} 558 err = obsClient.doActionWithBucket("SetBucketNotification", HTTP_PUT, input.Bucket, input, output) 559 if err != nil { 560 output = nil 561 } 562 return 563 } 564 565 // GetBucketNotification gets event notification settings of a bucket. 566 // 567 // You can use this API to obtain the event notification configuration of a bucket. 568 func (obsClient ObsClient) GetBucketNotification(bucketName string) (output *GetBucketNotificationOutput, err error) { 569 if obsClient.conf.signature != SignatureObs { 570 return obsClient.getBucketNotificationS3(bucketName) 571 } 572 output = &GetBucketNotificationOutput{} 573 err = obsClient.doActionWithBucket("GetBucketNotification", HTTP_GET, bucketName, newSubResourceSerial(SubResourceNotification), output) 574 if err != nil { 575 output = nil 576 } 577 return 578 } 579 580 func (obsClient ObsClient) getBucketNotificationS3(bucketName string) (output *GetBucketNotificationOutput, err error) { 581 outputS3 := &getBucketNotificationOutputS3{} 582 err = obsClient.doActionWithBucket("GetBucketNotification", HTTP_GET, bucketName, newSubResourceSerial(SubResourceNotification), outputS3) 583 if err != nil { 584 return nil, err 585 } 586 587 output = &GetBucketNotificationOutput{} 588 output.BaseModel = outputS3.BaseModel 589 topicConfigurations := make([]TopicConfiguration, 0, len(outputS3.TopicConfigurations)) 590 for _, topicConfigurationS3 := range outputS3.TopicConfigurations { 591 topicConfiguration := TopicConfiguration{} 592 topicConfiguration.ID = topicConfigurationS3.ID 593 topicConfiguration.Topic = topicConfigurationS3.Topic 594 topicConfiguration.FilterRules = topicConfigurationS3.FilterRules 595 596 events := make([]EventType, 0, len(topicConfigurationS3.Events)) 597 for _, event := range topicConfigurationS3.Events { 598 events = append(events, ParseStringToEventType(event)) 599 } 600 topicConfiguration.Events = events 601 topicConfigurations = append(topicConfigurations, topicConfiguration) 602 } 603 output.TopicConfigurations = topicConfigurations 604 return 605 } 606 607 // SetBucketReplication sets the cross-region replication for a bucket. 608 // 609 // You can use this API to create or update the cross-region replication for a bucket. 610 func (obsClient ObsClient) SetBucketReplication(input *SetBucketReplicationInput) (output *BaseModel, err error) { 611 if input == nil { 612 return nil, errors.New("SetBucketReplicationInput is nil") 613 } 614 output = &BaseModel{} 615 err = obsClient.doActionWithBucket("SetBucketReplication", HTTP_PUT, input.Bucket, input, output) 616 if err != nil { 617 output = nil 618 } 619 return 620 } 621 622 // GetBucketReplication gets the cross-region replication configuration of a bucket. 623 // 624 // You can use this API to obtain the cross-region replication configuration of a bucket. 625 func (obsClient ObsClient) GetBucketReplication(bucketName string) (output *GetBucketReplicationOutput, err error) { 626 output = &GetBucketReplicationOutput{} 627 err = obsClient.doActionWithBucket("GetBucketReplication", HTTP_GET, bucketName, newSubResourceSerial(SubResourceReplication), output) 628 if err != nil { 629 output = nil 630 } 631 return 632 } 633 634 // DeleteBucketReplication deletes the cross-region replication configuration of a bucket. 635 // 636 // You can use this API to delete the cross-region replication configuration of a bucket. 637 func (obsClient ObsClient) DeleteBucketReplication(bucketName string) (output *BaseModel, err error) { 638 output = &BaseModel{} 639 err = obsClient.doActionWithBucket("DeleteBucketReplication", HTTP_DELETE, bucketName, newSubResourceSerial(SubResourceReplication), output) 640 if err != nil { 641 output = nil 642 } 643 return 644 } 645 646 // SetWORMPolicy sets a default WORM policy for a bucket. 647 // 648 // You can use this API to configure the default WORM policy and a retention period. 649 func (obsClient ObsClient) SetWORMPolicy(input *SetWORMPolicyInput) (output *BaseModel, err error) { 650 if input == nil { 651 return nil, errors.New("SetBucketWORMInput is nil") 652 } 653 output = &BaseModel{} 654 err = obsClient.doActionWithBucket("SetWORMPolicy", HTTP_PUT, input.Bucket, input, output) 655 if err != nil { 656 output = nil 657 } 658 return 659 } 660 661 // GetWORMPolicy gets a WORM policy for a bucket. 662 // 663 // You can use this API to retrieve the default WORM policy and a retention period. 664 func (obsClient ObsClient) GetWORMPolicy(bucketName string) (output *GetBucketWORMPolicyOutput, err error) { 665 output = &GetBucketWORMPolicyOutput{} 666 err = obsClient.doActionWithBucket("GetWORMPolicy", HTTP_GET, bucketName, newSubResourceSerial(SubResourceObjectLock), output) 667 if err != nil { 668 output = nil 669 } 670 return 671 } 672 673 func (obsClient ObsClient) DeleteBucketCustomDomain(input *DeleteBucketCustomDomainInput) (output *BaseModel, err error) { 674 if input == nil { 675 return nil, errors.New("DeleteBucketCustomDomainInput is nil") 676 } 677 678 output = &BaseModel{} 679 err = obsClient.doActionWithBucket("DeleteBucketCustomDomain", HTTP_DELETE, input.Bucket, newSubResourceSerialV2(SubResourceCustomDomain, input.CustomDomain), output) 680 if err != nil { 681 output = nil 682 } 683 return 684 } 685 686 func (obsClient ObsClient) SetBucketCustomDomain(input *SetBucketCustomDomainInput) (output *BaseModel, err error) { 687 if input == nil { 688 return nil, errors.New("SetBucketCustomDomainInput is nil") 689 } 690 691 output = &BaseModel{} 692 err = obsClient.doActionWithBucket("SetBucketCustomDomain", HTTP_PUT, input.Bucket, newSubResourceSerialV2(SubResourceCustomDomain, input.CustomDomain), output) 693 if err != nil { 694 output = nil 695 } 696 return 697 } 698 699 func (obsClient ObsClient) GetBucketCustomDomain(bucketName string) (output *GetBucketCustomDomainOuput, err error) { 700 output = &GetBucketCustomDomainOuput{} 701 err = obsClient.doActionWithBucket("GetBucketCustomDomain", HTTP_GET, bucketName, newSubResourceSerial(SubResourceCustomDomain), output) 702 if err != nil { 703 output = nil 704 } 705 return 706 }