Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor get set tagging apis for bucket and object #1246

Merged
merged 9 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,12 @@ The full API Reference is available here.
- [list-incomplete-uploads.js](https://github.com/minio/minio-js/blob/master/examples/list-incomplete-uploads.js)
- [get-bucket-versioning.mjs](https://github.com/minio/minio-js/blob/master/examples/get-bucket-versioning.js)
- [set-bucket-versioning.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-versioning.js)
- [set-bucket-tagging.js](https://github.com/minio/minio-js/blob/master/examples/set-bucket-tagging.js)
- [set-bucket-tagging.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-tagging.js)
- [get-bucket-versioning.mjs](https://github.com/minio/minio-js/blob/master/examples/get-bucket-versioning.js)
- [set-bucket-versioning.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-versioning.js)
- [set-bucket-tagging.mjs](https://github.com/minio/minio-js/blob/master/examples/set-bucket-tagging.js)
- [get-bucket-tagging.mjs](https://github.com/minio/minio-js/blob/master/examples/get-bucket-tagging.mjs)
- [remove-bucket-tagging.js](https://github.com/minio/minio-js/blob/master/examples/remove-bucket-tagging.js)
- [remove-bucket-tagging.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-bucket-tagging.js)
- [set-bucket-lifecycle.js](https://github.com/minio/minio-js/blob/master/examples/set-bucket-lifecycle.js)
- [get-bucket-lifecycle.js](https://github.com/minio/minio-js/blob/master/examples/get-bucket-lifecycle.js)
- [remove-bucket-lifecycle.js](https://github.com/minio/minio-js/blob/master/examples/remove-bucket-lifecycle.js)
Expand All @@ -200,9 +203,9 @@ The full API Reference is available here.
- [stat-object.mjs](https://github.com/minio/minio-js/blob/master/examples/stat-object.mjs)
- [get-object-retention.js](https://github.com/minio/minio-js/blob/master/examples/get-object-retention.js)
- [put-object-retention.js](https://github.com/minio/minio-js/blob/master/examples/put-object-retention.js)
- [put-object-tagging.js](https://github.com/minio/minio-js/blob/master/examples/put-object-tagging.js)
- [put-object-tagging.mjs](https://github.com/minio/minio-js/blob/master/examples/put-object-tagging.js)
- [get-object-tagging.mjs](https://github.com/minio/minio-js/blob/master/examples/get-object-tagging.mjs)
- [remove-object-tagging.js](https://github.com/minio/minio-js/blob/master/examples/remove-object-tagging.js)
- [remove-object-tagging.mjs](https://github.com/minio/minio-js/blob/master/examples/remove-object-tagging.js)
- [set-object-legal-hold.js](https://github.com/minio/minio-js/blob/master/examples/set-object-legalhold.mjs)
- [get-object-legal-hold.js](https://github.com/minio/minio-js/blob/master/examples/get-object-legal-hold.mjs)
- [compose-object.js](https://github.com/minio/minio-js/blob/master/examples/compose-object.js)
Expand Down
112 changes: 36 additions & 76 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,27 +578,21 @@ await minioClient.removeBucketReplication('source-bucket')

<a name="setBucketTagging"></a>

### setBucketTagging(bucketName, tags, callback)
### setBucketTagging(bucketName, tags)

Set Tags on a Bucket

**Parameters**

| Param | Type | Description |
| --------------- | ---------- | --------------------------------------------------------- |
| `bucketName` | _string_ | Name of the bucket. |
| `tags` | _object_ | Tags map Configuration e.g: `{<tag-key-1>:<tag-value-1>}` |
| `callback(err)` | _function_ | Callback is called with `err` in case of error. |
| Param | Type | Description |
| ------------ | -------- | --------------------------------------------------------- |
| `bucketName` | _string_ | Name of the bucket. |
| `tags` | _object_ | Tags map Configuration e.g: `{<tag-key-1>:<tag-value-1>}` |

**Example**

```js
minioClient.setBucketTagging('bucketname', tags, function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await minioClient.setBucketTagging('bucketname', tags)
```

<a name="removeBucketTagging"></a>
Expand All @@ -609,44 +603,33 @@ Remove Tags on a Bucket

**Parameters**

| Param | Type | Description |
| --------------- | ---------- | ----------------------------------------------- |
| `bucketName` | _string_ | Name of the bucket. |
| `callback(err)` | _function_ | Callback is called with `err` in case of error. |
| Param | Type | Description |
| ------------ | -------- | ------------------- |
| `bucketName` | _string_ | Name of the bucket. |

**Example**

```js
minioClient.removeBucketTagging('bucketname', function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await minioClient.removeBucketTagging('bucketname')
```

<a name="getBucketTagging"></a>

### getBucketTagging(bucketName, callback)
### getBucketTagging(bucketName)

Remove Tags on a Bucket
Gets Tags on a Bucket

**Parameters**

| Param | Type | Description |
| ------------------------- | ---------- | ----------------------------------------------- |
| `bucketName` | _string_ | Name of the bucket. |
| `callback(err, tagsList)` | _function_ | Callback is called with `err` in case of error. |
| Param | Type | Description |
| ------------ | -------- | ------------------- |
| `bucketName` | _string_ | Name of the bucket. |

**Example**

```js
minioClient.getBucketTagging('bucketname', function (err, tagsList) {
if (err) {
return console.log(err)
}
console.log('Success', tagsList)
})
const tagList = await minioClient.getBucketTagging('bucketname')
console.log(tagList)
```

<a name="setBucketLifecycle"></a>
Expand Down Expand Up @@ -1417,79 +1400,57 @@ minioClient.getObjectRetention('bucketname', 'bucketname', { versionId: 'my-vers

<a name="setObjectTagging"></a>

### setObjectTagging(bucketName, objectName, tags[, putOpts, callback])
### setObjectTagging(bucketName, objectName, tags[, putOpts])

Put Tags on an Object

**Parameters**

| Param | Type | Description |
| --------------- | ---------- | ------------------------------------------------------------ |
| `bucketName` | _string_ | Name of the bucket. |
| `objectName` | _string_ | Name of the object. |
| `tags` | _object_ | Tags map Configuration e.g: `{<tag-key-1>:<tag-value-1>}` |
| `putOpts` | _object_ | Default is {}. e.g `{versionId:"my-version-id"}`. (Optional) |
| `callback(err)` | _function_ | Callback is called with `err` in case of error. |
| Param | Type | Description |
| ------------ | -------- | ------------------------------------------------------------ |
| `bucketName` | _string_ | Name of the bucket. |
| `objectName` | _string_ | Name of the object. |
| `tags` | _object_ | Tags map Configuration e.g: `{<tag-key-1>:<tag-value-1>}` |
| `putOpts` | _object_ | Default is {}. e.g `{versionId:"my-version-id"}`. (Optional) |

**Example**

```js
minioClient.setObjectTagging('bucketname', 'object-name', tags, function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await minioClient.setObjectTagging('bucketname', 'object-name', tags)
```

**Example 1**
Put tags on a version of an object.

```js
minioClient.setObjectTagging('bucketname', 'object-name', tags, { versionId: 'my-version-id' }, function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await minioClient.setObjectTagging('bucketname', 'object-name', tags, { versionId: 'my-version-id' })
```

<a name="removeObjectTagging"></a>

### removeObjectTagging(bucketName, objectName[, removeOpts, callback])
### removeObjectTagging(bucketName, objectName[, removeOpts])

Remove Tags on an Object

**Parameters**

| Param | Type | Description |
| --------------- | ---------- | ------------------------------------------------------------- |
| `bucketName` | _string_ | Name of the bucket. |
| `objectName` | _string_ | Name of the object. |
| `removeOpts` | _object_ | Defaults to {}. e.g `{versionId:"my-version-id"}`. (Optional) |
| `callback(err)` | _function_ | Callback is called with `err` in case of error. |
| Param | Type | Description |
| ------------ | -------- | ------------------------------------------------------------- |
| `bucketName` | _string_ | Name of the bucket. |
| `objectName` | _string_ | Name of the object. |
| `removeOpts` | _object_ | Defaults to {}. e.g `{versionId:"my-version-id"}`. (Optional) |

**Example**

```js
minioClient.removeObjectTagging('bucketname', 'object-name', function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await minioClient.removeObjectTagging('bucketname', 'object-name')
```

**Example1**
Remove tags on a version of an object.

```js
minioClient.removeObjectTagging('bucketname', 'object-name', { versionId: 'my-object-version-id' }, function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await minioClient.removeObjectTagging('bucketname', 'object-name', { versionId: 'my-object-version-id' })
```

<a name="getObjectTagging"></a>
Expand All @@ -1509,15 +1470,14 @@ Get Tags of an Object
**Example**

```js
const tagsList = await minioClient.getObjectTagging('bucketname', 'object-name')
console.log('Success', tagsList)
console.log(await minioClient.getObjectTagging('bucketname', 'object-name'))
```

**Example1**
Get tags on a version of an object.

```js
const tagsList = await minioClient.getObjectTagging('bucketname', 'object-name', { versionId: 'my-object-version-id' })
console.log(await minioClient.getObjectTagging('bucketname', 'object-name', { versionId: 'my-object-version-id' }))
```

<a name="getObjectLegalHold"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,4 @@ const s3Client = new Minio.Client({
secretKey: 'YOUR-SECRETACCESSKEY',
})

s3Client.removeBucketTagging('bucketname', function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await s3Client.removeBucketTagging('bucketname')
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,7 @@ const s3Client = new Minio.Client({
secretKey: 'YOUR-SECRETACCESSKEY',
})

s3Client.removeObjectTagging('bucketname', 'object-name', function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await s3Client.removeObjectTagging('bucketname', 'object-name')

//remove tags on a version of an object
s3Client.removeObjectTagging('bucketname', 'object-name', { versionId: 'my-object-version-id' }, function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await s3Client.removeObjectTagging('bucketname', 'object-name', { versionId: 'my-object-version-id' })
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,5 @@ const s3Client = new Minio.Client({
secretKey: 'YOUR-SECRETACCESSKEY',
})

const tagsMap = { tagkey: 'tagvalue' }

s3Client.setBucketTagging('bucketname', tagsMap, function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
const tagsMap = { tagkey: 'my-bucket-tag' }
await s3Client.setBucketTagging('test-bucket', tagsMap)
14 changes: 2 additions & 12 deletions examples/set-object-tagging.js → examples/set-object-tagging.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,7 @@ const s3Client = new Minio.Client({

const tagsMap = { tagkey: 'tagvalue' }

s3Client.setObjectTagging('bucketname', 'object-name', tagsMap, function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await s3Client.setObjectTagging('bucketname', 'object-name', tagsMap)

//Put tags on a version of an object
s3Client.setObjectTagging('bucketname', 'object-name', tagsMap, { versionId: 'my-version-id' }, function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
})
await s3Client.setObjectTagging('bucketname', 'object-name', tagsMap, { versionId: 'my-version-id' })
Loading
Loading