Added replication bulk modal to buckets list (#665)
* Added replication bulk modal to buckets list * Disabled buttons & inputs in loading state Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -19,19 +19,28 @@ package restapi
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/minio/console/models"
|
||||
"github.com/minio/console/restapi/operations"
|
||||
"github.com/minio/console/restapi/operations/user_api"
|
||||
"github.com/minio/minio-go/v7/pkg/replication"
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
"github.com/minio/minio/pkg/madmin"
|
||||
)
|
||||
|
||||
type RemoteBucketResult struct {
|
||||
OriginBucket string
|
||||
TargetBucket string
|
||||
Error string
|
||||
}
|
||||
|
||||
func registerAdminBucketRemoteHandlers(api *operations.ConsoleAPI) {
|
||||
// return list of remote buckets
|
||||
api.UserAPIListRemoteBucketsHandler = user_api.ListRemoteBucketsHandlerFunc(func(params user_api.ListRemoteBucketsParams, session *models.Principal) middleware.Responder {
|
||||
@@ -69,6 +78,38 @@ func registerAdminBucketRemoteHandlers(api *operations.ConsoleAPI) {
|
||||
return user_api.NewAddRemoteBucketCreated()
|
||||
})
|
||||
|
||||
// set multi-bucket replication
|
||||
api.UserAPISetMultiBucketReplicationHandler = user_api.SetMultiBucketReplicationHandlerFunc(func(params user_api.SetMultiBucketReplicationParams, session *models.Principal) middleware.Responder {
|
||||
response, err := setMultiBucketReplicationResponse(session, params)
|
||||
|
||||
if err != nil {
|
||||
return user_api.NewSetMultiBucketReplicationDefault(500).WithPayload(err)
|
||||
}
|
||||
|
||||
return user_api.NewSetMultiBucketReplicationOK().WithPayload(response)
|
||||
})
|
||||
|
||||
// list external buckets
|
||||
api.UserAPIListExternalBucketsHandler = user_api.ListExternalBucketsHandlerFunc(func(params user_api.ListExternalBucketsParams, session *models.Principal) middleware.Responder {
|
||||
response, err := listExternalBucketsResponse(params)
|
||||
|
||||
if err != nil {
|
||||
return user_api.NewListExternalBucketsDefault(500).WithPayload(err)
|
||||
}
|
||||
|
||||
return user_api.NewListExternalBucketsOK().WithPayload(response)
|
||||
})
|
||||
|
||||
// delete replication rule
|
||||
api.UserAPIDeleteBucketReplicationRuleHandler = user_api.DeleteBucketReplicationRuleHandlerFunc(func(params user_api.DeleteBucketReplicationRuleParams, session *models.Principal) middleware.Responder {
|
||||
err := deleteReplicationRuleResponse(session, params)
|
||||
|
||||
if err != nil {
|
||||
return user_api.NewDeleteBucketReplicationRuleDefault(500).WithPayload(err)
|
||||
}
|
||||
|
||||
return user_api.NewDeleteBucketReplicationRuleNoContent()
|
||||
})
|
||||
}
|
||||
|
||||
func getListRemoteBucketsResponse(session *models.Principal) (*models.ListRemoteBucketsResponse, error) {
|
||||
@@ -130,7 +171,7 @@ func getAddRemoteBucketResponse(session *models.Principal, params user_api.AddRe
|
||||
return err
|
||||
}
|
||||
adminClient := adminClient{client: mAdmin}
|
||||
err = addRemoteBucket(ctx, adminClient, *params.Body)
|
||||
_, err = addRemoteBucket(ctx, adminClient, *params.Body)
|
||||
if err != nil {
|
||||
log.Println("error adding remote bucket: ", err)
|
||||
return err
|
||||
@@ -184,13 +225,13 @@ func deleteRemoteBucket(ctx context.Context, client MinioAdmin, sourceBucketName
|
||||
return client.removeRemoteBucket(ctx, sourceBucketName, arn)
|
||||
}
|
||||
|
||||
func addRemoteBucket(ctx context.Context, client MinioAdmin, params models.CreateRemoteBucket) error {
|
||||
func addRemoteBucket(ctx context.Context, client MinioAdmin, params models.CreateRemoteBucket) (string, error) {
|
||||
TargetURL := *params.TargetURL
|
||||
accessKey := *params.AccessKey
|
||||
secretKey := *params.SecretKey
|
||||
u, err := url.Parse(TargetURL)
|
||||
if err != nil {
|
||||
return errors.New("malformed Remote target URL")
|
||||
return "", errors.New("malformed Remote target URL")
|
||||
}
|
||||
secure := u.Scheme == "https"
|
||||
host := u.Host
|
||||
@@ -212,6 +253,225 @@ func addRemoteBucket(ctx context.Context, client MinioAdmin, params models.Creat
|
||||
Type: "replication",
|
||||
Region: params.Region,
|
||||
}
|
||||
_, err = client.addRemoteBucket(ctx, *params.SourceBucket, remoteBucket)
|
||||
return err
|
||||
bucketARN, err := client.addRemoteBucket(ctx, *params.SourceBucket, remoteBucket)
|
||||
|
||||
return bucketARN, err
|
||||
}
|
||||
|
||||
func addBucketReplicationItem(ctx context.Context, session *models.Principal, minClient minioClient, bucketName, arn, destinationBucket string) error {
|
||||
// we will tolerate this call failing
|
||||
cfg, err := minClient.getBucketReplication(ctx, bucketName)
|
||||
if err != nil {
|
||||
log.Println("error versioning bucket:", err)
|
||||
}
|
||||
|
||||
// add rule
|
||||
maxPrio := 0
|
||||
for _, r := range cfg.Rules {
|
||||
if r.Priority > maxPrio {
|
||||
maxPrio = r.Priority
|
||||
}
|
||||
}
|
||||
maxPrio++
|
||||
|
||||
s3Client, err := newS3BucketClient(session, bucketName, "")
|
||||
if err != nil {
|
||||
log.Println("error creating S3Client:", err)
|
||||
return err
|
||||
}
|
||||
// create a mc S3Client interface implementation
|
||||
// defining the client to be used
|
||||
mcClient := mcClient{client: s3Client}
|
||||
|
||||
opts := replication.Options{
|
||||
RoleArn: arn,
|
||||
Priority: fmt.Sprintf("%d", maxPrio),
|
||||
RuleStatus: "enable",
|
||||
DestBucket: destinationBucket,
|
||||
Op: replication.AddOption,
|
||||
}
|
||||
|
||||
err2 := mcClient.setReplication(ctx, &cfg, opts)
|
||||
if err2 != nil {
|
||||
log.Println("error creating replication for bucket:", err2.Cause)
|
||||
return err2.Cause
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setMultiBucketReplication(ctx context.Context, session *models.Principal, client MinioAdmin, minClient minioClient, params user_api.SetMultiBucketReplicationParams) []RemoteBucketResult {
|
||||
bucketsRelation := params.Body.BucketsRelation
|
||||
|
||||
// Parallel remote bucket adding
|
||||
parallelRemoteBucket := func(bucketRelationData *models.MultiBucketsRelation) chan RemoteBucketResult {
|
||||
remoteProc := make(chan RemoteBucketResult)
|
||||
sourceBucket := bucketRelationData.OriginBucket
|
||||
targetBucket := bucketRelationData.DestinationBucket
|
||||
|
||||
go func() {
|
||||
defer close(remoteProc)
|
||||
|
||||
createRemoteBucketParams := models.CreateRemoteBucket{
|
||||
AccessKey: params.Body.AccessKey,
|
||||
SecretKey: params.Body.SecretKey,
|
||||
SourceBucket: &sourceBucket,
|
||||
TargetBucket: &targetBucket,
|
||||
Region: params.Body.Region,
|
||||
TargetURL: params.Body.TargetURL,
|
||||
}
|
||||
|
||||
// We add the remote bucket reference & store the arn or errors returned
|
||||
arn, err := addRemoteBucket(ctx, client, createRemoteBucketParams)
|
||||
|
||||
if err == nil {
|
||||
err = addBucketReplicationItem(ctx, session, minClient, sourceBucket, arn, targetBucket)
|
||||
}
|
||||
|
||||
var errorReturn = ""
|
||||
|
||||
if err != nil {
|
||||
errorReturn = err.Error()
|
||||
}
|
||||
|
||||
retParams := RemoteBucketResult{
|
||||
OriginBucket: sourceBucket,
|
||||
TargetBucket: targetBucket,
|
||||
Error: errorReturn,
|
||||
}
|
||||
|
||||
remoteProc <- retParams
|
||||
}()
|
||||
return remoteProc
|
||||
}
|
||||
|
||||
var bucketsManagement []chan RemoteBucketResult
|
||||
|
||||
for _, bucketName := range bucketsRelation {
|
||||
// We generate the ARNs for each bucket
|
||||
rBucket := parallelRemoteBucket(bucketName)
|
||||
bucketsManagement = append(bucketsManagement, rBucket)
|
||||
}
|
||||
|
||||
resultsList := []RemoteBucketResult{}
|
||||
for _, result := range bucketsManagement {
|
||||
res := <-result
|
||||
resultsList = append(resultsList, res)
|
||||
}
|
||||
|
||||
return resultsList
|
||||
}
|
||||
|
||||
func setMultiBucketReplicationResponse(session *models.Principal, params user_api.SetMultiBucketReplicationParams) (*models.MultiBucketResponseState, *models.Error) {
|
||||
ctx := context.Background()
|
||||
|
||||
mAdmin, err := newMAdminClient(session)
|
||||
if err != nil {
|
||||
log.Println("error creating Madmin Client:", err)
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
adminClient := adminClient{client: mAdmin}
|
||||
|
||||
mClient, err := newMinioClient(session)
|
||||
if err != nil {
|
||||
log.Println("error creating MinIO Client:", err)
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
mnClient := minioClient{client: mClient}
|
||||
|
||||
replicationResults := setMultiBucketReplication(ctx, session, adminClient, mnClient, params)
|
||||
|
||||
if replicationResults == nil {
|
||||
err = errors.New("error setting buckets replication")
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
|
||||
resParsed := []*models.MultiBucketResponseItem{}
|
||||
|
||||
for _, repResult := range replicationResults {
|
||||
responseItem := models.MultiBucketResponseItem{
|
||||
ErrorString: repResult.Error,
|
||||
OriginBucket: repResult.OriginBucket,
|
||||
TargetBucket: repResult.TargetBucket,
|
||||
}
|
||||
|
||||
resParsed = append(resParsed, &responseItem)
|
||||
}
|
||||
|
||||
resultsParsed := models.MultiBucketResponseState{
|
||||
ReplicationState: resParsed,
|
||||
}
|
||||
|
||||
return &resultsParsed, nil
|
||||
}
|
||||
|
||||
func listExternalBucketsResponse(params user_api.ListExternalBucketsParams) (*models.ListBucketsResponse, *models.Error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
|
||||
defer cancel()
|
||||
remoteAdmin, err := newAdminFromCreds(*params.Body.AccessKey, *params.Body.SecretKey, *params.Body.TargetURL, *params.Body.UseTLS)
|
||||
if err != nil {
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
remoteClient := adminClient{client: remoteAdmin}
|
||||
buckets, err := getAccountInfo(ctx, remoteClient)
|
||||
if err != nil {
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
|
||||
// serialize output
|
||||
listBucketsResponse := &models.ListBucketsResponse{
|
||||
Buckets: buckets,
|
||||
Total: int64(len(buckets)),
|
||||
}
|
||||
return listBucketsResponse, nil
|
||||
}
|
||||
|
||||
func deleteReplicationRule(ctx context.Context, session *models.Principal, bucketName, ruleID string) error {
|
||||
mClient, err := newMinioClient(session)
|
||||
if err != nil {
|
||||
log.Println("error creating MinIO Client:", err)
|
||||
return err
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
minClient := minioClient{client: mClient}
|
||||
|
||||
cfg, err := minClient.getBucketReplication(ctx, bucketName)
|
||||
if err != nil {
|
||||
log.Println("error versioning bucket:", err)
|
||||
}
|
||||
|
||||
s3Client, err := newS3BucketClient(session, bucketName, "")
|
||||
if err != nil {
|
||||
log.Println("error creating S3Client:", err)
|
||||
return err
|
||||
}
|
||||
// create a mc S3Client interface implementation
|
||||
// defining the client to be used
|
||||
mcClient := mcClient{client: s3Client}
|
||||
|
||||
opts := replication.Options{
|
||||
ID: ruleID,
|
||||
Op: replication.RemoveOption,
|
||||
}
|
||||
|
||||
err2 := mcClient.setReplication(ctx, &cfg, opts)
|
||||
if err2 != nil {
|
||||
return err2.Cause
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteReplicationRuleResponse(session *models.Principal, params user_api.DeleteBucketReplicationRuleParams) *models.Error {
|
||||
ctx := context.Background()
|
||||
|
||||
err := deleteReplicationRule(ctx, session, params.BucketName, params.RuleID)
|
||||
|
||||
if err != nil {
|
||||
return prepareError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -319,6 +319,20 @@ func newAdminFromClaims(claims *models.Principal) (*madmin.AdminClient, error) {
|
||||
return adminClient, nil
|
||||
}
|
||||
|
||||
// newAdminFromCreds Creates a minio client using custom credentials for connecting to a remote host
|
||||
func newAdminFromCreds(accessKey, secretKey, endpoint string, tlsEnabled bool) (*madmin.AdminClient, error) {
|
||||
minioClient, err := madmin.NewWithOptions(endpoint, &madmin.Options{
|
||||
Creds: credentials.NewStaticV4(accessKey, secretKey, ""),
|
||||
Secure: tlsEnabled,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return minioClient, nil
|
||||
}
|
||||
|
||||
// stsClient is a custom http client, this client should not be called directly and instead be
|
||||
// called using GetConsoleSTSClient() to ensure is initialized and the certificates are loaded correctly
|
||||
var stsClient *http.Client
|
||||
|
||||
@@ -362,6 +362,39 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets-replication": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"UserAPI"
|
||||
],
|
||||
"summary": "Sets Multi Bucket Replication in multiple Buckets",
|
||||
"operationId": "SetMultiBucketReplication",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/multiBucketReplication"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/multiBucketResponseState"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets/{bucket_name}/encryption/disable": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -1034,13 +1067,15 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
}
|
||||
},
|
||||
"/buckets/{bucket_name}/replication/{rule_id}": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"UserAPI"
|
||||
],
|
||||
"summary": "Add Bucket Replication",
|
||||
"operationId": "AddBucketReplication",
|
||||
"summary": "Bucket Replication Rule Delete",
|
||||
"operationId": "DeleteBucketReplicationRule",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
@@ -1049,16 +1084,14 @@ func init() {
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/addBucketReplication"
|
||||
}
|
||||
"type": "string",
|
||||
"name": "rule_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"204": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
@@ -1803,6 +1836,39 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/list-external-buckets": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"UserAPI"
|
||||
],
|
||||
"summary": "Lists an External list of buckets using custom credentials",
|
||||
"operationId": "ListExternalBuckets",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/listExternalBucketsParams"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/listBucketsResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/login": {
|
||||
"get": {
|
||||
"security": [],
|
||||
@@ -4363,6 +4429,33 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"listExternalBucketsParams": {
|
||||
"required": [
|
||||
"accessKey",
|
||||
"secretKey",
|
||||
"targetURL",
|
||||
"useTLS"
|
||||
],
|
||||
"properties": {
|
||||
"accessKey": {
|
||||
"type": "string",
|
||||
"minLength": 3
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretKey": {
|
||||
"type": "string",
|
||||
"minLength": 8
|
||||
},
|
||||
"targetURL": {
|
||||
"type": "string"
|
||||
},
|
||||
"useTLS": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"listGroupsResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -4589,6 +4682,73 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiBucketReplication": {
|
||||
"required": [
|
||||
"accessKey",
|
||||
"secretKey",
|
||||
"targetURL",
|
||||
"bucketsRelation"
|
||||
],
|
||||
"properties": {
|
||||
"accessKey": {
|
||||
"type": "string",
|
||||
"minLength": 3
|
||||
},
|
||||
"bucketsRelation": {
|
||||
"type": "array",
|
||||
"minLength": 1,
|
||||
"items": {
|
||||
"$ref": "#/definitions/multiBucketsRelation"
|
||||
}
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretKey": {
|
||||
"type": "string",
|
||||
"minLength": 8
|
||||
},
|
||||
"targetURL": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiBucketResponseItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"errorString": {
|
||||
"type": "string"
|
||||
},
|
||||
"originBucket": {
|
||||
"type": "string"
|
||||
},
|
||||
"targetBucket": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiBucketResponseState": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"replicationState": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/multiBucketResponseItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiBucketsRelation": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"destinationBucket": {
|
||||
"type": "string"
|
||||
},
|
||||
"originBucket": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nodeSelectorTerm": {
|
||||
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed. The TopologySelectorTerm type implements a subset of the NodeSelectorTerm.",
|
||||
"type": "object",
|
||||
@@ -6253,6 +6413,39 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets-replication": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"UserAPI"
|
||||
],
|
||||
"summary": "Sets Multi Bucket Replication in multiple Buckets",
|
||||
"operationId": "SetMultiBucketReplication",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/multiBucketReplication"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/multiBucketResponseState"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets/{bucket_name}/encryption/disable": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -6925,13 +7118,15 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
}
|
||||
},
|
||||
"/buckets/{bucket_name}/replication/{rule_id}": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"UserAPI"
|
||||
],
|
||||
"summary": "Add Bucket Replication",
|
||||
"operationId": "AddBucketReplication",
|
||||
"summary": "Bucket Replication Rule Delete",
|
||||
"operationId": "DeleteBucketReplicationRule",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
@@ -6940,16 +7135,14 @@ func init() {
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/addBucketReplication"
|
||||
}
|
||||
"type": "string",
|
||||
"name": "rule_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"204": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
@@ -7694,6 +7887,39 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/list-external-buckets": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"UserAPI"
|
||||
],
|
||||
"summary": "Lists an External list of buckets using custom credentials",
|
||||
"operationId": "ListExternalBuckets",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/listExternalBucketsParams"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/listBucketsResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/login": {
|
||||
"get": {
|
||||
"security": [],
|
||||
@@ -10863,6 +11089,33 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"listExternalBucketsParams": {
|
||||
"required": [
|
||||
"accessKey",
|
||||
"secretKey",
|
||||
"targetURL",
|
||||
"useTLS"
|
||||
],
|
||||
"properties": {
|
||||
"accessKey": {
|
||||
"type": "string",
|
||||
"minLength": 3
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretKey": {
|
||||
"type": "string",
|
||||
"minLength": 8
|
||||
},
|
||||
"targetURL": {
|
||||
"type": "string"
|
||||
},
|
||||
"useTLS": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"listGroupsResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -11089,6 +11342,73 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiBucketReplication": {
|
||||
"required": [
|
||||
"accessKey",
|
||||
"secretKey",
|
||||
"targetURL",
|
||||
"bucketsRelation"
|
||||
],
|
||||
"properties": {
|
||||
"accessKey": {
|
||||
"type": "string",
|
||||
"minLength": 3
|
||||
},
|
||||
"bucketsRelation": {
|
||||
"type": "array",
|
||||
"minLength": 1,
|
||||
"items": {
|
||||
"$ref": "#/definitions/multiBucketsRelation"
|
||||
}
|
||||
},
|
||||
"region": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretKey": {
|
||||
"type": "string",
|
||||
"minLength": 8
|
||||
},
|
||||
"targetURL": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiBucketResponseItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"errorString": {
|
||||
"type": "string"
|
||||
},
|
||||
"originBucket": {
|
||||
"type": "string"
|
||||
},
|
||||
"targetBucket": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiBucketResponseState": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"replicationState": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/multiBucketResponseItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiBucketsRelation": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"destinationBucket": {
|
||||
"type": "string"
|
||||
},
|
||||
"originBucket": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nodeSelectorTerm": {
|
||||
"description": "A null or empty node selector term matches no objects. The requirements of them are ANDed. The TopologySelectorTerm type implements a subset of the NodeSelectorTerm.",
|
||||
"type": "object",
|
||||
|
||||
@@ -67,9 +67,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
UserAPIAccountChangePasswordHandler: user_api.AccountChangePasswordHandlerFunc(func(params user_api.AccountChangePasswordParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.AccountChangePassword has not yet been implemented")
|
||||
}),
|
||||
UserAPIAddBucketReplicationHandler: user_api.AddBucketReplicationHandlerFunc(func(params user_api.AddBucketReplicationParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.AddBucketReplication has not yet been implemented")
|
||||
}),
|
||||
AdminAPIAddGroupHandler: admin_api.AddGroupHandlerFunc(func(params admin_api.AddGroupParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.AddGroup has not yet been implemented")
|
||||
}),
|
||||
@@ -118,6 +115,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
UserAPIDeleteBucketEventHandler: user_api.DeleteBucketEventHandlerFunc(func(params user_api.DeleteBucketEventParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.DeleteBucketEvent has not yet been implemented")
|
||||
}),
|
||||
UserAPIDeleteBucketReplicationRuleHandler: user_api.DeleteBucketReplicationRuleHandlerFunc(func(params user_api.DeleteBucketReplicationRuleParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.DeleteBucketReplicationRule has not yet been implemented")
|
||||
}),
|
||||
UserAPIDeleteObjectHandler: user_api.DeleteObjectHandlerFunc(func(params user_api.DeleteObjectParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.DeleteObject has not yet been implemented")
|
||||
}),
|
||||
@@ -199,6 +199,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
AdminAPIListConfigHandler: admin_api.ListConfigHandlerFunc(func(params admin_api.ListConfigParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.ListConfig has not yet been implemented")
|
||||
}),
|
||||
UserAPIListExternalBucketsHandler: user_api.ListExternalBucketsHandlerFunc(func(params user_api.ListExternalBucketsParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.ListExternalBuckets has not yet been implemented")
|
||||
}),
|
||||
AdminAPIListGroupsHandler: admin_api.ListGroupsHandlerFunc(func(params admin_api.ListGroupsParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.ListGroups has not yet been implemented")
|
||||
}),
|
||||
@@ -301,6 +304,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
AdminAPISetConfigHandler: admin_api.SetConfigHandlerFunc(func(params admin_api.SetConfigParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.SetConfig has not yet been implemented")
|
||||
}),
|
||||
UserAPISetMultiBucketReplicationHandler: user_api.SetMultiBucketReplicationHandlerFunc(func(params user_api.SetMultiBucketReplicationParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.SetMultiBucketReplication has not yet been implemented")
|
||||
}),
|
||||
AdminAPISetPolicyHandler: admin_api.SetPolicyHandlerFunc(func(params admin_api.SetPolicyParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.SetPolicy has not yet been implemented")
|
||||
}),
|
||||
@@ -403,8 +409,6 @@ type ConsoleAPI struct {
|
||||
|
||||
// UserAPIAccountChangePasswordHandler sets the operation handler for the account change password operation
|
||||
UserAPIAccountChangePasswordHandler user_api.AccountChangePasswordHandler
|
||||
// UserAPIAddBucketReplicationHandler sets the operation handler for the add bucket replication operation
|
||||
UserAPIAddBucketReplicationHandler user_api.AddBucketReplicationHandler
|
||||
// AdminAPIAddGroupHandler sets the operation handler for the add group operation
|
||||
AdminAPIAddGroupHandler admin_api.AddGroupHandler
|
||||
// AdminAPIAddNotificationEndpointHandler sets the operation handler for the add notification endpoint operation
|
||||
@@ -437,6 +441,8 @@ type ConsoleAPI struct {
|
||||
UserAPIDeleteBucketHandler user_api.DeleteBucketHandler
|
||||
// UserAPIDeleteBucketEventHandler sets the operation handler for the delete bucket event operation
|
||||
UserAPIDeleteBucketEventHandler user_api.DeleteBucketEventHandler
|
||||
// UserAPIDeleteBucketReplicationRuleHandler sets the operation handler for the delete bucket replication rule operation
|
||||
UserAPIDeleteBucketReplicationRuleHandler user_api.DeleteBucketReplicationRuleHandler
|
||||
// UserAPIDeleteObjectHandler sets the operation handler for the delete object operation
|
||||
UserAPIDeleteObjectHandler user_api.DeleteObjectHandler
|
||||
// UserAPIDeleteObjectRetentionHandler sets the operation handler for the delete object retention operation
|
||||
@@ -491,6 +497,8 @@ type ConsoleAPI struct {
|
||||
UserAPIListBucketsHandler user_api.ListBucketsHandler
|
||||
// AdminAPIListConfigHandler sets the operation handler for the list config operation
|
||||
AdminAPIListConfigHandler admin_api.ListConfigHandler
|
||||
// UserAPIListExternalBucketsHandler sets the operation handler for the list external buckets operation
|
||||
UserAPIListExternalBucketsHandler user_api.ListExternalBucketsHandler
|
||||
// AdminAPIListGroupsHandler sets the operation handler for the list groups operation
|
||||
AdminAPIListGroupsHandler admin_api.ListGroupsHandler
|
||||
// UserAPIListObjectsHandler sets the operation handler for the list objects operation
|
||||
@@ -559,6 +567,8 @@ type ConsoleAPI struct {
|
||||
UserAPISetBucketVersioningHandler user_api.SetBucketVersioningHandler
|
||||
// AdminAPISetConfigHandler sets the operation handler for the set config operation
|
||||
AdminAPISetConfigHandler admin_api.SetConfigHandler
|
||||
// UserAPISetMultiBucketReplicationHandler sets the operation handler for the set multi bucket replication operation
|
||||
UserAPISetMultiBucketReplicationHandler user_api.SetMultiBucketReplicationHandler
|
||||
// AdminAPISetPolicyHandler sets the operation handler for the set policy operation
|
||||
AdminAPISetPolicyHandler admin_api.SetPolicyHandler
|
||||
// AdminAPISetPolicyMultipleHandler sets the operation handler for the set policy multiple operation
|
||||
@@ -670,9 +680,6 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.UserAPIAccountChangePasswordHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.AccountChangePasswordHandler")
|
||||
}
|
||||
if o.UserAPIAddBucketReplicationHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.AddBucketReplicationHandler")
|
||||
}
|
||||
if o.AdminAPIAddGroupHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.AddGroupHandler")
|
||||
}
|
||||
@@ -721,6 +728,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.UserAPIDeleteBucketEventHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.DeleteBucketEventHandler")
|
||||
}
|
||||
if o.UserAPIDeleteBucketReplicationRuleHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.DeleteBucketReplicationRuleHandler")
|
||||
}
|
||||
if o.UserAPIDeleteObjectHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.DeleteObjectHandler")
|
||||
}
|
||||
@@ -802,6 +812,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.AdminAPIListConfigHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.ListConfigHandler")
|
||||
}
|
||||
if o.UserAPIListExternalBucketsHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.ListExternalBucketsHandler")
|
||||
}
|
||||
if o.AdminAPIListGroupsHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.ListGroupsHandler")
|
||||
}
|
||||
@@ -904,6 +917,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.AdminAPISetConfigHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.SetConfigHandler")
|
||||
}
|
||||
if o.UserAPISetMultiBucketReplicationHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.SetMultiBucketReplicationHandler")
|
||||
}
|
||||
if o.AdminAPISetPolicyHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.SetPolicyHandler")
|
||||
}
|
||||
@@ -1061,10 +1077,6 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/buckets/{bucket_name}/replication"] = user_api.NewAddBucketReplication(o.context, o.UserAPIAddBucketReplicationHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/groups"] = admin_api.NewAddGroup(o.context, o.AdminAPIAddGroupHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
@@ -1129,6 +1141,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/buckets/{bucket_name}/replication/{rule_id}"] = user_api.NewDeleteBucketReplicationRule(o.context, o.UserAPIDeleteBucketReplicationRuleHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/buckets/{bucket_name}/objects"] = user_api.NewDeleteObject(o.context, o.UserAPIDeleteObjectHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
@@ -1234,6 +1250,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/configs"] = admin_api.NewListConfig(o.context, o.AdminAPIListConfigHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/list-external-buckets"] = user_api.NewListExternalBuckets(o.context, o.UserAPIListExternalBucketsHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
@@ -1370,6 +1390,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/configs/{name}"] = admin_api.NewSetConfig(o.context, o.AdminAPISetConfigHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/buckets-replication"] = user_api.NewSetMultiBucketReplication(o.context, o.UserAPISetMultiBucketReplicationHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// AddBucketReplicationCreatedCode is the HTTP code returned for type AddBucketReplicationCreated
|
||||
const AddBucketReplicationCreatedCode int = 201
|
||||
|
||||
/*AddBucketReplicationCreated A successful response.
|
||||
|
||||
swagger:response addBucketReplicationCreated
|
||||
*/
|
||||
type AddBucketReplicationCreated struct {
|
||||
}
|
||||
|
||||
// NewAddBucketReplicationCreated creates AddBucketReplicationCreated with default headers values
|
||||
func NewAddBucketReplicationCreated() *AddBucketReplicationCreated {
|
||||
|
||||
return &AddBucketReplicationCreated{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *AddBucketReplicationCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(201)
|
||||
}
|
||||
|
||||
/*AddBucketReplicationDefault Generic error response.
|
||||
|
||||
swagger:response addBucketReplicationDefault
|
||||
*/
|
||||
type AddBucketReplicationDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewAddBucketReplicationDefault creates AddBucketReplicationDefault with default headers values
|
||||
func NewAddBucketReplicationDefault(code int) *AddBucketReplicationDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &AddBucketReplicationDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the add bucket replication default response
|
||||
func (o *AddBucketReplicationDefault) WithStatusCode(code int) *AddBucketReplicationDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the add bucket replication default response
|
||||
func (o *AddBucketReplicationDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the add bucket replication default response
|
||||
func (o *AddBucketReplicationDefault) WithPayload(payload *models.Error) *AddBucketReplicationDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the add bucket replication default response
|
||||
func (o *AddBucketReplicationDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *AddBucketReplicationDefault) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// DeleteBucketReplicationRuleHandlerFunc turns a function with the right signature into a delete bucket replication rule handler
|
||||
type DeleteBucketReplicationRuleHandlerFunc func(DeleteBucketReplicationRuleParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn DeleteBucketReplicationRuleHandlerFunc) Handle(params DeleteBucketReplicationRuleParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// DeleteBucketReplicationRuleHandler interface for that can handle valid delete bucket replication rule params
|
||||
type DeleteBucketReplicationRuleHandler interface {
|
||||
Handle(DeleteBucketReplicationRuleParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewDeleteBucketReplicationRule creates a new http.Handler for the delete bucket replication rule operation
|
||||
func NewDeleteBucketReplicationRule(ctx *middleware.Context, handler DeleteBucketReplicationRuleHandler) *DeleteBucketReplicationRule {
|
||||
return &DeleteBucketReplicationRule{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*DeleteBucketReplicationRule swagger:route DELETE /buckets/{bucket_name}/replication/{rule_id} UserAPI deleteBucketReplicationRule
|
||||
|
||||
Bucket Replication Rule Delete
|
||||
|
||||
*/
|
||||
type DeleteBucketReplicationRule struct {
|
||||
Context *middleware.Context
|
||||
Handler DeleteBucketReplicationRuleHandler
|
||||
}
|
||||
|
||||
func (o *DeleteBucketReplicationRule) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
r = rCtx
|
||||
}
|
||||
var Params = NewDeleteBucketReplicationRuleParams()
|
||||
|
||||
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)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// NewDeleteBucketReplicationRuleParams creates a new DeleteBucketReplicationRuleParams object
|
||||
// no default values defined in spec.
|
||||
func NewDeleteBucketReplicationRuleParams() DeleteBucketReplicationRuleParams {
|
||||
|
||||
return DeleteBucketReplicationRuleParams{}
|
||||
}
|
||||
|
||||
// DeleteBucketReplicationRuleParams contains all the bound params for the delete bucket replication rule operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters DeleteBucketReplicationRule
|
||||
type DeleteBucketReplicationRuleParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
BucketName string
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
RuleID 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 NewDeleteBucketReplicationRuleParams() beforehand.
|
||||
func (o *DeleteBucketReplicationRuleParams) 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)
|
||||
}
|
||||
|
||||
rRuleID, rhkRuleID, _ := route.Params.GetOK("rule_id")
|
||||
if err := o.bindRuleID(rRuleID, rhkRuleID, 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 *DeleteBucketReplicationRuleParams) 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
|
||||
}
|
||||
|
||||
// bindRuleID binds and validates parameter RuleID from path.
|
||||
func (o *DeleteBucketReplicationRuleParams) bindRuleID(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.RuleID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// DeleteBucketReplicationRuleNoContentCode is the HTTP code returned for type DeleteBucketReplicationRuleNoContent
|
||||
const DeleteBucketReplicationRuleNoContentCode int = 204
|
||||
|
||||
/*DeleteBucketReplicationRuleNoContent A successful response.
|
||||
|
||||
swagger:response deleteBucketReplicationRuleNoContent
|
||||
*/
|
||||
type DeleteBucketReplicationRuleNoContent struct {
|
||||
}
|
||||
|
||||
// NewDeleteBucketReplicationRuleNoContent creates DeleteBucketReplicationRuleNoContent with default headers values
|
||||
func NewDeleteBucketReplicationRuleNoContent() *DeleteBucketReplicationRuleNoContent {
|
||||
|
||||
return &DeleteBucketReplicationRuleNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteBucketReplicationRuleNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*DeleteBucketReplicationRuleDefault Generic error response.
|
||||
|
||||
swagger:response deleteBucketReplicationRuleDefault
|
||||
*/
|
||||
type DeleteBucketReplicationRuleDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteBucketReplicationRuleDefault creates DeleteBucketReplicationRuleDefault with default headers values
|
||||
func NewDeleteBucketReplicationRuleDefault(code int) *DeleteBucketReplicationRuleDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &DeleteBucketReplicationRuleDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the delete bucket replication rule default response
|
||||
func (o *DeleteBucketReplicationRuleDefault) WithStatusCode(code int) *DeleteBucketReplicationRuleDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the delete bucket replication rule default response
|
||||
func (o *DeleteBucketReplicationRuleDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete bucket replication rule default response
|
||||
func (o *DeleteBucketReplicationRuleDefault) WithPayload(payload *models.Error) *DeleteBucketReplicationRuleDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete bucket replication rule default response
|
||||
func (o *DeleteBucketReplicationRuleDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteBucketReplicationRuleDefault) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// DeleteBucketReplicationRuleURL generates an URL for the delete bucket replication rule operation
|
||||
type DeleteBucketReplicationRuleURL struct {
|
||||
BucketName string
|
||||
RuleID 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 *DeleteBucketReplicationRuleURL) WithBasePath(bp string) *DeleteBucketReplicationRuleURL {
|
||||
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 *DeleteBucketReplicationRuleURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *DeleteBucketReplicationRuleURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/buckets/{bucket_name}/replication/{rule_id}"
|
||||
|
||||
bucketName := o.BucketName
|
||||
if bucketName != "" {
|
||||
_path = strings.Replace(_path, "{bucket_name}", bucketName, -1)
|
||||
} else {
|
||||
return nil, errors.New("bucketName is required on DeleteBucketReplicationRuleURL")
|
||||
}
|
||||
|
||||
ruleID := o.RuleID
|
||||
if ruleID != "" {
|
||||
_path = strings.Replace(_path, "{rule_id}", ruleID, -1)
|
||||
} else {
|
||||
return nil, errors.New("ruleId is required on DeleteBucketReplicationRuleURL")
|
||||
}
|
||||
|
||||
_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 *DeleteBucketReplicationRuleURL) 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 *DeleteBucketReplicationRuleURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *DeleteBucketReplicationRuleURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on DeleteBucketReplicationRuleURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on DeleteBucketReplicationRuleURL")
|
||||
}
|
||||
|
||||
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 *DeleteBucketReplicationRuleURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -30,40 +30,40 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// AddBucketReplicationHandlerFunc turns a function with the right signature into a add bucket replication handler
|
||||
type AddBucketReplicationHandlerFunc func(AddBucketReplicationParams, *models.Principal) middleware.Responder
|
||||
// ListExternalBucketsHandlerFunc turns a function with the right signature into a list external buckets handler
|
||||
type ListExternalBucketsHandlerFunc func(ListExternalBucketsParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn AddBucketReplicationHandlerFunc) Handle(params AddBucketReplicationParams, principal *models.Principal) middleware.Responder {
|
||||
func (fn ListExternalBucketsHandlerFunc) Handle(params ListExternalBucketsParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// AddBucketReplicationHandler interface for that can handle valid add bucket replication params
|
||||
type AddBucketReplicationHandler interface {
|
||||
Handle(AddBucketReplicationParams, *models.Principal) middleware.Responder
|
||||
// ListExternalBucketsHandler interface for that can handle valid list external buckets params
|
||||
type ListExternalBucketsHandler interface {
|
||||
Handle(ListExternalBucketsParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewAddBucketReplication creates a new http.Handler for the add bucket replication operation
|
||||
func NewAddBucketReplication(ctx *middleware.Context, handler AddBucketReplicationHandler) *AddBucketReplication {
|
||||
return &AddBucketReplication{Context: ctx, Handler: handler}
|
||||
// NewListExternalBuckets creates a new http.Handler for the list external buckets operation
|
||||
func NewListExternalBuckets(ctx *middleware.Context, handler ListExternalBucketsHandler) *ListExternalBuckets {
|
||||
return &ListExternalBuckets{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*AddBucketReplication swagger:route POST /buckets/{bucket_name}/replication UserAPI addBucketReplication
|
||||
/*ListExternalBuckets swagger:route POST /list-external-buckets UserAPI listExternalBuckets
|
||||
|
||||
Add Bucket Replication
|
||||
Lists an External list of buckets using custom credentials
|
||||
|
||||
*/
|
||||
type AddBucketReplication struct {
|
||||
type ListExternalBuckets struct {
|
||||
Context *middleware.Context
|
||||
Handler AddBucketReplicationHandler
|
||||
Handler ListExternalBucketsHandler
|
||||
}
|
||||
|
||||
func (o *AddBucketReplication) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
func (o *ListExternalBuckets) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
r = rCtx
|
||||
}
|
||||
var Params = NewAddBucketReplicationParams()
|
||||
var Params = NewListExternalBucketsParams()
|
||||
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
@@ -29,23 +29,22 @@ import (
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewAddBucketReplicationParams creates a new AddBucketReplicationParams object
|
||||
// NewListExternalBucketsParams creates a new ListExternalBucketsParams object
|
||||
// no default values defined in spec.
|
||||
func NewAddBucketReplicationParams() AddBucketReplicationParams {
|
||||
func NewListExternalBucketsParams() ListExternalBucketsParams {
|
||||
|
||||
return AddBucketReplicationParams{}
|
||||
return ListExternalBucketsParams{}
|
||||
}
|
||||
|
||||
// AddBucketReplicationParams contains all the bound params for the add bucket replication operation
|
||||
// ListExternalBucketsParams contains all the bound params for the list external buckets operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters AddBucketReplication
|
||||
type AddBucketReplicationParams struct {
|
||||
// swagger:parameters ListExternalBuckets
|
||||
type ListExternalBucketsParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
@@ -54,26 +53,21 @@ type AddBucketReplicationParams struct {
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.AddBucketReplication
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
BucketName string
|
||||
Body *models.ListExternalBucketsParams
|
||||
}
|
||||
|
||||
// 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 NewAddBucketReplicationParams() beforehand.
|
||||
func (o *AddBucketReplicationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
// To ensure default values, the struct must have been initialized with NewListExternalBucketsParams() beforehand.
|
||||
func (o *ListExternalBucketsParams) 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.AddBucketReplication
|
||||
var body models.ListExternalBucketsParams
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
@@ -93,28 +87,8 @@ func (o *AddBucketReplicationParams) BindRequest(r *http.Request, route *middlew
|
||||
} 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 *AddBucketReplicationParams) 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
|
||||
}
|
||||
133
restapi/operations/user_api/list_external_buckets_responses.go
Normal file
133
restapi/operations/user_api/list_external_buckets_responses.go
Normal file
@@ -0,0 +1,133 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// ListExternalBucketsOKCode is the HTTP code returned for type ListExternalBucketsOK
|
||||
const ListExternalBucketsOKCode int = 200
|
||||
|
||||
/*ListExternalBucketsOK A successful response.
|
||||
|
||||
swagger:response listExternalBucketsOK
|
||||
*/
|
||||
type ListExternalBucketsOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.ListBucketsResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewListExternalBucketsOK creates ListExternalBucketsOK with default headers values
|
||||
func NewListExternalBucketsOK() *ListExternalBucketsOK {
|
||||
|
||||
return &ListExternalBucketsOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the list external buckets o k response
|
||||
func (o *ListExternalBucketsOK) WithPayload(payload *models.ListBucketsResponse) *ListExternalBucketsOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the list external buckets o k response
|
||||
func (o *ListExternalBucketsOK) SetPayload(payload *models.ListBucketsResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *ListExternalBucketsOK) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*ListExternalBucketsDefault Generic error response.
|
||||
|
||||
swagger:response listExternalBucketsDefault
|
||||
*/
|
||||
type ListExternalBucketsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewListExternalBucketsDefault creates ListExternalBucketsDefault with default headers values
|
||||
func NewListExternalBucketsDefault(code int) *ListExternalBucketsDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &ListExternalBucketsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the list external buckets default response
|
||||
func (o *ListExternalBucketsDefault) WithStatusCode(code int) *ListExternalBucketsDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the list external buckets default response
|
||||
func (o *ListExternalBucketsDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the list external buckets default response
|
||||
func (o *ListExternalBucketsDefault) WithPayload(payload *models.Error) *ListExternalBucketsDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the list external buckets default response
|
||||
func (o *ListExternalBucketsDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *ListExternalBucketsDefault) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,22 +26,17 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// AddBucketReplicationURL generates an URL for the add bucket replication operation
|
||||
type AddBucketReplicationURL struct {
|
||||
BucketName string
|
||||
|
||||
// ListExternalBucketsURL generates an URL for the list external buckets operation
|
||||
type ListExternalBucketsURL struct {
|
||||
_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 *AddBucketReplicationURL) WithBasePath(bp string) *AddBucketReplicationURL {
|
||||
func (o *ListExternalBucketsURL) WithBasePath(bp string) *ListExternalBucketsURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
@@ -49,22 +44,15 @@ func (o *AddBucketReplicationURL) WithBasePath(bp string) *AddBucketReplicationU
|
||||
// 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 *AddBucketReplicationURL) SetBasePath(bp string) {
|
||||
func (o *ListExternalBucketsURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *AddBucketReplicationURL) Build() (*url.URL, error) {
|
||||
func (o *ListExternalBucketsURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/buckets/{bucket_name}/replication"
|
||||
|
||||
bucketName := o.BucketName
|
||||
if bucketName != "" {
|
||||
_path = strings.Replace(_path, "{bucket_name}", bucketName, -1)
|
||||
} else {
|
||||
return nil, errors.New("bucketName is required on AddBucketReplicationURL")
|
||||
}
|
||||
var _path = "/list-external-buckets"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
@@ -76,7 +64,7 @@ func (o *AddBucketReplicationURL) Build() (*url.URL, error) {
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *AddBucketReplicationURL) Must(u *url.URL, err error) *url.URL {
|
||||
func (o *ListExternalBucketsURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -87,17 +75,17 @@ func (o *AddBucketReplicationURL) Must(u *url.URL, err error) *url.URL {
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *AddBucketReplicationURL) String() string {
|
||||
func (o *ListExternalBucketsURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *AddBucketReplicationURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
func (o *ListExternalBucketsURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on AddBucketReplicationURL")
|
||||
return nil, errors.New("scheme is required for a full url on ListExternalBucketsURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on AddBucketReplicationURL")
|
||||
return nil, errors.New("host is required for a full url on ListExternalBucketsURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
@@ -111,6 +99,6 @@ func (o *AddBucketReplicationURL) BuildFull(scheme, host string) (*url.URL, erro
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *AddBucketReplicationURL) StringFull(scheme, host string) string {
|
||||
func (o *ListExternalBucketsURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
90
restapi/operations/user_api/set_multi_bucket_replication.go
Normal file
90
restapi/operations/user_api/set_multi_bucket_replication.go
Normal file
@@ -0,0 +1,90 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// SetMultiBucketReplicationHandlerFunc turns a function with the right signature into a set multi bucket replication handler
|
||||
type SetMultiBucketReplicationHandlerFunc func(SetMultiBucketReplicationParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn SetMultiBucketReplicationHandlerFunc) Handle(params SetMultiBucketReplicationParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// SetMultiBucketReplicationHandler interface for that can handle valid set multi bucket replication params
|
||||
type SetMultiBucketReplicationHandler interface {
|
||||
Handle(SetMultiBucketReplicationParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewSetMultiBucketReplication creates a new http.Handler for the set multi bucket replication operation
|
||||
func NewSetMultiBucketReplication(ctx *middleware.Context, handler SetMultiBucketReplicationHandler) *SetMultiBucketReplication {
|
||||
return &SetMultiBucketReplication{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*SetMultiBucketReplication swagger:route POST /buckets-replication UserAPI setMultiBucketReplication
|
||||
|
||||
Sets Multi Bucket Replication in multiple Buckets
|
||||
|
||||
*/
|
||||
type SetMultiBucketReplication struct {
|
||||
Context *middleware.Context
|
||||
Handler SetMultiBucketReplicationHandler
|
||||
}
|
||||
|
||||
func (o *SetMultiBucketReplication) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
r = rCtx
|
||||
}
|
||||
var Params = NewSetMultiBucketReplicationParams()
|
||||
|
||||
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)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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/minio/console/models"
|
||||
)
|
||||
|
||||
// NewSetMultiBucketReplicationParams creates a new SetMultiBucketReplicationParams object
|
||||
// no default values defined in spec.
|
||||
func NewSetMultiBucketReplicationParams() SetMultiBucketReplicationParams {
|
||||
|
||||
return SetMultiBucketReplicationParams{}
|
||||
}
|
||||
|
||||
// SetMultiBucketReplicationParams contains all the bound params for the set multi bucket replication operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters SetMultiBucketReplication
|
||||
type SetMultiBucketReplicationParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.MultiBucketReplication
|
||||
}
|
||||
|
||||
// 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 NewSetMultiBucketReplicationParams() beforehand.
|
||||
func (o *SetMultiBucketReplicationParams) 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.MultiBucketReplication
|
||||
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)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// SetMultiBucketReplicationOKCode is the HTTP code returned for type SetMultiBucketReplicationOK
|
||||
const SetMultiBucketReplicationOKCode int = 200
|
||||
|
||||
/*SetMultiBucketReplicationOK A successful response.
|
||||
|
||||
swagger:response setMultiBucketReplicationOK
|
||||
*/
|
||||
type SetMultiBucketReplicationOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.MultiBucketResponseState `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewSetMultiBucketReplicationOK creates SetMultiBucketReplicationOK with default headers values
|
||||
func NewSetMultiBucketReplicationOK() *SetMultiBucketReplicationOK {
|
||||
|
||||
return &SetMultiBucketReplicationOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the set multi bucket replication o k response
|
||||
func (o *SetMultiBucketReplicationOK) WithPayload(payload *models.MultiBucketResponseState) *SetMultiBucketReplicationOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the set multi bucket replication o k response
|
||||
func (o *SetMultiBucketReplicationOK) SetPayload(payload *models.MultiBucketResponseState) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *SetMultiBucketReplicationOK) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*SetMultiBucketReplicationDefault Generic error response.
|
||||
|
||||
swagger:response setMultiBucketReplicationDefault
|
||||
*/
|
||||
type SetMultiBucketReplicationDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewSetMultiBucketReplicationDefault creates SetMultiBucketReplicationDefault with default headers values
|
||||
func NewSetMultiBucketReplicationDefault(code int) *SetMultiBucketReplicationDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &SetMultiBucketReplicationDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the set multi bucket replication default response
|
||||
func (o *SetMultiBucketReplicationDefault) WithStatusCode(code int) *SetMultiBucketReplicationDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the set multi bucket replication default response
|
||||
func (o *SetMultiBucketReplicationDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the set multi bucket replication default response
|
||||
func (o *SetMultiBucketReplicationDefault) WithPayload(payload *models.Error) *SetMultiBucketReplicationDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the set multi bucket replication default response
|
||||
func (o *SetMultiBucketReplicationDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *SetMultiBucketReplicationDefault) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// 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 user_api
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// SetMultiBucketReplicationURL generates an URL for the set multi bucket replication operation
|
||||
type SetMultiBucketReplicationURL 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 *SetMultiBucketReplicationURL) WithBasePath(bp string) *SetMultiBucketReplicationURL {
|
||||
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 *SetMultiBucketReplicationURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *SetMultiBucketReplicationURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/buckets-replication"
|
||||
|
||||
_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 *SetMultiBucketReplicationURL) 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 *SetMultiBucketReplicationURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *SetMultiBucketReplicationURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on SetMultiBucketReplicationURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on SetMultiBucketReplicationURL")
|
||||
}
|
||||
|
||||
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 *SetMultiBucketReplicationURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/replication"
|
||||
"github.com/minio/minio-go/v7/pkg/sse"
|
||||
|
||||
"errors"
|
||||
@@ -105,14 +104,6 @@ func registerBucketsHandlers(api *operations.ConsoleAPI) {
|
||||
}
|
||||
return user_api.NewGetBucketReplicationOK().WithPayload(getBucketReplication)
|
||||
})
|
||||
// get bucket replication
|
||||
api.UserAPIAddBucketReplicationHandler = user_api.AddBucketReplicationHandlerFunc(func(params user_api.AddBucketReplicationParams, session *models.Principal) middleware.Responder {
|
||||
err := getAddBucketReplicationdResponse(session, params.BucketName, ¶ms)
|
||||
if err != nil {
|
||||
return user_api.NewAddBucketReplicationDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String(err.Error())})
|
||||
}
|
||||
return user_api.NewAddBucketReplicationCreated()
|
||||
})
|
||||
// enable bucket encryption
|
||||
api.UserAPIEnableBucketEncryptionHandler = user_api.EnableBucketEncryptionHandlerFunc(func(params user_api.EnableBucketEncryptionParams, session *models.Principal) middleware.Responder {
|
||||
if err := enableBucketEncryptionResponse(session, params); err != nil {
|
||||
@@ -160,61 +151,6 @@ func registerBucketsHandlers(api *operations.ConsoleAPI) {
|
||||
})
|
||||
}
|
||||
|
||||
func getAddBucketReplicationdResponse(session *models.Principal, bucketName string, params *user_api.AddBucketReplicationParams) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
|
||||
defer cancel()
|
||||
|
||||
mClient, err := newMinioClient(session)
|
||||
if err != nil {
|
||||
log.Println("error creating MinIO Client:", err)
|
||||
return err
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
minioClient := minioClient{client: mClient}
|
||||
|
||||
// we will tolerate this call failing
|
||||
cfg, err := minioClient.getBucketReplication(ctx, bucketName)
|
||||
if err != nil {
|
||||
log.Println("error versioning bucket:", err)
|
||||
}
|
||||
|
||||
// add rule
|
||||
|
||||
maxPrio := 0
|
||||
for _, r := range cfg.Rules {
|
||||
if r.Priority > maxPrio {
|
||||
maxPrio = r.Priority
|
||||
}
|
||||
}
|
||||
maxPrio++
|
||||
|
||||
s3Client, err := newS3BucketClient(session, bucketName, "")
|
||||
if err != nil {
|
||||
log.Println("error creating S3Client:", err)
|
||||
return err
|
||||
}
|
||||
// create a mc S3Client interface implementation
|
||||
// defining the client to be used
|
||||
mcClient := mcClient{client: s3Client}
|
||||
|
||||
opts := replication.Options{
|
||||
RoleArn: params.Body.Arn,
|
||||
Priority: fmt.Sprintf("%d", maxPrio),
|
||||
RuleStatus: "enable",
|
||||
//ID: cliCtx.String("id"),
|
||||
DestBucket: params.Body.DestinationBucket,
|
||||
Op: replication.AddOption,
|
||||
}
|
||||
|
||||
err2 := mcClient.setReplication(ctx, &cfg, opts)
|
||||
if err2 != nil {
|
||||
log.Println("error creating replication for bucket:", err2.Cause)
|
||||
return err2.Cause
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type VersionState string
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user