mirror of
https://github.com/OpenMaxIO/openmaxio-object-browser
synced 2026-07-01 07:41:18 -07:00
Deprecated Lifecycle and Tiering UI (#3470)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -1,488 +0,0 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"strconv"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/minio/console/api/operations"
|
||||
"github.com/minio/console/api/operations/tiering"
|
||||
tieringApi "github.com/minio/console/api/operations/tiering"
|
||||
"github.com/minio/console/models"
|
||||
"github.com/minio/madmin-go/v3"
|
||||
)
|
||||
|
||||
func registerAdminTiersHandlers(api *operations.ConsoleAPI) {
|
||||
// return a list of notification endpoints
|
||||
api.TieringTiersListHandler = tieringApi.TiersListHandlerFunc(func(params tieringApi.TiersListParams, session *models.Principal) middleware.Responder {
|
||||
tierList, err := getTiersResponse(session, params)
|
||||
if err != nil {
|
||||
return tieringApi.NewTiersListDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
return tieringApi.NewTiersListOK().WithPayload(tierList)
|
||||
})
|
||||
api.TieringTiersListNamesHandler = tiering.TiersListNamesHandlerFunc(func(params tiering.TiersListNamesParams, session *models.Principal) middleware.Responder {
|
||||
tierList, err := getTiersNameResponse(session, params)
|
||||
if err != nil {
|
||||
return tieringApi.NewTiersListDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
return tieringApi.NewTiersListNamesOK().WithPayload(tierList)
|
||||
})
|
||||
// add a new tiers
|
||||
api.TieringAddTierHandler = tieringApi.AddTierHandlerFunc(func(params tieringApi.AddTierParams, session *models.Principal) middleware.Responder {
|
||||
err := getAddTierResponse(session, params)
|
||||
if err != nil {
|
||||
return tieringApi.NewAddTierDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
return tieringApi.NewAddTierCreated()
|
||||
})
|
||||
// get a tier
|
||||
api.TieringGetTierHandler = tieringApi.GetTierHandlerFunc(func(params tieringApi.GetTierParams, session *models.Principal) middleware.Responder {
|
||||
notifEndpoints, err := getGetTierResponse(session, params)
|
||||
if err != nil {
|
||||
return tieringApi.NewGetTierDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
return tieringApi.NewGetTierOK().WithPayload(notifEndpoints)
|
||||
})
|
||||
// edit credentials for a tier
|
||||
api.TieringEditTierCredentialsHandler = tieringApi.EditTierCredentialsHandlerFunc(func(params tieringApi.EditTierCredentialsParams, session *models.Principal) middleware.Responder {
|
||||
err := getEditTierCredentialsResponse(session, params)
|
||||
if err != nil {
|
||||
return tieringApi.NewEditTierCredentialsDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
return tieringApi.NewEditTierCredentialsOK()
|
||||
})
|
||||
// remove an empty tier
|
||||
api.TieringRemoveTierHandler = tieringApi.RemoveTierHandlerFunc(func(params tieringApi.RemoveTierParams, session *models.Principal) middleware.Responder {
|
||||
err := getRemoveTierResponse(session, params)
|
||||
if err != nil {
|
||||
return tieringApi.NewRemoveTierDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
return tieringApi.NewRemoveTierNoContent()
|
||||
})
|
||||
}
|
||||
|
||||
// getTiers returns a list of tiers with their stats
|
||||
func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse, error) {
|
||||
tiers, err := client.listTiers(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tierStatsInfo, err := client.tierStats(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tiersStatsMap := make(map[string]madmin.TierStats, len(tierStatsInfo))
|
||||
for _, stat := range tierStatsInfo {
|
||||
tiersStatsMap[stat.Name] = stat.Stats
|
||||
}
|
||||
|
||||
var tiersList []*models.Tier
|
||||
for _, tierData := range tiers {
|
||||
// Default Tier Stats
|
||||
tierStats := madmin.TierStats{
|
||||
NumObjects: 0,
|
||||
NumVersions: 0,
|
||||
TotalSize: 0,
|
||||
}
|
||||
if stats, ok := tiersStatsMap[tierData.Name]; ok {
|
||||
tierStats = stats
|
||||
}
|
||||
|
||||
status := client.verifyTierStatus(ctx, tierData.Name) == nil
|
||||
|
||||
switch tierData.Type {
|
||||
case madmin.S3:
|
||||
tiersList = append(tiersList, &models.Tier{
|
||||
Type: models.TierTypeS3,
|
||||
S3: &models.TierS3{
|
||||
Accesskey: tierData.S3.AccessKey,
|
||||
Bucket: tierData.S3.Bucket,
|
||||
Endpoint: tierData.S3.Endpoint,
|
||||
Name: tierData.Name,
|
||||
Prefix: tierData.S3.Prefix,
|
||||
Region: tierData.S3.Region,
|
||||
Secretkey: tierData.S3.SecretKey,
|
||||
Storageclass: tierData.S3.StorageClass,
|
||||
Usage: humanize.IBytes(tierStats.TotalSize),
|
||||
Objects: strconv.Itoa(tierStats.NumObjects),
|
||||
Versions: strconv.Itoa(tierStats.NumVersions),
|
||||
},
|
||||
Status: status,
|
||||
})
|
||||
case madmin.MinIO:
|
||||
tiersList = append(tiersList, &models.Tier{
|
||||
Type: models.TierTypeMinio,
|
||||
Minio: &models.TierMinio{
|
||||
Accesskey: tierData.MinIO.AccessKey,
|
||||
Bucket: tierData.MinIO.Bucket,
|
||||
Endpoint: tierData.MinIO.Endpoint,
|
||||
Name: tierData.Name,
|
||||
Prefix: tierData.MinIO.Prefix,
|
||||
Region: tierData.MinIO.Region,
|
||||
Secretkey: tierData.MinIO.SecretKey,
|
||||
Usage: humanize.IBytes(tierStats.TotalSize),
|
||||
Objects: strconv.Itoa(tierStats.NumObjects),
|
||||
Versions: strconv.Itoa(tierStats.NumVersions),
|
||||
},
|
||||
Status: status,
|
||||
})
|
||||
case madmin.GCS:
|
||||
tiersList = append(tiersList, &models.Tier{
|
||||
Type: models.TierTypeGcs,
|
||||
Gcs: &models.TierGcs{
|
||||
Bucket: tierData.GCS.Bucket,
|
||||
Creds: tierData.GCS.Creds,
|
||||
Endpoint: tierData.GCS.Endpoint,
|
||||
Name: tierData.Name,
|
||||
Prefix: tierData.GCS.Prefix,
|
||||
Region: tierData.GCS.Region,
|
||||
Usage: humanize.IBytes(tierStats.TotalSize),
|
||||
Objects: strconv.Itoa(tierStats.NumObjects),
|
||||
Versions: strconv.Itoa(tierStats.NumVersions),
|
||||
},
|
||||
Status: status,
|
||||
})
|
||||
case madmin.Azure:
|
||||
tiersList = append(tiersList, &models.Tier{
|
||||
Type: models.TierTypeAzure,
|
||||
Azure: &models.TierAzure{
|
||||
Accountkey: tierData.Azure.AccountKey,
|
||||
Accountname: tierData.Azure.AccountName,
|
||||
Bucket: tierData.Azure.Bucket,
|
||||
Endpoint: tierData.Azure.Endpoint,
|
||||
Name: tierData.Name,
|
||||
Prefix: tierData.Azure.Prefix,
|
||||
Region: tierData.Azure.Region,
|
||||
Usage: humanize.IBytes(tierStats.TotalSize),
|
||||
Objects: strconv.Itoa(tierStats.NumObjects),
|
||||
Versions: strconv.Itoa(tierStats.NumVersions),
|
||||
},
|
||||
Status: status,
|
||||
})
|
||||
case madmin.Unsupported:
|
||||
tiersList = append(tiersList, &models.Tier{
|
||||
Type: models.TierTypeUnsupported,
|
||||
Status: status,
|
||||
})
|
||||
}
|
||||
}
|
||||
// build response
|
||||
return &models.TierListResponse{
|
||||
Items: tiersList,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// getTiersResponse returns a response with a list of tiers
|
||||
func getTiersResponse(session *models.Principal, params tieringApi.TiersListParams) (*models.TierListResponse, *CodedAPIError) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
// serialize output
|
||||
tiersResp, err := getTiers(ctx, adminClient)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
return tiersResp, nil
|
||||
}
|
||||
|
||||
// getTiersNameResponse returns a response with a list of tiers' names
|
||||
func getTiersNameResponse(session *models.Principal, params tieringApi.TiersListNamesParams) (*models.TiersNameListResponse, *CodedAPIError) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
// serialize output
|
||||
tiersResp, err := getTiersName(ctx, adminClient)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
return tiersResp, nil
|
||||
}
|
||||
|
||||
// getTiersName fetches listTiers and returns a list of the tiers' names
|
||||
func getTiersName(ctx context.Context, client MinioAdmin) (*models.TiersNameListResponse, error) {
|
||||
tiers, err := client.listTiers(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tiersNameList := make([]string, len(tiers))
|
||||
for i, tierData := range tiers {
|
||||
tiersNameList[i] = tierData.Name
|
||||
}
|
||||
|
||||
return &models.TiersNameListResponse{
|
||||
Items: tiersNameList,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func addTier(ctx context.Context, client MinioAdmin, params *tieringApi.AddTierParams) error {
|
||||
var cfg *madmin.TierConfig
|
||||
var err error
|
||||
|
||||
switch params.Body.Type {
|
||||
|
||||
case models.TierTypeS3:
|
||||
cfg, err = madmin.NewTierS3(
|
||||
params.Body.S3.Name,
|
||||
params.Body.S3.Accesskey,
|
||||
params.Body.S3.Secretkey,
|
||||
params.Body.S3.Bucket,
|
||||
madmin.S3Region(params.Body.S3.Region),
|
||||
madmin.S3Prefix(params.Body.S3.Prefix),
|
||||
madmin.S3Endpoint(params.Body.S3.Endpoint),
|
||||
madmin.S3StorageClass(params.Body.S3.Storageclass),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case models.TierTypeMinio:
|
||||
cfg, err = madmin.NewTierMinIO(
|
||||
params.Body.Minio.Name,
|
||||
params.Body.Minio.Endpoint,
|
||||
params.Body.Minio.Accesskey,
|
||||
params.Body.Minio.Secretkey,
|
||||
params.Body.Minio.Bucket,
|
||||
madmin.MinIORegion(params.Body.Minio.Region),
|
||||
madmin.MinIOPrefix(params.Body.Minio.Prefix),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case models.TierTypeGcs:
|
||||
gcsOpts := []madmin.GCSOptions{}
|
||||
prefix := params.Body.Gcs.Prefix
|
||||
if prefix != "" {
|
||||
gcsOpts = append(gcsOpts, madmin.GCSPrefix(prefix))
|
||||
}
|
||||
|
||||
region := params.Body.Gcs.Region
|
||||
if region != "" {
|
||||
gcsOpts = append(gcsOpts, madmin.GCSRegion(region))
|
||||
}
|
||||
base64Text := make([]byte, base64.StdEncoding.EncodedLen(len(params.Body.Gcs.Creds)))
|
||||
l, _ := base64.StdEncoding.Decode(base64Text, []byte(params.Body.Gcs.Creds))
|
||||
|
||||
cfg, err = madmin.NewTierGCS(
|
||||
params.Body.Gcs.Name,
|
||||
base64Text[:l],
|
||||
params.Body.Gcs.Bucket,
|
||||
gcsOpts...,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case models.TierTypeAzure:
|
||||
cfg, err = madmin.NewTierAzure(
|
||||
params.Body.Azure.Name,
|
||||
params.Body.Azure.Accountname,
|
||||
params.Body.Azure.Accountkey,
|
||||
params.Body.Azure.Bucket,
|
||||
madmin.AzurePrefix(params.Body.Azure.Prefix),
|
||||
madmin.AzureEndpoint(params.Body.Azure.Endpoint),
|
||||
madmin.AzureRegion(params.Body.Azure.Region),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case models.TierTypeUnsupported:
|
||||
cfg = &madmin.TierConfig{
|
||||
Type: madmin.Unsupported,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
err = client.addTier(ctx, cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// getAddTierResponse returns the response of admin tier
|
||||
func getAddTierResponse(session *models.Principal, params tieringApi.AddTierParams) *CodedAPIError {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
|
||||
// serialize output
|
||||
errTier := addTier(ctx, adminClient, ¶ms)
|
||||
if errTier != nil {
|
||||
return ErrorWithContext(ctx, errTier)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getTier(ctx context.Context, client MinioAdmin, params *tieringApi.GetTierParams) (*models.Tier, error) {
|
||||
tiers, err := client.listTiers(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range tiers {
|
||||
switch tiers[i].Type {
|
||||
case madmin.S3:
|
||||
if params.Type != models.TierTypeS3 || tiers[i].Name != params.Name {
|
||||
continue
|
||||
}
|
||||
return &models.Tier{
|
||||
Type: models.TierTypeS3,
|
||||
S3: &models.TierS3{
|
||||
Accesskey: tiers[i].S3.AccessKey,
|
||||
Bucket: tiers[i].S3.Bucket,
|
||||
Endpoint: tiers[i].S3.Endpoint,
|
||||
Name: tiers[i].Name,
|
||||
Prefix: tiers[i].S3.Prefix,
|
||||
Region: tiers[i].S3.Region,
|
||||
Secretkey: tiers[i].S3.SecretKey,
|
||||
Storageclass: tiers[i].S3.StorageClass,
|
||||
},
|
||||
}, err
|
||||
case madmin.GCS:
|
||||
if params.Type != models.TierTypeGcs || tiers[i].Name != params.Name {
|
||||
continue
|
||||
}
|
||||
return &models.Tier{
|
||||
Type: models.TierTypeGcs,
|
||||
Gcs: &models.TierGcs{
|
||||
Bucket: tiers[i].GCS.Bucket,
|
||||
Creds: tiers[i].GCS.Creds,
|
||||
Endpoint: tiers[i].GCS.Endpoint,
|
||||
Name: tiers[i].Name,
|
||||
Prefix: tiers[i].GCS.Prefix,
|
||||
Region: tiers[i].GCS.Region,
|
||||
},
|
||||
}, nil
|
||||
case madmin.Azure:
|
||||
if params.Type != models.TierTypeAzure || tiers[i].Name != params.Name {
|
||||
continue
|
||||
}
|
||||
return &models.Tier{
|
||||
Type: models.TierTypeAzure,
|
||||
Azure: &models.TierAzure{
|
||||
Accountkey: tiers[i].Azure.AccountKey,
|
||||
Accountname: tiers[i].Azure.AccountName,
|
||||
Bucket: tiers[i].Azure.Bucket,
|
||||
Endpoint: tiers[i].Azure.Endpoint,
|
||||
Name: tiers[i].Name,
|
||||
Prefix: tiers[i].Azure.Prefix,
|
||||
Region: tiers[i].Azure.Region,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// build response
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
|
||||
// getGetTierResponse returns a tier
|
||||
func getGetTierResponse(session *models.Principal, params tieringApi.GetTierParams) (*models.Tier, *CodedAPIError) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
// serialize output
|
||||
addTierResp, err := getTier(ctx, adminClient, ¶ms)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
return addTierResp, nil
|
||||
}
|
||||
|
||||
func editTierCredentials(ctx context.Context, client MinioAdmin, params *tieringApi.EditTierCredentialsParams) error {
|
||||
base64Text := make([]byte, base64.StdEncoding.EncodedLen(len(params.Body.Creds)))
|
||||
l, err := base64.StdEncoding.Decode(base64Text, []byte(params.Body.Creds))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
creds := madmin.TierCreds{
|
||||
AccessKey: params.Body.AccessKey,
|
||||
SecretKey: params.Body.SecretKey,
|
||||
CredsJSON: base64Text[:l],
|
||||
}
|
||||
return client.editTierCreds(ctx, params.Name, creds)
|
||||
}
|
||||
|
||||
// getEditTierCredentialsResponse returns the result of editing credentials for a tier
|
||||
func getEditTierCredentialsResponse(session *models.Principal, params tieringApi.EditTierCredentialsParams) *CodedAPIError {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
// serialize output
|
||||
err = editTierCredentials(ctx, adminClient, ¶ms)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func removeTier(ctx context.Context, client MinioAdmin, params *tieringApi.RemoveTierParams) error {
|
||||
return client.removeTier(ctx, params.Name)
|
||||
}
|
||||
|
||||
func getRemoveTierResponse(session *models.Principal, params tieringApi.RemoveTierParams) *CodedAPIError {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
// serialize output
|
||||
err = removeTier(ctx, adminClient, ¶ms)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
tieringApi "github.com/minio/console/api/operations/tiering"
|
||||
"github.com/minio/console/models"
|
||||
"github.com/minio/madmin-go/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetTiers(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
// mock minIO client
|
||||
adminClient := AdminClientMock{}
|
||||
|
||||
function := "getTiers()"
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
// Test-1 : getTiers() get list of tiers
|
||||
// mock lifecycle response from MinIO
|
||||
returnListMock := []*madmin.TierConfig{
|
||||
{
|
||||
Version: "V1",
|
||||
Type: madmin.S3,
|
||||
Name: "S3 Tier",
|
||||
S3: &madmin.TierS3{
|
||||
Endpoint: "https://s3tier.test.com/",
|
||||
AccessKey: "Access Key",
|
||||
SecretKey: "Secret Key",
|
||||
Bucket: "buckets3",
|
||||
Prefix: "pref1",
|
||||
Region: "us-west-1",
|
||||
StorageClass: "TT1",
|
||||
},
|
||||
},
|
||||
{
|
||||
Version: "V1",
|
||||
Type: madmin.MinIO,
|
||||
Name: "MinIO Tier",
|
||||
MinIO: &madmin.TierMinIO{
|
||||
Endpoint: "https://minio-endpoint.test.com/",
|
||||
AccessKey: "access",
|
||||
SecretKey: "secret",
|
||||
Bucket: "somebucket",
|
||||
Prefix: "p1",
|
||||
Region: "us-east-2",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
returnStatsMock := []madmin.TierInfo{
|
||||
{
|
||||
Name: "STANDARD",
|
||||
Type: "internal",
|
||||
Stats: madmin.TierStats{NumObjects: 2, NumVersions: 2, TotalSize: 228915},
|
||||
},
|
||||
{
|
||||
Name: "MinIO Tier",
|
||||
Type: "internal",
|
||||
Stats: madmin.TierStats{NumObjects: 10, NumVersions: 3, TotalSize: 132788},
|
||||
},
|
||||
{
|
||||
Name: "S3 Tier",
|
||||
Type: "s3",
|
||||
Stats: madmin.TierStats{NumObjects: 0, NumVersions: 0, TotalSize: 0},
|
||||
},
|
||||
}
|
||||
|
||||
expectedOutput := &models.TierListResponse{
|
||||
Items: []*models.Tier{
|
||||
{
|
||||
Type: models.TierTypeS3,
|
||||
S3: &models.TierS3{
|
||||
Accesskey: "Access Key",
|
||||
Secretkey: "Secret Key",
|
||||
Bucket: "buckets3",
|
||||
Endpoint: "https://s3tier.test.com/",
|
||||
Name: "S3 Tier",
|
||||
Prefix: "pref1",
|
||||
Region: "us-west-1",
|
||||
Storageclass: "TT1",
|
||||
Usage: "0 B",
|
||||
Objects: "0",
|
||||
Versions: "0",
|
||||
},
|
||||
Status: false,
|
||||
},
|
||||
{
|
||||
Type: models.TierTypeMinio,
|
||||
Minio: &models.TierMinio{
|
||||
Accesskey: "access",
|
||||
Secretkey: "secret",
|
||||
Bucket: "somebucket",
|
||||
Endpoint: "https://minio-endpoint.test.com/",
|
||||
Name: "MinIO Tier",
|
||||
Prefix: "p1",
|
||||
Region: "us-east-2",
|
||||
Usage: "130 KiB",
|
||||
Objects: "10",
|
||||
Versions: "3",
|
||||
},
|
||||
Status: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
|
||||
return returnListMock, nil
|
||||
}
|
||||
|
||||
minioTierStatsMock = func(_ context.Context) ([]madmin.TierInfo, error) {
|
||||
return returnStatsMock, nil
|
||||
}
|
||||
|
||||
minioVerifyTierStatusMock = func(_ context.Context, _ string) error {
|
||||
return fmt.Errorf("someerror")
|
||||
}
|
||||
|
||||
tiersList, err := getTiers(ctx, adminClient)
|
||||
if err != nil {
|
||||
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
|
||||
}
|
||||
// verify length of tiers list is correct
|
||||
assert.Equal(len(tiersList.Items), len(returnListMock), fmt.Sprintf("Failed on %s: length of lists is not the same", function))
|
||||
assert.Equal(expectedOutput, tiersList)
|
||||
|
||||
// Test-2 : getTiers() list is empty
|
||||
returnListMockT2 := []*madmin.TierConfig{}
|
||||
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
|
||||
return returnListMockT2, nil
|
||||
}
|
||||
|
||||
tiersListT2, err := getTiers(ctx, adminClient)
|
||||
if err != nil {
|
||||
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
|
||||
}
|
||||
|
||||
if len(tiersListT2.Items) != 0 {
|
||||
t.Errorf("Failed on %s:, returned list was not empty", function)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetTiersName(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
// mock minIO client
|
||||
adminClient := AdminClientMock{}
|
||||
|
||||
function := "getTiersName()"
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
// Test-1 : getTiersName() get list tiers' names
|
||||
// mock lifecycle response from MinIO
|
||||
returnListMock := []*madmin.TierConfig{
|
||||
{
|
||||
Version: "V1",
|
||||
Type: madmin.S3,
|
||||
Name: "S3 Tier",
|
||||
S3: &madmin.TierS3{
|
||||
Endpoint: "https://s3tier.test.com/",
|
||||
AccessKey: "Access Key",
|
||||
SecretKey: "Secret Key",
|
||||
Bucket: "buckets3",
|
||||
Prefix: "pref1",
|
||||
Region: "us-west-1",
|
||||
StorageClass: "TT1",
|
||||
},
|
||||
},
|
||||
{
|
||||
Version: "V1",
|
||||
Type: madmin.MinIO,
|
||||
Name: "MinIO Tier",
|
||||
MinIO: &madmin.TierMinIO{
|
||||
Endpoint: "https://minio-endpoint.test.com/",
|
||||
AccessKey: "access",
|
||||
SecretKey: "secret",
|
||||
Bucket: "somebucket",
|
||||
Prefix: "p1",
|
||||
Region: "us-east-2",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expectedOutput := &models.TiersNameListResponse{
|
||||
Items: []string{"S3 Tier", "MinIO Tier"},
|
||||
}
|
||||
|
||||
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
|
||||
return returnListMock, nil
|
||||
}
|
||||
|
||||
tiersList, err := getTiersName(ctx, adminClient)
|
||||
if err != nil {
|
||||
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
|
||||
}
|
||||
// verify length of tiers list is correct
|
||||
assert.Equal(len(tiersList.Items), len(returnListMock), fmt.Sprintf("Failed on %s: length of lists is not the same", function))
|
||||
assert.Equal(expectedOutput, tiersList)
|
||||
|
||||
// Test-2 : getTiersName() list is empty
|
||||
returnListMockT2 := []*madmin.TierConfig{}
|
||||
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
|
||||
return returnListMockT2, nil
|
||||
}
|
||||
|
||||
emptyTierList, err := getTiersName(ctx, adminClient)
|
||||
if err != nil {
|
||||
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
|
||||
}
|
||||
|
||||
if len(emptyTierList.Items) != 0 {
|
||||
t.Errorf("Failed on %s:, returned list was not empty", function)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddTier(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
// mock minIO client
|
||||
adminClient := AdminClientMock{}
|
||||
|
||||
function := "addTier()"
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
// Test-1: addTier() add new Tier
|
||||
minioAddTiersMock = func(_ context.Context, _ *madmin.TierConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
paramsToAdd := tieringApi.AddTierParams{
|
||||
Body: &models.Tier{
|
||||
Type: "S3",
|
||||
S3: &models.TierS3{
|
||||
Accesskey: "TestAK",
|
||||
Bucket: "bucket1",
|
||||
Endpoint: "https://test.com/",
|
||||
Name: "TIERS3",
|
||||
Prefix: "Pr1",
|
||||
Region: "us-west-1",
|
||||
Secretkey: "SecretK",
|
||||
Storageclass: "STCLASS",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := addTier(ctx, adminClient, ¶msToAdd)
|
||||
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
|
||||
// Test-2: addTier() error adding Tier
|
||||
minioAddTiersMock = func(_ context.Context, _ *madmin.TierConfig) error {
|
||||
return errors.New("error setting new tier")
|
||||
}
|
||||
|
||||
err2 := addTier(ctx, adminClient, ¶msToAdd)
|
||||
|
||||
assert.Equal(errors.New("error setting new tier"), err2, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
}
|
||||
|
||||
func TestUpdateTierCreds(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
// mock minIO client
|
||||
adminClient := AdminClientMock{}
|
||||
|
||||
function := "editTierCredentials()"
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
// Test-1: editTierCredentials() update Tier configuration
|
||||
minioEditTiersMock = func(_ context.Context, _ string, _ madmin.TierCreds) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
params := &tieringApi.EditTierCredentialsParams{
|
||||
Name: "TESTTIER",
|
||||
Body: &models.TierCredentialsRequest{
|
||||
AccessKey: "New Key",
|
||||
SecretKey: "Secret Key",
|
||||
},
|
||||
}
|
||||
|
||||
err := editTierCredentials(ctx, adminClient, params)
|
||||
|
||||
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
|
||||
// Test-2: editTierCredentials() update Tier configuration failure
|
||||
minioEditTiersMock = func(_ context.Context, _ string, _ madmin.TierCreds) error {
|
||||
return errors.New("error message")
|
||||
}
|
||||
|
||||
errT2 := editTierCredentials(ctx, adminClient, params)
|
||||
|
||||
assert.Equal(errors.New("error message"), errT2, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
}
|
||||
@@ -38,7 +38,6 @@ import (
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"github.com/minio/minio-go/v7/pkg/lifecycle"
|
||||
"github.com/minio/minio-go/v7/pkg/notification"
|
||||
"github.com/minio/minio-go/v7/pkg/tags"
|
||||
)
|
||||
@@ -74,8 +73,6 @@ type MinioClient interface {
|
||||
setObjectLockConfig(ctx context.Context, bucketName string, mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit) error
|
||||
getBucketObjectLockConfig(ctx context.Context, bucketName string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error)
|
||||
getObjectLockConfig(ctx context.Context, bucketName string) (lock string, mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error)
|
||||
getLifecycleRules(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error)
|
||||
setBucketLifecycle(ctx context.Context, bucketName string, config *lifecycle.Configuration) error
|
||||
copyObject(ctx context.Context, dst minio.CopyDestOptions, src minio.CopySrcOptions) (minio.UploadInfo, error)
|
||||
GetBucketTagging(ctx context.Context, bucketName string) (*tags.Tags, error)
|
||||
SetBucketTagging(ctx context.Context, bucketName string, tags *tags.Tags) error
|
||||
@@ -209,14 +206,6 @@ func (c minioClient) getObjectLockConfig(ctx context.Context, bucketName string)
|
||||
return c.client.GetObjectLockConfig(ctx, bucketName)
|
||||
}
|
||||
|
||||
func (c minioClient) getLifecycleRules(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return c.client.GetBucketLifecycle(ctx, bucketName)
|
||||
}
|
||||
|
||||
func (c minioClient) setBucketLifecycle(ctx context.Context, bucketName string, config *lifecycle.Configuration) error {
|
||||
return c.client.SetBucketLifecycle(ctx, bucketName, config)
|
||||
}
|
||||
|
||||
func (c minioClient) copyObject(ctx context.Context, dst minio.CopyDestOptions, src minio.CopySrcOptions) (minio.UploadInfo, error) {
|
||||
return c.client.CopyObject(ctx, dst, src)
|
||||
}
|
||||
|
||||
@@ -125,8 +125,6 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler {
|
||||
registerConfigHandlers(api)
|
||||
// Register bucket events handlers
|
||||
registerBucketEventsHandlers(api)
|
||||
// Register bucket lifecycle handlers
|
||||
registerBucketsLifecycleHandlers(api)
|
||||
// Register service handlers
|
||||
registerServiceHandlers(api)
|
||||
// Register session handlers
|
||||
@@ -147,8 +145,6 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler {
|
||||
registerKMSHandlers(api)
|
||||
// Register admin IDP handlers
|
||||
registerIDPHandlers(api)
|
||||
// Register Account handlers
|
||||
registerAdminTiersHandlers(api)
|
||||
// Register Inspect Handler
|
||||
registerInspectHandler(api)
|
||||
// Register nodes handlers
|
||||
|
||||
1812
api/embedded_spec.go
1812
api/embedded_spec.go
File diff suppressed because it is too large
Load Diff
@@ -46,25 +46,24 @@ func TestError(t *testing.T) {
|
||||
appErrors := map[string]expectedError{
|
||||
"ErrDefault": {code: 500, err: ErrDefault},
|
||||
|
||||
"ErrForbidden": {code: 403, err: ErrForbidden},
|
||||
"ErrFileTooLarge": {code: 413, err: ErrFileTooLarge},
|
||||
"ErrInvalidSession": {code: 401, err: ErrInvalidSession},
|
||||
"ErrNotFound": {code: 404, err: ErrNotFound},
|
||||
"ErrGroupAlreadyExists": {code: 400, err: ErrGroupAlreadyExists},
|
||||
"ErrInvalidErasureCodingValue": {code: 400, err: ErrInvalidErasureCodingValue},
|
||||
"ErrBucketBodyNotInRequest": {code: 400, err: ErrBucketBodyNotInRequest},
|
||||
"ErrBucketNameNotInRequest": {code: 400, err: ErrBucketNameNotInRequest},
|
||||
"ErrGroupBodyNotInRequest": {code: 400, err: ErrGroupBodyNotInRequest},
|
||||
"ErrGroupNameNotInRequest": {code: 400, err: ErrGroupNameNotInRequest},
|
||||
"ErrPolicyNameNotInRequest": {code: 400, err: ErrPolicyNameNotInRequest},
|
||||
"ErrPolicyBodyNotInRequest": {code: 400, err: ErrPolicyBodyNotInRequest},
|
||||
"ErrInvalidEncryptionAlgorithm": {code: 500, err: ErrInvalidEncryptionAlgorithm},
|
||||
"ErrSSENotConfigured": {code: 404, err: ErrSSENotConfigured},
|
||||
"ErrBucketLifeCycleNotConfigured": {code: 404, err: ErrBucketLifeCycleNotConfigured},
|
||||
"ErrChangePassword": {code: 403, err: ErrChangePassword},
|
||||
"ErrInvalidLicense": {code: 404, err: ErrInvalidLicense},
|
||||
"ErrLicenseNotFound": {code: 404, err: ErrLicenseNotFound},
|
||||
"ErrAvoidSelfAccountDelete": {code: 403, err: ErrAvoidSelfAccountDelete},
|
||||
"ErrForbidden": {code: 403, err: ErrForbidden},
|
||||
"ErrFileTooLarge": {code: 413, err: ErrFileTooLarge},
|
||||
"ErrInvalidSession": {code: 401, err: ErrInvalidSession},
|
||||
"ErrNotFound": {code: 404, err: ErrNotFound},
|
||||
"ErrGroupAlreadyExists": {code: 400, err: ErrGroupAlreadyExists},
|
||||
"ErrInvalidErasureCodingValue": {code: 400, err: ErrInvalidErasureCodingValue},
|
||||
"ErrBucketBodyNotInRequest": {code: 400, err: ErrBucketBodyNotInRequest},
|
||||
"ErrBucketNameNotInRequest": {code: 400, err: ErrBucketNameNotInRequest},
|
||||
"ErrGroupBodyNotInRequest": {code: 400, err: ErrGroupBodyNotInRequest},
|
||||
"ErrGroupNameNotInRequest": {code: 400, err: ErrGroupNameNotInRequest},
|
||||
"ErrPolicyNameNotInRequest": {code: 400, err: ErrPolicyNameNotInRequest},
|
||||
"ErrPolicyBodyNotInRequest": {code: 400, err: ErrPolicyBodyNotInRequest},
|
||||
"ErrInvalidEncryptionAlgorithm": {code: 500, err: ErrInvalidEncryptionAlgorithm},
|
||||
"ErrSSENotConfigured": {code: 404, err: ErrSSENotConfigured},
|
||||
"ErrChangePassword": {code: 403, err: ErrChangePassword},
|
||||
"ErrInvalidLicense": {code: 404, err: ErrInvalidLicense},
|
||||
"ErrLicenseNotFound": {code: 404, err: ErrLicenseNotFound},
|
||||
"ErrAvoidSelfAccountDelete": {code: 403, err: ErrAvoidSelfAccountDelete},
|
||||
|
||||
"ErrNonUniqueAccessKey": {code: 500, err: ErrNonUniqueAccessKey},
|
||||
"ErrRemoteTierExists": {code: 400, err: ErrRemoteTierExists},
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// AddBucketLifecycleHandlerFunc turns a function with the right signature into a add bucket lifecycle handler
|
||||
type AddBucketLifecycleHandlerFunc func(AddBucketLifecycleParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn AddBucketLifecycleHandlerFunc) Handle(params AddBucketLifecycleParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// AddBucketLifecycleHandler interface for that can handle valid add bucket lifecycle params
|
||||
type AddBucketLifecycleHandler interface {
|
||||
Handle(AddBucketLifecycleParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewAddBucketLifecycle creates a new http.Handler for the add bucket lifecycle operation
|
||||
func NewAddBucketLifecycle(ctx *middleware.Context, handler AddBucketLifecycleHandler) *AddBucketLifecycle {
|
||||
return &AddBucketLifecycle{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
AddBucketLifecycle swagger:route POST /buckets/{bucket_name}/lifecycle Bucket addBucketLifecycle
|
||||
|
||||
Add Bucket Lifecycle
|
||||
*/
|
||||
type AddBucketLifecycle struct {
|
||||
Context *middleware.Context
|
||||
Handler AddBucketLifecycleHandler
|
||||
}
|
||||
|
||||
func (o *AddBucketLifecycle) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewAddBucketLifecycleParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewAddBucketLifecycleParams creates a new AddBucketLifecycleParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewAddBucketLifecycleParams() AddBucketLifecycleParams {
|
||||
|
||||
return AddBucketLifecycleParams{}
|
||||
}
|
||||
|
||||
// AddBucketLifecycleParams contains all the bound params for the add bucket lifecycle operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters AddBucketLifecycle
|
||||
type AddBucketLifecycleParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.AddBucketLifecycle
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
BucketName string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewAddBucketLifecycleParams() beforehand.
|
||||
func (o *AddBucketLifecycleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.AddBucketLifecycle
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
}
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(r.Context())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
|
||||
rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
|
||||
if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindBucketName binds and validates parameter BucketName from path.
|
||||
func (o *AddBucketLifecycleParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.BucketName = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// AddBucketLifecycleCreatedCode is the HTTP code returned for type AddBucketLifecycleCreated
|
||||
const AddBucketLifecycleCreatedCode int = 201
|
||||
|
||||
/*
|
||||
AddBucketLifecycleCreated A successful response.
|
||||
|
||||
swagger:response addBucketLifecycleCreated
|
||||
*/
|
||||
type AddBucketLifecycleCreated struct {
|
||||
}
|
||||
|
||||
// NewAddBucketLifecycleCreated creates AddBucketLifecycleCreated with default headers values
|
||||
func NewAddBucketLifecycleCreated() *AddBucketLifecycleCreated {
|
||||
|
||||
return &AddBucketLifecycleCreated{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *AddBucketLifecycleCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(201)
|
||||
}
|
||||
|
||||
/*
|
||||
AddBucketLifecycleDefault Generic error response.
|
||||
|
||||
swagger:response addBucketLifecycleDefault
|
||||
*/
|
||||
type AddBucketLifecycleDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewAddBucketLifecycleDefault creates AddBucketLifecycleDefault with default headers values
|
||||
func NewAddBucketLifecycleDefault(code int) *AddBucketLifecycleDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &AddBucketLifecycleDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the add bucket lifecycle default response
|
||||
func (o *AddBucketLifecycleDefault) WithStatusCode(code int) *AddBucketLifecycleDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the add bucket lifecycle default response
|
||||
func (o *AddBucketLifecycleDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the add bucket lifecycle default response
|
||||
func (o *AddBucketLifecycleDefault) WithPayload(payload *models.APIError) *AddBucketLifecycleDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the add bucket lifecycle default response
|
||||
func (o *AddBucketLifecycleDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *AddBucketLifecycleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// AddBucketLifecycleURL generates an URL for the add bucket lifecycle operation
|
||||
type AddBucketLifecycleURL struct {
|
||||
BucketName string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *AddBucketLifecycleURL) WithBasePath(bp string) *AddBucketLifecycleURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *AddBucketLifecycleURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *AddBucketLifecycleURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/buckets/{bucket_name}/lifecycle"
|
||||
|
||||
bucketName := o.BucketName
|
||||
if bucketName != "" {
|
||||
_path = strings.Replace(_path, "{bucket_name}", bucketName, -1)
|
||||
} else {
|
||||
return nil, errors.New("bucketName is required on AddBucketLifecycleURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *AddBucketLifecycleURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *AddBucketLifecycleURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *AddBucketLifecycleURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on AddBucketLifecycleURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on AddBucketLifecycleURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *AddBucketLifecycleURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// AddMultiBucketLifecycleHandlerFunc turns a function with the right signature into a add multi bucket lifecycle handler
|
||||
type AddMultiBucketLifecycleHandlerFunc func(AddMultiBucketLifecycleParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn AddMultiBucketLifecycleHandlerFunc) Handle(params AddMultiBucketLifecycleParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// AddMultiBucketLifecycleHandler interface for that can handle valid add multi bucket lifecycle params
|
||||
type AddMultiBucketLifecycleHandler interface {
|
||||
Handle(AddMultiBucketLifecycleParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewAddMultiBucketLifecycle creates a new http.Handler for the add multi bucket lifecycle operation
|
||||
func NewAddMultiBucketLifecycle(ctx *middleware.Context, handler AddMultiBucketLifecycleHandler) *AddMultiBucketLifecycle {
|
||||
return &AddMultiBucketLifecycle{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
AddMultiBucketLifecycle swagger:route POST /buckets/multi-lifecycle Bucket addMultiBucketLifecycle
|
||||
|
||||
Add Multi Bucket Lifecycle
|
||||
*/
|
||||
type AddMultiBucketLifecycle struct {
|
||||
Context *middleware.Context
|
||||
Handler AddMultiBucketLifecycleHandler
|
||||
}
|
||||
|
||||
func (o *AddMultiBucketLifecycle) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewAddMultiBucketLifecycleParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewAddMultiBucketLifecycleParams creates a new AddMultiBucketLifecycleParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewAddMultiBucketLifecycleParams() AddMultiBucketLifecycleParams {
|
||||
|
||||
return AddMultiBucketLifecycleParams{}
|
||||
}
|
||||
|
||||
// AddMultiBucketLifecycleParams contains all the bound params for the add multi bucket lifecycle operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters AddMultiBucketLifecycle
|
||||
type AddMultiBucketLifecycleParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.AddMultiBucketLifecycle
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewAddMultiBucketLifecycleParams() beforehand.
|
||||
func (o *AddMultiBucketLifecycleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.AddMultiBucketLifecycle
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
}
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(r.Context())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// AddMultiBucketLifecycleOKCode is the HTTP code returned for type AddMultiBucketLifecycleOK
|
||||
const AddMultiBucketLifecycleOKCode int = 200
|
||||
|
||||
/*
|
||||
AddMultiBucketLifecycleOK A successful response.
|
||||
|
||||
swagger:response addMultiBucketLifecycleOK
|
||||
*/
|
||||
type AddMultiBucketLifecycleOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.MultiLifecycleResult `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewAddMultiBucketLifecycleOK creates AddMultiBucketLifecycleOK with default headers values
|
||||
func NewAddMultiBucketLifecycleOK() *AddMultiBucketLifecycleOK {
|
||||
|
||||
return &AddMultiBucketLifecycleOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the add multi bucket lifecycle o k response
|
||||
func (o *AddMultiBucketLifecycleOK) WithPayload(payload *models.MultiLifecycleResult) *AddMultiBucketLifecycleOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the add multi bucket lifecycle o k response
|
||||
func (o *AddMultiBucketLifecycleOK) SetPayload(payload *models.MultiLifecycleResult) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *AddMultiBucketLifecycleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
AddMultiBucketLifecycleDefault Generic error response.
|
||||
|
||||
swagger:response addMultiBucketLifecycleDefault
|
||||
*/
|
||||
type AddMultiBucketLifecycleDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewAddMultiBucketLifecycleDefault creates AddMultiBucketLifecycleDefault with default headers values
|
||||
func NewAddMultiBucketLifecycleDefault(code int) *AddMultiBucketLifecycleDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &AddMultiBucketLifecycleDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the add multi bucket lifecycle default response
|
||||
func (o *AddMultiBucketLifecycleDefault) WithStatusCode(code int) *AddMultiBucketLifecycleDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the add multi bucket lifecycle default response
|
||||
func (o *AddMultiBucketLifecycleDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the add multi bucket lifecycle default response
|
||||
func (o *AddMultiBucketLifecycleDefault) WithPayload(payload *models.APIError) *AddMultiBucketLifecycleDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the add multi bucket lifecycle default response
|
||||
func (o *AddMultiBucketLifecycleDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *AddMultiBucketLifecycleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// AddMultiBucketLifecycleURL generates an URL for the add multi bucket lifecycle operation
|
||||
type AddMultiBucketLifecycleURL struct {
|
||||
_basePath string
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *AddMultiBucketLifecycleURL) WithBasePath(bp string) *AddMultiBucketLifecycleURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *AddMultiBucketLifecycleURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *AddMultiBucketLifecycleURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/buckets/multi-lifecycle"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *AddMultiBucketLifecycleURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *AddMultiBucketLifecycleURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *AddMultiBucketLifecycleURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on AddMultiBucketLifecycleURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on AddMultiBucketLifecycleURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *AddMultiBucketLifecycleURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// DeleteBucketLifecycleRuleHandlerFunc turns a function with the right signature into a delete bucket lifecycle rule handler
|
||||
type DeleteBucketLifecycleRuleHandlerFunc func(DeleteBucketLifecycleRuleParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn DeleteBucketLifecycleRuleHandlerFunc) Handle(params DeleteBucketLifecycleRuleParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// DeleteBucketLifecycleRuleHandler interface for that can handle valid delete bucket lifecycle rule params
|
||||
type DeleteBucketLifecycleRuleHandler interface {
|
||||
Handle(DeleteBucketLifecycleRuleParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewDeleteBucketLifecycleRule creates a new http.Handler for the delete bucket lifecycle rule operation
|
||||
func NewDeleteBucketLifecycleRule(ctx *middleware.Context, handler DeleteBucketLifecycleRuleHandler) *DeleteBucketLifecycleRule {
|
||||
return &DeleteBucketLifecycleRule{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteBucketLifecycleRule swagger:route DELETE /buckets/{bucket_name}/lifecycle/{lifecycle_id} Bucket deleteBucketLifecycleRule
|
||||
|
||||
Delete Lifecycle rule
|
||||
*/
|
||||
type DeleteBucketLifecycleRule struct {
|
||||
Context *middleware.Context
|
||||
Handler DeleteBucketLifecycleRuleHandler
|
||||
}
|
||||
|
||||
func (o *DeleteBucketLifecycleRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewDeleteBucketLifecycleRuleParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDeleteBucketLifecycleRuleParams creates a new DeleteBucketLifecycleRuleParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewDeleteBucketLifecycleRuleParams() DeleteBucketLifecycleRuleParams {
|
||||
|
||||
return DeleteBucketLifecycleRuleParams{}
|
||||
}
|
||||
|
||||
// DeleteBucketLifecycleRuleParams contains all the bound params for the delete bucket lifecycle rule operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters DeleteBucketLifecycleRule
|
||||
type DeleteBucketLifecycleRuleParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
BucketName string
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
LifecycleID string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewDeleteBucketLifecycleRuleParams() beforehand.
|
||||
func (o *DeleteBucketLifecycleRuleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
|
||||
if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rLifecycleID, rhkLifecycleID, _ := route.Params.GetOK("lifecycle_id")
|
||||
if err := o.bindLifecycleID(rLifecycleID, rhkLifecycleID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindBucketName binds and validates parameter BucketName from path.
|
||||
func (o *DeleteBucketLifecycleRuleParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.BucketName = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindLifecycleID binds and validates parameter LifecycleID from path.
|
||||
func (o *DeleteBucketLifecycleRuleParams) bindLifecycleID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.LifecycleID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// DeleteBucketLifecycleRuleNoContentCode is the HTTP code returned for type DeleteBucketLifecycleRuleNoContent
|
||||
const DeleteBucketLifecycleRuleNoContentCode int = 204
|
||||
|
||||
/*
|
||||
DeleteBucketLifecycleRuleNoContent A successful response.
|
||||
|
||||
swagger:response deleteBucketLifecycleRuleNoContent
|
||||
*/
|
||||
type DeleteBucketLifecycleRuleNoContent struct {
|
||||
}
|
||||
|
||||
// NewDeleteBucketLifecycleRuleNoContent creates DeleteBucketLifecycleRuleNoContent with default headers values
|
||||
func NewDeleteBucketLifecycleRuleNoContent() *DeleteBucketLifecycleRuleNoContent {
|
||||
|
||||
return &DeleteBucketLifecycleRuleNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteBucketLifecycleRuleNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteBucketLifecycleRuleDefault Generic error response.
|
||||
|
||||
swagger:response deleteBucketLifecycleRuleDefault
|
||||
*/
|
||||
type DeleteBucketLifecycleRuleDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteBucketLifecycleRuleDefault creates DeleteBucketLifecycleRuleDefault with default headers values
|
||||
func NewDeleteBucketLifecycleRuleDefault(code int) *DeleteBucketLifecycleRuleDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &DeleteBucketLifecycleRuleDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the delete bucket lifecycle rule default response
|
||||
func (o *DeleteBucketLifecycleRuleDefault) WithStatusCode(code int) *DeleteBucketLifecycleRuleDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the delete bucket lifecycle rule default response
|
||||
func (o *DeleteBucketLifecycleRuleDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete bucket lifecycle rule default response
|
||||
func (o *DeleteBucketLifecycleRuleDefault) WithPayload(payload *models.APIError) *DeleteBucketLifecycleRuleDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete bucket lifecycle rule default response
|
||||
func (o *DeleteBucketLifecycleRuleDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteBucketLifecycleRuleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DeleteBucketLifecycleRuleURL generates an URL for the delete bucket lifecycle rule operation
|
||||
type DeleteBucketLifecycleRuleURL struct {
|
||||
BucketName string
|
||||
LifecycleID string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *DeleteBucketLifecycleRuleURL) WithBasePath(bp string) *DeleteBucketLifecycleRuleURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *DeleteBucketLifecycleRuleURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *DeleteBucketLifecycleRuleURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/buckets/{bucket_name}/lifecycle/{lifecycle_id}"
|
||||
|
||||
bucketName := o.BucketName
|
||||
if bucketName != "" {
|
||||
_path = strings.Replace(_path, "{bucket_name}", bucketName, -1)
|
||||
} else {
|
||||
return nil, errors.New("bucketName is required on DeleteBucketLifecycleRuleURL")
|
||||
}
|
||||
|
||||
lifecycleID := o.LifecycleID
|
||||
if lifecycleID != "" {
|
||||
_path = strings.Replace(_path, "{lifecycle_id}", lifecycleID, -1)
|
||||
} else {
|
||||
return nil, errors.New("lifecycleId is required on DeleteBucketLifecycleRuleURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *DeleteBucketLifecycleRuleURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *DeleteBucketLifecycleRuleURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *DeleteBucketLifecycleRuleURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on DeleteBucketLifecycleRuleURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on DeleteBucketLifecycleRuleURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *DeleteBucketLifecycleRuleURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// GetBucketLifecycleHandlerFunc turns a function with the right signature into a get bucket lifecycle handler
|
||||
type GetBucketLifecycleHandlerFunc func(GetBucketLifecycleParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetBucketLifecycleHandlerFunc) Handle(params GetBucketLifecycleParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// GetBucketLifecycleHandler interface for that can handle valid get bucket lifecycle params
|
||||
type GetBucketLifecycleHandler interface {
|
||||
Handle(GetBucketLifecycleParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetBucketLifecycle creates a new http.Handler for the get bucket lifecycle operation
|
||||
func NewGetBucketLifecycle(ctx *middleware.Context, handler GetBucketLifecycleHandler) *GetBucketLifecycle {
|
||||
return &GetBucketLifecycle{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
GetBucketLifecycle swagger:route GET /buckets/{bucket_name}/lifecycle Bucket getBucketLifecycle
|
||||
|
||||
Bucket Lifecycle
|
||||
*/
|
||||
type GetBucketLifecycle struct {
|
||||
Context *middleware.Context
|
||||
Handler GetBucketLifecycleHandler
|
||||
}
|
||||
|
||||
func (o *GetBucketLifecycle) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewGetBucketLifecycleParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewGetBucketLifecycleParams creates a new GetBucketLifecycleParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewGetBucketLifecycleParams() GetBucketLifecycleParams {
|
||||
|
||||
return GetBucketLifecycleParams{}
|
||||
}
|
||||
|
||||
// GetBucketLifecycleParams contains all the bound params for the get bucket lifecycle operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetBucketLifecycle
|
||||
type GetBucketLifecycleParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
BucketName string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewGetBucketLifecycleParams() beforehand.
|
||||
func (o *GetBucketLifecycleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
|
||||
if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindBucketName binds and validates parameter BucketName from path.
|
||||
func (o *GetBucketLifecycleParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.BucketName = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// GetBucketLifecycleOKCode is the HTTP code returned for type GetBucketLifecycleOK
|
||||
const GetBucketLifecycleOKCode int = 200
|
||||
|
||||
/*
|
||||
GetBucketLifecycleOK A successful response.
|
||||
|
||||
swagger:response getBucketLifecycleOK
|
||||
*/
|
||||
type GetBucketLifecycleOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.BucketLifecycleResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetBucketLifecycleOK creates GetBucketLifecycleOK with default headers values
|
||||
func NewGetBucketLifecycleOK() *GetBucketLifecycleOK {
|
||||
|
||||
return &GetBucketLifecycleOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get bucket lifecycle o k response
|
||||
func (o *GetBucketLifecycleOK) WithPayload(payload *models.BucketLifecycleResponse) *GetBucketLifecycleOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get bucket lifecycle o k response
|
||||
func (o *GetBucketLifecycleOK) SetPayload(payload *models.BucketLifecycleResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetBucketLifecycleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GetBucketLifecycleDefault Generic error response.
|
||||
|
||||
swagger:response getBucketLifecycleDefault
|
||||
*/
|
||||
type GetBucketLifecycleDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetBucketLifecycleDefault creates GetBucketLifecycleDefault with default headers values
|
||||
func NewGetBucketLifecycleDefault(code int) *GetBucketLifecycleDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetBucketLifecycleDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get bucket lifecycle default response
|
||||
func (o *GetBucketLifecycleDefault) WithStatusCode(code int) *GetBucketLifecycleDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get bucket lifecycle default response
|
||||
func (o *GetBucketLifecycleDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get bucket lifecycle default response
|
||||
func (o *GetBucketLifecycleDefault) WithPayload(payload *models.APIError) *GetBucketLifecycleDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get bucket lifecycle default response
|
||||
func (o *GetBucketLifecycleDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetBucketLifecycleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetBucketLifecycleURL generates an URL for the get bucket lifecycle operation
|
||||
type GetBucketLifecycleURL struct {
|
||||
BucketName string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetBucketLifecycleURL) WithBasePath(bp string) *GetBucketLifecycleURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetBucketLifecycleURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *GetBucketLifecycleURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/buckets/{bucket_name}/lifecycle"
|
||||
|
||||
bucketName := o.BucketName
|
||||
if bucketName != "" {
|
||||
_path = strings.Replace(_path, "{bucket_name}", bucketName, -1)
|
||||
} else {
|
||||
return nil, errors.New("bucketName is required on GetBucketLifecycleURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *GetBucketLifecycleURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *GetBucketLifecycleURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *GetBucketLifecycleURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on GetBucketLifecycleURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on GetBucketLifecycleURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *GetBucketLifecycleURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// UpdateBucketLifecycleHandlerFunc turns a function with the right signature into a update bucket lifecycle handler
|
||||
type UpdateBucketLifecycleHandlerFunc func(UpdateBucketLifecycleParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn UpdateBucketLifecycleHandlerFunc) Handle(params UpdateBucketLifecycleParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// UpdateBucketLifecycleHandler interface for that can handle valid update bucket lifecycle params
|
||||
type UpdateBucketLifecycleHandler interface {
|
||||
Handle(UpdateBucketLifecycleParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewUpdateBucketLifecycle creates a new http.Handler for the update bucket lifecycle operation
|
||||
func NewUpdateBucketLifecycle(ctx *middleware.Context, handler UpdateBucketLifecycleHandler) *UpdateBucketLifecycle {
|
||||
return &UpdateBucketLifecycle{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateBucketLifecycle swagger:route PUT /buckets/{bucket_name}/lifecycle/{lifecycle_id} Bucket updateBucketLifecycle
|
||||
|
||||
Update Lifecycle rule
|
||||
*/
|
||||
type UpdateBucketLifecycle struct {
|
||||
Context *middleware.Context
|
||||
Handler UpdateBucketLifecycleHandler
|
||||
}
|
||||
|
||||
func (o *UpdateBucketLifecycle) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewUpdateBucketLifecycleParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewUpdateBucketLifecycleParams creates a new UpdateBucketLifecycleParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewUpdateBucketLifecycleParams() UpdateBucketLifecycleParams {
|
||||
|
||||
return UpdateBucketLifecycleParams{}
|
||||
}
|
||||
|
||||
// UpdateBucketLifecycleParams contains all the bound params for the update bucket lifecycle operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters UpdateBucketLifecycle
|
||||
type UpdateBucketLifecycleParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.UpdateBucketLifecycle
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
BucketName string
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
LifecycleID string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewUpdateBucketLifecycleParams() beforehand.
|
||||
func (o *UpdateBucketLifecycleParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.UpdateBucketLifecycle
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
}
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(r.Context())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
|
||||
rBucketName, rhkBucketName, _ := route.Params.GetOK("bucket_name")
|
||||
if err := o.bindBucketName(rBucketName, rhkBucketName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rLifecycleID, rhkLifecycleID, _ := route.Params.GetOK("lifecycle_id")
|
||||
if err := o.bindLifecycleID(rLifecycleID, rhkLifecycleID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindBucketName binds and validates parameter BucketName from path.
|
||||
func (o *UpdateBucketLifecycleParams) bindBucketName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.BucketName = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindLifecycleID binds and validates parameter LifecycleID from path.
|
||||
func (o *UpdateBucketLifecycleParams) bindLifecycleID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.LifecycleID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// UpdateBucketLifecycleOKCode is the HTTP code returned for type UpdateBucketLifecycleOK
|
||||
const UpdateBucketLifecycleOKCode int = 200
|
||||
|
||||
/*
|
||||
UpdateBucketLifecycleOK A successful response.
|
||||
|
||||
swagger:response updateBucketLifecycleOK
|
||||
*/
|
||||
type UpdateBucketLifecycleOK struct {
|
||||
}
|
||||
|
||||
// NewUpdateBucketLifecycleOK creates UpdateBucketLifecycleOK with default headers values
|
||||
func NewUpdateBucketLifecycleOK() *UpdateBucketLifecycleOK {
|
||||
|
||||
return &UpdateBucketLifecycleOK{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *UpdateBucketLifecycleOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(200)
|
||||
}
|
||||
|
||||
/*
|
||||
UpdateBucketLifecycleDefault Generic error response.
|
||||
|
||||
swagger:response updateBucketLifecycleDefault
|
||||
*/
|
||||
type UpdateBucketLifecycleDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewUpdateBucketLifecycleDefault creates UpdateBucketLifecycleDefault with default headers values
|
||||
func NewUpdateBucketLifecycleDefault(code int) *UpdateBucketLifecycleDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &UpdateBucketLifecycleDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the update bucket lifecycle default response
|
||||
func (o *UpdateBucketLifecycleDefault) WithStatusCode(code int) *UpdateBucketLifecycleDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the update bucket lifecycle default response
|
||||
func (o *UpdateBucketLifecycleDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the update bucket lifecycle default response
|
||||
func (o *UpdateBucketLifecycleDefault) WithPayload(payload *models.APIError) *UpdateBucketLifecycleDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the update bucket lifecycle default response
|
||||
func (o *UpdateBucketLifecycleDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *UpdateBucketLifecycleDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package bucket
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// UpdateBucketLifecycleURL generates an URL for the update bucket lifecycle operation
|
||||
type UpdateBucketLifecycleURL struct {
|
||||
BucketName string
|
||||
LifecycleID string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *UpdateBucketLifecycleURL) WithBasePath(bp string) *UpdateBucketLifecycleURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *UpdateBucketLifecycleURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *UpdateBucketLifecycleURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/buckets/{bucket_name}/lifecycle/{lifecycle_id}"
|
||||
|
||||
bucketName := o.BucketName
|
||||
if bucketName != "" {
|
||||
_path = strings.Replace(_path, "{bucket_name}", bucketName, -1)
|
||||
} else {
|
||||
return nil, errors.New("bucketName is required on UpdateBucketLifecycleURL")
|
||||
}
|
||||
|
||||
lifecycleID := o.LifecycleID
|
||||
if lifecycleID != "" {
|
||||
_path = strings.Replace(_path, "{lifecycle_id}", lifecycleID, -1)
|
||||
} else {
|
||||
return nil, errors.New("lifecycleId is required on UpdateBucketLifecycleURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *UpdateBucketLifecycleURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *UpdateBucketLifecycleURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *UpdateBucketLifecycleURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on UpdateBucketLifecycleURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on UpdateBucketLifecycleURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *UpdateBucketLifecycleURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -52,7 +52,6 @@ import (
|
||||
"github.com/minio/console/api/operations/service"
|
||||
"github.com/minio/console/api/operations/service_account"
|
||||
"github.com/minio/console/api/operations/system"
|
||||
"github.com/minio/console/api/operations/tiering"
|
||||
"github.com/minio/console/api/operations/user"
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
@@ -84,15 +83,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
AccountAccountChangePasswordHandler: account.AccountChangePasswordHandlerFunc(func(params account.AccountChangePasswordParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation account.AccountChangePassword has not yet been implemented")
|
||||
}),
|
||||
BucketAddBucketLifecycleHandler: bucket.AddBucketLifecycleHandlerFunc(func(params bucket.AddBucketLifecycleParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.AddBucketLifecycle has not yet been implemented")
|
||||
}),
|
||||
GroupAddGroupHandler: group.AddGroupHandlerFunc(func(params group.AddGroupParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation group.AddGroup has not yet been implemented")
|
||||
}),
|
||||
BucketAddMultiBucketLifecycleHandler: bucket.AddMultiBucketLifecycleHandlerFunc(func(params bucket.AddMultiBucketLifecycleParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.AddMultiBucketLifecycle has not yet been implemented")
|
||||
}),
|
||||
ConfigurationAddNotificationEndpointHandler: configuration.AddNotificationEndpointHandlerFunc(func(params configuration.AddNotificationEndpointParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation configuration.AddNotificationEndpoint has not yet been implemented")
|
||||
}),
|
||||
@@ -102,9 +95,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
BucketAddRemoteBucketHandler: bucket.AddRemoteBucketHandlerFunc(func(params bucket.AddRemoteBucketParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.AddRemoteBucket has not yet been implemented")
|
||||
}),
|
||||
TieringAddTierHandler: tiering.AddTierHandlerFunc(func(params tiering.AddTierParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation tiering.AddTier has not yet been implemented")
|
||||
}),
|
||||
UserAddUserHandler: user.AddUserHandlerFunc(func(params user.AddUserParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user.AddUser has not yet been implemented")
|
||||
}),
|
||||
@@ -165,9 +155,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
BucketDeleteBucketEventHandler: bucket.DeleteBucketEventHandlerFunc(func(params bucket.DeleteBucketEventParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.DeleteBucketEvent has not yet been implemented")
|
||||
}),
|
||||
BucketDeleteBucketLifecycleRuleHandler: bucket.DeleteBucketLifecycleRuleHandlerFunc(func(params bucket.DeleteBucketLifecycleRuleParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.DeleteBucketLifecycleRule has not yet been implemented")
|
||||
}),
|
||||
BucketDeleteBucketReplicationRuleHandler: bucket.DeleteBucketReplicationRuleHandlerFunc(func(params bucket.DeleteBucketReplicationRuleParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.DeleteBucketReplicationRule has not yet been implemented")
|
||||
}),
|
||||
@@ -207,9 +194,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
PublicDownloadSharedObjectHandler: public.DownloadSharedObjectHandlerFunc(func(params public.DownloadSharedObjectParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation public.DownloadSharedObject has not yet been implemented")
|
||||
}),
|
||||
TieringEditTierCredentialsHandler: tiering.EditTierCredentialsHandlerFunc(func(params tiering.EditTierCredentialsParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation tiering.EditTierCredentials has not yet been implemented")
|
||||
}),
|
||||
BucketEnableBucketEncryptionHandler: bucket.EnableBucketEncryptionHandlerFunc(func(params bucket.EnableBucketEncryptionParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.EnableBucketEncryption has not yet been implemented")
|
||||
}),
|
||||
@@ -219,9 +203,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
BucketGetBucketEncryptionInfoHandler: bucket.GetBucketEncryptionInfoHandlerFunc(func(params bucket.GetBucketEncryptionInfoParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.GetBucketEncryptionInfo has not yet been implemented")
|
||||
}),
|
||||
BucketGetBucketLifecycleHandler: bucket.GetBucketLifecycleHandlerFunc(func(params bucket.GetBucketLifecycleParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.GetBucketLifecycle has not yet been implemented")
|
||||
}),
|
||||
BucketGetBucketObjectLockingStatusHandler: bucket.GetBucketObjectLockingStatusHandlerFunc(func(params bucket.GetBucketObjectLockingStatusParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.GetBucketObjectLockingStatus has not yet been implemented")
|
||||
}),
|
||||
@@ -261,9 +242,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
ServiceAccountGetServiceAccountHandler: service_account.GetServiceAccountHandlerFunc(func(params service_account.GetServiceAccountParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation service_account.GetServiceAccount has not yet been implemented")
|
||||
}),
|
||||
TieringGetTierHandler: tiering.GetTierHandlerFunc(func(params tiering.GetTierParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation tiering.GetTier has not yet been implemented")
|
||||
}),
|
||||
UserGetUserInfoHandler: user.GetUserInfoHandlerFunc(func(params user.GetUserInfoParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user.GetUserInfo has not yet been implemented")
|
||||
}),
|
||||
@@ -408,9 +386,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
PolicyRemovePolicyHandler: policy.RemovePolicyHandlerFunc(func(params policy.RemovePolicyParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation policy.RemovePolicy has not yet been implemented")
|
||||
}),
|
||||
TieringRemoveTierHandler: tiering.RemoveTierHandlerFunc(func(params tiering.RemoveTierParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation tiering.RemoveTier has not yet been implemented")
|
||||
}),
|
||||
UserRemoveUserHandler: user.RemoveUserHandlerFunc(func(params user.RemoveUserParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user.RemoveUser has not yet been implemented")
|
||||
}),
|
||||
@@ -450,15 +425,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
ObjectShareObjectHandler: object.ShareObjectHandlerFunc(func(params object.ShareObjectParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation object.ShareObject has not yet been implemented")
|
||||
}),
|
||||
TieringTiersListHandler: tiering.TiersListHandlerFunc(func(params tiering.TiersListParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation tiering.TiersList has not yet been implemented")
|
||||
}),
|
||||
TieringTiersListNamesHandler: tiering.TiersListNamesHandlerFunc(func(params tiering.TiersListNamesParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation tiering.TiersListNames has not yet been implemented")
|
||||
}),
|
||||
BucketUpdateBucketLifecycleHandler: bucket.UpdateBucketLifecycleHandlerFunc(func(params bucket.UpdateBucketLifecycleParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.UpdateBucketLifecycle has not yet been implemented")
|
||||
}),
|
||||
IdpUpdateConfigurationHandler: idp.UpdateConfigurationHandlerFunc(func(params idp.UpdateConfigurationParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation idp.UpdateConfiguration has not yet been implemented")
|
||||
}),
|
||||
@@ -542,20 +508,14 @@ type ConsoleAPI struct {
|
||||
|
||||
// AccountAccountChangePasswordHandler sets the operation handler for the account change password operation
|
||||
AccountAccountChangePasswordHandler account.AccountChangePasswordHandler
|
||||
// BucketAddBucketLifecycleHandler sets the operation handler for the add bucket lifecycle operation
|
||||
BucketAddBucketLifecycleHandler bucket.AddBucketLifecycleHandler
|
||||
// GroupAddGroupHandler sets the operation handler for the add group operation
|
||||
GroupAddGroupHandler group.AddGroupHandler
|
||||
// BucketAddMultiBucketLifecycleHandler sets the operation handler for the add multi bucket lifecycle operation
|
||||
BucketAddMultiBucketLifecycleHandler bucket.AddMultiBucketLifecycleHandler
|
||||
// ConfigurationAddNotificationEndpointHandler sets the operation handler for the add notification endpoint operation
|
||||
ConfigurationAddNotificationEndpointHandler configuration.AddNotificationEndpointHandler
|
||||
// PolicyAddPolicyHandler sets the operation handler for the add policy operation
|
||||
PolicyAddPolicyHandler policy.AddPolicyHandler
|
||||
// BucketAddRemoteBucketHandler sets the operation handler for the add remote bucket operation
|
||||
BucketAddRemoteBucketHandler bucket.AddRemoteBucketHandler
|
||||
// TieringAddTierHandler sets the operation handler for the add tier operation
|
||||
TieringAddTierHandler tiering.AddTierHandler
|
||||
// UserAddUserHandler sets the operation handler for the add user operation
|
||||
UserAddUserHandler user.AddUserHandler
|
||||
// SystemAdminInfoHandler sets the operation handler for the admin info operation
|
||||
@@ -596,8 +556,6 @@ type ConsoleAPI struct {
|
||||
BucketDeleteBucketHandler bucket.DeleteBucketHandler
|
||||
// BucketDeleteBucketEventHandler sets the operation handler for the delete bucket event operation
|
||||
BucketDeleteBucketEventHandler bucket.DeleteBucketEventHandler
|
||||
// BucketDeleteBucketLifecycleRuleHandler sets the operation handler for the delete bucket lifecycle rule operation
|
||||
BucketDeleteBucketLifecycleRuleHandler bucket.DeleteBucketLifecycleRuleHandler
|
||||
// BucketDeleteBucketReplicationRuleHandler sets the operation handler for the delete bucket replication rule operation
|
||||
BucketDeleteBucketReplicationRuleHandler bucket.DeleteBucketReplicationRuleHandler
|
||||
// IdpDeleteConfigurationHandler sets the operation handler for the delete configuration operation
|
||||
@@ -624,16 +582,12 @@ type ConsoleAPI struct {
|
||||
ObjectDownloadMultipleObjectsHandler object.DownloadMultipleObjectsHandler
|
||||
// PublicDownloadSharedObjectHandler sets the operation handler for the download shared object operation
|
||||
PublicDownloadSharedObjectHandler public.DownloadSharedObjectHandler
|
||||
// TieringEditTierCredentialsHandler sets the operation handler for the edit tier credentials operation
|
||||
TieringEditTierCredentialsHandler tiering.EditTierCredentialsHandler
|
||||
// BucketEnableBucketEncryptionHandler sets the operation handler for the enable bucket encryption operation
|
||||
BucketEnableBucketEncryptionHandler bucket.EnableBucketEncryptionHandler
|
||||
// ConfigurationExportConfigHandler sets the operation handler for the export config operation
|
||||
ConfigurationExportConfigHandler configuration.ExportConfigHandler
|
||||
// BucketGetBucketEncryptionInfoHandler sets the operation handler for the get bucket encryption info operation
|
||||
BucketGetBucketEncryptionInfoHandler bucket.GetBucketEncryptionInfoHandler
|
||||
// BucketGetBucketLifecycleHandler sets the operation handler for the get bucket lifecycle operation
|
||||
BucketGetBucketLifecycleHandler bucket.GetBucketLifecycleHandler
|
||||
// BucketGetBucketObjectLockingStatusHandler sets the operation handler for the get bucket object locking status operation
|
||||
BucketGetBucketObjectLockingStatusHandler bucket.GetBucketObjectLockingStatusHandler
|
||||
// BucketGetBucketQuotaHandler sets the operation handler for the get bucket quota operation
|
||||
@@ -660,8 +614,6 @@ type ConsoleAPI struct {
|
||||
PolicyGetSAUserPolicyHandler policy.GetSAUserPolicyHandler
|
||||
// ServiceAccountGetServiceAccountHandler sets the operation handler for the get service account operation
|
||||
ServiceAccountGetServiceAccountHandler service_account.GetServiceAccountHandler
|
||||
// TieringGetTierHandler sets the operation handler for the get tier operation
|
||||
TieringGetTierHandler tiering.GetTierHandler
|
||||
// UserGetUserInfoHandler sets the operation handler for the get user info operation
|
||||
UserGetUserInfoHandler user.GetUserInfoHandler
|
||||
// PolicyGetUserPolicyHandler sets the operation handler for the get user policy operation
|
||||
@@ -758,8 +710,6 @@ type ConsoleAPI struct {
|
||||
GroupRemoveGroupHandler group.RemoveGroupHandler
|
||||
// PolicyRemovePolicyHandler sets the operation handler for the remove policy operation
|
||||
PolicyRemovePolicyHandler policy.RemovePolicyHandler
|
||||
// TieringRemoveTierHandler sets the operation handler for the remove tier operation
|
||||
TieringRemoveTierHandler tiering.RemoveTierHandler
|
||||
// UserRemoveUserHandler sets the operation handler for the remove user operation
|
||||
UserRemoveUserHandler user.RemoveUserHandler
|
||||
// ConfigurationResetConfigHandler sets the operation handler for the reset config operation
|
||||
@@ -786,12 +736,6 @@ type ConsoleAPI struct {
|
||||
PolicySetPolicyMultipleHandler policy.SetPolicyMultipleHandler
|
||||
// ObjectShareObjectHandler sets the operation handler for the share object operation
|
||||
ObjectShareObjectHandler object.ShareObjectHandler
|
||||
// TieringTiersListHandler sets the operation handler for the tiers list operation
|
||||
TieringTiersListHandler tiering.TiersListHandler
|
||||
// TieringTiersListNamesHandler sets the operation handler for the tiers list names operation
|
||||
TieringTiersListNamesHandler tiering.TiersListNamesHandler
|
||||
// BucketUpdateBucketLifecycleHandler sets the operation handler for the update bucket lifecycle operation
|
||||
BucketUpdateBucketLifecycleHandler bucket.UpdateBucketLifecycleHandler
|
||||
// IdpUpdateConfigurationHandler sets the operation handler for the update configuration operation
|
||||
IdpUpdateConfigurationHandler idp.UpdateConfigurationHandler
|
||||
// GroupUpdateGroupHandler sets the operation handler for the update group operation
|
||||
@@ -897,15 +841,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.AccountAccountChangePasswordHandler == nil {
|
||||
unregistered = append(unregistered, "account.AccountChangePasswordHandler")
|
||||
}
|
||||
if o.BucketAddBucketLifecycleHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.AddBucketLifecycleHandler")
|
||||
}
|
||||
if o.GroupAddGroupHandler == nil {
|
||||
unregistered = append(unregistered, "group.AddGroupHandler")
|
||||
}
|
||||
if o.BucketAddMultiBucketLifecycleHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.AddMultiBucketLifecycleHandler")
|
||||
}
|
||||
if o.ConfigurationAddNotificationEndpointHandler == nil {
|
||||
unregistered = append(unregistered, "configuration.AddNotificationEndpointHandler")
|
||||
}
|
||||
@@ -915,9 +853,6 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.BucketAddRemoteBucketHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.AddRemoteBucketHandler")
|
||||
}
|
||||
if o.TieringAddTierHandler == nil {
|
||||
unregistered = append(unregistered, "tiering.AddTierHandler")
|
||||
}
|
||||
if o.UserAddUserHandler == nil {
|
||||
unregistered = append(unregistered, "user.AddUserHandler")
|
||||
}
|
||||
@@ -978,9 +913,6 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.BucketDeleteBucketEventHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.DeleteBucketEventHandler")
|
||||
}
|
||||
if o.BucketDeleteBucketLifecycleRuleHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.DeleteBucketLifecycleRuleHandler")
|
||||
}
|
||||
if o.BucketDeleteBucketReplicationRuleHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.DeleteBucketReplicationRuleHandler")
|
||||
}
|
||||
@@ -1020,9 +952,6 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.PublicDownloadSharedObjectHandler == nil {
|
||||
unregistered = append(unregistered, "public.DownloadSharedObjectHandler")
|
||||
}
|
||||
if o.TieringEditTierCredentialsHandler == nil {
|
||||
unregistered = append(unregistered, "tiering.EditTierCredentialsHandler")
|
||||
}
|
||||
if o.BucketEnableBucketEncryptionHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.EnableBucketEncryptionHandler")
|
||||
}
|
||||
@@ -1032,9 +961,6 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.BucketGetBucketEncryptionInfoHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.GetBucketEncryptionInfoHandler")
|
||||
}
|
||||
if o.BucketGetBucketLifecycleHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.GetBucketLifecycleHandler")
|
||||
}
|
||||
if o.BucketGetBucketObjectLockingStatusHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.GetBucketObjectLockingStatusHandler")
|
||||
}
|
||||
@@ -1074,9 +1000,6 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.ServiceAccountGetServiceAccountHandler == nil {
|
||||
unregistered = append(unregistered, "service_account.GetServiceAccountHandler")
|
||||
}
|
||||
if o.TieringGetTierHandler == nil {
|
||||
unregistered = append(unregistered, "tiering.GetTierHandler")
|
||||
}
|
||||
if o.UserGetUserInfoHandler == nil {
|
||||
unregistered = append(unregistered, "user.GetUserInfoHandler")
|
||||
}
|
||||
@@ -1221,9 +1144,6 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.PolicyRemovePolicyHandler == nil {
|
||||
unregistered = append(unregistered, "policy.RemovePolicyHandler")
|
||||
}
|
||||
if o.TieringRemoveTierHandler == nil {
|
||||
unregistered = append(unregistered, "tiering.RemoveTierHandler")
|
||||
}
|
||||
if o.UserRemoveUserHandler == nil {
|
||||
unregistered = append(unregistered, "user.RemoveUserHandler")
|
||||
}
|
||||
@@ -1263,15 +1183,6 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.ObjectShareObjectHandler == nil {
|
||||
unregistered = append(unregistered, "object.ShareObjectHandler")
|
||||
}
|
||||
if o.TieringTiersListHandler == nil {
|
||||
unregistered = append(unregistered, "tiering.TiersListHandler")
|
||||
}
|
||||
if o.TieringTiersListNamesHandler == nil {
|
||||
unregistered = append(unregistered, "tiering.TiersListNamesHandler")
|
||||
}
|
||||
if o.BucketUpdateBucketLifecycleHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.UpdateBucketLifecycleHandler")
|
||||
}
|
||||
if o.IdpUpdateConfigurationHandler == nil {
|
||||
unregistered = append(unregistered, "idp.UpdateConfigurationHandler")
|
||||
}
|
||||
@@ -1405,18 +1316,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/buckets/{bucket_name}/lifecycle"] = bucket.NewAddBucketLifecycle(o.context, o.BucketAddBucketLifecycleHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/groups"] = group.NewAddGroup(o.context, o.GroupAddGroupHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/buckets/multi-lifecycle"] = bucket.NewAddMultiBucketLifecycle(o.context, o.BucketAddMultiBucketLifecycleHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/admin/notification_endpoints"] = configuration.NewAddNotificationEndpoint(o.context, o.ConfigurationAddNotificationEndpointHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
@@ -1429,10 +1332,6 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/admin/tiers"] = tiering.NewAddTier(o.context, o.TieringAddTierHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/users"] = user.NewAddUser(o.context, o.UserAddUserHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
@@ -1513,10 +1412,6 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/buckets/{bucket_name}/lifecycle/{lifecycle_id}"] = bucket.NewDeleteBucketLifecycleRule(o.context, o.BucketDeleteBucketLifecycleRuleHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/buckets/{bucket_name}/replication/{rule_id}"] = bucket.NewDeleteBucketReplicationRule(o.context, o.BucketDeleteBucketReplicationRuleHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
@@ -1566,10 +1461,6 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/download-shared-object/{url}"] = public.NewDownloadSharedObject(o.context, o.PublicDownloadSharedObjectHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/admin/tiers/{type}/{name}/credentials"] = tiering.NewEditTierCredentials(o.context, o.TieringEditTierCredentialsHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
@@ -1585,10 +1476,6 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/buckets/{bucket_name}/lifecycle"] = bucket.NewGetBucketLifecycle(o.context, o.BucketGetBucketLifecycleHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/buckets/{bucket_name}/object-locking"] = bucket.NewGetBucketObjectLockingStatus(o.context, o.BucketGetBucketObjectLockingStatusHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
@@ -1641,10 +1528,6 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/admin/tiers/{type}/{name}"] = tiering.NewGetTier(o.context, o.TieringGetTierHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/user/{name}"] = user.NewGetUserInfo(o.context, o.UserGetUserInfoHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
@@ -1837,10 +1720,6 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/admin/tiers/{name}/remove"] = tiering.NewRemoveTier(o.context, o.TieringRemoveTierHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/user/{name}"] = user.NewRemoveUser(o.context, o.UserRemoveUserHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
@@ -1890,18 +1769,6 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/buckets/{bucket_name}/objects/share"] = object.NewShareObject(o.context, o.ObjectShareObjectHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/admin/tiers"] = tiering.NewTiersList(o.context, o.TieringTiersListHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/admin/tiers/names"] = tiering.NewTiersListNames(o.context, o.TieringTiersListNamesHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/buckets/{bucket_name}/lifecycle/{lifecycle_id}"] = bucket.NewUpdateBucketLifecycle(o.context, o.BucketUpdateBucketLifecycleHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// AddTierHandlerFunc turns a function with the right signature into a add tier handler
|
||||
type AddTierHandlerFunc func(AddTierParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn AddTierHandlerFunc) Handle(params AddTierParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// AddTierHandler interface for that can handle valid add tier params
|
||||
type AddTierHandler interface {
|
||||
Handle(AddTierParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewAddTier creates a new http.Handler for the add tier operation
|
||||
func NewAddTier(ctx *middleware.Context, handler AddTierHandler) *AddTier {
|
||||
return &AddTier{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
AddTier swagger:route POST /admin/tiers Tiering addTier
|
||||
|
||||
Allows to configure a new tier
|
||||
*/
|
||||
type AddTier struct {
|
||||
Context *middleware.Context
|
||||
Handler AddTierHandler
|
||||
}
|
||||
|
||||
func (o *AddTier) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewAddTierParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewAddTierParams creates a new AddTierParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewAddTierParams() AddTierParams {
|
||||
|
||||
return AddTierParams{}
|
||||
}
|
||||
|
||||
// AddTierParams contains all the bound params for the add tier operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters AddTier
|
||||
type AddTierParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.Tier
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewAddTierParams() beforehand.
|
||||
func (o *AddTierParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.Tier
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
}
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(r.Context())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// AddTierCreatedCode is the HTTP code returned for type AddTierCreated
|
||||
const AddTierCreatedCode int = 201
|
||||
|
||||
/*
|
||||
AddTierCreated A successful response.
|
||||
|
||||
swagger:response addTierCreated
|
||||
*/
|
||||
type AddTierCreated struct {
|
||||
}
|
||||
|
||||
// NewAddTierCreated creates AddTierCreated with default headers values
|
||||
func NewAddTierCreated() *AddTierCreated {
|
||||
|
||||
return &AddTierCreated{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *AddTierCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(201)
|
||||
}
|
||||
|
||||
/*
|
||||
AddTierDefault Generic error response.
|
||||
|
||||
swagger:response addTierDefault
|
||||
*/
|
||||
type AddTierDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewAddTierDefault creates AddTierDefault with default headers values
|
||||
func NewAddTierDefault(code int) *AddTierDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &AddTierDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the add tier default response
|
||||
func (o *AddTierDefault) WithStatusCode(code int) *AddTierDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the add tier default response
|
||||
func (o *AddTierDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the add tier default response
|
||||
func (o *AddTierDefault) WithPayload(payload *models.APIError) *AddTierDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the add tier default response
|
||||
func (o *AddTierDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *AddTierDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// AddTierURL generates an URL for the add tier operation
|
||||
type AddTierURL struct {
|
||||
_basePath string
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *AddTierURL) WithBasePath(bp string) *AddTierURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *AddTierURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *AddTierURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/admin/tiers"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *AddTierURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *AddTierURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *AddTierURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on AddTierURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on AddTierURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *AddTierURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// EditTierCredentialsHandlerFunc turns a function with the right signature into a edit tier credentials handler
|
||||
type EditTierCredentialsHandlerFunc func(EditTierCredentialsParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn EditTierCredentialsHandlerFunc) Handle(params EditTierCredentialsParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// EditTierCredentialsHandler interface for that can handle valid edit tier credentials params
|
||||
type EditTierCredentialsHandler interface {
|
||||
Handle(EditTierCredentialsParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewEditTierCredentials creates a new http.Handler for the edit tier credentials operation
|
||||
func NewEditTierCredentials(ctx *middleware.Context, handler EditTierCredentialsHandler) *EditTierCredentials {
|
||||
return &EditTierCredentials{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
EditTierCredentials swagger:route PUT /admin/tiers/{type}/{name}/credentials Tiering editTierCredentials
|
||||
|
||||
Edit Tier Credentials
|
||||
*/
|
||||
type EditTierCredentials struct {
|
||||
Context *middleware.Context
|
||||
Handler EditTierCredentialsHandler
|
||||
}
|
||||
|
||||
func (o *EditTierCredentials) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewEditTierCredentialsParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewEditTierCredentialsParams creates a new EditTierCredentialsParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewEditTierCredentialsParams() EditTierCredentialsParams {
|
||||
|
||||
return EditTierCredentialsParams{}
|
||||
}
|
||||
|
||||
// EditTierCredentialsParams contains all the bound params for the edit tier credentials operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters EditTierCredentials
|
||||
type EditTierCredentialsParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.TierCredentialsRequest
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Type string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewEditTierCredentialsParams() beforehand.
|
||||
func (o *EditTierCredentialsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.TierCredentialsRequest
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
}
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(r.Context())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rType, rhkType, _ := route.Params.GetOK("type")
|
||||
if err := o.bindType(rType, rhkType, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *EditTierCredentialsParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindType binds and validates parameter Type from path.
|
||||
func (o *EditTierCredentialsParams) bindType(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Type = raw
|
||||
|
||||
if err := o.validateType(formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateType carries on validations for parameter Type
|
||||
func (o *EditTierCredentialsParams) validateType(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.EnumCase("type", "path", o.Type, []interface{}{"s3", "gcs", "azure", "minio"}, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// EditTierCredentialsOKCode is the HTTP code returned for type EditTierCredentialsOK
|
||||
const EditTierCredentialsOKCode int = 200
|
||||
|
||||
/*
|
||||
EditTierCredentialsOK A successful response.
|
||||
|
||||
swagger:response editTierCredentialsOK
|
||||
*/
|
||||
type EditTierCredentialsOK struct {
|
||||
}
|
||||
|
||||
// NewEditTierCredentialsOK creates EditTierCredentialsOK with default headers values
|
||||
func NewEditTierCredentialsOK() *EditTierCredentialsOK {
|
||||
|
||||
return &EditTierCredentialsOK{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *EditTierCredentialsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(200)
|
||||
}
|
||||
|
||||
/*
|
||||
EditTierCredentialsDefault Generic error response.
|
||||
|
||||
swagger:response editTierCredentialsDefault
|
||||
*/
|
||||
type EditTierCredentialsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewEditTierCredentialsDefault creates EditTierCredentialsDefault with default headers values
|
||||
func NewEditTierCredentialsDefault(code int) *EditTierCredentialsDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &EditTierCredentialsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the edit tier credentials default response
|
||||
func (o *EditTierCredentialsDefault) WithStatusCode(code int) *EditTierCredentialsDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the edit tier credentials default response
|
||||
func (o *EditTierCredentialsDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the edit tier credentials default response
|
||||
func (o *EditTierCredentialsDefault) WithPayload(payload *models.APIError) *EditTierCredentialsDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the edit tier credentials default response
|
||||
func (o *EditTierCredentialsDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *EditTierCredentialsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// EditTierCredentialsURL generates an URL for the edit tier credentials operation
|
||||
type EditTierCredentialsURL struct {
|
||||
Name string
|
||||
Type string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *EditTierCredentialsURL) WithBasePath(bp string) *EditTierCredentialsURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *EditTierCredentialsURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *EditTierCredentialsURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/admin/tiers/{type}/{name}/credentials"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on EditTierCredentialsURL")
|
||||
}
|
||||
|
||||
typeVar := o.Type
|
||||
if typeVar != "" {
|
||||
_path = strings.Replace(_path, "{type}", typeVar, -1)
|
||||
} else {
|
||||
return nil, errors.New("type is required on EditTierCredentialsURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *EditTierCredentialsURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *EditTierCredentialsURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *EditTierCredentialsURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on EditTierCredentialsURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on EditTierCredentialsURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *EditTierCredentialsURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// GetTierHandlerFunc turns a function with the right signature into a get tier handler
|
||||
type GetTierHandlerFunc func(GetTierParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetTierHandlerFunc) Handle(params GetTierParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// GetTierHandler interface for that can handle valid get tier params
|
||||
type GetTierHandler interface {
|
||||
Handle(GetTierParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetTier creates a new http.Handler for the get tier operation
|
||||
func NewGetTier(ctx *middleware.Context, handler GetTierHandler) *GetTier {
|
||||
return &GetTier{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
GetTier swagger:route GET /admin/tiers/{type}/{name} Tiering getTier
|
||||
|
||||
Get Tier
|
||||
*/
|
||||
type GetTier struct {
|
||||
Context *middleware.Context
|
||||
Handler GetTierHandler
|
||||
}
|
||||
|
||||
func (o *GetTier) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewGetTierParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// NewGetTierParams creates a new GetTierParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewGetTierParams() GetTierParams {
|
||||
|
||||
return GetTierParams{}
|
||||
}
|
||||
|
||||
// GetTierParams contains all the bound params for the get tier operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetTier
|
||||
type GetTierParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Type string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewGetTierParams() beforehand.
|
||||
func (o *GetTierParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rType, rhkType, _ := route.Params.GetOK("type")
|
||||
if err := o.bindType(rType, rhkType, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *GetTierParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindType binds and validates parameter Type from path.
|
||||
func (o *GetTierParams) bindType(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Type = raw
|
||||
|
||||
if err := o.validateType(formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateType carries on validations for parameter Type
|
||||
func (o *GetTierParams) validateType(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.EnumCase("type", "path", o.Type, []interface{}{"s3", "gcs", "azure", "minio"}, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// GetTierOKCode is the HTTP code returned for type GetTierOK
|
||||
const GetTierOKCode int = 200
|
||||
|
||||
/*
|
||||
GetTierOK A successful response.
|
||||
|
||||
swagger:response getTierOK
|
||||
*/
|
||||
type GetTierOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Tier `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetTierOK creates GetTierOK with default headers values
|
||||
func NewGetTierOK() *GetTierOK {
|
||||
|
||||
return &GetTierOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get tier o k response
|
||||
func (o *GetTierOK) WithPayload(payload *models.Tier) *GetTierOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get tier o k response
|
||||
func (o *GetTierOK) SetPayload(payload *models.Tier) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetTierOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GetTierDefault Generic error response.
|
||||
|
||||
swagger:response getTierDefault
|
||||
*/
|
||||
type GetTierDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetTierDefault creates GetTierDefault with default headers values
|
||||
func NewGetTierDefault(code int) *GetTierDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetTierDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get tier default response
|
||||
func (o *GetTierDefault) WithStatusCode(code int) *GetTierDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get tier default response
|
||||
func (o *GetTierDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get tier default response
|
||||
func (o *GetTierDefault) WithPayload(payload *models.APIError) *GetTierDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get tier default response
|
||||
func (o *GetTierDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetTierDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetTierURL generates an URL for the get tier operation
|
||||
type GetTierURL struct {
|
||||
Name string
|
||||
Type string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetTierURL) WithBasePath(bp string) *GetTierURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetTierURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *GetTierURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/admin/tiers/{type}/{name}"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on GetTierURL")
|
||||
}
|
||||
|
||||
typeVar := o.Type
|
||||
if typeVar != "" {
|
||||
_path = strings.Replace(_path, "{type}", typeVar, -1)
|
||||
} else {
|
||||
return nil, errors.New("type is required on GetTierURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *GetTierURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *GetTierURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *GetTierURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on GetTierURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on GetTierURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *GetTierURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// RemoveTierHandlerFunc turns a function with the right signature into a remove tier handler
|
||||
type RemoveTierHandlerFunc func(RemoveTierParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn RemoveTierHandlerFunc) Handle(params RemoveTierParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// RemoveTierHandler interface for that can handle valid remove tier params
|
||||
type RemoveTierHandler interface {
|
||||
Handle(RemoveTierParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewRemoveTier creates a new http.Handler for the remove tier operation
|
||||
func NewRemoveTier(ctx *middleware.Context, handler RemoveTierHandler) *RemoveTier {
|
||||
return &RemoveTier{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
RemoveTier swagger:route DELETE /admin/tiers/{name}/remove Tiering removeTier
|
||||
|
||||
Remove Tier
|
||||
*/
|
||||
type RemoveTier struct {
|
||||
Context *middleware.Context
|
||||
Handler RemoveTierHandler
|
||||
}
|
||||
|
||||
func (o *RemoveTier) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewRemoveTierParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewRemoveTierParams creates a new RemoveTierParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewRemoveTierParams() RemoveTierParams {
|
||||
|
||||
return RemoveTierParams{}
|
||||
}
|
||||
|
||||
// RemoveTierParams contains all the bound params for the remove tier operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters RemoveTier
|
||||
type RemoveTierParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewRemoveTierParams() beforehand.
|
||||
func (o *RemoveTierParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
rName, rhkName, _ := route.Params.GetOK("name")
|
||||
if err := o.bindName(rName, rhkName, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindName binds and validates parameter Name from path.
|
||||
func (o *RemoveTierParams) bindName(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// RemoveTierNoContentCode is the HTTP code returned for type RemoveTierNoContent
|
||||
const RemoveTierNoContentCode int = 204
|
||||
|
||||
/*
|
||||
RemoveTierNoContent A successful response.
|
||||
|
||||
swagger:response removeTierNoContent
|
||||
*/
|
||||
type RemoveTierNoContent struct {
|
||||
}
|
||||
|
||||
// NewRemoveTierNoContent creates RemoveTierNoContent with default headers values
|
||||
func NewRemoveTierNoContent() *RemoveTierNoContent {
|
||||
|
||||
return &RemoveTierNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *RemoveTierNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*
|
||||
RemoveTierDefault Generic error response.
|
||||
|
||||
swagger:response removeTierDefault
|
||||
*/
|
||||
type RemoveTierDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewRemoveTierDefault creates RemoveTierDefault with default headers values
|
||||
func NewRemoveTierDefault(code int) *RemoveTierDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &RemoveTierDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the remove tier default response
|
||||
func (o *RemoveTierDefault) WithStatusCode(code int) *RemoveTierDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the remove tier default response
|
||||
func (o *RemoveTierDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the remove tier default response
|
||||
func (o *RemoveTierDefault) WithPayload(payload *models.APIError) *RemoveTierDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the remove tier default response
|
||||
func (o *RemoveTierDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *RemoveTierDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// RemoveTierURL generates an URL for the remove tier operation
|
||||
type RemoveTierURL struct {
|
||||
Name string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *RemoveTierURL) WithBasePath(bp string) *RemoveTierURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *RemoveTierURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *RemoveTierURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/admin/tiers/{name}/remove"
|
||||
|
||||
name := o.Name
|
||||
if name != "" {
|
||||
_path = strings.Replace(_path, "{name}", name, -1)
|
||||
} else {
|
||||
return nil, errors.New("name is required on RemoveTierURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *RemoveTierURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *RemoveTierURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *RemoveTierURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on RemoveTierURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on RemoveTierURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *RemoveTierURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// TiersListHandlerFunc turns a function with the right signature into a tiers list handler
|
||||
type TiersListHandlerFunc func(TiersListParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn TiersListHandlerFunc) Handle(params TiersListParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// TiersListHandler interface for that can handle valid tiers list params
|
||||
type TiersListHandler interface {
|
||||
Handle(TiersListParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewTiersList creates a new http.Handler for the tiers list operation
|
||||
func NewTiersList(ctx *middleware.Context, handler TiersListHandler) *TiersList {
|
||||
return &TiersList{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
TiersList swagger:route GET /admin/tiers Tiering tiersList
|
||||
|
||||
Returns a list of tiers for ilm
|
||||
*/
|
||||
type TiersList struct {
|
||||
Context *middleware.Context
|
||||
Handler TiersListHandler
|
||||
}
|
||||
|
||||
func (o *TiersList) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewTiersListParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// TiersListNamesHandlerFunc turns a function with the right signature into a tiers list names handler
|
||||
type TiersListNamesHandlerFunc func(TiersListNamesParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn TiersListNamesHandlerFunc) Handle(params TiersListNamesParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// TiersListNamesHandler interface for that can handle valid tiers list names params
|
||||
type TiersListNamesHandler interface {
|
||||
Handle(TiersListNamesParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewTiersListNames creates a new http.Handler for the tiers list names operation
|
||||
func NewTiersListNames(ctx *middleware.Context, handler TiersListNamesHandler) *TiersListNames {
|
||||
return &TiersListNames{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
TiersListNames swagger:route GET /admin/tiers/names Tiering tiersListNames
|
||||
|
||||
Returns a list of tiers' names for ilm
|
||||
*/
|
||||
type TiersListNames struct {
|
||||
Context *middleware.Context
|
||||
Handler TiersListNamesHandler
|
||||
}
|
||||
|
||||
func (o *TiersListNames) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewTiersListNamesParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// NewTiersListNamesParams creates a new TiersListNamesParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewTiersListNamesParams() TiersListNamesParams {
|
||||
|
||||
return TiersListNamesParams{}
|
||||
}
|
||||
|
||||
// TiersListNamesParams contains all the bound params for the tiers list names operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters TiersListNames
|
||||
type TiersListNamesParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewTiersListNamesParams() beforehand.
|
||||
func (o *TiersListNamesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// TiersListNamesOKCode is the HTTP code returned for type TiersListNamesOK
|
||||
const TiersListNamesOKCode int = 200
|
||||
|
||||
/*
|
||||
TiersListNamesOK A successful response.
|
||||
|
||||
swagger:response tiersListNamesOK
|
||||
*/
|
||||
type TiersListNamesOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.TiersNameListResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewTiersListNamesOK creates TiersListNamesOK with default headers values
|
||||
func NewTiersListNamesOK() *TiersListNamesOK {
|
||||
|
||||
return &TiersListNamesOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the tiers list names o k response
|
||||
func (o *TiersListNamesOK) WithPayload(payload *models.TiersNameListResponse) *TiersListNamesOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the tiers list names o k response
|
||||
func (o *TiersListNamesOK) SetPayload(payload *models.TiersNameListResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *TiersListNamesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
TiersListNamesDefault Generic error response.
|
||||
|
||||
swagger:response tiersListNamesDefault
|
||||
*/
|
||||
type TiersListNamesDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewTiersListNamesDefault creates TiersListNamesDefault with default headers values
|
||||
func NewTiersListNamesDefault(code int) *TiersListNamesDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &TiersListNamesDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the tiers list names default response
|
||||
func (o *TiersListNamesDefault) WithStatusCode(code int) *TiersListNamesDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the tiers list names default response
|
||||
func (o *TiersListNamesDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the tiers list names default response
|
||||
func (o *TiersListNamesDefault) WithPayload(payload *models.APIError) *TiersListNamesDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the tiers list names default response
|
||||
func (o *TiersListNamesDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *TiersListNamesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// TiersListNamesURL generates an URL for the tiers list names operation
|
||||
type TiersListNamesURL struct {
|
||||
_basePath string
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *TiersListNamesURL) WithBasePath(bp string) *TiersListNamesURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *TiersListNamesURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *TiersListNamesURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/admin/tiers/names"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *TiersListNamesURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *TiersListNamesURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *TiersListNamesURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on TiersListNamesURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on TiersListNamesURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *TiersListNamesURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// NewTiersListParams creates a new TiersListParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewTiersListParams() TiersListParams {
|
||||
|
||||
return TiersListParams{}
|
||||
}
|
||||
|
||||
// TiersListParams contains all the bound params for the tiers list operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters TiersList
|
||||
type TiersListParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewTiersListParams() beforehand.
|
||||
func (o *TiersListParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// TiersListOKCode is the HTTP code returned for type TiersListOK
|
||||
const TiersListOKCode int = 200
|
||||
|
||||
/*
|
||||
TiersListOK A successful response.
|
||||
|
||||
swagger:response tiersListOK
|
||||
*/
|
||||
type TiersListOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.TierListResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewTiersListOK creates TiersListOK with default headers values
|
||||
func NewTiersListOK() *TiersListOK {
|
||||
|
||||
return &TiersListOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the tiers list o k response
|
||||
func (o *TiersListOK) WithPayload(payload *models.TierListResponse) *TiersListOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the tiers list o k response
|
||||
func (o *TiersListOK) SetPayload(payload *models.TierListResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *TiersListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
TiersListDefault Generic error response.
|
||||
|
||||
swagger:response tiersListDefault
|
||||
*/
|
||||
type TiersListDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.APIError `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewTiersListDefault creates TiersListDefault with default headers values
|
||||
func NewTiersListDefault(code int) *TiersListDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &TiersListDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the tiers list default response
|
||||
func (o *TiersListDefault) WithStatusCode(code int) *TiersListDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the tiers list default response
|
||||
func (o *TiersListDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the tiers list default response
|
||||
func (o *TiersListDefault) WithPayload(payload *models.APIError) *TiersListDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the tiers list default response
|
||||
func (o *TiersListDefault) SetPayload(payload *models.APIError) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *TiersListDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2023 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package tiering
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// TiersListURL generates an URL for the tiers list operation
|
||||
type TiersListURL struct {
|
||||
_basePath string
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *TiersListURL) WithBasePath(bp string) *TiersListURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *TiersListURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *TiersListURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/admin/tiers"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *TiersListURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *TiersListURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *TiersListURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on TiersListURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on TiersListURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *TiersListURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -1,543 +0,0 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio-go/v7"
|
||||
|
||||
"github.com/rs/xid"
|
||||
|
||||
"github.com/minio/mc/cmd/ilm"
|
||||
|
||||
"github.com/minio/minio-go/v7/pkg/lifecycle"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/minio/console/api/operations"
|
||||
bucketApi "github.com/minio/console/api/operations/bucket"
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
type MultiLifecycleResult struct {
|
||||
BucketName string
|
||||
Error string
|
||||
}
|
||||
|
||||
func registerBucketsLifecycleHandlers(api *operations.ConsoleAPI) {
|
||||
api.BucketGetBucketLifecycleHandler = bucketApi.GetBucketLifecycleHandlerFunc(func(params bucketApi.GetBucketLifecycleParams, session *models.Principal) middleware.Responder {
|
||||
listBucketLifecycleResponse, err := getBucketLifecycleResponse(session, params)
|
||||
if err != nil {
|
||||
return bucketApi.NewGetBucketLifecycleDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
return bucketApi.NewGetBucketLifecycleOK().WithPayload(listBucketLifecycleResponse)
|
||||
})
|
||||
api.BucketAddBucketLifecycleHandler = bucketApi.AddBucketLifecycleHandlerFunc(func(params bucketApi.AddBucketLifecycleParams, session *models.Principal) middleware.Responder {
|
||||
err := getAddBucketLifecycleResponse(session, params)
|
||||
if err != nil {
|
||||
return bucketApi.NewAddBucketLifecycleDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
return bucketApi.NewAddBucketLifecycleCreated()
|
||||
})
|
||||
api.BucketUpdateBucketLifecycleHandler = bucketApi.UpdateBucketLifecycleHandlerFunc(func(params bucketApi.UpdateBucketLifecycleParams, session *models.Principal) middleware.Responder {
|
||||
err := getEditBucketLifecycleRule(session, params)
|
||||
if err != nil {
|
||||
return bucketApi.NewUpdateBucketLifecycleDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
|
||||
return bucketApi.NewUpdateBucketLifecycleOK()
|
||||
})
|
||||
api.BucketDeleteBucketLifecycleRuleHandler = bucketApi.DeleteBucketLifecycleRuleHandlerFunc(func(params bucketApi.DeleteBucketLifecycleRuleParams, session *models.Principal) middleware.Responder {
|
||||
err := getDeleteBucketLifecycleRule(session, params)
|
||||
if err != nil {
|
||||
return bucketApi.NewDeleteBucketLifecycleRuleDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
|
||||
return bucketApi.NewDeleteBucketLifecycleRuleNoContent()
|
||||
})
|
||||
api.BucketAddMultiBucketLifecycleHandler = bucketApi.AddMultiBucketLifecycleHandlerFunc(func(params bucketApi.AddMultiBucketLifecycleParams, session *models.Principal) middleware.Responder {
|
||||
multiBucketResponse, err := getAddMultiBucketLifecycleResponse(session, params)
|
||||
if err != nil {
|
||||
bucketApi.NewAddMultiBucketLifecycleDefault(err.Code).WithPayload(err.APIError)
|
||||
}
|
||||
|
||||
return bucketApi.NewAddMultiBucketLifecycleOK().WithPayload(multiBucketResponse)
|
||||
})
|
||||
}
|
||||
|
||||
// getBucketLifecycle() gets lifecycle lists for a bucket from MinIO API and returns their implementations
|
||||
func getBucketLifecycle(ctx context.Context, client MinioClient, bucketName string) (*models.BucketLifecycleResponse, error) {
|
||||
lifecycleList, err := client.getLifecycleRules(ctx, bucketName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var rules []*models.ObjectBucketLifecycle
|
||||
|
||||
for _, rule := range lifecycleList.Rules {
|
||||
|
||||
var tags []*models.LifecycleTag
|
||||
|
||||
for _, tagData := range rule.RuleFilter.And.Tags {
|
||||
tags = append(tags, &models.LifecycleTag{
|
||||
Key: tagData.Key,
|
||||
Value: tagData.Value,
|
||||
})
|
||||
}
|
||||
if rule.RuleFilter.Tag.Key != "" {
|
||||
tags = append(tags, &models.LifecycleTag{
|
||||
Key: rule.RuleFilter.Tag.Key,
|
||||
Value: rule.RuleFilter.Tag.Value,
|
||||
})
|
||||
}
|
||||
rulePrefix := rule.RuleFilter.And.Prefix
|
||||
|
||||
if rulePrefix == "" {
|
||||
rulePrefix = rule.RuleFilter.Prefix
|
||||
}
|
||||
|
||||
rules = append(rules, &models.ObjectBucketLifecycle{
|
||||
ID: rule.ID,
|
||||
Status: rule.Status,
|
||||
Prefix: rulePrefix,
|
||||
Expiration: &models.ExpirationResponse{
|
||||
Date: rule.Expiration.Date.Format(time.RFC3339),
|
||||
Days: int64(rule.Expiration.Days),
|
||||
DeleteMarker: rule.Expiration.DeleteMarker.IsEnabled(),
|
||||
DeleteAll: bool(rule.Expiration.DeleteAll),
|
||||
NoncurrentExpirationDays: int64(rule.NoncurrentVersionExpiration.NoncurrentDays),
|
||||
NewerNoncurrentExpirationVersions: int64(rule.NoncurrentVersionExpiration.NewerNoncurrentVersions),
|
||||
},
|
||||
Transition: &models.TransitionResponse{
|
||||
Date: rule.Transition.Date.Format(time.RFC3339),
|
||||
Days: int64(rule.Transition.Days),
|
||||
StorageClass: rule.Transition.StorageClass,
|
||||
NoncurrentStorageClass: rule.NoncurrentVersionTransition.StorageClass,
|
||||
NoncurrentTransitionDays: int64(rule.NoncurrentVersionTransition.NoncurrentDays),
|
||||
},
|
||||
Tags: tags,
|
||||
})
|
||||
}
|
||||
|
||||
// serialize output
|
||||
lifecycleBucketsResponse := &models.BucketLifecycleResponse{
|
||||
Lifecycle: rules,
|
||||
}
|
||||
|
||||
return lifecycleBucketsResponse, nil
|
||||
}
|
||||
|
||||
// getBucketLifecycleResponse performs getBucketLifecycle() and serializes it to the handler's output
|
||||
func getBucketLifecycleResponse(session *models.Principal, params bucketApi.GetBucketLifecycleParams) (*models.BucketLifecycleResponse, *CodedAPIError) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mClient, err := newMinioClient(session, getClientIP(params.HTTPRequest))
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
minioClient := minioClient{client: mClient}
|
||||
|
||||
bucketEvents, err := getBucketLifecycle(ctx, minioClient, params.BucketName)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, ErrBucketLifeCycleNotConfigured, err)
|
||||
}
|
||||
return bucketEvents, nil
|
||||
}
|
||||
|
||||
// addBucketLifecycle gets lifecycle lists for a bucket from MinIO API and returns their implementations
|
||||
func addBucketLifecycle(ctx context.Context, client MinioClient, params bucketApi.AddBucketLifecycleParams) error {
|
||||
// Configuration that is already set.
|
||||
lfcCfg, err := client.getLifecycleRules(ctx, params.BucketName)
|
||||
if err != nil {
|
||||
if e := err; minio.ToErrorResponse(e).Code == "NoSuchLifecycleConfiguration" {
|
||||
lfcCfg = lifecycle.NewConfiguration()
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
id := xid.New().String()
|
||||
|
||||
opts := ilm.LifecycleOptions{}
|
||||
|
||||
// Verify if transition rule is requested
|
||||
switch params.Body.Type {
|
||||
case models.AddBucketLifecycleTypeTransition:
|
||||
if params.Body.TransitionDays == 0 && params.Body.NoncurrentversionTransitionDays == 0 {
|
||||
return errors.New("you must provide a value for transition days or date")
|
||||
}
|
||||
|
||||
status := !params.Body.Disable
|
||||
opts = ilm.LifecycleOptions{
|
||||
ID: id,
|
||||
Prefix: ¶ms.Body.Prefix,
|
||||
Status: &status,
|
||||
Tags: ¶ms.Body.Tags,
|
||||
ExpiredObjectDeleteMarker: ¶ms.Body.ExpiredObjectDeleteMarker,
|
||||
ExpiredObjectAllversions: ¶ms.Body.ExpiredObjectDeleteAll,
|
||||
}
|
||||
|
||||
if params.Body.NoncurrentversionTransitionDays > 0 {
|
||||
noncurrentVersionTransitionDays := int(params.Body.NoncurrentversionTransitionDays)
|
||||
noncurrentVersionTransitionStorageClass := strings.ToUpper(params.Body.NoncurrentversionTransitionStorageClass)
|
||||
opts.NoncurrentVersionTransitionDays = &noncurrentVersionTransitionDays
|
||||
opts.NoncurrentVersionTransitionStorageClass = &noncurrentVersionTransitionStorageClass
|
||||
} else if params.Body.TransitionDays > 0 {
|
||||
tdays := strconv.Itoa(int(params.Body.TransitionDays))
|
||||
sclass := strings.ToUpper(params.Body.StorageClass)
|
||||
opts.TransitionDays = &tdays
|
||||
opts.StorageClass = &sclass
|
||||
}
|
||||
|
||||
case models.AddBucketLifecycleTypeExpiry:
|
||||
// Verify if expiry items are set
|
||||
if params.Body.NoncurrentversionTransitionDays != 0 {
|
||||
return errors.New("non current version Transition Days cannot be set when expiry is being configured")
|
||||
}
|
||||
|
||||
if params.Body.NoncurrentversionTransitionStorageClass != "" {
|
||||
return errors.New("non current version Transition Storage Class cannot be set when expiry is being configured")
|
||||
}
|
||||
|
||||
status := !params.Body.Disable
|
||||
opts = ilm.LifecycleOptions{
|
||||
ID: id,
|
||||
Prefix: ¶ms.Body.Prefix,
|
||||
Status: &status,
|
||||
Tags: ¶ms.Body.Tags,
|
||||
ExpiredObjectDeleteMarker: ¶ms.Body.ExpiredObjectDeleteMarker,
|
||||
ExpiredObjectAllversions: ¶ms.Body.ExpiredObjectDeleteAll,
|
||||
}
|
||||
|
||||
if params.Body.NewerNoncurrentversionExpirationVersions > 0 {
|
||||
versions := int(params.Body.NewerNoncurrentversionExpirationVersions)
|
||||
opts.NewerNoncurrentExpirationVersions = &versions
|
||||
}
|
||||
switch {
|
||||
case params.Body.NoncurrentversionExpirationDays > 0:
|
||||
days := int(params.Body.NoncurrentversionExpirationDays)
|
||||
opts.NoncurrentVersionExpirationDays = &days
|
||||
case params.Body.ExpiryDays > 0:
|
||||
days := strconv.Itoa(int(params.Body.ExpiryDays))
|
||||
opts.ExpiryDays = &days
|
||||
}
|
||||
default:
|
||||
// Non set, we return errors
|
||||
return errors.New("no valid lifecycle configuration requested")
|
||||
}
|
||||
|
||||
newRule, merr := opts.ToILMRule()
|
||||
if merr != nil {
|
||||
return merr.ToGoError()
|
||||
}
|
||||
|
||||
lfcCfg.Rules = append(lfcCfg.Rules, newRule)
|
||||
|
||||
return client.setBucketLifecycle(ctx, params.BucketName, lfcCfg)
|
||||
}
|
||||
|
||||
// getAddBucketLifecycleResponse returns the response of adding a bucket lifecycle response
|
||||
func getAddBucketLifecycleResponse(session *models.Principal, params bucketApi.AddBucketLifecycleParams) *CodedAPIError {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mClient, err := newMinioClient(session, getClientIP(params.HTTPRequest))
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
minioClient := minioClient{client: mClient}
|
||||
|
||||
err = addBucketLifecycle(ctx, minioClient, params)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// editBucketLifecycle gets lifecycle lists for a bucket from MinIO API and updates the selected lifecycle rule
|
||||
func editBucketLifecycle(ctx context.Context, client MinioClient, params bucketApi.UpdateBucketLifecycleParams) error {
|
||||
// Configuration that is already set.
|
||||
lfcCfg, err := client.getLifecycleRules(ctx, params.BucketName)
|
||||
if err != nil {
|
||||
if e := err; minio.ToErrorResponse(e).Code == "NoSuchLifecycleConfiguration" {
|
||||
lfcCfg = lifecycle.NewConfiguration()
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
id := params.LifecycleID
|
||||
|
||||
opts := ilm.LifecycleOptions{}
|
||||
|
||||
// Verify if transition items are set
|
||||
switch *params.Body.Type {
|
||||
case models.UpdateBucketLifecycleTypeTransition:
|
||||
if params.Body.TransitionDays == 0 && params.Body.NoncurrentversionTransitionDays == 0 {
|
||||
return errors.New("you must select transition days or non-current transition days configuration")
|
||||
}
|
||||
|
||||
status := !params.Body.Disable
|
||||
opts = ilm.LifecycleOptions{
|
||||
ID: id,
|
||||
Prefix: ¶ms.Body.Prefix,
|
||||
Status: &status,
|
||||
Tags: ¶ms.Body.Tags,
|
||||
ExpiredObjectDeleteMarker: ¶ms.Body.ExpiredObjectDeleteMarker,
|
||||
ExpiredObjectAllversions: ¶ms.Body.ExpiredObjectDeleteAll,
|
||||
}
|
||||
|
||||
if params.Body.NoncurrentversionTransitionDays > 0 {
|
||||
noncurrentVersionTransitionDays := int(params.Body.NoncurrentversionTransitionDays)
|
||||
noncurrentVersionTransitionStorageClass := strings.ToUpper(params.Body.NoncurrentversionTransitionStorageClass)
|
||||
opts.NoncurrentVersionTransitionDays = &noncurrentVersionTransitionDays
|
||||
opts.NoncurrentVersionTransitionStorageClass = &noncurrentVersionTransitionStorageClass
|
||||
|
||||
} else {
|
||||
tdays := strconv.Itoa(int(params.Body.TransitionDays))
|
||||
sclass := strings.ToUpper(params.Body.StorageClass)
|
||||
opts.TransitionDays = &tdays
|
||||
opts.StorageClass = &sclass
|
||||
}
|
||||
case models.UpdateBucketLifecycleTypeExpiry: // Verify if expiry configuration is set
|
||||
if params.Body.NoncurrentversionTransitionDays != 0 {
|
||||
return errors.New("non current version Transition Days cannot be set when expiry is being configured")
|
||||
}
|
||||
|
||||
if params.Body.NoncurrentversionTransitionStorageClass != "" {
|
||||
return errors.New("non current version Transition Storage Class cannot be set when expiry is being configured")
|
||||
}
|
||||
|
||||
status := !params.Body.Disable
|
||||
opts = ilm.LifecycleOptions{
|
||||
ID: id,
|
||||
Prefix: ¶ms.Body.Prefix,
|
||||
Status: &status,
|
||||
Tags: ¶ms.Body.Tags,
|
||||
ExpiredObjectDeleteMarker: ¶ms.Body.ExpiredObjectDeleteMarker,
|
||||
ExpiredObjectAllversions: ¶ms.Body.ExpiredObjectDeleteAll,
|
||||
}
|
||||
|
||||
if params.Body.NoncurrentversionExpirationDays > 0 {
|
||||
days := int(params.Body.NoncurrentversionExpirationDays)
|
||||
opts.NoncurrentVersionExpirationDays = &days
|
||||
} else {
|
||||
days := strconv.Itoa(int(params.Body.ExpiryDays))
|
||||
opts.ExpiryDays = &days
|
||||
}
|
||||
default:
|
||||
// Non set, we return errors
|
||||
return errors.New("no valid configuration requested")
|
||||
}
|
||||
|
||||
var rule *lifecycle.Rule
|
||||
for i := range lfcCfg.Rules {
|
||||
if lfcCfg.Rules[i].ID == opts.ID {
|
||||
rule = &lfcCfg.Rules[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if rule == nil {
|
||||
return errors.New("unable to find the matching rule to update")
|
||||
}
|
||||
|
||||
err2 := ilm.ApplyRuleFields(rule, opts)
|
||||
if err2.ToGoError() != nil {
|
||||
return fmt.Errorf("Unable to generate new lifecycle rule: %v", err2.ToGoError())
|
||||
}
|
||||
|
||||
return client.setBucketLifecycle(ctx, params.BucketName, lfcCfg)
|
||||
}
|
||||
|
||||
// getEditBucketLifecycleRule returns the response of bucket lifecycle tier edit
|
||||
func getEditBucketLifecycleRule(session *models.Principal, params bucketApi.UpdateBucketLifecycleParams) *CodedAPIError {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mClient, err := newMinioClient(session, getClientIP(params.HTTPRequest))
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
minioClient := minioClient{client: mClient}
|
||||
|
||||
err = editBucketLifecycle(ctx, minioClient, params)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// deleteBucketLifecycle deletes lifecycle rule by passing an empty rule to a selected ID
|
||||
func deleteBucketLifecycle(ctx context.Context, client MinioClient, params bucketApi.DeleteBucketLifecycleRuleParams) error {
|
||||
// Configuration that is already set.
|
||||
lfcCfg, err := client.getLifecycleRules(ctx, params.BucketName)
|
||||
if err != nil {
|
||||
if e := err; minio.ToErrorResponse(e).Code == "NoSuchLifecycleConfiguration" {
|
||||
lfcCfg = lifecycle.NewConfiguration()
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(lfcCfg.Rules) == 0 {
|
||||
return errors.New("no rules available to delete")
|
||||
}
|
||||
|
||||
var newRules []lifecycle.Rule
|
||||
|
||||
for _, rule := range lfcCfg.Rules {
|
||||
if rule.ID != params.LifecycleID {
|
||||
newRules = append(newRules, rule)
|
||||
}
|
||||
}
|
||||
|
||||
if len(newRules) == len(lfcCfg.Rules) && len(lfcCfg.Rules) > 0 {
|
||||
// rule doesn't exist
|
||||
return fmt.Errorf("lifecycle rule for id '%s' doesn't exist", params.LifecycleID)
|
||||
}
|
||||
|
||||
lfcCfg.Rules = newRules
|
||||
|
||||
return client.setBucketLifecycle(ctx, params.BucketName, lfcCfg)
|
||||
}
|
||||
|
||||
// getDeleteBucketLifecycleRule returns the response of bucket lifecycle tier delete
|
||||
func getDeleteBucketLifecycleRule(session *models.Principal, params bucketApi.DeleteBucketLifecycleRuleParams) *CodedAPIError {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mClient, err := newMinioClient(session, getClientIP(params.HTTPRequest))
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
minioClient := minioClient{client: mClient}
|
||||
|
||||
err = deleteBucketLifecycle(ctx, minioClient, params)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// addMultiBucketLifecycle creates multibuckets lifecycle assignments
|
||||
func addMultiBucketLifecycle(ctx context.Context, client MinioClient, params bucketApi.AddMultiBucketLifecycleParams) []MultiLifecycleResult {
|
||||
bucketsRelation := params.Body.Buckets
|
||||
|
||||
// Parallel Lifecycle rules set
|
||||
|
||||
parallelLifecycleBucket := func(bucketName string) chan MultiLifecycleResult {
|
||||
remoteProc := make(chan MultiLifecycleResult)
|
||||
|
||||
lifecycleParams := models.AddBucketLifecycle{
|
||||
Type: *params.Body.Type,
|
||||
StorageClass: params.Body.StorageClass,
|
||||
TransitionDays: params.Body.TransitionDays,
|
||||
Prefix: params.Body.Prefix,
|
||||
NoncurrentversionTransitionDays: params.Body.NoncurrentversionTransitionDays,
|
||||
NoncurrentversionTransitionStorageClass: params.Body.NoncurrentversionTransitionStorageClass,
|
||||
NoncurrentversionExpirationDays: params.Body.NoncurrentversionExpirationDays,
|
||||
Tags: params.Body.Tags,
|
||||
ExpiryDays: params.Body.ExpiryDays,
|
||||
Disable: false,
|
||||
ExpiredObjectDeleteMarker: params.Body.ExpiredObjectDeleteMarker,
|
||||
ExpiredObjectDeleteAll: params.Body.ExpiredObjectDeleteMarker,
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer close(remoteProc)
|
||||
|
||||
lifecycleParams := bucketApi.AddBucketLifecycleParams{
|
||||
BucketName: bucketName,
|
||||
Body: &lifecycleParams,
|
||||
}
|
||||
|
||||
// We add lifecycle rule & expect a response
|
||||
err := addBucketLifecycle(ctx, client, lifecycleParams)
|
||||
|
||||
errorReturn := ""
|
||||
|
||||
if err != nil {
|
||||
errorReturn = err.Error()
|
||||
}
|
||||
|
||||
retParams := MultiLifecycleResult{
|
||||
BucketName: bucketName,
|
||||
Error: errorReturn,
|
||||
}
|
||||
|
||||
remoteProc <- retParams
|
||||
}()
|
||||
return remoteProc
|
||||
}
|
||||
|
||||
var lifecycleManagement []chan MultiLifecycleResult
|
||||
|
||||
for _, bucketName := range bucketsRelation {
|
||||
rBucket := parallelLifecycleBucket(bucketName)
|
||||
lifecycleManagement = append(lifecycleManagement, rBucket)
|
||||
}
|
||||
|
||||
var resultsList []MultiLifecycleResult
|
||||
for _, result := range lifecycleManagement {
|
||||
res := <-result
|
||||
resultsList = append(resultsList, res)
|
||||
}
|
||||
|
||||
return resultsList
|
||||
}
|
||||
|
||||
// getAddMultiBucketLifecycleResponse returns the response of multibucket lifecycle assignment
|
||||
func getAddMultiBucketLifecycleResponse(session *models.Principal, params bucketApi.AddMultiBucketLifecycleParams) (*models.MultiLifecycleResult, *CodedAPIError) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
mClient, err := newMinioClient(session, getClientIP(params.HTTPRequest))
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
minioClient := minioClient{client: mClient}
|
||||
|
||||
multiCycleResult := addMultiBucketLifecycle(ctx, minioClient, params)
|
||||
|
||||
var returnList []*models.MulticycleResultItem
|
||||
|
||||
for _, resultItem := range multiCycleResult {
|
||||
multicycleRS := models.MulticycleResultItem{
|
||||
BucketName: resultItem.BucketName,
|
||||
Error: resultItem.Error,
|
||||
}
|
||||
|
||||
returnList = append(returnList, &multicycleRS)
|
||||
}
|
||||
|
||||
finalResult := models.MultiLifecycleResult{Results: returnList}
|
||||
|
||||
return &finalResult, nil
|
||||
}
|
||||
@@ -1,370 +0,0 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
bucketApi "github.com/minio/console/api/operations/bucket"
|
||||
"github.com/minio/minio-go/v7/pkg/lifecycle"
|
||||
)
|
||||
|
||||
// assigning mock at runtime instead of compile time
|
||||
var minioGetLifecycleRulesMock func(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error)
|
||||
|
||||
// mock function of getLifecycleRules()
|
||||
func (ac minioClientMock) getLifecycleRules(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return minioGetLifecycleRulesMock(ctx, bucketName)
|
||||
}
|
||||
|
||||
// assign mock for set Bucket Lifecycle
|
||||
var minioSetBucketLifecycleMock func(ctx context.Context, bucketName string, config *lifecycle.Configuration) error
|
||||
|
||||
// mock function of setBucketLifecycle()
|
||||
func (ac minioClientMock) setBucketLifecycle(ctx context.Context, bucketName string, config *lifecycle.Configuration) error {
|
||||
return minioSetBucketLifecycleMock(ctx, bucketName, config)
|
||||
}
|
||||
|
||||
func TestGetLifecycleRules(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
// mock minIO client
|
||||
minClient := minioClientMock{}
|
||||
|
||||
function := "getBucketLifecycle()"
|
||||
bucketName := "testBucket"
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
// Test-1 : getBucketLifecycle() get list of events for a particular bucket only one config
|
||||
// mock lifecycle response from MinIO
|
||||
mockLifecycle := lifecycle.Configuration{
|
||||
Rules: []lifecycle.Rule{
|
||||
{
|
||||
ID: "TESTRULE",
|
||||
Expiration: lifecycle.Expiration{Days: 15},
|
||||
Status: "Enabled",
|
||||
RuleFilter: lifecycle.Filter{Tag: lifecycle.Tag{Key: "tag1", Value: "val1"}, And: lifecycle.And{Prefix: "prefix1"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expectedOutput := models.BucketLifecycleResponse{
|
||||
Lifecycle: []*models.ObjectBucketLifecycle{
|
||||
{
|
||||
ID: "TESTRULE",
|
||||
Status: "Enabled",
|
||||
Prefix: "prefix1",
|
||||
Expiration: &models.ExpirationResponse{Days: int64(15)},
|
||||
Transition: &models.TransitionResponse{},
|
||||
Tags: []*models.LifecycleTag{{Key: "tag1", Value: "val1"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle, nil
|
||||
}
|
||||
|
||||
lifeCycleConfigs, err := getBucketLifecycle(ctx, minClient, bucketName)
|
||||
if err != nil {
|
||||
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
|
||||
}
|
||||
// verify length of buckets is correct
|
||||
assert.Equal(len(expectedOutput.Lifecycle), len(lifeCycleConfigs.Lifecycle), fmt.Sprintf("Failed on %s: length of lists is not the same", function))
|
||||
for i, conf := range lifeCycleConfigs.Lifecycle {
|
||||
assert.Equal(expectedOutput.Lifecycle[i].ID, conf.ID)
|
||||
assert.Equal(expectedOutput.Lifecycle[i].Status, conf.Status)
|
||||
assert.Equal(expectedOutput.Lifecycle[i].Prefix, conf.Prefix)
|
||||
assert.Equal(expectedOutput.Lifecycle[i].Expiration.Days, conf.Expiration.Days)
|
||||
for j, event := range conf.Tags {
|
||||
assert.Equal(expectedOutput.Lifecycle[i].Tags[j], event)
|
||||
}
|
||||
}
|
||||
|
||||
// Test-2 : getBucketLifecycle() get list of events is empty
|
||||
mockLifecycleT2 := lifecycle.Configuration{
|
||||
Rules: []lifecycle.Rule{},
|
||||
}
|
||||
|
||||
expectedOutputT2 := models.BucketLifecycleResponse{
|
||||
Lifecycle: []*models.ObjectBucketLifecycle{},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycleT2, nil
|
||||
}
|
||||
|
||||
lifeCycleConfigsT2, err := getBucketLifecycle(ctx, minClient, bucketName)
|
||||
if err != nil {
|
||||
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
|
||||
}
|
||||
// verify length of buckets is correct
|
||||
assert.Equal(len(expectedOutputT2.Lifecycle), len(lifeCycleConfigsT2.Lifecycle), fmt.Sprintf("Failed on %s: length of lists is not the same", function))
|
||||
|
||||
// Test-3 : getBucketLifecycle() get list of events returns an error
|
||||
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return nil, errors.New("error returned")
|
||||
}
|
||||
|
||||
_, errT3 := getBucketLifecycle(ctx, minClient, bucketName)
|
||||
|
||||
errorCompare := errors.New("error returned")
|
||||
|
||||
assert.Equal(errorCompare, errT3, fmt.Sprintf("Failed on %s: Invalid error message", function))
|
||||
|
||||
// verify length of buckets is correct
|
||||
assert.Equal(len(expectedOutputT2.Lifecycle), len(lifeCycleConfigsT2.Lifecycle), fmt.Sprintf("Failed on %s: length of lists is not the same", function))
|
||||
}
|
||||
|
||||
func TestSetLifecycleRule(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
// mock minIO client
|
||||
minClient := minioClientMock{}
|
||||
|
||||
function := "addBucketLifecycle()"
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
// Test-1 : addBucketLifecycle() get list of events for a particular bucket only one config
|
||||
// mock create request
|
||||
mockLifecycle := lifecycle.Configuration{
|
||||
Rules: []lifecycle.Rule{
|
||||
{
|
||||
ID: "TESTRULE",
|
||||
Expiration: lifecycle.Expiration{Days: 15},
|
||||
Status: "Enabled",
|
||||
RuleFilter: lifecycle.Filter{Tag: lifecycle.Tag{Key: "tag1", Value: "val1"}, And: lifecycle.And{Prefix: "prefix1"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle, nil
|
||||
}
|
||||
|
||||
expiryRule := "expiry"
|
||||
|
||||
insertMock := bucketApi.AddBucketLifecycleParams{
|
||||
BucketName: "testBucket",
|
||||
Body: &models.AddBucketLifecycle{
|
||||
Type: expiryRule,
|
||||
Disable: false,
|
||||
ExpiredObjectDeleteMarker: false,
|
||||
ExpiryDays: int32(16),
|
||||
NoncurrentversionExpirationDays: 0,
|
||||
NoncurrentversionTransitionDays: 0,
|
||||
NoncurrentversionTransitionStorageClass: "",
|
||||
Prefix: "pref1",
|
||||
StorageClass: "",
|
||||
Tags: "",
|
||||
TransitionDays: 0,
|
||||
},
|
||||
}
|
||||
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := addBucketLifecycle(ctx, minClient, insertMock)
|
||||
|
||||
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
|
||||
// Test-2 : addBucketLifecycle() returns error
|
||||
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return errors.New("error setting lifecycle")
|
||||
}
|
||||
|
||||
err2 := addBucketLifecycle(ctx, minClient, insertMock)
|
||||
|
||||
assert.Equal(errors.New("error setting lifecycle"), err2, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
}
|
||||
|
||||
func TestUpdateLifecycleRule(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
// mock minIO client
|
||||
minClient := minioClientMock{}
|
||||
|
||||
function := "editBucketLifecycle()"
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
// Test-1 : editBucketLifecycle() get list of events for a particular bucket only one config (get lifecycle mock)
|
||||
// mock create request
|
||||
mockLifecycle := lifecycle.Configuration{
|
||||
Rules: []lifecycle.Rule{
|
||||
{
|
||||
ID: "TESTRULE",
|
||||
Expiration: lifecycle.Expiration{Days: 15},
|
||||
Status: "Enabled",
|
||||
RuleFilter: lifecycle.Filter{Tag: lifecycle.Tag{Key: "tag1", Value: "val1"}, And: lifecycle.And{Prefix: "prefix1"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle, nil
|
||||
}
|
||||
|
||||
// Test-2 : editBucketLifecycle() Update lifecycle rule
|
||||
|
||||
expiryRule := "expiry"
|
||||
|
||||
editMock := bucketApi.UpdateBucketLifecycleParams{
|
||||
BucketName: "testBucket",
|
||||
Body: &models.UpdateBucketLifecycle{
|
||||
Type: &expiryRule,
|
||||
Disable: false,
|
||||
ExpiredObjectDeleteMarker: false,
|
||||
ExpiryDays: int32(16),
|
||||
NoncurrentversionExpirationDays: 0,
|
||||
NoncurrentversionTransitionDays: 0,
|
||||
NoncurrentversionTransitionStorageClass: "",
|
||||
Prefix: "pref1",
|
||||
StorageClass: "",
|
||||
Tags: "",
|
||||
TransitionDays: 0,
|
||||
},
|
||||
LifecycleID: "TESTRULE",
|
||||
}
|
||||
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := editBucketLifecycle(ctx, minClient, editMock)
|
||||
|
||||
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
|
||||
// Test-2a : editBucketLifecycle() Update lifecycle rule
|
||||
|
||||
transitionRule := "transition"
|
||||
|
||||
editMock = bucketApi.UpdateBucketLifecycleParams{
|
||||
BucketName: "testBucket",
|
||||
Body: &models.UpdateBucketLifecycle{
|
||||
Type: &transitionRule,
|
||||
Disable: false,
|
||||
ExpiredObjectDeleteMarker: false,
|
||||
NoncurrentversionTransitionDays: 5,
|
||||
Prefix: "pref1",
|
||||
StorageClass: "TEST",
|
||||
NoncurrentversionTransitionStorageClass: "TESTNC",
|
||||
Tags: "",
|
||||
TransitionDays: int32(16),
|
||||
},
|
||||
LifecycleID: "TESTRULE",
|
||||
}
|
||||
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
err = editBucketLifecycle(ctx, minClient, editMock)
|
||||
|
||||
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
|
||||
// Test-3 : editBucketLifecycle() returns error
|
||||
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return errors.New("error setting lifecycle")
|
||||
}
|
||||
|
||||
err2 := editBucketLifecycle(ctx, minClient, editMock)
|
||||
|
||||
assert.Equal(errors.New("error setting lifecycle"), err2, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
}
|
||||
|
||||
func TestDeleteLifecycleRule(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
// mock minIO client
|
||||
minClient := minioClientMock{}
|
||||
|
||||
function := "deleteBucketLifecycle()"
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Test-1 : deleteBucketLifecycle() get list of events for a particular bucket only one config (get lifecycle mock)
|
||||
// mock create request
|
||||
mockLifecycle := lifecycle.Configuration{
|
||||
Rules: []lifecycle.Rule{
|
||||
{
|
||||
ID: "TESTRULE",
|
||||
Expiration: lifecycle.Expiration{Days: 15},
|
||||
Status: "Enabled",
|
||||
RuleFilter: lifecycle.Filter{Tag: lifecycle.Tag{Key: "tag1", Value: "val1"}, And: lifecycle.And{Prefix: "prefix1"}},
|
||||
},
|
||||
{
|
||||
ID: "TESTRULE2",
|
||||
Transition: lifecycle.Transition{Days: 10, StorageClass: "TESTSTCLASS"},
|
||||
Status: "Enabled",
|
||||
RuleFilter: lifecycle.Filter{Tag: lifecycle.Tag{Key: "tag1", Value: "val1"}, And: lifecycle.And{Prefix: "prefix1"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle, nil
|
||||
}
|
||||
|
||||
// Test-2 : deleteBucketLifecycle() try to delete an available rule
|
||||
|
||||
availableParams := bucketApi.DeleteBucketLifecycleRuleParams{
|
||||
LifecycleID: "TESTRULE2",
|
||||
BucketName: "testBucket",
|
||||
}
|
||||
|
||||
err := deleteBucketLifecycle(ctx, minClient, availableParams)
|
||||
|
||||
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
|
||||
// Test-3 : deleteBucketLifecycle() returns error trying to delete a non available rule
|
||||
|
||||
nonAvailableParams := bucketApi.DeleteBucketLifecycleRuleParams{
|
||||
LifecycleID: "INVALIDTESTRULE",
|
||||
BucketName: "testBucket",
|
||||
}
|
||||
|
||||
err2 := deleteBucketLifecycle(ctx, minClient, nonAvailableParams)
|
||||
|
||||
assert.Equal(fmt.Errorf("lifecycle rule for id '%s' doesn't exist", nonAvailableParams.LifecycleID), err2, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
|
||||
// Test-4 : deleteBucketLifecycle() returns error trying to delete a rule when no rules are available
|
||||
|
||||
mockLifecycle2 := lifecycle.Configuration{
|
||||
Rules: []lifecycle.Rule{},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle2, nil
|
||||
}
|
||||
|
||||
err3 := deleteBucketLifecycle(ctx, minClient, nonAvailableParams)
|
||||
|
||||
assert.Equal(errors.New("no rules available to delete"), err3, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
}
|
||||
Reference in New Issue
Block a user