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: makeBucket #1222

Merged
merged 29 commits into from
Nov 13, 2023
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
be572b5
put
trim21 Oct 29, 2023
9127d8d
lint fix
trim21 Oct 29, 2023
1ed96cf
fix template string
trim21 Oct 29, 2023
0ee8f79
fix test
trim21 Oct 29, 2023
06059be
fix example
trim21 Oct 29, 2023
3ee5b80
fix test
trim21 Oct 29, 2023
2a981a3
refactor: `makeBucket`
trim21 Oct 31, 2023
01f78db
callbackify
trim21 Oct 31, 2023
1a9225f
fix test
trim21 Oct 31, 2023
5ac96c8
fix test
trim21 Oct 31, 2023
cc157ed
Update functional-tests.js
trim21 Oct 31, 2023
b76c0c0
Update functional-tests.js
trim21 Oct 31, 2023
2a34b84
docs
trim21 Oct 31, 2023
82cdc0e
Update README.md
trim21 Oct 31, 2023
3e9d7b0
Update API.md
trim21 Oct 31, 2023
7157f32
Update put-object-retention.js
trim21 Nov 2, 2023
23ec423
Merge branch 'master' into putObjectRetention
trim21 Nov 3, 2023
2917862
fix lint warning
trim21 Nov 3, 2023
b3037b6
Merge remote-tracking branch 'upstream/master' into putObjectRetention
trim21 Nov 4, 2023
8f3c59d
Merge branch 'master' into makeBucket
trim21 Nov 5, 2023
f3d6e2a
Update minio.d.ts
trim21 Nov 5, 2023
6b78c87
format
trim21 Nov 5, 2023
f54c86c
remove use of xml
trim21 Nov 5, 2023
9be7d32
Merge remote-tracking branch 'upstream/master' into makeBucket
trim21 Nov 6, 2023
5bf694a
less diff
trim21 Nov 6, 2023
46e325e
Merge remote-tracking branch 'upstream/master' into makeBucket
trim21 Nov 8, 2023
d14fb35
Remove redundant code in client.ts.
trim21 Nov 8, 2023
ffffded
Fix makeBucket request payload for non-default
trim21 Nov 8, 2023
0c3208d
Merge branch 'master' into makeBucket
prakashsvmx Nov 9, 2023
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
Prev Previous commit
Next Next commit
fix test
trim21 committed Oct 29, 2023
commit 0ee8f79ed8674f8c9b2c9f37c8332032e2276b27
29 changes: 11 additions & 18 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -1420,18 +1420,17 @@ minioClient.removeIncompleteUpload('mybucket', 'photo.jpg', function (err) {

<a name="putObjectRetention"></a>

### putObjectRetention(bucketName, objectName [, retentionOpts] [, callback])
### async putObjectRetention(bucketName, objectName [, retentionOpts])

Apply retention on an object.

**Parameters**

| Param | Type | Description |
| --------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bucketName` | _string_ | Name of the bucket. |
| `objectName` | _string_ | Name of the object. |
| `retentionOpts` | _object_ | Options for retention like : `{ governanceBypass:true/false ,mode:COMPLIANCE/GOVERNANCE, retainUntilDate: _date_ , versionId:"my-versionId" }` Default is `{}` (Optional) |
| `callback(err)` | _function_ | Callback function is called with non `null` value in case of error. If no callback is passed, a `Promise` is returned. |
| Param | Type | Description |
| --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bucketName` | _string_ | Name of the bucket. |
| `objectName` | _string_ | Name of the object. |
| `retentionOpts` | _object_ | Options for retention like : `{ governanceBypass:true/false ,mode:COMPLIANCE/GOVERNANCE, retainUntilDate: _date_ , versionId:"my-versionId" }` Default is `{}` (Optional) |

**Example**
Apply object retention on an object
@@ -1445,17 +1444,11 @@ expirationDate.setDate(expirationDate.getDate() + 1)
expirationDate.setUTCHours(0, 0, 0, 0) //Should be start of the day.(midnight)
const versionId = 'e67b4b08-144d-4fc4-ba15-43c3f7f9ba74'

const objRetPromise = minioClient.putObjectRetention(
bucketName,
objectName,
{ Mode: 'GOVERNANCE', retainUntilDate: retainUntilDate.toISOString(), versionId: versionId },
function (err) {
if (err) {
return console.log(err)
}
console.log('Success')
},
)
const objRetPromise = await minioClient.putObjectRetention(bucketName, objectName, {
Mode: 'GOVERNANCE',
retainUntilDate: retainUntilDate.toISOString(),
versionId: versionId,
})
```

<a name="getObjectRetention"></a>
84 changes: 49 additions & 35 deletions tests/unit/test.js
Original file line number Diff line number Diff line change
@@ -1184,54 +1184,68 @@ describe('Client', function () {
}
})
it('should fail on empty bucket', (done) => {
try {
client.putObjectRetention('', '', {}, function () {})
} catch (e) {
done()
}
client.putObjectRetention('', '', {}, function (err) {
if (err) {
done()
} else {
done(new Error('expecting error'))
}
})
})

it('should fail on null object', (done) => {
try {
client.putObjectRetention('my-bucket', null, {}, function () {})
} catch (e) {
done()
}
client.putObjectRetention('my-bucket', null, {}, function (err) {
if (err) {
done()
} else {
done(new Error('expecting error'))
}
})
})
it('should fail on empty object', (done) => {
try {
client.putObjectRetention('my-bucket', '', {}, function () {})
} catch (e) {
done()
}
client.putObjectRetention('my-bucket', '', {}, function (err) {
if (err) {
done()
} else {
done(new Error('expecting error'))
}
})
})
it('should fail on passing invalid mode ', (done) => {
try {
client.putObjectRetention('my-bucket', 'my-object', { mode: 'invalid_mode' }, function () {})
} catch (e) {
done()
}
client.putObjectRetention('my-bucket', 'my-object', { mode: 'invalid_mode' }, function (err) {
if (err) {
done()
} else {
done(new Error('expecting error'))
}
})
})
it('should fail on passing invalid governanceBypass ', (done) => {
try {
client.putObjectRetention('my-bucket', 'my-object', { governanceBypass: 'nonbool' }, function () {})
} catch (e) {
done()
}
client.putObjectRetention('my-bucket', 'my-object', { governanceBypass: 'nonbool' }, function (err) {
if (err) {
done()
} else {
done(new Error('expecting error'))
}
})
})
it('should fail on passing invalid (null) retainUntilDate ', (done) => {
try {
client.putObjectRetention('my-bucket', 'my-object', { retainUntilDate: 12345 }, function () {})
} catch (e) {
done()
}
client.putObjectRetention('my-bucket', 'my-object', { retainUntilDate: 12345 }, function (err) {
if (err) {
done()
} else {
done(new Error('expecting error'))
}
})
})
it('should fail on passing invalid versionId ', (done) => {
try {
client.putObjectRetention('my-bucket', { versionId: 'COMPLIANCE' }, function () {})
} catch (e) {
done()
}
client.putObjectRetention('my-bucket', { versionId: 'COMPLIANCE' }, function (err) {
if (err) {
done()
} else {
done(new Error('expecting error'))
}
})
})
})
})