Vacuum Swagger (#3533)

This commit is contained in:
Daniel Valdivia
2025-05-09 16:41:27 -07:00
committed by GitHub
parent ee974a5961
commit e2bbf91e8a
138 changed files with 69 additions and 21974 deletions

View File

@@ -2002,165 +2002,6 @@ func TestSetBucketVersioning(t *testing.T) {
assert.Equal("Suspended", result.Status, result)
}
func EnableBucketEncryption(bucketName, encType, kmsKeyID string) (*http.Response, error) {
// Helper function to enable bucket encryption
// HTTP Verb: POST
// URL: /buckets/{bucket_name}/encryption/enable
// Body:
// {
// "encType":"sse-s3",
// "kmsKeyID":""
// }
requestDataAdd := map[string]interface{}{
"encType": encType,
"kmsKeyID": kmsKeyID,
}
requestDataJSON, _ := json.Marshal(requestDataAdd)
requestDataBody := bytes.NewReader(requestDataJSON)
request, err := http.NewRequest(
"POST", "http://localhost:9090/api/v1/buckets/"+bucketName+"/encryption/enable", requestDataBody)
if err != nil {
log.Println(err)
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
// Performing the call
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}
func GetBucketEncryptionInformation(bucketName string) (*http.Response, error) {
/*
Helper function to get bucket encryption information
HTTP Verb: GET
URL: api/v1/buckets/<bucket-name>/encryption/info
Response: {"algorithm":"AES256"}
*/
request, err := http.NewRequest(
"GET", "http://localhost:9090/api/v1/buckets/"+bucketName+"/encryption/info", nil)
if err != nil {
log.Println(err)
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}
func DisableBucketEncryption(bucketName string) (*http.Response, error) {
/*
Helper function to disable bucket's encryption
HTTP Verb: POST
URL: /buckets/{bucket_name}/encryption/disable
*/
request, err := http.NewRequest(
"POST",
"http://localhost:9090/api/v1/buckets/"+bucketName+"/encryption/disable",
nil,
)
if err != nil {
log.Println(err)
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}
func SetAccessRuleWithBucket(bucketName, prefix, access string) (*http.Response, error) {
/*
Helper function to Set Access Rule within Bucket
HTTP Verb: PUT
URL: /bucket/{bucket}/access-rules
Data Example:
{
"prefix":"prefix",
"access":"readonly"
}
*/
requestDataAdd := map[string]interface{}{
"prefix": prefix,
"access": access,
}
requestDataJSON, _ := json.Marshal(requestDataAdd)
requestDataBody := bytes.NewReader(requestDataJSON)
request, err := http.NewRequest(
"PUT",
"http://localhost:9090/api/v1/bucket/"+bucketName+"/access-rules",
requestDataBody,
)
if err != nil {
log.Println(err)
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}
func ListAccessRulesWithBucket(bucketName string) (*http.Response, error) {
/*
Helper function to List Access Rules Within Bucket
HTTP Verb: GET
URL: /bucket/{bucket}/access-rules
*/
request, err := http.NewRequest(
"GET",
"http://localhost:9090/api/v1/bucket/"+bucketName+"/access-rules", nil)
if err != nil {
log.Println(err)
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}
func DeleteAccessRuleWithBucket(bucketName, prefix string) (*http.Response, error) {
/*
Helper function to Delete Access Rule With Bucket
HTTP Verb: DELETE
URL: /bucket/{bucket}/access-rules
Data Example: {"prefix":"prefix"}
*/
requestDataAdd := map[string]interface{}{
"prefix": prefix,
}
requestDataJSON, _ := json.Marshal(requestDataAdd)
requestDataBody := bytes.NewReader(requestDataJSON)
request, err := http.NewRequest(
"DELETE",
"http://localhost:9090/api/v1/bucket/"+bucketName+"/access-rules",
requestDataBody,
)
if err != nil {
log.Println(err)
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}
func GetBucketRewind(bucketName, date string) (*http.Response, error) {
/*
Helper function to get objects in a bucket for a rewind date