Updated on 2026-08-14 GMT+08:00

Deleting a Bucket Inventory Rule

Function

This API is used to delete the inventory rule of a specified bucket by specifying the rule ID. For more information about the use and limitations of bucket inventories, see Bucket Inventories in the Object Storage Service User Guide.

To perform this operation, you must have the DeleteBucketInventoryConfiguration permission. By default, only the bucket owner can perform this operation. The bucket owner can grant the permission to other users by configuring the bucket policy or user policy.

For more information about permission control, see the permission control in the OBS Permission Configuration Guide.

For fusion buckets, inventory rules can be configured for an active bucket, but cannot be configured for a standby bucket.

Authorization Information

To call this API, you must be the bucket owner or have the permissions to delete bucket inventory rules. You are advised to use IAM or bucket policies for authorization. For details about OBS authorization methods, see Differences Between OBS Permissions Control Methods.

  • If you use IAM for authorization, you need to use either role/policy-based authorization or identity policy-based authorization and configure the required permission:
    • If you use role/policy-based authorization (IAM v3 APIs in the old IAM version), the obs:bucket:DeleteBucketInventoryConfiguration permission is required. For details, see Creating a Custom IAM Policy.
    • If you use identity policy-based authorization (IAM v5 APIs in the new IAM version), as shown in the following table, the obs:bucket:deleteBucketInventoryConfiguration permission is required. For details, see Creating a Custom IAM Identity Policy.

      Action

      Action

      Access Level

      Access Level

      Resource Type (*: required)

      Resource Type (*: required)

      Condition Key

      Condition Key

      AliasAlias

      Alias

      Dependency

      Dependencies

      obs:bucket:deleteBucketInventoryConfiguration

      Write

      bucket *

      -

      -

      -

      • obs:EpochTime
      • obs:SourceIp
      • obs:TlsVersion
      • obs:CustomDomain
  • If you use bucket policies for authorization, the obs:bucket:DeleteBucketInventoryConfiguration permission is required. For details, see Creating a Custom Bucket Policy.

Method

func (obsClient ObsClient) DeleteBucketInventory(input *DeleteBucketInventoryInput, extensions ...extensionOptions) (output *BaseModel, err error)

Request Parameters

Table 1 DeleteBucketInventoryInput parameters

Parameter

Type

Mandatory (Yes/No)

Description

Bucket

string

Yes

Explanation:

Bucket name.

Value range:

None

Id

string

Yes

Explanation:

ID of the inventory rule to be deleted.

Value range:

The value can contain a maximum of 64 bytes, including letters (a–z and A–Z), digits (0–9), hyphens (-), underscores (_), and periods (.).

Response Parameter Description

Table 2 BaseModel

Parameter

Type

Description

StatusCode

int

Explanation:

HTTP status code

Restrictions:

None

Value range:

A status code is a group of digits that can be 2xx (indicating successes) or 4xx or 5xx (indicating errors). It indicates the status of a response. For more information, see Status Code.

Default value:

None

RequestId

string

Explanation:

Request ID returned by the OBS server

Restrictions:

None

Value range:

None

Default value:

None

ResponseHeaders

map[string][]string

Explanation:

HTTP response headers

Restrictions:

None

Value range:

None

Default value:

None

Sample Code

This example deletes the inventory rule with ID inventory-rule-1 from bucket examplebucket.

package main

import (
	"fmt"
	"log"

        obs "github.com/huaweicloud/huaweicloud-sdk-go-obs/obs"
)

func main() {
    // Obtain an AK/SK pair using environment variables or import an AK/SK pair in other ways. Using hard coding may result in leakage.
    // Obtain an AK/SK pair on the management console. For details, see https://support.huaweicloud.com/intl/en-us/usermanual-ca/ca_01_0003.html.
        ak := os.Getenv("AccessKeyID")
        sk := os.Getenv("SecretAccessKey")
    // (Optional) If you use a temporary AK/SK pair and a security token to access OBS, you are not advised to use hard coding, which may result in information leakage. You can obtain an AK/SK pair using environment variables or import an AK/SK pair in other ways.
    securityToken := os.Getenv("SecurityToken")


    // Enter the endpoint corresponding to the bucket. CN-Hong Kong is used here as an example. Replace it with the one currently in use.
    endPoint := "https://obs.ap-southeast-1.myhuaweicloud.com"




	// Create a client.
    obsClient, err := obs.New(ak, sk, endPoint, obs.WithSecurityToken(securityToken))
    if err != nil {
        fmt.Printf("Create obsClient error, errMsg: %s", err.Error())
    }

	// Delete the inventory rule.
	input := &obs.DeleteBucketInventoryInput{
		Bucket: "my-bucket",
		Id:     "inventory-rule-1",
	}

	output, err := client.DeleteBucketInventory(input)
	if err != nil {
		log.Fatalf("Failed to delete bucket inventory: %v", err)
	}

	fmt.Printf("Request ID: %s\n", output.RequestId)
	fmt.Println("Inventory configuration deleted successfully")

}