mirror of
https://github.com/OpenMaxIO/openmaxio-object-browser
synced 2026-07-01 07:41:18 -07:00
Add share link exp api (#3095)
This commit is contained in:
88
models/max_share_link_exp_response.go
Normal file
88
models/max_share_link_exp_response.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) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package 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/errors"
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MaxShareLinkExpResponse max share link exp response
|
||||||
|
//
|
||||||
|
// swagger:model maxShareLinkExpResponse
|
||||||
|
type MaxShareLinkExpResponse struct {
|
||||||
|
|
||||||
|
// exp
|
||||||
|
// Required: true
|
||||||
|
Exp *int64 `json:"exp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this max share link exp response
|
||||||
|
func (m *MaxShareLinkExpResponse) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := m.validateExp(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MaxShareLinkExpResponse) validateExp(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("exp", "body", m.Exp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this max share link exp response based on context it is used
|
||||||
|
func (m *MaxShareLinkExpResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *MaxShareLinkExpResponse) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *MaxShareLinkExpResponse) UnmarshalBinary(b []byte) error {
|
||||||
|
var res MaxShareLinkExpResponse
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -1499,6 +1499,11 @@ export interface LdapPolicyEntity {
|
|||||||
groups?: string[];
|
groups?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MaxShareLinkExpResponse {
|
||||||
|
/** @format int64 */
|
||||||
|
exp: number;
|
||||||
|
}
|
||||||
|
|
||||||
export type QueryParamsType = Record<string | number, any>;
|
export type QueryParamsType = Record<string | number, any>;
|
||||||
export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
|
export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
|
||||||
|
|
||||||
@@ -2916,6 +2921,24 @@ export class Api<
|
|||||||
format: "json",
|
format: "json",
|
||||||
...params,
|
...params,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No description
|
||||||
|
*
|
||||||
|
* @tags Bucket
|
||||||
|
* @name GetMaxShareLinkExp
|
||||||
|
* @summary Get max expiration time for share link in seconds
|
||||||
|
* @request GET:/buckets/max-share-exp
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
getMaxShareLinkExp: (params: RequestParams = {}) =>
|
||||||
|
this.request<MaxShareLinkExpResponse, ApiError>({
|
||||||
|
path: `/buckets/max-share-exp`,
|
||||||
|
method: "GET",
|
||||||
|
secure: true,
|
||||||
|
format: "json",
|
||||||
|
...params,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
listExternalBuckets = {
|
listExternalBuckets = {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -911,6 +911,29 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/buckets/max-share-exp": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Bucket"
|
||||||
|
],
|
||||||
|
"summary": "Get max expiration time for share link in seconds",
|
||||||
|
"operationId": "GetMaxShareLinkExp",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/maxShareLinkExpResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"description": "Generic error response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/ApiError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/buckets/multi-lifecycle": {
|
"/buckets/multi-lifecycle": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -7094,6 +7117,18 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"maxShareLinkExpResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"exp"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"exp": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -9941,6 +9976,29 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/buckets/max-share-exp": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Bucket"
|
||||||
|
],
|
||||||
|
"summary": "Get max expiration time for share link in seconds",
|
||||||
|
"operationId": "GetMaxShareLinkExp",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/maxShareLinkExpResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"description": "Generic error response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/ApiError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/buckets/multi-lifecycle": {
|
"/buckets/multi-lifecycle": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -16325,6 +16383,18 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"maxShareLinkExpResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"exp"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"exp": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
88
restapi/operations/bucket/get_max_share_link_exp.go
Normal file
88
restapi/operations/bucket/get_max_share_link_exp.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) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package bucket
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the generate command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-openapi/runtime/middleware"
|
||||||
|
|
||||||
|
"github.com/minio/console/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetMaxShareLinkExpHandlerFunc turns a function with the right signature into a get max share link exp handler
|
||||||
|
type GetMaxShareLinkExpHandlerFunc func(GetMaxShareLinkExpParams, *models.Principal) middleware.Responder
|
||||||
|
|
||||||
|
// Handle executing the request and returning a response
|
||||||
|
func (fn GetMaxShareLinkExpHandlerFunc) Handle(params GetMaxShareLinkExpParams, principal *models.Principal) middleware.Responder {
|
||||||
|
return fn(params, principal)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMaxShareLinkExpHandler interface for that can handle valid get max share link exp params
|
||||||
|
type GetMaxShareLinkExpHandler interface {
|
||||||
|
Handle(GetMaxShareLinkExpParams, *models.Principal) middleware.Responder
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGetMaxShareLinkExp creates a new http.Handler for the get max share link exp operation
|
||||||
|
func NewGetMaxShareLinkExp(ctx *middleware.Context, handler GetMaxShareLinkExpHandler) *GetMaxShareLinkExp {
|
||||||
|
return &GetMaxShareLinkExp{Context: ctx, Handler: handler}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
GetMaxShareLinkExp swagger:route GET /buckets/max-share-exp Bucket getMaxShareLinkExp
|
||||||
|
|
||||||
|
Get max expiration time for share link in seconds
|
||||||
|
*/
|
||||||
|
type GetMaxShareLinkExp struct {
|
||||||
|
Context *middleware.Context
|
||||||
|
Handler GetMaxShareLinkExpHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *GetMaxShareLinkExp) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||||
|
if rCtx != nil {
|
||||||
|
*r = *rCtx
|
||||||
|
}
|
||||||
|
var Params = NewGetMaxShareLinkExpParams()
|
||||||
|
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,63 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package bucket
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-openapi/errors"
|
||||||
|
"github.com/go-openapi/runtime/middleware"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewGetMaxShareLinkExpParams creates a new GetMaxShareLinkExpParams object
|
||||||
|
//
|
||||||
|
// There are no default values defined in the spec.
|
||||||
|
func NewGetMaxShareLinkExpParams() GetMaxShareLinkExpParams {
|
||||||
|
|
||||||
|
return GetMaxShareLinkExpParams{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMaxShareLinkExpParams contains all the bound params for the get max share link exp operation
|
||||||
|
// typically these are obtained from a http.Request
|
||||||
|
//
|
||||||
|
// swagger:parameters GetMaxShareLinkExp
|
||||||
|
type GetMaxShareLinkExpParams struct {
|
||||||
|
|
||||||
|
// HTTP Request Object
|
||||||
|
HTTPRequest *http.Request `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||||
|
// for simple values it will use straight method calls.
|
||||||
|
//
|
||||||
|
// To ensure default values, the struct must have been initialized with NewGetMaxShareLinkExpParams() beforehand.
|
||||||
|
func (o *GetMaxShareLinkExpParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
o.HTTPRequest = r
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
135
restapi/operations/bucket/get_max_share_link_exp_responses.go
Normal file
135
restapi/operations/bucket/get_max_share_link_exp_responses.go
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package bucket
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-openapi/runtime"
|
||||||
|
|
||||||
|
"github.com/minio/console/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetMaxShareLinkExpOKCode is the HTTP code returned for type GetMaxShareLinkExpOK
|
||||||
|
const GetMaxShareLinkExpOKCode int = 200
|
||||||
|
|
||||||
|
/*
|
||||||
|
GetMaxShareLinkExpOK A successful response.
|
||||||
|
|
||||||
|
swagger:response getMaxShareLinkExpOK
|
||||||
|
*/
|
||||||
|
type GetMaxShareLinkExpOK struct {
|
||||||
|
|
||||||
|
/*
|
||||||
|
In: Body
|
||||||
|
*/
|
||||||
|
Payload *models.MaxShareLinkExpResponse `json:"body,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGetMaxShareLinkExpOK creates GetMaxShareLinkExpOK with default headers values
|
||||||
|
func NewGetMaxShareLinkExpOK() *GetMaxShareLinkExpOK {
|
||||||
|
|
||||||
|
return &GetMaxShareLinkExpOK{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPayload adds the payload to the get max share link exp o k response
|
||||||
|
func (o *GetMaxShareLinkExpOK) WithPayload(payload *models.MaxShareLinkExpResponse) *GetMaxShareLinkExpOK {
|
||||||
|
o.Payload = payload
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPayload sets the payload to the get max share link exp o k response
|
||||||
|
func (o *GetMaxShareLinkExpOK) SetPayload(payload *models.MaxShareLinkExpResponse) {
|
||||||
|
o.Payload = payload
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteResponse to the client
|
||||||
|
func (o *GetMaxShareLinkExpOK) 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
GetMaxShareLinkExpDefault Generic error response.
|
||||||
|
|
||||||
|
swagger:response getMaxShareLinkExpDefault
|
||||||
|
*/
|
||||||
|
type GetMaxShareLinkExpDefault struct {
|
||||||
|
_statusCode int
|
||||||
|
|
||||||
|
/*
|
||||||
|
In: Body
|
||||||
|
*/
|
||||||
|
Payload *models.APIError `json:"body,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGetMaxShareLinkExpDefault creates GetMaxShareLinkExpDefault with default headers values
|
||||||
|
func NewGetMaxShareLinkExpDefault(code int) *GetMaxShareLinkExpDefault {
|
||||||
|
if code <= 0 {
|
||||||
|
code = 500
|
||||||
|
}
|
||||||
|
|
||||||
|
return &GetMaxShareLinkExpDefault{
|
||||||
|
_statusCode: code,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithStatusCode adds the status to the get max share link exp default response
|
||||||
|
func (o *GetMaxShareLinkExpDefault) WithStatusCode(code int) *GetMaxShareLinkExpDefault {
|
||||||
|
o._statusCode = code
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatusCode sets the status to the get max share link exp default response
|
||||||
|
func (o *GetMaxShareLinkExpDefault) SetStatusCode(code int) {
|
||||||
|
o._statusCode = code
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPayload adds the payload to the get max share link exp default response
|
||||||
|
func (o *GetMaxShareLinkExpDefault) WithPayload(payload *models.APIError) *GetMaxShareLinkExpDefault {
|
||||||
|
o.Payload = payload
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPayload sets the payload to the get max share link exp default response
|
||||||
|
func (o *GetMaxShareLinkExpDefault) SetPayload(payload *models.APIError) {
|
||||||
|
o.Payload = payload
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteResponse to the client
|
||||||
|
func (o *GetMaxShareLinkExpDefault) 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
104
restapi/operations/bucket/get_max_share_link_exp_urlbuilder.go
Normal file
104
restapi/operations/bucket/get_max_share_link_exp_urlbuilder.go
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package bucket
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the generate command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/url"
|
||||||
|
golangswaggerpaths "path"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetMaxShareLinkExpURL generates an URL for the get max share link exp operation
|
||||||
|
type GetMaxShareLinkExpURL 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 *GetMaxShareLinkExpURL) WithBasePath(bp string) *GetMaxShareLinkExpURL {
|
||||||
|
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 *GetMaxShareLinkExpURL) SetBasePath(bp string) {
|
||||||
|
o._basePath = bp
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build a url path and query string
|
||||||
|
func (o *GetMaxShareLinkExpURL) Build() (*url.URL, error) {
|
||||||
|
var _result url.URL
|
||||||
|
|
||||||
|
var _path = "/buckets/max-share-exp"
|
||||||
|
|
||||||
|
_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 *GetMaxShareLinkExpURL) 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 *GetMaxShareLinkExpURL) String() string {
|
||||||
|
return o.Must(o.Build()).String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// BuildFull builds a full url with scheme, host, path and query string
|
||||||
|
func (o *GetMaxShareLinkExpURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||||
|
if scheme == "" {
|
||||||
|
return nil, errors.New("scheme is required for a full url on GetMaxShareLinkExpURL")
|
||||||
|
}
|
||||||
|
if host == "" {
|
||||||
|
return nil, errors.New("host is required for a full url on GetMaxShareLinkExpURL")
|
||||||
|
}
|
||||||
|
|
||||||
|
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 *GetMaxShareLinkExpURL) StringFull(scheme, host string) string {
|
||||||
|
return o.Must(o.BuildFull(scheme, host)).String()
|
||||||
|
}
|
||||||
@@ -256,6 +256,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
|||||||
IdpGetLDAPEntitiesHandler: idp.GetLDAPEntitiesHandlerFunc(func(params idp.GetLDAPEntitiesParams, principal *models.Principal) middleware.Responder {
|
IdpGetLDAPEntitiesHandler: idp.GetLDAPEntitiesHandlerFunc(func(params idp.GetLDAPEntitiesParams, principal *models.Principal) middleware.Responder {
|
||||||
return middleware.NotImplemented("operation idp.GetLDAPEntities has not yet been implemented")
|
return middleware.NotImplemented("operation idp.GetLDAPEntities has not yet been implemented")
|
||||||
}),
|
}),
|
||||||
|
BucketGetMaxShareLinkExpHandler: bucket.GetMaxShareLinkExpHandlerFunc(func(params bucket.GetMaxShareLinkExpParams, principal *models.Principal) middleware.Responder {
|
||||||
|
return middleware.NotImplemented("operation bucket.GetMaxShareLinkExp has not yet been implemented")
|
||||||
|
}),
|
||||||
ObjectGetObjectMetadataHandler: object.GetObjectMetadataHandlerFunc(func(params object.GetObjectMetadataParams, principal *models.Principal) middleware.Responder {
|
ObjectGetObjectMetadataHandler: object.GetObjectMetadataHandlerFunc(func(params object.GetObjectMetadataParams, principal *models.Principal) middleware.Responder {
|
||||||
return middleware.NotImplemented("operation object.GetObjectMetadata has not yet been implemented")
|
return middleware.NotImplemented("operation object.GetObjectMetadata has not yet been implemented")
|
||||||
}),
|
}),
|
||||||
@@ -731,6 +734,8 @@ type ConsoleAPI struct {
|
|||||||
IdpGetConfigurationHandler idp.GetConfigurationHandler
|
IdpGetConfigurationHandler idp.GetConfigurationHandler
|
||||||
// IdpGetLDAPEntitiesHandler sets the operation handler for the get l d a p entities operation
|
// IdpGetLDAPEntitiesHandler sets the operation handler for the get l d a p entities operation
|
||||||
IdpGetLDAPEntitiesHandler idp.GetLDAPEntitiesHandler
|
IdpGetLDAPEntitiesHandler idp.GetLDAPEntitiesHandler
|
||||||
|
// BucketGetMaxShareLinkExpHandler sets the operation handler for the get max share link exp operation
|
||||||
|
BucketGetMaxShareLinkExpHandler bucket.GetMaxShareLinkExpHandler
|
||||||
// ObjectGetObjectMetadataHandler sets the operation handler for the get object metadata operation
|
// ObjectGetObjectMetadataHandler sets the operation handler for the get object metadata operation
|
||||||
ObjectGetObjectMetadataHandler object.GetObjectMetadataHandler
|
ObjectGetObjectMetadataHandler object.GetObjectMetadataHandler
|
||||||
// PolicyGetSAUserPolicyHandler sets the operation handler for the get s a user policy operation
|
// PolicyGetSAUserPolicyHandler sets the operation handler for the get s a user policy operation
|
||||||
@@ -1190,6 +1195,9 @@ func (o *ConsoleAPI) Validate() error {
|
|||||||
if o.IdpGetLDAPEntitiesHandler == nil {
|
if o.IdpGetLDAPEntitiesHandler == nil {
|
||||||
unregistered = append(unregistered, "idp.GetLDAPEntitiesHandler")
|
unregistered = append(unregistered, "idp.GetLDAPEntitiesHandler")
|
||||||
}
|
}
|
||||||
|
if o.BucketGetMaxShareLinkExpHandler == nil {
|
||||||
|
unregistered = append(unregistered, "bucket.GetMaxShareLinkExpHandler")
|
||||||
|
}
|
||||||
if o.ObjectGetObjectMetadataHandler == nil {
|
if o.ObjectGetObjectMetadataHandler == nil {
|
||||||
unregistered = append(unregistered, "object.GetObjectMetadataHandler")
|
unregistered = append(unregistered, "object.GetObjectMetadataHandler")
|
||||||
}
|
}
|
||||||
@@ -1824,6 +1832,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
|||||||
if o.handlers["GET"] == nil {
|
if o.handlers["GET"] == nil {
|
||||||
o.handlers["GET"] = make(map[string]http.Handler)
|
o.handlers["GET"] = make(map[string]http.Handler)
|
||||||
}
|
}
|
||||||
|
o.handlers["GET"]["/buckets/max-share-exp"] = bucket.NewGetMaxShareLinkExp(o.context, o.BucketGetMaxShareLinkExpHandler)
|
||||||
|
if o.handlers["GET"] == nil {
|
||||||
|
o.handlers["GET"] = make(map[string]http.Handler)
|
||||||
|
}
|
||||||
o.handlers["GET"]["/buckets/{bucket_name}/objects/metadata"] = object.NewGetObjectMetadata(o.context, o.ObjectGetObjectMetadataHandler)
|
o.handlers["GET"]["/buckets/{bucket_name}/objects/metadata"] = object.NewGetObjectMetadata(o.context, o.ObjectGetObjectMetadataHandler)
|
||||||
if o.handlers["GET"] == nil {
|
if o.handlers["GET"] == nil {
|
||||||
o.handlers["GET"] = make(map[string]http.Handler)
|
o.handlers["GET"] = make(map[string]http.Handler)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import (
|
|||||||
"github.com/go-openapi/runtime/middleware"
|
"github.com/go-openapi/runtime/middleware"
|
||||||
"github.com/go-openapi/swag"
|
"github.com/go-openapi/swag"
|
||||||
"github.com/minio/console/models"
|
"github.com/minio/console/models"
|
||||||
|
"github.com/minio/console/pkg/auth/token"
|
||||||
"github.com/minio/console/restapi/operations"
|
"github.com/minio/console/restapi/operations"
|
||||||
bucketApi "github.com/minio/console/restapi/operations/bucket"
|
bucketApi "github.com/minio/console/restapi/operations/bucket"
|
||||||
"github.com/minio/minio-go/v7/pkg/policy"
|
"github.com/minio/minio-go/v7/pkg/policy"
|
||||||
@@ -178,6 +179,14 @@ func registerBucketsHandlers(api *operations.ConsoleAPI) {
|
|||||||
}
|
}
|
||||||
return bucketApi.NewGetBucketRewindOK().WithPayload(getBucketRewind)
|
return bucketApi.NewGetBucketRewindOK().WithPayload(getBucketRewind)
|
||||||
})
|
})
|
||||||
|
// get max allowed share link expiration time
|
||||||
|
api.BucketGetMaxShareLinkExpHandler = bucketApi.GetMaxShareLinkExpHandlerFunc(func(params bucketApi.GetMaxShareLinkExpParams, session *models.Principal) middleware.Responder {
|
||||||
|
val, err := getMaxShareLinkExpirationResponse(session, params)
|
||||||
|
if err != nil {
|
||||||
|
return bucketApi.NewGetMaxShareLinkExpDefault(err.Code).WithPayload(err.APIError)
|
||||||
|
}
|
||||||
|
return bucketApi.NewGetMaxShareLinkExpOK().WithPayload(val)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type VersionState string
|
type VersionState string
|
||||||
@@ -1067,3 +1076,31 @@ func getBucketRewindResponse(session *models.Principal, params bucketApi.GetBuck
|
|||||||
Objects: rewindItems,
|
Objects: rewindItems,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getMaxShareLinkExpirationResponse(session *models.Principal, params bucketApi.GetMaxShareLinkExpParams) (*models.MaxShareLinkExpResponse, *CodedAPIError) {
|
||||||
|
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
maxShareLinkExpSeconds, err := getMaxShareLinkExpirationSeconds(session)
|
||||||
|
if err != nil {
|
||||||
|
return nil, ErrorWithContext(ctx, err)
|
||||||
|
}
|
||||||
|
return &models.MaxShareLinkExpResponse{Exp: swag.Int64(maxShareLinkExpSeconds)}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getMaxShareLinkExpirationSeconds returns the max share link expiration time in seconds which is the sts token expiration time
|
||||||
|
func getMaxShareLinkExpirationSeconds(session *models.Principal) (int64, error) {
|
||||||
|
creds := getConsoleCredentialsFromSession(session)
|
||||||
|
|
||||||
|
val, err := creds.Get()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if val.SignerType.IsAnonymous() {
|
||||||
|
return 0, ErrAccessDenied
|
||||||
|
}
|
||||||
|
maxShareLinkExp := token.GetConsoleSTSDuration()
|
||||||
|
|
||||||
|
return int64(maxShareLinkExp.Seconds()), nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,10 +20,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/minio/console/pkg/auth/token"
|
||||||
"github.com/minio/console/pkg/utils"
|
"github.com/minio/console/pkg/utils"
|
||||||
|
|
||||||
"github.com/go-openapi/swag"
|
"github.com/go-openapi/swag"
|
||||||
@@ -1212,3 +1214,75 @@ func Test_getAccountBuckets(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_getMaxShareLinkExpirationSeconds(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
session *models.Principal
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want int64
|
||||||
|
wantErr bool
|
||||||
|
preFunc func()
|
||||||
|
postFunc func()
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "empty session returns error",
|
||||||
|
args: args{
|
||||||
|
session: nil,
|
||||||
|
},
|
||||||
|
want: 0,
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "invalid/expired session returns error",
|
||||||
|
args: args{
|
||||||
|
session: &models.Principal{
|
||||||
|
STSAccessKeyID: "",
|
||||||
|
STSSecretAccessKey: "",
|
||||||
|
STSSessionToken: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: 0,
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "valid session, returns value from env variable",
|
||||||
|
args: args{
|
||||||
|
session: &models.Principal{
|
||||||
|
STSAccessKeyID: "VQH975JV49JYDLK7F81G",
|
||||||
|
STSSecretAccessKey: "zZ2oMQrZwPWGEf1yyHneWFK2JBlGkVjYTJnfw75X",
|
||||||
|
STSSessionToken: "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJWUUg5NzVKVjQ5SllETEs3RjgxRyIsImV4cCI6MTY5Nzc0Mzg1MywicGFyZW50IjoibWluaW9hZG1pbiJ9.tRJVb3gbRFswKyNsxz_Dbw1SHoIQRRgA3xmXpXE4shScCsQXDydc7U_F9QOjL_BQDcgs65ZqWo3N2CIPmWoGDA",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
want: 3600,
|
||||||
|
wantErr: false,
|
||||||
|
preFunc: func() {
|
||||||
|
os.Setenv(token.ConsoleSTSDuration, "1h")
|
||||||
|
},
|
||||||
|
postFunc: func() {
|
||||||
|
os.Unsetenv(token.ConsoleSTSDuration)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if tt.preFunc != nil {
|
||||||
|
tt.preFunc()
|
||||||
|
}
|
||||||
|
expTime, err := getMaxShareLinkExpirationSeconds(tt.args.session)
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("getMaxShareLinkExpirationSeconds() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(expTime, tt.want) {
|
||||||
|
t.Errorf("getMaxShareLinkExpirationSeconds() got = %v, want %v", expTime, tt.want)
|
||||||
|
}
|
||||||
|
if tt.postFunc != nil {
|
||||||
|
tt.postFunc()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
113
swagger.yml
113
swagger.yml
@@ -884,50 +884,6 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- Bucket
|
- Bucket
|
||||||
|
|
||||||
/list-external-buckets:
|
|
||||||
post:
|
|
||||||
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/ApiError"
|
|
||||||
tags:
|
|
||||||
- Bucket
|
|
||||||
|
|
||||||
/buckets-replication:
|
|
||||||
post:
|
|
||||||
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/ApiError"
|
|
||||||
tags:
|
|
||||||
- Bucket
|
|
||||||
|
|
||||||
/buckets/{bucket_name}/replication:
|
/buckets/{bucket_name}/replication:
|
||||||
get:
|
get:
|
||||||
summary: Bucket Replication
|
summary: Bucket Replication
|
||||||
@@ -1339,6 +1295,66 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- Bucket
|
- Bucket
|
||||||
|
|
||||||
|
/buckets/max-share-exp:
|
||||||
|
get:
|
||||||
|
summary: Get max expiration time for share link in seconds
|
||||||
|
operationId: GetMaxShareLinkExp
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: A successful response.
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/maxShareLinkExpResponse"
|
||||||
|
default:
|
||||||
|
description: Generic error response.
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/ApiError"
|
||||||
|
tags:
|
||||||
|
- Bucket
|
||||||
|
|
||||||
|
/list-external-buckets:
|
||||||
|
post:
|
||||||
|
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/ApiError"
|
||||||
|
tags:
|
||||||
|
- Bucket
|
||||||
|
|
||||||
|
/buckets-replication:
|
||||||
|
post:
|
||||||
|
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/ApiError"
|
||||||
|
tags:
|
||||||
|
- Bucket
|
||||||
|
|
||||||
/service-accounts:
|
/service-accounts:
|
||||||
get:
|
get:
|
||||||
summary: List User's Service Accounts
|
summary: List User's Service Accounts
|
||||||
@@ -6120,3 +6136,12 @@ definitions:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
maxShareLinkExpResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
exp:
|
||||||
|
type: number
|
||||||
|
format: int64
|
||||||
|
required:
|
||||||
|
- exp
|
||||||
|
|||||||
Reference in New Issue
Block a user