Access Rules for bucket (#941)
* access rules * separate DELETE API call Co-authored-by: Adam Stafford <adamstafford@Adams-MacBook-Pro.local>
This commit is contained in:
@@ -82,6 +82,27 @@ func registersPoliciesHandler(api *operations.ConsoleAPI) {
|
||||
}
|
||||
return admin_api.NewListPoliciesWithBucketOK().WithPayload(policyResponse)
|
||||
})
|
||||
api.AdminAPIListAccessRulesWithBucketHandler = admin_api.ListAccessRulesWithBucketHandlerFunc(func(params admin_api.ListAccessRulesWithBucketParams, session *models.Principal) middleware.Responder {
|
||||
policyResponse, err := getListAccessRulesWithBucketResponse(session, params.Bucket)
|
||||
if err != nil {
|
||||
return admin_api.NewListAccessRulesWithBucketDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return admin_api.NewListAccessRulesWithBucketOK().WithPayload(policyResponse)
|
||||
})
|
||||
api.AdminAPISetAccessRuleWithBucketHandler = admin_api.SetAccessRuleWithBucketHandlerFunc(func(params admin_api.SetAccessRuleWithBucketParams, session *models.Principal) middleware.Responder {
|
||||
policyResponse, err := getSetAccessRuleWithBucketResponse(session, params.Bucket, params.Prefixaccess)
|
||||
if err != nil {
|
||||
return admin_api.NewSetAccessRuleWithBucketDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return admin_api.NewSetAccessRuleWithBucketOK().WithPayload(policyResponse)
|
||||
})
|
||||
api.AdminAPIDeleteAccessRuleWithBucketHandler = admin_api.DeleteAccessRuleWithBucketHandlerFunc(func(params admin_api.DeleteAccessRuleWithBucketParams, session *models.Principal) middleware.Responder {
|
||||
policyResponse, err := getDeleteAccessRuleWithBucketResponse(session, params.Bucket, params.Prefix)
|
||||
if err != nil {
|
||||
return admin_api.NewDeleteAccessRuleWithBucketDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return admin_api.NewDeleteAccessRuleWithBucketOK().WithPayload(policyResponse)
|
||||
})
|
||||
api.AdminAPIListUsersForPolicyHandler = admin_api.ListUsersForPolicyHandlerFunc(func(params admin_api.ListUsersForPolicyParams, session *models.Principal) middleware.Responder {
|
||||
policyUsersResponse, err := getListUsersForPolicyResponse(session, params.Policy)
|
||||
if err != nil {
|
||||
@@ -98,6 +119,46 @@ func registersPoliciesHandler(api *operations.ConsoleAPI) {
|
||||
})
|
||||
}
|
||||
|
||||
func getListAccessRulesWithBucketResponse(session *models.Principal, bucket string) (*models.ListAccessRulesResponse, *models.Error) {
|
||||
ctx := context.Background()
|
||||
client, err := newS3BucketClient(session, bucket, "")
|
||||
if err != nil {
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
accessRules, _ := client.GetAccessRules(ctx)
|
||||
var accessRuleList []*models.AccessRule
|
||||
for k, v := range accessRules {
|
||||
accessRuleList = append(accessRuleList, &models.AccessRule{Prefix: k[len(bucket)+1 : len(k)-1], Access: v})
|
||||
}
|
||||
return &models.ListAccessRulesResponse{AccessRules: accessRuleList}, nil
|
||||
}
|
||||
|
||||
func getSetAccessRuleWithBucketResponse(session *models.Principal, bucket string, prefixAccess *models.PrefixAccessPair) (bool, *models.Error) {
|
||||
ctx := context.Background()
|
||||
client, err := newS3BucketClient(session, bucket, prefixAccess.Prefix)
|
||||
if err != nil {
|
||||
return false, prepareError(err)
|
||||
}
|
||||
errorVal := client.SetAccess(ctx, prefixAccess.Access, false)
|
||||
if errorVal != nil {
|
||||
return false, prepareError(errorVal.Cause)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func getDeleteAccessRuleWithBucketResponse(session *models.Principal, bucket string, prefix string) (bool, *models.Error) {
|
||||
ctx := context.Background()
|
||||
client, err := newS3BucketClient(session, bucket, prefix)
|
||||
if err != nil {
|
||||
return false, prepareError(err)
|
||||
}
|
||||
errorVal := client.SetAccess(ctx, "none", false)
|
||||
if errorVal != nil {
|
||||
return false, prepareError(errorVal.Cause)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func getListPoliciesWithBucketResponse(session *models.Principal, bucket string) (*models.ListPoliciesResponse, *models.Error) {
|
||||
ctx := context.Background()
|
||||
mAdmin, err := NewMinioAdminClient(session)
|
||||
|
||||
@@ -492,6 +492,123 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bucket/{bucket}/access-rules": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "List Access Rules With Given Bucket",
|
||||
"operationId": "ListAccessRulesWithBucket",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "bucket",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"name": "offset",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/listAccessRulesResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "Add Access Rule To Given Bucket",
|
||||
"operationId": "SetAccessRuleWithBucket",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "bucket",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "prefixaccess",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/prefixAccessPair"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bucket/{bucket}/access-rules/{prefix}": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "Delete Access Rule From Given Bucket",
|
||||
"operationId": "DeleteAccessRuleWithBucket",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "bucket",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "prefix",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -3194,6 +3311,17 @@ func init() {
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"accessRule": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access": {
|
||||
"type": "string"
|
||||
},
|
||||
"prefix": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"accountChangePasswordRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -3889,6 +4017,23 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"listAccessRulesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accessRules": {
|
||||
"type": "array",
|
||||
"title": "list of policies",
|
||||
"items": {
|
||||
"$ref": "#/definitions/accessRule"
|
||||
}
|
||||
},
|
||||
"total": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"title": "total number of policies"
|
||||
}
|
||||
}
|
||||
},
|
||||
"listBucketEventsResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -4456,6 +4601,17 @@ func init() {
|
||||
"group"
|
||||
]
|
||||
},
|
||||
"prefixAccessPair": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access": {
|
||||
"type": "string"
|
||||
},
|
||||
"prefix": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"principal": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -5663,6 +5819,123 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bucket/{bucket}/access-rules": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "List Access Rules With Given Bucket",
|
||||
"operationId": "ListAccessRulesWithBucket",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "bucket",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"name": "offset",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/listAccessRulesResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "Add Access Rule To Given Bucket",
|
||||
"operationId": "SetAccessRuleWithBucket",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "bucket",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "prefixaccess",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/prefixAccessPair"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bucket/{bucket}/access-rules/{prefix}": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"AdminAPI"
|
||||
],
|
||||
"summary": "Delete Access Rule From Given Bucket",
|
||||
"operationId": "DeleteAccessRuleWithBucket",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "bucket",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "prefix",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/buckets": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -8419,6 +8692,17 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"accessRule": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access": {
|
||||
"type": "string"
|
||||
},
|
||||
"prefix": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"accountChangePasswordRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -9114,6 +9398,23 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"listAccessRulesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accessRules": {
|
||||
"type": "array",
|
||||
"title": "list of policies",
|
||||
"items": {
|
||||
"$ref": "#/definitions/accessRule"
|
||||
}
|
||||
},
|
||||
"total": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"title": "total number of policies"
|
||||
}
|
||||
}
|
||||
},
|
||||
"listBucketEventsResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -9681,6 +9982,17 @@ func init() {
|
||||
"group"
|
||||
]
|
||||
},
|
||||
"prefixAccessPair": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access": {
|
||||
"type": "string"
|
||||
},
|
||||
"prefix": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"principal": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -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 admin_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"
|
||||
)
|
||||
|
||||
// DeleteAccessRuleWithBucketHandlerFunc turns a function with the right signature into a delete access rule with bucket handler
|
||||
type DeleteAccessRuleWithBucketHandlerFunc func(DeleteAccessRuleWithBucketParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn DeleteAccessRuleWithBucketHandlerFunc) Handle(params DeleteAccessRuleWithBucketParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// DeleteAccessRuleWithBucketHandler interface for that can handle valid delete access rule with bucket params
|
||||
type DeleteAccessRuleWithBucketHandler interface {
|
||||
Handle(DeleteAccessRuleWithBucketParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewDeleteAccessRuleWithBucket creates a new http.Handler for the delete access rule with bucket operation
|
||||
func NewDeleteAccessRuleWithBucket(ctx *middleware.Context, handler DeleteAccessRuleWithBucketHandler) *DeleteAccessRuleWithBucket {
|
||||
return &DeleteAccessRuleWithBucket{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* DeleteAccessRuleWithBucket swagger:route DELETE /bucket/{bucket}/access-rules/{prefix} AdminAPI deleteAccessRuleWithBucket
|
||||
|
||||
Delete Access Rule From Given Bucket
|
||||
|
||||
*/
|
||||
type DeleteAccessRuleWithBucket struct {
|
||||
Context *middleware.Context
|
||||
Handler DeleteAccessRuleWithBucketHandler
|
||||
}
|
||||
|
||||
func (o *DeleteAccessRuleWithBucket) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewDeleteAccessRuleWithBucketParams()
|
||||
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,112 @@
|
||||
// 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 admin_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewDeleteAccessRuleWithBucketParams creates a new DeleteAccessRuleWithBucketParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewDeleteAccessRuleWithBucketParams() DeleteAccessRuleWithBucketParams {
|
||||
|
||||
return DeleteAccessRuleWithBucketParams{}
|
||||
}
|
||||
|
||||
// DeleteAccessRuleWithBucketParams contains all the bound params for the delete access rule with bucket operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters DeleteAccessRuleWithBucket
|
||||
type DeleteAccessRuleWithBucketParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Bucket string
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Prefix string
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewDeleteAccessRuleWithBucketParams() beforehand.
|
||||
func (o *DeleteAccessRuleWithBucketParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
rBucket, rhkBucket, _ := route.Params.GetOK("bucket")
|
||||
if err := o.bindBucket(rBucket, rhkBucket, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rPrefix, rhkPrefix, _ := route.Params.GetOK("prefix")
|
||||
if err := o.bindPrefix(rPrefix, rhkPrefix, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindBucket binds and validates parameter Bucket from path.
|
||||
func (o *DeleteAccessRuleWithBucketParams) bindBucket(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Bucket = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindPrefix binds and validates parameter Prefix from path.
|
||||
func (o *DeleteAccessRuleWithBucketParams) bindPrefix(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Prefix = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
// 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 admin_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"
|
||||
)
|
||||
|
||||
// DeleteAccessRuleWithBucketOKCode is the HTTP code returned for type DeleteAccessRuleWithBucketOK
|
||||
const DeleteAccessRuleWithBucketOKCode int = 200
|
||||
|
||||
/*DeleteAccessRuleWithBucketOK A successful response.
|
||||
|
||||
swagger:response deleteAccessRuleWithBucketOK
|
||||
*/
|
||||
type DeleteAccessRuleWithBucketOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload bool `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteAccessRuleWithBucketOK creates DeleteAccessRuleWithBucketOK with default headers values
|
||||
func NewDeleteAccessRuleWithBucketOK() *DeleteAccessRuleWithBucketOK {
|
||||
|
||||
return &DeleteAccessRuleWithBucketOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete access rule with bucket o k response
|
||||
func (o *DeleteAccessRuleWithBucketOK) WithPayload(payload bool) *DeleteAccessRuleWithBucketOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete access rule with bucket o k response
|
||||
func (o *DeleteAccessRuleWithBucketOK) SetPayload(payload bool) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteAccessRuleWithBucketOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
|
||||
/*DeleteAccessRuleWithBucketDefault Generic error response.
|
||||
|
||||
swagger:response deleteAccessRuleWithBucketDefault
|
||||
*/
|
||||
type DeleteAccessRuleWithBucketDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewDeleteAccessRuleWithBucketDefault creates DeleteAccessRuleWithBucketDefault with default headers values
|
||||
func NewDeleteAccessRuleWithBucketDefault(code int) *DeleteAccessRuleWithBucketDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &DeleteAccessRuleWithBucketDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the delete access rule with bucket default response
|
||||
func (o *DeleteAccessRuleWithBucketDefault) WithStatusCode(code int) *DeleteAccessRuleWithBucketDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the delete access rule with bucket default response
|
||||
func (o *DeleteAccessRuleWithBucketDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the delete access rule with bucket default response
|
||||
func (o *DeleteAccessRuleWithBucketDefault) WithPayload(payload *models.Error) *DeleteAccessRuleWithBucketDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the delete access rule with bucket default response
|
||||
func (o *DeleteAccessRuleWithBucketDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteAccessRuleWithBucketDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2021 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package admin_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DeleteAccessRuleWithBucketURL generates an URL for the delete access rule with bucket operation
|
||||
type DeleteAccessRuleWithBucketURL struct {
|
||||
Bucket string
|
||||
Prefix string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *DeleteAccessRuleWithBucketURL) WithBasePath(bp string) *DeleteAccessRuleWithBucketURL {
|
||||
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 *DeleteAccessRuleWithBucketURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *DeleteAccessRuleWithBucketURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/bucket/{bucket}/access-rules/{prefix}"
|
||||
|
||||
bucket := o.Bucket
|
||||
if bucket != "" {
|
||||
_path = strings.Replace(_path, "{bucket}", bucket, -1)
|
||||
} else {
|
||||
return nil, errors.New("bucket is required on DeleteAccessRuleWithBucketURL")
|
||||
}
|
||||
|
||||
prefix := o.Prefix
|
||||
if prefix != "" {
|
||||
_path = strings.Replace(_path, "{prefix}", prefix, -1)
|
||||
} else {
|
||||
return nil, errors.New("prefix is required on DeleteAccessRuleWithBucketURL")
|
||||
}
|
||||
|
||||
_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 *DeleteAccessRuleWithBucketURL) 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 *DeleteAccessRuleWithBucketURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *DeleteAccessRuleWithBucketURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on DeleteAccessRuleWithBucketURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on DeleteAccessRuleWithBucketURL")
|
||||
}
|
||||
|
||||
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 *DeleteAccessRuleWithBucketURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -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 admin_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"
|
||||
)
|
||||
|
||||
// ListAccessRulesWithBucketHandlerFunc turns a function with the right signature into a list access rules with bucket handler
|
||||
type ListAccessRulesWithBucketHandlerFunc func(ListAccessRulesWithBucketParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn ListAccessRulesWithBucketHandlerFunc) Handle(params ListAccessRulesWithBucketParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// ListAccessRulesWithBucketHandler interface for that can handle valid list access rules with bucket params
|
||||
type ListAccessRulesWithBucketHandler interface {
|
||||
Handle(ListAccessRulesWithBucketParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewListAccessRulesWithBucket creates a new http.Handler for the list access rules with bucket operation
|
||||
func NewListAccessRulesWithBucket(ctx *middleware.Context, handler ListAccessRulesWithBucketHandler) *ListAccessRulesWithBucket {
|
||||
return &ListAccessRulesWithBucket{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* ListAccessRulesWithBucket swagger:route GET /bucket/{bucket}/access-rules AdminAPI listAccessRulesWithBucket
|
||||
|
||||
List Access Rules With Given Bucket
|
||||
|
||||
*/
|
||||
type ListAccessRulesWithBucket struct {
|
||||
Context *middleware.Context
|
||||
Handler ListAccessRulesWithBucketHandler
|
||||
}
|
||||
|
||||
func (o *ListAccessRulesWithBucket) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewListAccessRulesWithBucketParams()
|
||||
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,156 @@
|
||||
// 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 admin_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// NewListAccessRulesWithBucketParams creates a new ListAccessRulesWithBucketParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewListAccessRulesWithBucketParams() ListAccessRulesWithBucketParams {
|
||||
|
||||
return ListAccessRulesWithBucketParams{}
|
||||
}
|
||||
|
||||
// ListAccessRulesWithBucketParams contains all the bound params for the list access rules with bucket operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters ListAccessRulesWithBucket
|
||||
type ListAccessRulesWithBucketParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Bucket string
|
||||
/*
|
||||
In: query
|
||||
*/
|
||||
Limit *int32
|
||||
/*
|
||||
In: query
|
||||
*/
|
||||
Offset *int32
|
||||
}
|
||||
|
||||
// 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 NewListAccessRulesWithBucketParams() beforehand.
|
||||
func (o *ListAccessRulesWithBucketParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
rBucket, rhkBucket, _ := route.Params.GetOK("bucket")
|
||||
if err := o.bindBucket(rBucket, rhkBucket, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qLimit, qhkLimit, _ := qs.GetOK("limit")
|
||||
if err := o.bindLimit(qLimit, qhkLimit, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qOffset, qhkOffset, _ := qs.GetOK("offset")
|
||||
if err := o.bindOffset(qOffset, qhkOffset, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindBucket binds and validates parameter Bucket from path.
|
||||
func (o *ListAccessRulesWithBucketParams) bindBucket(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Bucket = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindLimit binds and validates parameter Limit from query.
|
||||
func (o *ListAccessRulesWithBucketParams) bindLimit(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: false
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if raw == "" { // empty values pass all other validations
|
||||
return nil
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt32(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("limit", "query", "int32", raw)
|
||||
}
|
||||
o.Limit = &value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindOffset binds and validates parameter Offset from query.
|
||||
func (o *ListAccessRulesWithBucketParams) bindOffset(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: false
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if raw == "" { // empty values pass all other validations
|
||||
return nil
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt32(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("offset", "query", "int32", raw)
|
||||
}
|
||||
o.Offset = &value
|
||||
|
||||
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 admin_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"
|
||||
)
|
||||
|
||||
// ListAccessRulesWithBucketOKCode is the HTTP code returned for type ListAccessRulesWithBucketOK
|
||||
const ListAccessRulesWithBucketOKCode int = 200
|
||||
|
||||
/*ListAccessRulesWithBucketOK A successful response.
|
||||
|
||||
swagger:response listAccessRulesWithBucketOK
|
||||
*/
|
||||
type ListAccessRulesWithBucketOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.ListAccessRulesResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewListAccessRulesWithBucketOK creates ListAccessRulesWithBucketOK with default headers values
|
||||
func NewListAccessRulesWithBucketOK() *ListAccessRulesWithBucketOK {
|
||||
|
||||
return &ListAccessRulesWithBucketOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the list access rules with bucket o k response
|
||||
func (o *ListAccessRulesWithBucketOK) WithPayload(payload *models.ListAccessRulesResponse) *ListAccessRulesWithBucketOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the list access rules with bucket o k response
|
||||
func (o *ListAccessRulesWithBucketOK) SetPayload(payload *models.ListAccessRulesResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *ListAccessRulesWithBucketOK) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*ListAccessRulesWithBucketDefault Generic error response.
|
||||
|
||||
swagger:response listAccessRulesWithBucketDefault
|
||||
*/
|
||||
type ListAccessRulesWithBucketDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewListAccessRulesWithBucketDefault creates ListAccessRulesWithBucketDefault with default headers values
|
||||
func NewListAccessRulesWithBucketDefault(code int) *ListAccessRulesWithBucketDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &ListAccessRulesWithBucketDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the list access rules with bucket default response
|
||||
func (o *ListAccessRulesWithBucketDefault) WithStatusCode(code int) *ListAccessRulesWithBucketDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the list access rules with bucket default response
|
||||
func (o *ListAccessRulesWithBucketDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the list access rules with bucket default response
|
||||
func (o *ListAccessRulesWithBucketDefault) WithPayload(payload *models.Error) *ListAccessRulesWithBucketDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the list access rules with bucket default response
|
||||
func (o *ListAccessRulesWithBucketDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *ListAccessRulesWithBucketDefault) 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,141 @@
|
||||
// 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 admin_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// ListAccessRulesWithBucketURL generates an URL for the list access rules with bucket operation
|
||||
type ListAccessRulesWithBucketURL struct {
|
||||
Bucket string
|
||||
|
||||
Limit *int32
|
||||
Offset *int32
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *ListAccessRulesWithBucketURL) WithBasePath(bp string) *ListAccessRulesWithBucketURL {
|
||||
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 *ListAccessRulesWithBucketURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *ListAccessRulesWithBucketURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/bucket/{bucket}/access-rules"
|
||||
|
||||
bucket := o.Bucket
|
||||
if bucket != "" {
|
||||
_path = strings.Replace(_path, "{bucket}", bucket, -1)
|
||||
} else {
|
||||
return nil, errors.New("bucket is required on ListAccessRulesWithBucketURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
qs := make(url.Values)
|
||||
|
||||
var limitQ string
|
||||
if o.Limit != nil {
|
||||
limitQ = swag.FormatInt32(*o.Limit)
|
||||
}
|
||||
if limitQ != "" {
|
||||
qs.Set("limit", limitQ)
|
||||
}
|
||||
|
||||
var offsetQ string
|
||||
if o.Offset != nil {
|
||||
offsetQ = swag.FormatInt32(*o.Offset)
|
||||
}
|
||||
if offsetQ != "" {
|
||||
qs.Set("offset", offsetQ)
|
||||
}
|
||||
|
||||
_result.RawQuery = qs.Encode()
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *ListAccessRulesWithBucketURL) 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 *ListAccessRulesWithBucketURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *ListAccessRulesWithBucketURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on ListAccessRulesWithBucketURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on ListAccessRulesWithBucketURL")
|
||||
}
|
||||
|
||||
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 *ListAccessRulesWithBucketURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
88
restapi/operations/admin_api/set_access_rule_with_bucket.go
Normal file
88
restapi/operations/admin_api/set_access_rule_with_bucket.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 admin_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"
|
||||
)
|
||||
|
||||
// SetAccessRuleWithBucketHandlerFunc turns a function with the right signature into a set access rule with bucket handler
|
||||
type SetAccessRuleWithBucketHandlerFunc func(SetAccessRuleWithBucketParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn SetAccessRuleWithBucketHandlerFunc) Handle(params SetAccessRuleWithBucketParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// SetAccessRuleWithBucketHandler interface for that can handle valid set access rule with bucket params
|
||||
type SetAccessRuleWithBucketHandler interface {
|
||||
Handle(SetAccessRuleWithBucketParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewSetAccessRuleWithBucket creates a new http.Handler for the set access rule with bucket operation
|
||||
func NewSetAccessRuleWithBucket(ctx *middleware.Context, handler SetAccessRuleWithBucketHandler) *SetAccessRuleWithBucket {
|
||||
return &SetAccessRuleWithBucket{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* SetAccessRuleWithBucket swagger:route PUT /bucket/{bucket}/access-rules AdminAPI setAccessRuleWithBucket
|
||||
|
||||
Add Access Rule To Given Bucket
|
||||
|
||||
*/
|
||||
type SetAccessRuleWithBucket struct {
|
||||
Context *middleware.Context
|
||||
Handler SetAccessRuleWithBucketHandler
|
||||
}
|
||||
|
||||
func (o *SetAccessRuleWithBucket) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewSetAccessRuleWithBucketParams()
|
||||
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,127 @@
|
||||
// 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 admin_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/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewSetAccessRuleWithBucketParams creates a new SetAccessRuleWithBucketParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewSetAccessRuleWithBucketParams() SetAccessRuleWithBucketParams {
|
||||
|
||||
return SetAccessRuleWithBucketParams{}
|
||||
}
|
||||
|
||||
// SetAccessRuleWithBucketParams contains all the bound params for the set access rule with bucket operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters SetAccessRuleWithBucket
|
||||
type SetAccessRuleWithBucketParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Bucket string
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Prefixaccess *models.PrefixAccessPair
|
||||
}
|
||||
|
||||
// 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 NewSetAccessRuleWithBucketParams() beforehand.
|
||||
func (o *SetAccessRuleWithBucketParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
rBucket, rhkBucket, _ := route.Params.GetOK("bucket")
|
||||
if err := o.bindBucket(rBucket, rhkBucket, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.PrefixAccessPair
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("prefixaccess", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("prefixaccess", "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.Prefixaccess = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("prefixaccess", "body", ""))
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindBucket binds and validates parameter Bucket from path.
|
||||
func (o *SetAccessRuleWithBucketParams) bindBucket(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Bucket = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
// 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 admin_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"
|
||||
)
|
||||
|
||||
// SetAccessRuleWithBucketOKCode is the HTTP code returned for type SetAccessRuleWithBucketOK
|
||||
const SetAccessRuleWithBucketOKCode int = 200
|
||||
|
||||
/*SetAccessRuleWithBucketOK A successful response.
|
||||
|
||||
swagger:response setAccessRuleWithBucketOK
|
||||
*/
|
||||
type SetAccessRuleWithBucketOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload bool `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewSetAccessRuleWithBucketOK creates SetAccessRuleWithBucketOK with default headers values
|
||||
func NewSetAccessRuleWithBucketOK() *SetAccessRuleWithBucketOK {
|
||||
|
||||
return &SetAccessRuleWithBucketOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the set access rule with bucket o k response
|
||||
func (o *SetAccessRuleWithBucketOK) WithPayload(payload bool) *SetAccessRuleWithBucketOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the set access rule with bucket o k response
|
||||
func (o *SetAccessRuleWithBucketOK) SetPayload(payload bool) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *SetAccessRuleWithBucketOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
|
||||
/*SetAccessRuleWithBucketDefault Generic error response.
|
||||
|
||||
swagger:response setAccessRuleWithBucketDefault
|
||||
*/
|
||||
type SetAccessRuleWithBucketDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewSetAccessRuleWithBucketDefault creates SetAccessRuleWithBucketDefault with default headers values
|
||||
func NewSetAccessRuleWithBucketDefault(code int) *SetAccessRuleWithBucketDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &SetAccessRuleWithBucketDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the set access rule with bucket default response
|
||||
func (o *SetAccessRuleWithBucketDefault) WithStatusCode(code int) *SetAccessRuleWithBucketDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the set access rule with bucket default response
|
||||
func (o *SetAccessRuleWithBucketDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the set access rule with bucket default response
|
||||
func (o *SetAccessRuleWithBucketDefault) WithPayload(payload *models.Error) *SetAccessRuleWithBucketDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the set access rule with bucket default response
|
||||
func (o *SetAccessRuleWithBucketDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *SetAccessRuleWithBucketDefault) 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,116 @@
|
||||
// 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 admin_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// SetAccessRuleWithBucketURL generates an URL for the set access rule with bucket operation
|
||||
type SetAccessRuleWithBucketURL struct {
|
||||
Bucket string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ struct{}
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *SetAccessRuleWithBucketURL) WithBasePath(bp string) *SetAccessRuleWithBucketURL {
|
||||
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 *SetAccessRuleWithBucketURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *SetAccessRuleWithBucketURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/bucket/{bucket}/access-rules"
|
||||
|
||||
bucket := o.Bucket
|
||||
if bucket != "" {
|
||||
_path = strings.Replace(_path, "{bucket}", bucket, -1)
|
||||
} else {
|
||||
return nil, errors.New("bucket is required on SetAccessRuleWithBucketURL")
|
||||
}
|
||||
|
||||
_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 *SetAccessRuleWithBucketURL) 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 *SetAccessRuleWithBucketURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *SetAccessRuleWithBucketURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on SetAccessRuleWithBucketURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on SetAccessRuleWithBucketURL")
|
||||
}
|
||||
|
||||
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 *SetAccessRuleWithBucketURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -119,6 +119,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
AdminAPIDashboardWidgetDetailsHandler: admin_api.DashboardWidgetDetailsHandlerFunc(func(params admin_api.DashboardWidgetDetailsParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.DashboardWidgetDetails has not yet been implemented")
|
||||
}),
|
||||
AdminAPIDeleteAccessRuleWithBucketHandler: admin_api.DeleteAccessRuleWithBucketHandlerFunc(func(params admin_api.DeleteAccessRuleWithBucketParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.DeleteAccessRuleWithBucket has not yet been implemented")
|
||||
}),
|
||||
UserAPIDeleteBucketHandler: user_api.DeleteBucketHandlerFunc(func(params user_api.DeleteBucketParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.DeleteBucket has not yet been implemented")
|
||||
}),
|
||||
@@ -194,6 +197,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
AdminAPIListAUserServiceAccountsHandler: admin_api.ListAUserServiceAccountsHandlerFunc(func(params admin_api.ListAUserServiceAccountsParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.ListAUserServiceAccounts has not yet been implemented")
|
||||
}),
|
||||
AdminAPIListAccessRulesWithBucketHandler: admin_api.ListAccessRulesWithBucketHandlerFunc(func(params admin_api.ListAccessRulesWithBucketParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.ListAccessRulesWithBucket has not yet been implemented")
|
||||
}),
|
||||
UserAPIListBucketEventsHandler: user_api.ListBucketEventsHandlerFunc(func(params user_api.ListBucketEventsParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.ListBucketEvents has not yet been implemented")
|
||||
}),
|
||||
@@ -299,6 +305,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
UserAPISessionCheckHandler: user_api.SessionCheckHandlerFunc(func(params user_api.SessionCheckParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.SessionCheck has not yet been implemented")
|
||||
}),
|
||||
AdminAPISetAccessRuleWithBucketHandler: admin_api.SetAccessRuleWithBucketHandlerFunc(func(params admin_api.SetAccessRuleWithBucketParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.SetAccessRuleWithBucket has not yet been implemented")
|
||||
}),
|
||||
UserAPISetBucketQuotaHandler: user_api.SetBucketQuotaHandlerFunc(func(params user_api.SetBucketQuotaParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.SetBucketQuota has not yet been implemented")
|
||||
}),
|
||||
@@ -432,6 +441,8 @@ type ConsoleAPI struct {
|
||||
UserAPICreateServiceAccountHandler user_api.CreateServiceAccountHandler
|
||||
// AdminAPIDashboardWidgetDetailsHandler sets the operation handler for the dashboard widget details operation
|
||||
AdminAPIDashboardWidgetDetailsHandler admin_api.DashboardWidgetDetailsHandler
|
||||
// AdminAPIDeleteAccessRuleWithBucketHandler sets the operation handler for the delete access rule with bucket operation
|
||||
AdminAPIDeleteAccessRuleWithBucketHandler admin_api.DeleteAccessRuleWithBucketHandler
|
||||
// UserAPIDeleteBucketHandler sets the operation handler for the delete bucket operation
|
||||
UserAPIDeleteBucketHandler user_api.DeleteBucketHandler
|
||||
// UserAPIDeleteBucketEventHandler sets the operation handler for the delete bucket event operation
|
||||
@@ -482,6 +493,8 @@ type ConsoleAPI struct {
|
||||
UserAPIHasPermissionToHandler user_api.HasPermissionToHandler
|
||||
// AdminAPIListAUserServiceAccountsHandler sets the operation handler for the list a user service accounts operation
|
||||
AdminAPIListAUserServiceAccountsHandler admin_api.ListAUserServiceAccountsHandler
|
||||
// AdminAPIListAccessRulesWithBucketHandler sets the operation handler for the list access rules with bucket operation
|
||||
AdminAPIListAccessRulesWithBucketHandler admin_api.ListAccessRulesWithBucketHandler
|
||||
// UserAPIListBucketEventsHandler sets the operation handler for the list bucket events operation
|
||||
UserAPIListBucketEventsHandler user_api.ListBucketEventsHandler
|
||||
// UserAPIListBucketsHandler sets the operation handler for the list buckets operation
|
||||
@@ -552,6 +565,8 @@ type ConsoleAPI struct {
|
||||
AdminAPIRestartServiceHandler admin_api.RestartServiceHandler
|
||||
// UserAPISessionCheckHandler sets the operation handler for the session check operation
|
||||
UserAPISessionCheckHandler user_api.SessionCheckHandler
|
||||
// AdminAPISetAccessRuleWithBucketHandler sets the operation handler for the set access rule with bucket operation
|
||||
AdminAPISetAccessRuleWithBucketHandler admin_api.SetAccessRuleWithBucketHandler
|
||||
// UserAPISetBucketQuotaHandler sets the operation handler for the set bucket quota operation
|
||||
UserAPISetBucketQuotaHandler user_api.SetBucketQuotaHandler
|
||||
// UserAPISetBucketRetentionConfigHandler sets the operation handler for the set bucket retention config operation
|
||||
@@ -721,6 +736,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.AdminAPIDashboardWidgetDetailsHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.DashboardWidgetDetailsHandler")
|
||||
}
|
||||
if o.AdminAPIDeleteAccessRuleWithBucketHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.DeleteAccessRuleWithBucketHandler")
|
||||
}
|
||||
if o.UserAPIDeleteBucketHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.DeleteBucketHandler")
|
||||
}
|
||||
@@ -796,6 +814,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.AdminAPIListAUserServiceAccountsHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.ListAUserServiceAccountsHandler")
|
||||
}
|
||||
if o.AdminAPIListAccessRulesWithBucketHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.ListAccessRulesWithBucketHandler")
|
||||
}
|
||||
if o.UserAPIListBucketEventsHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.ListBucketEventsHandler")
|
||||
}
|
||||
@@ -901,6 +922,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.UserAPISessionCheckHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.SessionCheckHandler")
|
||||
}
|
||||
if o.AdminAPISetAccessRuleWithBucketHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.SetAccessRuleWithBucketHandler")
|
||||
}
|
||||
if o.UserAPISetBucketQuotaHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.SetBucketQuotaHandler")
|
||||
}
|
||||
@@ -1120,6 +1144,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/bucket/{bucket}/access-rules/{prefix}"] = admin_api.NewDeleteAccessRuleWithBucket(o.context, o.AdminAPIDeleteAccessRuleWithBucketHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/buckets/{name}"] = user_api.NewDeleteBucket(o.context, o.UserAPIDeleteBucketHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
@@ -1220,6 +1248,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/bucket/{bucket}/access-rules"] = admin_api.NewListAccessRulesWithBucket(o.context, o.AdminAPIListAccessRulesWithBucketHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/buckets/{bucket_name}/events"] = user_api.NewListBucketEvents(o.context, o.UserAPIListBucketEventsHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
@@ -1360,6 +1392,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/bucket/{bucket}/access-rules"] = admin_api.NewSetAccessRuleWithBucket(o.context, o.AdminAPISetAccessRuleWithBucketHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/buckets/{name}/quota"] = user_api.NewSetBucketQuota(o.context, o.UserAPISetBucketQuotaHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
|
||||
Reference in New Issue
Block a user