Added lifecycle rules to multiple buckets at once support (#1566)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net> Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -43,9 +43,6 @@ type AddBucketLifecycle struct {
|
||||
// Non required, toggle to disable or enable rule
|
||||
ExpiredObjectDeleteMarker bool `json:"expired_object_delete_marker,omitempty"`
|
||||
|
||||
// Required in case of expiry_days or transition fields are not set. it defines an expiry date for ILM
|
||||
ExpiryDate string `json:"expiry_date,omitempty"`
|
||||
|
||||
// Required in case of expiry_date or transition fields are not set. it defines an expiry days for ILM
|
||||
ExpiryDays int32 `json:"expiry_days,omitempty"`
|
||||
|
||||
@@ -67,9 +64,6 @@ type AddBucketLifecycle struct {
|
||||
// Non required field, tags to match ILM files
|
||||
Tags string `json:"tags,omitempty"`
|
||||
|
||||
// Required in case of transition_days or expiry fields are not set. it defines a transition date for ILM
|
||||
TransitionDate string `json:"transition_date,omitempty"`
|
||||
|
||||
// Required in case of transition_date or expiry fields are not set. it defines a transition days for ILM
|
||||
TransitionDays int32 `json:"transition_days,omitempty"`
|
||||
|
||||
|
||||
168
models/add_multi_bucket_lifecycle.go
Normal file
168
models/add_multi_bucket_lifecycle.go
Normal file
@@ -0,0 +1,168 @@
|
||||
// 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 models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// AddMultiBucketLifecycle add multi bucket lifecycle
|
||||
//
|
||||
// swagger:model addMultiBucketLifecycle
|
||||
type AddMultiBucketLifecycle struct {
|
||||
|
||||
// buckets
|
||||
// Required: true
|
||||
Buckets []string `json:"buckets"`
|
||||
|
||||
// Non required, toggle to disable or enable rule
|
||||
ExpiredObjectDeleteMarker bool `json:"expired_object_delete_marker,omitempty"`
|
||||
|
||||
// Required in case of expiry_date or transition fields are not set. it defines an expiry days for ILM
|
||||
ExpiryDays int32 `json:"expiry_days,omitempty"`
|
||||
|
||||
// Non required, can be set in case of expiration is enabled
|
||||
NoncurrentversionExpirationDays int32 `json:"noncurrentversion_expiration_days,omitempty"`
|
||||
|
||||
// Non required, can be set in case of transition is enabled
|
||||
NoncurrentversionTransitionDays int32 `json:"noncurrentversion_transition_days,omitempty"`
|
||||
|
||||
// Non required, can be set in case of transition is enabled
|
||||
NoncurrentversionTransitionStorageClass string `json:"noncurrentversion_transition_storage_class,omitempty"`
|
||||
|
||||
// Non required field, it matches a prefix to perform ILM operations on it
|
||||
Prefix string `json:"prefix,omitempty"`
|
||||
|
||||
// Required only in case of transition is set. it refers to a tier
|
||||
StorageClass string `json:"storage_class,omitempty"`
|
||||
|
||||
// Non required field, tags to match ILM files
|
||||
Tags string `json:"tags,omitempty"`
|
||||
|
||||
// Required in case of transition_date or expiry fields are not set. it defines a transition days for ILM
|
||||
TransitionDays int32 `json:"transition_days,omitempty"`
|
||||
|
||||
// ILM Rule type (Expiry or transition)
|
||||
// Required: true
|
||||
// Enum: [expiry transition]
|
||||
Type *string `json:"type"`
|
||||
}
|
||||
|
||||
// Validate validates this add multi bucket lifecycle
|
||||
func (m *AddMultiBucketLifecycle) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateBuckets(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateType(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AddMultiBucketLifecycle) validateBuckets(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("buckets", "body", m.Buckets); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var addMultiBucketLifecycleTypeTypePropEnum []interface{}
|
||||
|
||||
func init() {
|
||||
var res []string
|
||||
if err := json.Unmarshal([]byte(`["expiry","transition"]`), &res); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, v := range res {
|
||||
addMultiBucketLifecycleTypeTypePropEnum = append(addMultiBucketLifecycleTypeTypePropEnum, v)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
// AddMultiBucketLifecycleTypeExpiry captures enum value "expiry"
|
||||
AddMultiBucketLifecycleTypeExpiry string = "expiry"
|
||||
|
||||
// AddMultiBucketLifecycleTypeTransition captures enum value "transition"
|
||||
AddMultiBucketLifecycleTypeTransition string = "transition"
|
||||
)
|
||||
|
||||
// prop value enum
|
||||
func (m *AddMultiBucketLifecycle) validateTypeEnum(path, location string, value string) error {
|
||||
if err := validate.EnumCase(path, location, value, addMultiBucketLifecycleTypeTypePropEnum, true); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AddMultiBucketLifecycle) validateType(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("type", "body", m.Type); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// value enum
|
||||
if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this add multi bucket lifecycle based on context it is used
|
||||
func (m *AddMultiBucketLifecycle) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *AddMultiBucketLifecycle) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *AddMultiBucketLifecycle) UnmarshalBinary(b []byte) error {
|
||||
var res AddMultiBucketLifecycle
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
133
models/multi_lifecycle_result.go
Normal file
133
models/multi_lifecycle_result.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 models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// MultiLifecycleResult multi lifecycle result
|
||||
//
|
||||
// swagger:model multiLifecycleResult
|
||||
type MultiLifecycleResult struct {
|
||||
|
||||
// results
|
||||
Results []*MulticycleResultItem `json:"results"`
|
||||
}
|
||||
|
||||
// Validate validates this multi lifecycle result
|
||||
func (m *MultiLifecycleResult) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateResults(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MultiLifecycleResult) validateResults(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Results) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Results); i++ {
|
||||
if swag.IsZero(m.Results[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Results[i] != nil {
|
||||
if err := m.Results[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("results" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("results" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validate this multi lifecycle result based on the context it is used
|
||||
func (m *MultiLifecycleResult) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateResults(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MultiLifecycleResult) contextValidateResults(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Results); i++ {
|
||||
|
||||
if m.Results[i] != nil {
|
||||
if err := m.Results[i].ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("results" + "." + strconv.Itoa(i))
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("results" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *MultiLifecycleResult) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *MultiLifecycleResult) UnmarshalBinary(b []byte) error {
|
||||
var res MultiLifecycleResult
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
70
models/multicycle_result_item.go
Normal file
70
models/multicycle_result_item.go
Normal file
@@ -0,0 +1,70 @@
|
||||
// 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 models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// MulticycleResultItem multicycle result item
|
||||
//
|
||||
// swagger:model multicycleResultItem
|
||||
type MulticycleResultItem struct {
|
||||
|
||||
// bucket name
|
||||
BucketName string `json:"bucketName,omitempty"`
|
||||
|
||||
// error
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this multicycle result item
|
||||
func (m *MulticycleResultItem) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this multicycle result item based on context it is used
|
||||
func (m *MulticycleResultItem) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *MulticycleResultItem) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *MulticycleResultItem) UnmarshalBinary(b []byte) error {
|
||||
var res MulticycleResultItem
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -20,69 +20,38 @@ import { SVGProps } from "react";
|
||||
const LifecycleConfigIcon = (props: SVGProps<SVGSVGElement>) => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="284.616"
|
||||
height="49.568"
|
||||
className={"min-icon"}
|
||||
viewBox="0 0 256 256"
|
||||
fill={"currentcolor"}
|
||||
{...props}
|
||||
>
|
||||
<defs>
|
||||
<clipPath id="clip-path">
|
||||
<rect
|
||||
id="Rectángulo_1035"
|
||||
data-name="Rectángulo 1035"
|
||||
width="210.934"
|
||||
height="255.994"
|
||||
fill="none"
|
||||
/>
|
||||
</clipPath>
|
||||
<clipPath id="clip-Lifecycle_configuration">
|
||||
<rect width="256" height="256" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g
|
||||
id="Lifecycle_configuration"
|
||||
data-name="Lifecycle configuration"
|
||||
clipPath="url(#clip-Lifecycle_configuration)"
|
||||
>
|
||||
<rect width="256" height="256" fill="#fff" />
|
||||
<g
|
||||
id="Lifecycle_configuration_Icon"
|
||||
data-name="Lifecycle configuration Icon"
|
||||
>
|
||||
<g
|
||||
id="Grupo_2424"
|
||||
data-name="Grupo 2424"
|
||||
transform="translate(23.344 0.006)"
|
||||
>
|
||||
<g id="Grupo_2423" data-name="Grupo 2423" clipPath="url(#clip-path)">
|
||||
<g transform="translate(23.344 0.006)">
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<path
|
||||
id="Trazado_7180"
|
||||
data-name="Trazado 7180"
|
||||
d="M75.518,71.671a11.964,11.964,0,0,0,16.92,0L118.06,46.047a11.963,11.963,0,0,0,0-16.92L92.437,3.5a11.964,11.964,0,0,0-16.92,16.92L82.892,27.8A104.264,104.264,0,0,0,0,129.712a11.964,11.964,0,1,0,23.928,0A80.279,80.279,0,0,1,75.4,54.879a11.959,11.959,0,0,0,.116,16.791"
|
||||
transform="translate(0 0)"
|
||||
d="M76.7,73.6c4.6,4.6,11.9,4.6,16.5,0l0,0l25-25c4.6-4.6,4.6-11.9,0-16.5l0,0l-25-25
|
||||
c-4.6-4.6-11.9-4.6-16.5,0s-4.6,11.9,0,16.5l7.2,7.2c-47,9.9-80.8,51.3-80.8,99.4c0,6.4,5.2,11.7,11.7,11.7
|
||||
s11.7-5.2,11.7-11.7c0-32.4,20-61.4,50.2-73C72.2,61.8,72.2,69.1,76.7,73.6"
|
||||
/>
|
||||
<path
|
||||
id="Trazado_7181"
|
||||
data-name="Trazado 7181"
|
||||
d="M372.224,332.6a11.964,11.964,0,0,0-23.928,0,80.278,80.278,0,0,1-51.474,74.833,11.96,11.96,0,0,0-17.036-16.791l-25.623,25.623a11.914,11.914,0,0,0-3.011,5.053,12.017,12.017,0,0,0-.274,5.692,11.91,11.91,0,0,0,3.285,6.175l0,0,25.621,25.621a11.964,11.964,0,0,0,16.92-16.92l-7.374-7.375A104.262,104.262,0,0,0,372.224,332.6"
|
||||
transform="translate(-161.29 -206.318)"
|
||||
d="M208.8,126.8c0-6.4-5.2-11.7-11.7-11.7c-6.4,0-11.7,5.2-11.7,11.7c0,32.4-20,61.4-50.2,73
|
||||
c4.5-4.6,4.4-12-0.2-16.5c-4.6-4.5-11.9-4.4-16.4,0.1l-25,25c-1.4,1.4-2.4,3.1-2.9,4.9c-0.5,1.8-0.6,3.7-0.3,5.5
|
||||
c0.4,2.3,1.6,4.4,3.2,6l0,0l25,25c4.6,4.6,11.9,4.6,16.5,0s4.6-11.9,0-16.5l-7.2-7.2C175,216.3,208.7,174.9,208.8,126.8"
|
||||
/>
|
||||
<path
|
||||
id="Trazado_7182"
|
||||
data-name="Trazado 7182"
|
||||
d="M225.178,323.044l6.176-4.656a24.5,24.5,0,0,0,2.824,1.184l1.1,7.65a2.82,2.82,0,0,0,2.824,2.428H249a2.827,2.827,0,0,0,2.824-2.428l1.1-7.65a25.862,25.862,0,0,0,2.824-1.184l6.178,4.628a2.822,2.822,0,0,0,3.7-.252l7.705-7.705a2.824,2.824,0,0,0,.255-3.7l-4.6-6.154a25.662,25.662,0,0,0,1.184-2.822l7.65-1.1a2.826,2.826,0,0,0,2.428-2.822V287.536a2.826,2.826,0,0,0-2.4-2.792l-7.648-1.1A26.6,26.6,0,0,0,269,280.821l4.633-6.183a2.817,2.817,0,0,0-.258-3.7l-7.7-7.762a2.814,2.814,0,0,0-3.693-.254l-6.187,4.656a25.437,25.437,0,0,0-2.823-1.184l-1.1-7.648a2.822,2.822,0,0,0-2.822-2.428H238.126a2.819,2.819,0,0,0-2.82,2.428l-1.1,7.648a25.448,25.448,0,0,0-2.824,1.184l-6.2-4.656a2.83,2.83,0,0,0-3.705.254l-7.7,7.705a2.817,2.817,0,0,0-.258,3.7l4.661,6.183a24.842,24.842,0,0,0-1.193,2.822l-7.643,1.1a2.822,2.822,0,0,0-2.429,2.823V298.4a2.822,2.822,0,0,0,2.429,2.823l7.643,1.1a24.549,24.549,0,0,0,1.193,2.823l-4.661,6.238a2.821,2.821,0,0,0,.258,3.7l7.7,7.705a2.833,2.833,0,0,0,3.705.252m9.93-30.056a8.466,8.466,0,1,1,16.931-.007v.007a8.464,8.464,0,0,1-8.46,8.468h-.008a8.465,8.465,0,0,1-8.463-8.467Z"
|
||||
transform="translate(-133.14 -164.935)"
|
||||
d="M92.8,157.8l6-4.5c0.9,0.4,1.8,0.8,2.8,1.2l1.1,7.5c0.2,1.4,1.4,2.4,2.8,2.4h10.6
|
||||
c1.4,0,2.6-1,2.8-2.4l1.1-7.5c0.9-0.3,1.9-0.7,2.8-1.2l6,4.5c1.1,0.8,2.6,0.7,3.6-0.2l7.5-7.5c1-1,1.1-2.5,0.2-3.6l-4.5-6
|
||||
c0.4-0.9,0.8-1.8,1.2-2.8l7.5-1.1c1.4-0.2,2.4-1.4,2.4-2.8v-10.7c0-1.4-1-2.5-2.3-2.7l-7.5-1.1c-0.3-0.9-0.7-1.9-1.2-2.8
|
||||
l4.5-6c0.8-1.1,0.7-2.6-0.3-3.6l-7.5-7.6c-1-1-2.5-1.1-3.6-0.2l-6,4.5c-0.9-0.4-1.8-0.8-2.8-1.2l-1.1-7.5
|
||||
c-0.2-1.4-1.4-2.4-2.8-2.4h-10.7c-1.4,0-2.6,1-2.7,2.4l-1.1,7.5c-0.9,0.3-1.9,0.7-2.8,1.2l-6-4.5c-1.1-0.8-2.6-0.7-3.6,0.2
|
||||
l-7.5,7.5c-1,1-1.1,2.5-0.3,3.6l4.5,6c-0.4,0.9-0.8,1.8-1.2,2.8l-7.5,1.1c-1.4,0.2-2.4,1.4-2.4,2.8v10.6c0,1.4,1,2.6,2.4,2.8
|
||||
l7.5,1.1c0.3,0.9,0.7,1.9,1.2,2.8l-4.5,6.1c-0.8,1.1-0.7,2.6,0.3,3.6l7.5,7.5C90.2,158.6,91.7,158.7,92.8,157.8 M102.5,128.5
|
||||
c-0.1-4.6,3.6-8.3,8.2-8.3c4.6-0.1,8.3,3.6,8.3,8.2c0,0.1,0,0.1,0,0.2l0,0c0,4.6-3.7,8.3-8.2,8.3l0,0
|
||||
C106.2,136.8,102.5,133.1,102.5,128.5L102.5,128.5L102.5,128.5z"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
<rect
|
||||
id="Rectángulo_1036"
|
||||
data-name="Rectángulo 1036"
|
||||
width="256"
|
||||
height="256"
|
||||
fill="none"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
@@ -287,6 +287,7 @@ const BucketLifecyclePanel = ({
|
||||
</Grid>
|
||||
{!loadingLifecycle && (
|
||||
<Grid item xs={12}>
|
||||
<br />
|
||||
<HelpBox
|
||||
title={"Lifecycle Rules"}
|
||||
iconComponent={<TiersIcon />}
|
||||
|
||||
@@ -0,0 +1,462 @@
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2022 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/>.
|
||||
|
||||
import React, { Fragment, useEffect, useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { Theme } from "@mui/material/styles";
|
||||
import createStyles from "@mui/styles/createStyles";
|
||||
import withStyles from "@mui/styles/withStyles";
|
||||
import { SelectChangeEvent, Tooltip } from "@mui/material";
|
||||
import get from "lodash/get";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
|
||||
import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";
|
||||
import {
|
||||
createTenantCommon,
|
||||
formFieldStyles,
|
||||
modalStyleUtils,
|
||||
spacingUtils,
|
||||
} from "../../Common/FormComponents/common/styleLibrary";
|
||||
import { setModalErrorSnackMessage } from "../../../../actions";
|
||||
import InputBoxWrapper from "../../Common/FormComponents/InputBoxWrapper/InputBoxWrapper";
|
||||
import ModalWrapper from "../../Common/ModalWrapper/ModalWrapper";
|
||||
import PredefinedList from "../../Common/FormComponents/PredefinedList/PredefinedList";
|
||||
import api from "../../../../common/api";
|
||||
import GenericWizard from "../../Common/GenericWizard/GenericWizard";
|
||||
import FormSwitchWrapper from "../../Common/FormComponents/FormSwitchWrapper/FormSwitchWrapper";
|
||||
import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapper";
|
||||
import RadioGroupSelector from "../../Common/FormComponents/RadioGroupSelector/RadioGroupSelector";
|
||||
import { ErrorResponseHandler } from "../../../../common/types";
|
||||
import QueryMultiSelector from "../../Common/FormComponents/QueryMultiSelector/QueryMultiSelector";
|
||||
import { ITiersDropDown } from "../BucketDetails/AddLifecycleModal";
|
||||
import {
|
||||
ITierElement,
|
||||
ITierResponse,
|
||||
} from "../../Configurations/TiersConfiguration/types";
|
||||
import { MultiBucketResult } from "../types";
|
||||
|
||||
interface IBulkReplicationModal {
|
||||
open: boolean;
|
||||
closeModalAndRefresh: (clearSelection: boolean) => any;
|
||||
classes: any;
|
||||
buckets: string[];
|
||||
setModalErrorSnackMessage: typeof setModalErrorSnackMessage;
|
||||
}
|
||||
|
||||
const styles = (theme: Theme) =>
|
||||
createStyles({
|
||||
resultGrid: {
|
||||
display: "grid",
|
||||
gridTemplateColumns: "45px auto",
|
||||
alignItems: "center",
|
||||
justifyContent: "stretch",
|
||||
},
|
||||
errorIcon: {
|
||||
paddingTop: 5,
|
||||
color: "#C72C48",
|
||||
},
|
||||
successIcon: {
|
||||
paddingTop: 5,
|
||||
color: "#42C91A",
|
||||
},
|
||||
hide: {
|
||||
opacity: 0,
|
||||
transitionDuration: "0.3s",
|
||||
},
|
||||
...spacingUtils,
|
||||
...modalStyleUtils,
|
||||
...formFieldStyles,
|
||||
...createTenantCommon,
|
||||
});
|
||||
|
||||
const AddBulkReplicationModal = ({
|
||||
open,
|
||||
closeModalAndRefresh,
|
||||
classes,
|
||||
buckets,
|
||||
setModalErrorSnackMessage,
|
||||
}: IBulkReplicationModal) => {
|
||||
const [addLoading, setAddLoading] = useState<boolean>(false);
|
||||
const [loadingTiers, setLoadingTiers] = useState<boolean>(true);
|
||||
const [tiersList, setTiersList] = useState<ITiersDropDown[]>([]);
|
||||
const [prefix, setPrefix] = useState("");
|
||||
const [tags, setTags] = useState<string>("");
|
||||
const [storageClass, setStorageClass] = useState("");
|
||||
const [NCTransitionSC, setNCTransitionSC] = useState("");
|
||||
const [expiredObjectDM, setExpiredObjectDM] = useState<boolean>(false);
|
||||
const [NCExpirationDays, setNCExpirationDays] = useState<string>("0");
|
||||
const [NCTransitionDays, setNCTransitionDays] = useState<string>("0");
|
||||
const [ilmType, setIlmType] = useState<string>("expiry");
|
||||
const [expiryDays, setExpiryDays] = useState<string>("0");
|
||||
const [transitionDays, setTransitionDays] = useState<string>("0");
|
||||
const [isFormValid, setIsFormValid] = useState<boolean>(false);
|
||||
const [results, setResults] = useState<MultiBucketResult | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (loadingTiers) {
|
||||
api
|
||||
.invoke("GET", `/api/v1/admin/tiers`)
|
||||
.then((res: ITierResponse) => {
|
||||
const tiersList: ITierElement[] | null = get(res, "items", []);
|
||||
|
||||
if (tiersList !== null && tiersList.length >= 1) {
|
||||
const objList = tiersList.map((tier: ITierElement) => {
|
||||
const tierType = tier.type;
|
||||
const value = get(tier, `${tierType}.name`, "");
|
||||
|
||||
return { label: value, value: value };
|
||||
});
|
||||
|
||||
setTiersList(objList);
|
||||
if (objList.length > 0) {
|
||||
setStorageClass(objList[0].value);
|
||||
}
|
||||
}
|
||||
setLoadingTiers(false);
|
||||
})
|
||||
.catch((err: ErrorResponseHandler) => {
|
||||
setLoadingTiers(false);
|
||||
setModalErrorSnackMessage(err);
|
||||
});
|
||||
}
|
||||
}, [loadingTiers, setModalErrorSnackMessage]);
|
||||
|
||||
useEffect(() => {
|
||||
let valid = true;
|
||||
|
||||
if (ilmType !== "expiry") {
|
||||
if (storageClass === "") {
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
setIsFormValid(valid);
|
||||
}, [ilmType, expiryDays, transitionDays, storageClass]);
|
||||
|
||||
const LogoToShow = ({ errString }: { errString: string }) => {
|
||||
switch (errString) {
|
||||
case "":
|
||||
return (
|
||||
<div className={classes.successIcon}>
|
||||
<CheckCircleOutlineIcon />
|
||||
</div>
|
||||
);
|
||||
case "n/a":
|
||||
return null;
|
||||
default:
|
||||
if (errString) {
|
||||
return (
|
||||
<div className={classes.errorIcon}>
|
||||
<Tooltip title={errString} placement="top-start">
|
||||
<ErrorOutlineIcon />
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const createLifecycleRules = (to: any) => {
|
||||
let rules = {};
|
||||
|
||||
if (ilmType === "expiry") {
|
||||
let expiry = {
|
||||
expiry_days: parseInt(expiryDays),
|
||||
};
|
||||
|
||||
rules = {
|
||||
...expiry,
|
||||
noncurrentversion_expiration_days: parseInt(NCExpirationDays),
|
||||
};
|
||||
} else {
|
||||
let transition = {
|
||||
transition_days: parseInt(transitionDays),
|
||||
};
|
||||
|
||||
rules = {
|
||||
...transition,
|
||||
noncurrentversion_transition_days: parseInt(NCTransitionDays),
|
||||
noncurrentversion_transition_storage_class: NCTransitionSC,
|
||||
storage_class: storageClass,
|
||||
};
|
||||
}
|
||||
|
||||
const lifecycleInsert = {
|
||||
buckets,
|
||||
type: ilmType,
|
||||
prefix,
|
||||
tags,
|
||||
expired_object_delete_marker: expiredObjectDM,
|
||||
...rules,
|
||||
};
|
||||
|
||||
api
|
||||
.invoke("POST", `/api/v1/buckets/multi-lifecycle`, lifecycleInsert)
|
||||
.then((res: MultiBucketResult) => {
|
||||
setAddLoading(false);
|
||||
setResults(res);
|
||||
to("++");
|
||||
})
|
||||
.catch((err: ErrorResponseHandler) => {
|
||||
setAddLoading(false);
|
||||
setModalErrorSnackMessage(err);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<ModalWrapper
|
||||
modalOpen={open}
|
||||
onClose={() => {
|
||||
closeModalAndRefresh(false);
|
||||
}}
|
||||
title="Set Lifecycle to multiple buckets"
|
||||
>
|
||||
<GenericWizard
|
||||
loadingStep={addLoading || loadingTiers}
|
||||
wizardSteps={[
|
||||
{
|
||||
label: "Lifecycle Configuration",
|
||||
componentRender: (
|
||||
<Fragment>
|
||||
<Grid item xs={12}>
|
||||
<PredefinedList
|
||||
label="Local Buckets to replicate"
|
||||
content={buckets.join(", ")}
|
||||
/>
|
||||
</Grid>
|
||||
<h4>Remote Endpoint Configuration</h4>
|
||||
<Grid container>
|
||||
<Grid item xs={12} className={classes.formScrollable}>
|
||||
<Grid item xs={12} className={classes.formFieldRow}>
|
||||
<fieldset className={classes.fieldGroup}>
|
||||
<legend className={classes.descriptionText}>
|
||||
Lifecycle Configuration
|
||||
</legend>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<RadioGroupSelector
|
||||
currentSelection={ilmType}
|
||||
id="quota_type"
|
||||
name="quota_type"
|
||||
label="ILM Rule"
|
||||
onChange={(
|
||||
e: React.ChangeEvent<{ value: unknown }>
|
||||
) => {
|
||||
setIlmType(e.target.value as string);
|
||||
}}
|
||||
selectorOptions={[
|
||||
{ value: "expiry", label: "Expiry" },
|
||||
{ value: "transition", label: "Transition" },
|
||||
]}
|
||||
/>
|
||||
</Grid>
|
||||
{ilmType === "expiry" ? (
|
||||
<Fragment>
|
||||
<Grid item xs={12} className={classes.formFieldRow}>
|
||||
<InputBoxWrapper
|
||||
type="number"
|
||||
id="expiry_days"
|
||||
name="expiry_days"
|
||||
onChange={(
|
||||
e: React.ChangeEvent<HTMLInputElement>
|
||||
) => {
|
||||
setExpiryDays(e.target.value);
|
||||
}}
|
||||
label="Expiry Days"
|
||||
value={expiryDays}
|
||||
min="0"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} className={classes.formFieldRow}>
|
||||
<InputBoxWrapper
|
||||
type="number"
|
||||
id="noncurrentversion_expiration_days"
|
||||
name="noncurrentversion_expiration_days"
|
||||
onChange={(
|
||||
e: React.ChangeEvent<HTMLInputElement>
|
||||
) => {
|
||||
setNCExpirationDays(e.target.value);
|
||||
}}
|
||||
label="Non-current Expiration Days"
|
||||
value={NCExpirationDays}
|
||||
min="0"
|
||||
/>
|
||||
</Grid>
|
||||
</Fragment>
|
||||
) : (
|
||||
<Fragment>
|
||||
<Grid item xs={12} className={classes.formFieldRow}>
|
||||
<InputBoxWrapper
|
||||
type="number"
|
||||
id="transition_days"
|
||||
name="transition_days"
|
||||
onChange={(
|
||||
e: React.ChangeEvent<HTMLInputElement>
|
||||
) => {
|
||||
setTransitionDays(e.target.value);
|
||||
}}
|
||||
label="Transition Days"
|
||||
value={transitionDays}
|
||||
min="0"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} className={classes.formFieldRow}>
|
||||
<InputBoxWrapper
|
||||
type="number"
|
||||
id="noncurrentversion_transition_days"
|
||||
name="noncurrentversion_transition_days"
|
||||
onChange={(
|
||||
e: React.ChangeEvent<HTMLInputElement>
|
||||
) => {
|
||||
setNCTransitionDays(e.target.value);
|
||||
}}
|
||||
label="Non-current Transition Days"
|
||||
value={NCTransitionDays}
|
||||
min="0"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} className={classes.formFieldRow}>
|
||||
<InputBoxWrapper
|
||||
id="noncurrentversion_t_SC"
|
||||
name="noncurrentversion_t_SC"
|
||||
onChange={(
|
||||
e: React.ChangeEvent<HTMLInputElement>
|
||||
) => {
|
||||
setNCTransitionSC(e.target.value);
|
||||
}}
|
||||
placeholder="Set Non-current Version Transition Storage Class"
|
||||
label="Non-current Version Transition Storage Class"
|
||||
value={NCTransitionSC}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} className={classes.formFieldRow}>
|
||||
<SelectWrapper
|
||||
label="Storage Class"
|
||||
id="storage_class"
|
||||
name="storage_class"
|
||||
value={storageClass}
|
||||
onChange={(e: SelectChangeEvent<string>) => {
|
||||
setStorageClass(e.target.value as string);
|
||||
}}
|
||||
options={tiersList}
|
||||
/>
|
||||
</Grid>
|
||||
</Fragment>
|
||||
)}
|
||||
</fieldset>
|
||||
</Grid>
|
||||
<Grid item xs={12} className={classes.formFieldRow}>
|
||||
<fieldset className={classes.fieldGroup}>
|
||||
<legend className={classes.descriptionText}>
|
||||
File Configuration
|
||||
</legend>
|
||||
|
||||
<Grid item xs={12}>
|
||||
<InputBoxWrapper
|
||||
id="prefix"
|
||||
name="prefix"
|
||||
onChange={(
|
||||
e: React.ChangeEvent<HTMLInputElement>
|
||||
) => {
|
||||
setPrefix(e.target.value);
|
||||
}}
|
||||
label="Prefix"
|
||||
value={prefix}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<QueryMultiSelector
|
||||
name="tags"
|
||||
label="Tags"
|
||||
elements={tags}
|
||||
onChange={(vl: string) => {
|
||||
setTags(vl);
|
||||
}}
|
||||
keyPlaceholder="Tag Key"
|
||||
valuePlaceholder="Tag Value"
|
||||
withBorder
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<FormSwitchWrapper
|
||||
value="expired_delete_marker"
|
||||
id="expired_delete_marker"
|
||||
name="expired_delete_marker"
|
||||
checked={expiredObjectDM}
|
||||
onChange={(
|
||||
event: React.ChangeEvent<HTMLInputElement>
|
||||
) => {
|
||||
setExpiredObjectDM(event.target.checked);
|
||||
}}
|
||||
label={"Expired Object Delete Marker"}
|
||||
/>
|
||||
</Grid>
|
||||
</fieldset>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Fragment>
|
||||
),
|
||||
buttons: [
|
||||
{
|
||||
type: "custom",
|
||||
label: "Create Rules",
|
||||
enabled: !loadingTiers && !addLoading && isFormValid,
|
||||
action: createLifecycleRules,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Results",
|
||||
componentRender: (
|
||||
<Fragment>
|
||||
<h3>Multi Bucket lifecycle Assignments Results</h3>
|
||||
<Grid container>
|
||||
<Grid item xs={12} className={classes.formScrollable}>
|
||||
<h4>Buckets Results</h4>
|
||||
{results?.results.map((resultItem) => {
|
||||
return (
|
||||
<div className={classes.resultGrid}>
|
||||
{LogoToShow({ errString: resultItem.error || "" })}
|
||||
<span>{resultItem.bucketName}</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Fragment>
|
||||
),
|
||||
buttons: [
|
||||
{
|
||||
type: "custom",
|
||||
label: "Done",
|
||||
enabled: !addLoading,
|
||||
action: () => closeModalAndRefresh(true),
|
||||
},
|
||||
],
|
||||
},
|
||||
]}
|
||||
forModal
|
||||
/>
|
||||
</ModalWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
const connector = connect(null, {
|
||||
setModalErrorSnackMessage,
|
||||
});
|
||||
|
||||
export default withStyles(styles)(connector(AddBulkReplicationModal));
|
||||
@@ -22,7 +22,7 @@ import withStyles from "@mui/styles/withStyles";
|
||||
import { LinearProgress } from "@mui/material";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import { Bucket, BucketList } from "../types";
|
||||
import { AddIcon, BucketsIcon } from "../../../../icons";
|
||||
import {AddIcon, BucketsIcon, LifecycleConfigIcon} from "../../../../icons";
|
||||
import { AppState } from "../../../../store";
|
||||
import { setErrorSnackMessage } from "../../../../actions";
|
||||
import {
|
||||
@@ -50,6 +50,7 @@ import PageLayout from "../../Common/Layout/PageLayout";
|
||||
import SearchBox from "../../Common/SearchBox";
|
||||
import VirtualizedList from "../../Common/VirtualizedList/VirtualizedList";
|
||||
import RBIconButton from "../BucketDetails/SummaryItems/RBIconButton";
|
||||
import BulkLifecycleModal from "./BulkLifecycleModal";
|
||||
|
||||
const styles = (theme: Theme) =>
|
||||
createStyles({
|
||||
@@ -100,6 +101,7 @@ const ListBuckets = ({
|
||||
const [selectedBuckets, setSelectedBuckets] = useState<string[]>([]);
|
||||
const [replicationModalOpen, setReplicationModalOpen] =
|
||||
useState<boolean>(false);
|
||||
const [lifecycleModalOpen, setLifecycleModalOpen] = useState<boolean>(false);
|
||||
|
||||
const [bulkSelect, setBulkSelect] = useState<boolean>(false);
|
||||
|
||||
@@ -174,6 +176,14 @@ const ListBuckets = ({
|
||||
}
|
||||
};
|
||||
|
||||
const closeBulkLifecycleModal = (unselectAll: boolean) => {
|
||||
setLifecycleModalOpen(false);
|
||||
|
||||
if (unselectAll) {
|
||||
setSelectedBuckets([]);
|
||||
}
|
||||
};
|
||||
|
||||
const renderItemLine = (index: number) => {
|
||||
const bucket = filteredRecords[index] || null;
|
||||
if (bucket) {
|
||||
@@ -213,6 +223,13 @@ const ListBuckets = ({
|
||||
closeModalAndRefresh={closeBulkReplicationModal}
|
||||
/>
|
||||
)}
|
||||
{lifecycleModalOpen && (
|
||||
<BulkLifecycleModal
|
||||
buckets={selectedBuckets}
|
||||
closeModalAndRefresh={closeBulkLifecycleModal}
|
||||
open={lifecycleModalOpen}
|
||||
/>
|
||||
)}
|
||||
<PageHeader label={"Buckets"} />
|
||||
<PageLayout>
|
||||
<Grid item xs={12} className={classes.actionsTray} display="flex">
|
||||
@@ -241,6 +258,18 @@ const ListBuckets = ({
|
||||
variant={bulkSelect ? "contained" : "outlined"}
|
||||
/>
|
||||
|
||||
<RBIconButton
|
||||
tooltip={"Set Lifecycle"}
|
||||
onClick={() => {
|
||||
setLifecycleModalOpen(true);
|
||||
}}
|
||||
text={""}
|
||||
icon={<LifecycleConfigIcon />}
|
||||
disabled={selectedBuckets.length === 0}
|
||||
color={"primary"}
|
||||
variant={"outlined"}
|
||||
/>
|
||||
|
||||
<RBIconButton
|
||||
tooltip={"Set Replication"}
|
||||
onClick={() => {
|
||||
|
||||
@@ -201,3 +201,12 @@ export interface LifeCycleItem {
|
||||
tags?: any;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export interface MultiBucketResult {
|
||||
bucketName: string,
|
||||
error?: string,
|
||||
}
|
||||
|
||||
export interface MultiBucketResult {
|
||||
results: MultiBucketResult[],
|
||||
}
|
||||
|
||||
@@ -698,6 +698,39 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets/multi-lifecycle": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"UserAPI"
|
||||
],
|
||||
"summary": "Add Multi Bucket Lifecycle",
|
||||
"operationId": "AddMultiBucketLifecycle",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/addMultiBucketLifecycle"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/multiLifecycleResult"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets/{bucket_name}/delete-objects": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -3850,10 +3883,6 @@ func init() {
|
||||
"description": "Non required, toggle to disable or enable rule",
|
||||
"type": "boolean"
|
||||
},
|
||||
"expiry_date": {
|
||||
"description": "Required in case of expiry_days or transition fields are not set. it defines an expiry date for ILM",
|
||||
"type": "string"
|
||||
},
|
||||
"expiry_days": {
|
||||
"description": "Required in case of expiry_date or transition fields are not set. it defines an expiry days for ILM",
|
||||
"type": "integer",
|
||||
@@ -3888,10 +3917,6 @@ func init() {
|
||||
"description": "Non required field, tags to match ILM files",
|
||||
"type": "string"
|
||||
},
|
||||
"transition_date": {
|
||||
"description": "Required in case of transition_days or expiry fields are not set. it defines a transition date for ILM",
|
||||
"type": "string"
|
||||
},
|
||||
"transition_days": {
|
||||
"description": "Required in case of transition_date or expiry fields are not set. it defines a transition days for ILM",
|
||||
"type": "integer",
|
||||
@@ -3937,6 +3962,73 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"addMultiBucketLifecycle": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"buckets",
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"buckets": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"expired_object_delete_marker": {
|
||||
"description": "Non required, toggle to disable or enable rule",
|
||||
"type": "boolean"
|
||||
},
|
||||
"expiry_days": {
|
||||
"description": "Required in case of expiry_date or transition fields are not set. it defines an expiry days for ILM",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": 0
|
||||
},
|
||||
"noncurrentversion_expiration_days": {
|
||||
"description": "Non required, can be set in case of expiration is enabled",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": 0
|
||||
},
|
||||
"noncurrentversion_transition_days": {
|
||||
"description": "Non required, can be set in case of transition is enabled",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": 0
|
||||
},
|
||||
"noncurrentversion_transition_storage_class": {
|
||||
"description": "Non required, can be set in case of transition is enabled",
|
||||
"type": "string"
|
||||
},
|
||||
"prefix": {
|
||||
"description": "Non required field, it matches a prefix to perform ILM operations on it",
|
||||
"type": "string"
|
||||
},
|
||||
"storage_class": {
|
||||
"description": "Required only in case of transition is set. it refers to a tier",
|
||||
"type": "string"
|
||||
},
|
||||
"tags": {
|
||||
"description": "Non required field, tags to match ILM files",
|
||||
"type": "string"
|
||||
},
|
||||
"transition_days": {
|
||||
"description": "Required in case of transition_date or expiry fields are not set. it defines a transition days for ILM",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": 0
|
||||
},
|
||||
"type": {
|
||||
"description": "ILM Rule type (Expiry or transition)",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"expiry",
|
||||
"transition"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"addPolicyRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -5043,6 +5135,27 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiLifecycleResult": {
|
||||
"properties": {
|
||||
"results": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/multicycleResultItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"multicycleResultItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"bucketName": {
|
||||
"type": "string"
|
||||
},
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nofiticationService": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -6956,6 +7069,39 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets/multi-lifecycle": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"UserAPI"
|
||||
],
|
||||
"summary": "Add Multi Bucket Lifecycle",
|
||||
"operationId": "AddMultiBucketLifecycle",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/addMultiBucketLifecycle"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/multiLifecycleResult"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets/{bucket_name}/delete-objects": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -10226,10 +10372,6 @@ func init() {
|
||||
"description": "Non required, toggle to disable or enable rule",
|
||||
"type": "boolean"
|
||||
},
|
||||
"expiry_date": {
|
||||
"description": "Required in case of expiry_days or transition fields are not set. it defines an expiry date for ILM",
|
||||
"type": "string"
|
||||
},
|
||||
"expiry_days": {
|
||||
"description": "Required in case of expiry_date or transition fields are not set. it defines an expiry days for ILM",
|
||||
"type": "integer",
|
||||
@@ -10264,10 +10406,6 @@ func init() {
|
||||
"description": "Non required field, tags to match ILM files",
|
||||
"type": "string"
|
||||
},
|
||||
"transition_date": {
|
||||
"description": "Required in case of transition_days or expiry fields are not set. it defines a transition date for ILM",
|
||||
"type": "string"
|
||||
},
|
||||
"transition_days": {
|
||||
"description": "Required in case of transition_date or expiry fields are not set. it defines a transition days for ILM",
|
||||
"type": "integer",
|
||||
@@ -10313,6 +10451,73 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"addMultiBucketLifecycle": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"buckets",
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"buckets": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"expired_object_delete_marker": {
|
||||
"description": "Non required, toggle to disable or enable rule",
|
||||
"type": "boolean"
|
||||
},
|
||||
"expiry_days": {
|
||||
"description": "Required in case of expiry_date or transition fields are not set. it defines an expiry days for ILM",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": 0
|
||||
},
|
||||
"noncurrentversion_expiration_days": {
|
||||
"description": "Non required, can be set in case of expiration is enabled",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": 0
|
||||
},
|
||||
"noncurrentversion_transition_days": {
|
||||
"description": "Non required, can be set in case of transition is enabled",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": 0
|
||||
},
|
||||
"noncurrentversion_transition_storage_class": {
|
||||
"description": "Non required, can be set in case of transition is enabled",
|
||||
"type": "string"
|
||||
},
|
||||
"prefix": {
|
||||
"description": "Non required field, it matches a prefix to perform ILM operations on it",
|
||||
"type": "string"
|
||||
},
|
||||
"storage_class": {
|
||||
"description": "Required only in case of transition is set. it refers to a tier",
|
||||
"type": "string"
|
||||
},
|
||||
"tags": {
|
||||
"description": "Non required field, tags to match ILM files",
|
||||
"type": "string"
|
||||
},
|
||||
"transition_days": {
|
||||
"description": "Required in case of transition_date or expiry fields are not set. it defines a transition days for ILM",
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"default": 0
|
||||
},
|
||||
"type": {
|
||||
"description": "ILM Rule type (Expiry or transition)",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"expiry",
|
||||
"transition"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"addPolicyRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -11419,6 +11624,27 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"multiLifecycleResult": {
|
||||
"properties": {
|
||||
"results": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/multicycleResultItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"multicycleResultItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"bucketName": {
|
||||
"type": "string"
|
||||
},
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nofiticationService": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
||||
@@ -74,6 +74,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
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")
|
||||
}),
|
||||
UserAPIAddMultiBucketLifecycleHandler: user_api.AddMultiBucketLifecycleHandlerFunc(func(params user_api.AddMultiBucketLifecycleParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.AddMultiBucketLifecycle has not yet been implemented")
|
||||
}),
|
||||
AdminAPIAddNotificationEndpointHandler: admin_api.AddNotificationEndpointHandlerFunc(func(params admin_api.AddNotificationEndpointParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.AddNotificationEndpoint has not yet been implemented")
|
||||
}),
|
||||
@@ -456,6 +459,8 @@ type ConsoleAPI struct {
|
||||
UserAPIAddBucketLifecycleHandler user_api.AddBucketLifecycleHandler
|
||||
// AdminAPIAddGroupHandler sets the operation handler for the add group operation
|
||||
AdminAPIAddGroupHandler admin_api.AddGroupHandler
|
||||
// UserAPIAddMultiBucketLifecycleHandler sets the operation handler for the add multi bucket lifecycle operation
|
||||
UserAPIAddMultiBucketLifecycleHandler user_api.AddMultiBucketLifecycleHandler
|
||||
// AdminAPIAddNotificationEndpointHandler sets the operation handler for the add notification endpoint operation
|
||||
AdminAPIAddNotificationEndpointHandler admin_api.AddNotificationEndpointHandler
|
||||
// AdminAPIAddPolicyHandler sets the operation handler for the add policy operation
|
||||
@@ -766,6 +771,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.AdminAPIAddGroupHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.AddGroupHandler")
|
||||
}
|
||||
if o.UserAPIAddMultiBucketLifecycleHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.AddMultiBucketLifecycleHandler")
|
||||
}
|
||||
if o.AdminAPIAddNotificationEndpointHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.AddNotificationEndpointHandler")
|
||||
}
|
||||
@@ -1204,6 +1212,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/buckets/multi-lifecycle"] = user_api.NewAddMultiBucketLifecycle(o.context, o.UserAPIAddMultiBucketLifecycleHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/admin/notification_endpoints"] = admin_api.NewAddNotificationEndpoint(o.context, o.AdminAPIAddNotificationEndpointHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
|
||||
88
restapi/operations/user_api/add_multi_bucket_lifecycle.go
Normal file
88
restapi/operations/user_api/add_multi_bucket_lifecycle.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// 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 UserAPI 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)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// 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 (
|
||||
"context"
|
||||
"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(context.Background())
|
||||
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
|
||||
}
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
// 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.Error `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.Error) *AddMultiBucketLifecycleDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the add multi bucket lifecycle default response
|
||||
func (o *AddMultiBucketLifecycleDefault) SetPayload(payload *models.Error) {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
// 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()
|
||||
}
|
||||
@@ -39,6 +39,11 @@ import (
|
||||
"github.com/minio/console/restapi/operations/user_api"
|
||||
)
|
||||
|
||||
type MultiLifecycleResult struct {
|
||||
BucketName string
|
||||
Error string
|
||||
}
|
||||
|
||||
func registerBucketsLifecycleHandlers(api *operations.ConsoleAPI) {
|
||||
api.UserAPIGetBucketLifecycleHandler = user_api.GetBucketLifecycleHandlerFunc(func(params user_api.GetBucketLifecycleParams, session *models.Principal) middleware.Responder {
|
||||
listBucketLifecycleResponse, err := getBucketLifecycleResponse(session, params)
|
||||
@@ -70,6 +75,14 @@ func registerBucketsLifecycleHandlers(api *operations.ConsoleAPI) {
|
||||
|
||||
return user_api.NewDeleteBucketLifecycleRuleNoContent()
|
||||
})
|
||||
api.UserAPIAddMultiBucketLifecycleHandler = user_api.AddMultiBucketLifecycleHandlerFunc(func(params user_api.AddMultiBucketLifecycleParams, session *models.Principal) middleware.Responder {
|
||||
multiBucketResponse, err := getAddMultiBucketLifecycleResponse(session, params)
|
||||
if err != nil {
|
||||
user_api.NewAddMultiBucketLifecycleDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
|
||||
return user_api.NewAddMultiBucketLifecycleOK().WithPayload(multiBucketResponse)
|
||||
})
|
||||
}
|
||||
|
||||
// getBucketLifecycle() gets lifecycle lists for a bucket from MinIO API and returns their implementations
|
||||
@@ -376,3 +389,98 @@ func getDeleteBucketLifecycleRule(session *models.Principal, params user_api.Del
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// addMultiBucketLifecycle creates multibuckets lifecycle assignments
|
||||
func addMultiBucketLifecycle(ctx context.Context, client MinioClient, params user_api.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,
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer close(remoteProc)
|
||||
|
||||
lifecycleParams := user_api.AddBucketLifecycleParams{
|
||||
BucketName: bucketName,
|
||||
Body: &lifecycleParams,
|
||||
}
|
||||
|
||||
// We add lifecycle rule & expect a response
|
||||
err := addBucketLifecycle(ctx, client, lifecycleParams)
|
||||
|
||||
var 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 user_api.AddMultiBucketLifecycleParams) (*models.MultiLifecycleResult, *models.Error) {
|
||||
ctx := context.Background()
|
||||
mClient, err := newMinioClient(session)
|
||||
if err != nil {
|
||||
return nil, prepareError(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
|
||||
}
|
||||
|
||||
@@ -178,7 +178,6 @@ func TestSetLifecycleRule(t *testing.T) {
|
||||
Prefix: "pref1",
|
||||
StorageClass: "",
|
||||
Tags: "",
|
||||
TransitionDate: "",
|
||||
TransitionDays: 0,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1115,6 +1115,28 @@ paths:
|
||||
tags:
|
||||
- UserAPI
|
||||
|
||||
/buckets/multi-lifecycle:
|
||||
post:
|
||||
summary: Add Multi Bucket Lifecycle
|
||||
operationId: AddMultiBucketLifecycle
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: "#/definitions/addMultiBucketLifecycle"
|
||||
responses:
|
||||
200:
|
||||
description: A successful response.
|
||||
schema:
|
||||
$ref: "#/definitions/multiLifecycleResult"
|
||||
default:
|
||||
description: Generic error response.
|
||||
schema:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- UserAPI
|
||||
|
||||
/buckets/{bucket_name}/lifecycle/{lifecycle_id}:
|
||||
put:
|
||||
summary: Update Lifecycle rule
|
||||
@@ -3931,17 +3953,11 @@ definitions:
|
||||
tags:
|
||||
description: Non required field, tags to match ILM files
|
||||
type: string
|
||||
expiry_date:
|
||||
description: Required in case of expiry_days or transition fields are not set. it defines an expiry date for ILM
|
||||
type: string
|
||||
expiry_days:
|
||||
description: Required in case of expiry_date or transition fields are not set. it defines an expiry days for ILM
|
||||
type: integer
|
||||
format: int32
|
||||
default: 0
|
||||
transition_date:
|
||||
description: Required in case of transition_days or expiry fields are not set. it defines a transition date for ILM
|
||||
type: string
|
||||
transition_days:
|
||||
description: Required in case of transition_date or expiry fields are not set. it defines a transition days for ILM
|
||||
type: integer
|
||||
@@ -4020,6 +4036,73 @@ definitions:
|
||||
description: Non required, can be set in case of transition is enabled
|
||||
type: string
|
||||
|
||||
addMultiBucketLifecycle:
|
||||
type: object
|
||||
required:
|
||||
- buckets
|
||||
- type
|
||||
properties:
|
||||
buckets:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
type:
|
||||
description: ILM Rule type (Expiry or transition)
|
||||
type: string
|
||||
enum:
|
||||
- expiry
|
||||
- transition
|
||||
prefix:
|
||||
description: Non required field, it matches a prefix to perform ILM operations on it
|
||||
type: string
|
||||
tags:
|
||||
description: Non required field, tags to match ILM files
|
||||
type: string
|
||||
expiry_days:
|
||||
description: Required in case of expiry_date or transition fields are not set. it defines an expiry days for ILM
|
||||
type: integer
|
||||
format: int32
|
||||
default: 0
|
||||
transition_days:
|
||||
description: Required in case of transition_date or expiry fields are not set. it defines a transition days for ILM
|
||||
type: integer
|
||||
format: int32
|
||||
default: 0
|
||||
storage_class:
|
||||
description: Required only in case of transition is set. it refers to a tier
|
||||
type: string
|
||||
expired_object_delete_marker:
|
||||
description: Non required, toggle to disable or enable rule
|
||||
type: boolean
|
||||
noncurrentversion_expiration_days:
|
||||
description: Non required, can be set in case of expiration is enabled
|
||||
type: integer
|
||||
format: int32
|
||||
default: 0
|
||||
noncurrentversion_transition_days:
|
||||
description: Non required, can be set in case of transition is enabled
|
||||
type: integer
|
||||
format: int32
|
||||
default: 0
|
||||
noncurrentversion_transition_storage_class:
|
||||
description: Non required, can be set in case of transition is enabled
|
||||
type: string
|
||||
|
||||
multicycleResultItem:
|
||||
type: object
|
||||
properties:
|
||||
bucketName:
|
||||
type: string
|
||||
error:
|
||||
type: string
|
||||
|
||||
multiLifecycleResult:
|
||||
properties:
|
||||
results:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/multicycleResultItem"
|
||||
|
||||
prefixAccessPair:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
Reference in New Issue
Block a user