Skip to content

Commit

Permalink
add {set,get,delete}_{bucket,object}_tags apis
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurugana committed Oct 15, 2020
1 parent 19f660e commit 4c64e95
Show file tree
Hide file tree
Showing 12 changed files with 566 additions and 5 deletions.
139 changes: 136 additions & 3 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ s3Client = Minio(
| [`delete_bucket_replication`](#delete_bucket_replication) | [`fget_object`](#fget_object) | | [`get_bucket_encryption`](#get_bucket_encryption) |
| [`get_bucket_replication`](#get_bucket_replication) | [`remove_objects`](#remove_objects) | | [`remove_all_bucket_notification`](#remove_all_bucket_notification) |
| [`set_bucket_replication`](#set_bucket_replication) | [`select_object_content`](#select_object_content) | | [`put_bucket_encryption`](#put_bucket_encryption) |
| [`delete_bucket_lifecycle`](#delete_bucket_lifecycle) | | | [`delete_bucket_encryption`](#delete_bucket_encryption) |
| [`get_bucket_lifecycle`](#get_bucket_lifecycle) | | | |
| [`set_bucket_lifecycle`](#set_bucket_lifecycle) | | | |
| [`delete_bucket_lifecycle`](#delete_bucket_lifecycle) | [`delete_object_tags`](#delete_object_tags) | | [`delete_bucket_encryption`](#delete_bucket_encryption) |
| [`get_bucket_lifecycle`](#get_bucket_lifecycle) | [`get_object_tags`](#get_object_tags) | | |
| [`set_bucket_lifecycle`](#set_bucket_lifecycle) | [`set_object_tags`](#set_object_tags) | | |
| [`delete_bucket_tags`](#delete_bucket_tags) | | | |
| [`get_bucket_tags`](#get_bucket_tags) | | | |
| [`set_bucket_tags`](#set_bucket_tags) | | | |

## 1. Constructor

Expand Down Expand Up @@ -776,6 +779,68 @@ config = LifecycleConfig(
minio.set_bucket_lifecycle("my-bucketname", config)
```

<a name="delete_bucket_tags"></a>

### delete_bucket_tags(bucket_name)

Delete tags configuration of a bucket.

__Parameters__

| Param | Type | Description |
|:----------------|:------|:--------------------|
| ``bucket_name`` | _str_ | Name of the bucket. |

__Example__

```py
minio.delete_bucket_tags("my-bucketname")
```

<a name="get_bucket_tags"></a>

### get_bucket_tags(bucket_name)

Get tags configuration of a bucket.

__Parameters__

| Param | Type | Description |
|:----------------|:------|:--------------------|
| ``bucket_name`` | _str_ | Name of the bucket. |

| Return |
|:---------------|
| _Tags_ object. |

__Example__

```py
tags = minio.get_bucket_tags("my-bucketname")
```

<a name="set_bucket_tags"></a>

### set_bucket_tags(bucket_name, tags)

Set tags configuration to a bucket.

__Parameters__

| Param | Type | Description |
|:----------------|:-------|:--------------------|
| ``bucket_name`` | _str_ | Name of the bucket. |
| ``tags`` | _Tags_ | Tags configuration. |

__Example__

```py
tags = Tags.new_bucket_tags()
tags["Project"] = "Project One"
tags["User"] = "jsmith"
client.set_bucket_tags("my-bucketname", tags)
```

## 3. Object operations

<a name="get_object"></a>
Expand Down Expand Up @@ -1134,6 +1199,74 @@ minio.remove_objects(
)
```

<a name="delete_object_tags"></a>

### delete_object_tags(bucket_name, object_name, version_id=None)

Delete tags configuration of an object.

__Parameters__

| Param | Type | Description |
|:----------------|:------|:---------------------------|
| ``bucket_name`` | _str_ | Name of the bucket. |
| ``object_name`` | _str_ | Object name in the bucket. |
| ``version_id`` | _str_ | Version ID of the object. |

__Example__

```py
minio.delete_object_tags("my-bucketname", "my-objectname")
```

<a name="get_object_tags"></a>

### get_object_tags(bucket_name, object_name, version_id=None)

Get tags configuration of an object.

__Parameters__

| Param | Type | Description |
|:----------------|:------|:---------------------------|
| ``bucket_name`` | _str_ | Name of the bucket. |
| ``object_name`` | _str_ | Object name in the bucket. |
| ``version_id`` | _str_ | Version ID of the object. |

| Return |
|:---------------|
| _Tags_ object. |

__Example__

```py
tags = minio.get_object_tags("my-bucketname", "my-objectname")
```

<a name="set_object_tags"></a>

### set_object_tags(bucket_name, object_name, tags, version_id=None)

Set tags configuration to an object.

__Parameters__

| Param | Type | Description |
|:----------------|:-------|:---------------------------|
| ``bucket_name`` | _str_ | Name of the bucket. |
| ``object_name`` | _str_ | Object name in the bucket. |
| ``tags`` | _Tags_ | Tags configuration. |
| ``version_id`` | _str_ | Version ID of the object. |

__Example__

```py
tags = Tags.new_object_tags()
tags["Project"] = "Project One"
tags["User"] = "jsmith"
client.set_object_tags("my-bucketname", "my-objectname", tags)
```

## 4. Presigned operations

<a name="presigned_get_object"></a>
Expand Down
28 changes: 28 additions & 0 deletions examples/delete_bucket_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage.
# Copyright (C) 2020 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
# dummy values, please replace them with original values.

from minio import Minio

client = Minio(
"play.min.io",
access_key="Q3AM3UQ867SPQQA43P2F",
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

client.delete_bucket_tags("my-bucketname")
28 changes: 28 additions & 0 deletions examples/delete_object_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage.
# Copyright (C) 2020 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
# dummy values, please replace them with original values.

from minio import Minio

client = Minio(
"play.min.io",
access_key="Q3AM3UQ867SPQQA43P2F",
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

client.delete_object_tags("my-bucketname", "my-objectname")
28 changes: 28 additions & 0 deletions examples/get_bucket_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage.
# Copyright (C) 2020 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
# dummy values, please replace them with original values.

from minio import Minio

client = Minio(
"play.min.io",
access_key="Q3AM3UQ867SPQQA43P2F",
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

tags = client.get_bucket_tags("my-bucketname")
28 changes: 28 additions & 0 deletions examples/get_object_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage.
# Copyright (C) 2020 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
# dummy values, please replace them with original values.

from minio import Minio

client = Minio(
"play.min.io",
access_key="Q3AM3UQ867SPQQA43P2F",
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

tags = client.get_object_tags("my-bucketname", "my-objectname")
32 changes: 32 additions & 0 deletions examples/set_bucket_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage.
# Copyright (C) 2020 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
# dummy values, please replace them with original values.

from minio import Minio
from minio.commonconfig import Tags

client = Minio(
"play.min.io",
access_key="Q3AM3UQ867SPQQA43P2F",
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

tags = Tags.new_bucket_tags()
tags["Project"] = "Project One"
tags["User"] = "jsmith"
client.set_bucket_tags("my-bucketname", tags)
32 changes: 32 additions & 0 deletions examples/set_object_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage.
# Copyright (C) 2020 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
# dummy values, please replace them with original values.

from minio import Minio
from minio.commonconfig import Tags

client = Minio(
"play.min.io",
access_key="Q3AM3UQ867SPQQA43P2F",
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

tags = Tags.new_object_tags()
tags["Project"] = "Project One"
tags["User"] = "jsmith"
client.set_object_tags("my-bucketname", "my-objectname", tags)
Loading

0 comments on commit 4c64e95

Please sign in to comment.