API to receive an email address and set it (#2095)

* Generate swagger code for new endpoints
* Implemetn swagger APIs
* Add unit tests
This commit is contained in:
Javier Adriel
2022-06-09 18:13:46 -05:00
committed by GitHub
parent 5a8e029005
commit c509e5db70
25 changed files with 2400 additions and 0 deletions

67
models/mp_integration.go Normal file
View File

@@ -0,0 +1,67 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// MpIntegration mp integration
//
// swagger:model mpIntegration
type MpIntegration struct {
// email
Email string `json:"email,omitempty"`
}
// Validate validates this mp integration
func (m *MpIntegration) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this mp integration based on context it is used
func (m *MpIntegration) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *MpIntegration) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *MpIntegration) UnmarshalBinary(b []byte) error {
var res MpIntegration
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -89,6 +89,7 @@ func configureAPI(api *operations.OperatorAPI) http.Handler {
registerVolumesHandlers(api)
// Namespaces handlers
registerNamespaceHandlers(api)
registerMarketplaceHandlers(api)
api.PreServerShutdown = func() {}

View File

@@ -310,6 +310,103 @@ func init() {
}
}
},
"/mp-integration": {
"get": {
"tags": [
"OperatorAPI"
],
"summary": "Returns email registered for marketplace integration",
"operationId": "GetMPIntegration",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/mpIntegration"
}
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/error"
}
}
}
},
"post": {
"tags": [
"OperatorAPI"
],
"summary": "Set email to register for marketplace integration",
"operationId": "PostMPIntegration",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/mpIntegration"
}
}
],
"responses": {
"201": {
"description": "A successful response."
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/error"
}
}
}
},
"delete": {
"tags": [
"OperatorAPI"
],
"summary": "Delete email registered for marketplace integration",
"operationId": "DeleteMPIntegration",
"responses": {
"204": {
"description": "A successful response."
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/error"
}
}
}
},
"patch": {
"tags": [
"OperatorAPI"
],
"summary": "Update email registered for marketplace integration",
"operationId": "PatchMPIntegration",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/mpIntegration"
}
}
],
"responses": {
"200": {
"description": "A successful response."
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/error"
}
}
}
}
},
"/namespace": {
"post": {
"tags": [
@@ -3302,6 +3399,14 @@ func init() {
}
}
},
"mpIntegration": {
"type": "object",
"properties": {
"email": {
"type": "string"
}
}
},
"namespace": {
"type": "object",
"required": [
@@ -4914,6 +5019,103 @@ func init() {
}
}
},
"/mp-integration": {
"get": {
"tags": [
"OperatorAPI"
],
"summary": "Returns email registered for marketplace integration",
"operationId": "GetMPIntegration",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/mpIntegration"
}
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/error"
}
}
}
},
"post": {
"tags": [
"OperatorAPI"
],
"summary": "Set email to register for marketplace integration",
"operationId": "PostMPIntegration",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/mpIntegration"
}
}
],
"responses": {
"201": {
"description": "A successful response."
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/error"
}
}
}
},
"delete": {
"tags": [
"OperatorAPI"
],
"summary": "Delete email registered for marketplace integration",
"operationId": "DeleteMPIntegration",
"responses": {
"204": {
"description": "A successful response."
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/error"
}
}
}
},
"patch": {
"tags": [
"OperatorAPI"
],
"summary": "Update email registered for marketplace integration",
"operationId": "PatchMPIntegration",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/mpIntegration"
}
}
],
"responses": {
"200": {
"description": "A successful response."
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/error"
}
}
}
}
},
"/namespace": {
"post": {
"tags": [
@@ -8737,6 +8939,14 @@ func init() {
}
}
},
"mpIntegration": {
"type": "object",
"properties": {
"email": {
"type": "string"
}
}
},
"namespace": {
"type": "object",
"required": [

View File

@@ -39,6 +39,10 @@ type K8sClientI interface {
createSecret(ctx context.Context, namespace string, secret *v1.Secret, opts metav1.CreateOptions) (*v1.Secret, error)
updateSecret(ctx context.Context, namespace string, secret *v1.Secret, opts metav1.UpdateOptions) (*v1.Secret, error)
getPVC(ctx context.Context, namespace string, pvcName string, opts metav1.GetOptions) (*v1.PersistentVolumeClaim, error)
getConfigMap(ctx context.Context, namespace, configMap string, opts metav1.GetOptions) (*v1.ConfigMap, error)
createConfigMap(ctx context.Context, namespace string, cm *v1.ConfigMap, opts metav1.CreateOptions) (*v1.ConfigMap, error)
updateConfigMap(ctx context.Context, namespace string, cm *v1.ConfigMap, opts metav1.UpdateOptions) (*v1.ConfigMap, error)
deleteConfigMap(ctx context.Context, namespace string, name string, opts metav1.DeleteOptions) error
}
// Interface implementation
@@ -87,3 +91,19 @@ func (c *k8sClient) getStorageClasses(ctx context.Context, opts metav1.ListOptio
func (c *k8sClient) getPVC(ctx context.Context, namespace string, pvcName string, opts metav1.GetOptions) (*v1.PersistentVolumeClaim, error) {
return c.client.CoreV1().PersistentVolumeClaims(namespace).Get(ctx, pvcName, opts)
}
func (c *k8sClient) getConfigMap(ctx context.Context, namespace, name string, opts metav1.GetOptions) (*v1.ConfigMap, error) {
return c.client.CoreV1().ConfigMaps(namespace).Get(ctx, name, opts)
}
func (c *k8sClient) createConfigMap(ctx context.Context, namespace string, cm *v1.ConfigMap, opts metav1.CreateOptions) (*v1.ConfigMap, error) {
return c.client.CoreV1().ConfigMaps(namespace).Create(ctx, cm, opts)
}
func (c *k8sClient) updateConfigMap(ctx context.Context, namespace string, cm *v1.ConfigMap, opts metav1.UpdateOptions) (*v1.ConfigMap, error) {
return c.client.CoreV1().ConfigMaps(namespace).Update(ctx, cm, opts)
}
func (c *k8sClient) deleteConfigMap(ctx context.Context, namespace string, name string, opts metav1.DeleteOptions) error {
return c.client.CoreV1().ConfigMaps(namespace).Delete(ctx, name, opts)
}

184
operatorapi/marketplace.go Normal file
View File

@@ -0,0 +1,184 @@
// 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 operatorapi
import (
"context"
"fmt"
"os"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/cluster"
"github.com/minio/console/models"
"github.com/minio/console/operatorapi/operations"
"github.com/minio/console/operatorapi/operations/operator_api"
errors "github.com/minio/console/restapi"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var (
mpConfigMapDefault = "mp-config"
mpConfigMapKey = "MP_CONFIG_KEY"
mpEmail = "email"
emailNotSetMsg = "Email was not sent in request"
)
func registerMarketplaceHandlers(api *operations.OperatorAPI) {
api.OperatorAPIGetMPIntegrationHandler = operator_api.GetMPIntegrationHandlerFunc(func(params operator_api.GetMPIntegrationParams, session *models.Principal) middleware.Responder {
payload, err := getMPIntegrationResponse(session, params)
if err != nil {
return operator_api.NewGetMPIntegrationDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewGetMPIntegrationOK().WithPayload(payload)
})
api.OperatorAPIPostMPIntegrationHandler = operator_api.PostMPIntegrationHandlerFunc(func(params operator_api.PostMPIntegrationParams, session *models.Principal) middleware.Responder {
err := postMPIntegrationResponse(session, params)
if err != nil {
return operator_api.NewPostMPIntegrationDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewPostMPIntegrationCreated()
})
api.OperatorAPIPatchMPIntegrationHandler = operator_api.PatchMPIntegrationHandlerFunc(func(params operator_api.PatchMPIntegrationParams, session *models.Principal) middleware.Responder {
err := patchMPIntegrationResponse(session, params)
if err != nil {
return operator_api.NewPatchMPIntegrationDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewPatchMPIntegrationOK()
})
api.OperatorAPIDeleteMPIntegrationHandler = operator_api.DeleteMPIntegrationHandlerFunc(func(params operator_api.DeleteMPIntegrationParams, session *models.Principal) middleware.Responder {
if err := deleteMPIntegrationResponse(session, params); err != nil {
return operator_api.NewDeleteMPIntegrationDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewDeleteMPIntegrationNoContent()
})
}
func getMPIntegrationResponse(session *models.Principal, params operator_api.GetMPIntegrationParams) (*models.MpIntegration, *models.Error) {
if true { // This block will be removed once service to register emails is deployed
return nil, &models.Error{Code: 501}
}
clientSet, err := cluster.K8sClient(session.STSSessionToken)
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if err != nil {
return nil, errors.ErrorWithContext(ctx, err)
}
mpEmail, err := getMPEmail(ctx, &k8sClient{client: clientSet})
if err != nil {
return nil, errors.ErrorWithContext(ctx, errors.ErrNotFound)
}
return &models.MpIntegration{
Email: mpEmail,
}, nil
}
func getMPEmail(ctx context.Context, clientSet K8sClientI) (string, error) {
cm, err := clientSet.getConfigMap(ctx, "default", getMPConfigMapKey(mpConfigMapKey), metav1.GetOptions{})
if err != nil {
return "", err
}
return cm.Data[mpEmail], nil
}
func postMPIntegrationResponse(session *models.Principal, params operator_api.PostMPIntegrationParams) *models.Error {
if true { // This block will be removed once service to register emails is deployed
return &models.Error{Code: 501}
}
clientSet, err := cluster.K8sClient(session.STSSessionToken)
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if err != nil {
return errors.ErrorWithContext(ctx, err)
}
return setMPIntegration(ctx, params.Body.Email, false, &k8sClient{client: clientSet})
}
func patchMPIntegrationResponse(session *models.Principal, params operator_api.PatchMPIntegrationParams) *models.Error {
if true { // This block will be removed once service to register emails is deployed
return &models.Error{Code: 501}
}
clientSet, err := cluster.K8sClient(session.STSSessionToken)
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if err != nil {
return errors.ErrorWithContext(ctx, err)
}
return setMPIntegration(ctx, params.Body.Email, true, &k8sClient{client: clientSet})
}
func setMPIntegration(ctx context.Context, email string, override bool, clientSet K8sClientI) *models.Error {
if email == "" {
return errors.ErrorWithContext(ctx, errors.ErrBadRequest, fmt.Errorf(emailNotSetMsg))
}
if _, err := setMPEmail(ctx, email, override, clientSet); err != nil {
return errors.ErrorWithContext(ctx, err)
}
return nil
}
func setMPEmail(ctx context.Context, email string, override bool, clientSet K8sClientI) (*corev1.ConfigMap, error) {
cm := createCM(email)
if override {
return clientSet.updateConfigMap(ctx, "default", cm, metav1.UpdateOptions{})
}
return clientSet.createConfigMap(ctx, "default", cm, metav1.CreateOptions{})
}
func createCM(email string) *corev1.ConfigMap {
return &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Kind: "ConfigMap",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: getMPConfigMapKey(mpConfigMapKey),
Namespace: "default",
},
Data: map[string]string{mpEmail: email},
}
}
func deleteMPIntegrationResponse(session *models.Principal, params operator_api.DeleteMPIntegrationParams) *models.Error {
if true { // This block will be removed once service to register emails is deployed
return &models.Error{Code: 501}
}
clientSet, err := cluster.K8sClient(session.STSSessionToken)
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if err != nil {
return errors.ErrorWithContext(ctx, err)
}
return deleteMPIntegration(ctx, &k8sClient{client: clientSet})
}
func deleteMPIntegration(ctx context.Context, clientSet K8sClientI) *models.Error {
if err := clientSet.deleteConfigMap(ctx, "default", getMPConfigMapKey(mpConfigMapKey), metav1.DeleteOptions{}); err != nil {
return errors.ErrorWithContext(ctx, err)
}
return nil
}
func getMPConfigMapKey(envVar string) string {
if mp := os.Getenv(envVar); mp != "" {
return mp
}
return mpConfigMapDefault
}

View File

@@ -0,0 +1,225 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package operatorapi
import (
"context"
"errors"
"net/http"
"os"
"testing"
"github.com/minio/console/models"
"github.com/minio/console/operatorapi/operations"
"github.com/minio/console/operatorapi/operations/operator_api"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var (
testWithError = false
errMock = errors.New("mock error")
k8sClientGetConfigMapMock func(ctx context.Context, namespace, configMap string, opts metav1.GetOptions) (*corev1.ConfigMap, error)
k8sClientCreateConfigMapMock func(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.CreateOptions) (*corev1.ConfigMap, error)
k8sClientUpdateConfigMapMock func(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.UpdateOptions) (*corev1.ConfigMap, error)
k8sClientDeleteConfigMapMock func(ctx context.Context, namespace string, name string, opts metav1.DeleteOptions) error
)
type MarketplaceTestSuite struct {
suite.Suite
assert *assert.Assertions
kClient k8sClientMock
namespace string
}
func (c k8sClientMock) getConfigMap(ctx context.Context, namespace, configMap string, opts metav1.GetOptions) (*corev1.ConfigMap, error) {
return k8sClientGetConfigMapMock(ctx, namespace, configMap, opts)
}
func (c k8sClientMock) createConfigMap(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.CreateOptions) (*corev1.ConfigMap, error) {
return k8sClientCreateConfigMapMock(ctx, namespace, cm, opts)
}
func (c k8sClientMock) updateConfigMap(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.UpdateOptions) (*corev1.ConfigMap, error) {
return k8sClientUpdateConfigMapMock(ctx, namespace, cm, opts)
}
func (c k8sClientMock) deleteConfigMap(ctx context.Context, namespace string, name string, opts metav1.DeleteOptions) error {
return k8sClientDeleteConfigMapMock(ctx, namespace, name, opts)
}
func (suite *MarketplaceTestSuite) SetupSuite() {
suite.assert = assert.New(suite.T())
suite.namespace = "default"
k8sClientGetConfigMapMock = suite.getConfigMapMock
k8sClientCreateConfigMapMock = suite.createConfigMapMock
k8sClientUpdateConfigMapMock = suite.updateConfigMapMock
k8sClientDeleteConfigMapMock = suite.deleteConfigMapMock
os.Setenv(mpConfigMapKey, "mp-mock-config")
}
func (suite *MarketplaceTestSuite) TearDownSuite() {
os.Unsetenv(mpConfigMapKey)
}
func (suite *MarketplaceTestSuite) getConfigMapMock(ctx context.Context, namespace, configMap string, opts metav1.GetOptions) (*corev1.ConfigMap, error) {
if testWithError {
return nil, errMock
}
return &corev1.ConfigMap{Data: map[string]string{mpEmail: "mock@mock.com"}}, nil
}
func (suite *MarketplaceTestSuite) createConfigMapMock(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.CreateOptions) (*corev1.ConfigMap, error) {
if testWithError {
return nil, errMock
}
return &corev1.ConfigMap{}, nil
}
func (suite *MarketplaceTestSuite) updateConfigMapMock(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.UpdateOptions) (*corev1.ConfigMap, error) {
if testWithError {
return nil, errMock
}
return &corev1.ConfigMap{}, nil
}
func (suite *MarketplaceTestSuite) deleteConfigMapMock(ctx context.Context, namespace string, name string, opts metav1.DeleteOptions) error {
if testWithError {
return errMock
}
return nil
}
func (suite *MarketplaceTestSuite) TestRegisterMarketplaceHandlers() {
api := &operations.OperatorAPI{}
suite.assert.Nil(api.OperatorAPIGetMPIntegrationHandler)
suite.assert.Nil(api.OperatorAPIPostMPIntegrationHandler)
suite.assert.Nil(api.OperatorAPIPatchMPIntegrationHandler)
suite.assert.Nil(api.OperatorAPIDeleteMPIntegrationHandler)
registerMarketplaceHandlers(api)
suite.assert.NotNil(api.OperatorAPIGetMPIntegrationHandler)
suite.assert.NotNil(api.OperatorAPIPostMPIntegrationHandler)
suite.assert.NotNil(api.OperatorAPIPatchMPIntegrationHandler)
suite.assert.NotNil(api.OperatorAPIDeleteMPIntegrationHandler)
}
// TODO
// WIP - Complete successful tests to RUD handlers
// WIP - Add tests to POST handler
// WIP - Check how to mock k8s objects for tests with no error
func (suite *MarketplaceTestSuite) TestGetMPIntegrationHandlerWithError() {
api := &operations.OperatorAPI{}
registerMarketplaceHandlers(api)
params := operator_api.NewGetMPIntegrationParams()
params.HTTPRequest = &http.Request{}
response := api.OperatorAPIGetMPIntegrationHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.GetMPIntegrationDefault)
suite.assert.True(ok)
}
func (suite *MarketplaceTestSuite) TestPatchMPIntegrationHandlerWithError() {
api := &operations.OperatorAPI{}
registerMarketplaceHandlers(api)
params := operator_api.NewPatchMPIntegrationParams()
params.HTTPRequest = &http.Request{}
params.Body = &models.MpIntegration{Email: "mock@mock.com"}
response := api.OperatorAPIPatchMPIntegrationHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.PatchMPIntegrationDefault)
suite.assert.True(ok)
}
func (suite *MarketplaceTestSuite) TestDeleteMPIntegrationHandlerWithError() {
api := &operations.OperatorAPI{}
registerMarketplaceHandlers(api)
params := operator_api.NewDeleteMPIntegrationParams()
params.HTTPRequest = &http.Request{}
response := api.OperatorAPIDeleteMPIntegrationHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.DeleteMPIntegrationDefault)
suite.assert.True(ok)
}
func (suite *MarketplaceTestSuite) TestGetMPEmailWithError() {
testWithError = true
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
email, err := getMPEmail(ctx, &suite.kClient)
suite.assert.NotNil(err)
suite.assert.Empty(email)
}
func (suite *MarketplaceTestSuite) TestGetMPEmailNoError() {
testWithError = false
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
email, err := getMPEmail(ctx, &suite.kClient)
suite.assert.Nil(err)
suite.assert.NotEmpty(email)
}
func (suite *MarketplaceTestSuite) TestSetMPIntegrationNoEmail() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := setMPIntegration(ctx, "", false, &suite.kClient)
suite.assert.NotNil(err)
}
func (suite *MarketplaceTestSuite) TestSetMPIntegrationWithError() {
testWithError = true
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := setMPIntegration(ctx, "mock@mock.com", false, &suite.kClient)
suite.assert.NotNil(err)
}
func (suite *MarketplaceTestSuite) TestSetMPIntegrationNoError() {
testWithError = false
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := setMPIntegration(ctx, "mock@mock.com", false, &suite.kClient)
suite.assert.Nil(err)
}
func (suite *MarketplaceTestSuite) TestSetMPIntegrationOverrideNoError() {
testWithError = false
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := setMPIntegration(ctx, "mock@mock.com", true, &suite.kClient)
suite.assert.Nil(err)
}
func (suite *MarketplaceTestSuite) TestDeleteMPIntegrationWithError() {
testWithError = true
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := deleteMPIntegration(ctx, &suite.kClient)
suite.assert.NotNil(err)
}
func (suite *MarketplaceTestSuite) TestDeleteMPIntegrationNoError() {
testWithError = false
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := deleteMPIntegration(ctx, &suite.kClient)
suite.assert.Nil(err)
}
func TestMarketplace(t *testing.T) {
suite.Run(t, new(MarketplaceTestSuite))
}

View File

@@ -73,6 +73,9 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
OperatorAPICreateTenantHandler: operator_api.CreateTenantHandlerFunc(func(params operator_api.CreateTenantParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.CreateTenant has not yet been implemented")
}),
OperatorAPIDeleteMPIntegrationHandler: operator_api.DeleteMPIntegrationHandlerFunc(func(params operator_api.DeleteMPIntegrationParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.DeleteMPIntegration has not yet been implemented")
}),
OperatorAPIDeletePVCHandler: operator_api.DeletePVCHandlerFunc(func(params operator_api.DeletePVCParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.DeletePVC has not yet been implemented")
}),
@@ -94,6 +97,9 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
OperatorAPIGetAllocatableResourcesHandler: operator_api.GetAllocatableResourcesHandlerFunc(func(params operator_api.GetAllocatableResourcesParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.GetAllocatableResources has not yet been implemented")
}),
OperatorAPIGetMPIntegrationHandler: operator_api.GetMPIntegrationHandlerFunc(func(params operator_api.GetMPIntegrationParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.GetMPIntegration has not yet been implemented")
}),
OperatorAPIGetMaxAllocatableMemHandler: operator_api.GetMaxAllocatableMemHandlerFunc(func(params operator_api.GetMaxAllocatableMemParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.GetMaxAllocatableMem has not yet been implemented")
}),
@@ -163,6 +169,12 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
AuthLogoutHandler: auth.LogoutHandlerFunc(func(params auth.LogoutParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation auth.Logout has not yet been implemented")
}),
OperatorAPIPatchMPIntegrationHandler: operator_api.PatchMPIntegrationHandlerFunc(func(params operator_api.PatchMPIntegrationParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.PatchMPIntegration has not yet been implemented")
}),
OperatorAPIPostMPIntegrationHandler: operator_api.PostMPIntegrationHandlerFunc(func(params operator_api.PostMPIntegrationParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.PostMPIntegration has not yet been implemented")
}),
OperatorAPIPutTenantYAMLHandler: operator_api.PutTenantYAMLHandlerFunc(func(params operator_api.PutTenantYAMLParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.PutTenantYAML has not yet been implemented")
}),
@@ -281,6 +293,8 @@ type OperatorAPI struct {
OperatorAPICreateNamespaceHandler operator_api.CreateNamespaceHandler
// OperatorAPICreateTenantHandler sets the operation handler for the create tenant operation
OperatorAPICreateTenantHandler operator_api.CreateTenantHandler
// OperatorAPIDeleteMPIntegrationHandler sets the operation handler for the delete m p integration operation
OperatorAPIDeleteMPIntegrationHandler operator_api.DeleteMPIntegrationHandler
// OperatorAPIDeletePVCHandler sets the operation handler for the delete p v c operation
OperatorAPIDeletePVCHandler operator_api.DeletePVCHandler
// OperatorAPIDeletePodHandler sets the operation handler for the delete pod operation
@@ -295,6 +309,8 @@ type OperatorAPI struct {
OperatorAPIEnableTenantLoggingHandler operator_api.EnableTenantLoggingHandler
// OperatorAPIGetAllocatableResourcesHandler sets the operation handler for the get allocatable resources operation
OperatorAPIGetAllocatableResourcesHandler operator_api.GetAllocatableResourcesHandler
// OperatorAPIGetMPIntegrationHandler sets the operation handler for the get m p integration operation
OperatorAPIGetMPIntegrationHandler operator_api.GetMPIntegrationHandler
// OperatorAPIGetMaxAllocatableMemHandler sets the operation handler for the get max allocatable mem operation
OperatorAPIGetMaxAllocatableMemHandler operator_api.GetMaxAllocatableMemHandler
// OperatorAPIGetPVCDescribeHandler sets the operation handler for the get p v c describe operation
@@ -341,6 +357,10 @@ type OperatorAPI struct {
AuthLoginOperatorHandler auth.LoginOperatorHandler
// AuthLogoutHandler sets the operation handler for the logout operation
AuthLogoutHandler auth.LogoutHandler
// OperatorAPIPatchMPIntegrationHandler sets the operation handler for the patch m p integration operation
OperatorAPIPatchMPIntegrationHandler operator_api.PatchMPIntegrationHandler
// OperatorAPIPostMPIntegrationHandler sets the operation handler for the post m p integration operation
OperatorAPIPostMPIntegrationHandler operator_api.PostMPIntegrationHandler
// OperatorAPIPutTenantYAMLHandler sets the operation handler for the put tenant y a m l operation
OperatorAPIPutTenantYAMLHandler operator_api.PutTenantYAMLHandler
// AuthSessionCheckHandler sets the operation handler for the session check operation
@@ -473,6 +493,9 @@ func (o *OperatorAPI) Validate() error {
if o.OperatorAPICreateTenantHandler == nil {
unregistered = append(unregistered, "operator_api.CreateTenantHandler")
}
if o.OperatorAPIDeleteMPIntegrationHandler == nil {
unregistered = append(unregistered, "operator_api.DeleteMPIntegrationHandler")
}
if o.OperatorAPIDeletePVCHandler == nil {
unregistered = append(unregistered, "operator_api.DeletePVCHandler")
}
@@ -494,6 +517,9 @@ func (o *OperatorAPI) Validate() error {
if o.OperatorAPIGetAllocatableResourcesHandler == nil {
unregistered = append(unregistered, "operator_api.GetAllocatableResourcesHandler")
}
if o.OperatorAPIGetMPIntegrationHandler == nil {
unregistered = append(unregistered, "operator_api.GetMPIntegrationHandler")
}
if o.OperatorAPIGetMaxAllocatableMemHandler == nil {
unregistered = append(unregistered, "operator_api.GetMaxAllocatableMemHandler")
}
@@ -563,6 +589,12 @@ func (o *OperatorAPI) Validate() error {
if o.AuthLogoutHandler == nil {
unregistered = append(unregistered, "auth.LogoutHandler")
}
if o.OperatorAPIPatchMPIntegrationHandler == nil {
unregistered = append(unregistered, "operator_api.PatchMPIntegrationHandler")
}
if o.OperatorAPIPostMPIntegrationHandler == nil {
unregistered = append(unregistered, "operator_api.PostMPIntegrationHandler")
}
if o.OperatorAPIPutTenantYAMLHandler == nil {
unregistered = append(unregistered, "operator_api.PutTenantYAMLHandler")
}
@@ -739,6 +771,10 @@ func (o *OperatorAPI) initHandlerCache() {
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
}
o.handlers["DELETE"]["/mp-integration"] = operator_api.NewDeleteMPIntegration(o.context, o.OperatorAPIDeleteMPIntegrationHandler)
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
}
o.handlers["DELETE"]["/namespaces/{namespace}/tenants/{tenant}/pvc/{PVCName}"] = operator_api.NewDeletePVC(o.context, o.OperatorAPIDeletePVCHandler)
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)
@@ -767,6 +803,10 @@ func (o *OperatorAPI) initHandlerCache() {
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/mp-integration"] = operator_api.NewGetMPIntegration(o.context, o.OperatorAPIGetMPIntegrationHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/cluster/max-allocatable-memory"] = operator_api.NewGetMaxAllocatableMem(o.context, o.OperatorAPIGetMaxAllocatableMemHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
@@ -856,6 +896,14 @@ func (o *OperatorAPI) initHandlerCache() {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/logout"] = auth.NewLogout(o.context, o.AuthLogoutHandler)
if o.handlers["PATCH"] == nil {
o.handlers["PATCH"] = make(map[string]http.Handler)
}
o.handlers["PATCH"]["/mp-integration"] = operator_api.NewPatchMPIntegration(o.context, o.OperatorAPIPatchMPIntegrationHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/mp-integration"] = operator_api.NewPostMPIntegration(o.context, o.OperatorAPIPostMPIntegrationHandler)
if o.handlers["PUT"] == nil {
o.handlers["PUT"] = make(map[string]http.Handler)
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// DeleteMPIntegrationHandlerFunc turns a function with the right signature into a delete m p integration handler
type DeleteMPIntegrationHandlerFunc func(DeleteMPIntegrationParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn DeleteMPIntegrationHandlerFunc) Handle(params DeleteMPIntegrationParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// DeleteMPIntegrationHandler interface for that can handle valid delete m p integration params
type DeleteMPIntegrationHandler interface {
Handle(DeleteMPIntegrationParams, *models.Principal) middleware.Responder
}
// NewDeleteMPIntegration creates a new http.Handler for the delete m p integration operation
func NewDeleteMPIntegration(ctx *middleware.Context, handler DeleteMPIntegrationHandler) *DeleteMPIntegration {
return &DeleteMPIntegration{Context: ctx, Handler: handler}
}
/* DeleteMPIntegration swagger:route DELETE /mp-integration OperatorAPI deleteMPIntegration
Delete email registered for marketplace integration
*/
type DeleteMPIntegration struct {
Context *middleware.Context
Handler DeleteMPIntegrationHandler
}
func (o *DeleteMPIntegration) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewDeleteMPIntegrationParams()
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)
}

View File

@@ -0,0 +1,63 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// NewDeleteMPIntegrationParams creates a new DeleteMPIntegrationParams object
//
// There are no default values defined in the spec.
func NewDeleteMPIntegrationParams() DeleteMPIntegrationParams {
return DeleteMPIntegrationParams{}
}
// DeleteMPIntegrationParams contains all the bound params for the delete m p integration operation
// typically these are obtained from a http.Request
//
// swagger:parameters DeleteMPIntegration
type DeleteMPIntegrationParams 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 NewDeleteMPIntegrationParams() beforehand.
func (o *DeleteMPIntegrationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -0,0 +1,113 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// DeleteMPIntegrationNoContentCode is the HTTP code returned for type DeleteMPIntegrationNoContent
const DeleteMPIntegrationNoContentCode int = 204
/*DeleteMPIntegrationNoContent A successful response.
swagger:response deleteMPIntegrationNoContent
*/
type DeleteMPIntegrationNoContent struct {
}
// NewDeleteMPIntegrationNoContent creates DeleteMPIntegrationNoContent with default headers values
func NewDeleteMPIntegrationNoContent() *DeleteMPIntegrationNoContent {
return &DeleteMPIntegrationNoContent{}
}
// WriteResponse to the client
func (o *DeleteMPIntegrationNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(204)
}
/*DeleteMPIntegrationDefault Generic error response.
swagger:response deleteMPIntegrationDefault
*/
type DeleteMPIntegrationDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewDeleteMPIntegrationDefault creates DeleteMPIntegrationDefault with default headers values
func NewDeleteMPIntegrationDefault(code int) *DeleteMPIntegrationDefault {
if code <= 0 {
code = 500
}
return &DeleteMPIntegrationDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the delete m p integration default response
func (o *DeleteMPIntegrationDefault) WithStatusCode(code int) *DeleteMPIntegrationDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the delete m p integration default response
func (o *DeleteMPIntegrationDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the delete m p integration default response
func (o *DeleteMPIntegrationDefault) WithPayload(payload *models.Error) *DeleteMPIntegrationDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the delete m p integration default response
func (o *DeleteMPIntegrationDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *DeleteMPIntegrationDefault) 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
}
}
}

View File

@@ -0,0 +1,104 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// DeleteMPIntegrationURL generates an URL for the delete m p integration operation
type DeleteMPIntegrationURL 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 *DeleteMPIntegrationURL) WithBasePath(bp string) *DeleteMPIntegrationURL {
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 *DeleteMPIntegrationURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *DeleteMPIntegrationURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/mp-integration"
_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 *DeleteMPIntegrationURL) 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 *DeleteMPIntegrationURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *DeleteMPIntegrationURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on DeleteMPIntegrationURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on DeleteMPIntegrationURL")
}
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 *DeleteMPIntegrationURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// GetMPIntegrationHandlerFunc turns a function with the right signature into a get m p integration handler
type GetMPIntegrationHandlerFunc func(GetMPIntegrationParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn GetMPIntegrationHandlerFunc) Handle(params GetMPIntegrationParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// GetMPIntegrationHandler interface for that can handle valid get m p integration params
type GetMPIntegrationHandler interface {
Handle(GetMPIntegrationParams, *models.Principal) middleware.Responder
}
// NewGetMPIntegration creates a new http.Handler for the get m p integration operation
func NewGetMPIntegration(ctx *middleware.Context, handler GetMPIntegrationHandler) *GetMPIntegration {
return &GetMPIntegration{Context: ctx, Handler: handler}
}
/* GetMPIntegration swagger:route GET /mp-integration OperatorAPI getMPIntegration
Returns email registered for marketplace integration
*/
type GetMPIntegration struct {
Context *middleware.Context
Handler GetMPIntegrationHandler
}
func (o *GetMPIntegration) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewGetMPIntegrationParams()
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)
}

View File

@@ -0,0 +1,63 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// NewGetMPIntegrationParams creates a new GetMPIntegrationParams object
//
// There are no default values defined in the spec.
func NewGetMPIntegrationParams() GetMPIntegrationParams {
return GetMPIntegrationParams{}
}
// GetMPIntegrationParams contains all the bound params for the get m p integration operation
// typically these are obtained from a http.Request
//
// swagger:parameters GetMPIntegration
type GetMPIntegrationParams 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 NewGetMPIntegrationParams() beforehand.
func (o *GetMPIntegrationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// GetMPIntegrationOKCode is the HTTP code returned for type GetMPIntegrationOK
const GetMPIntegrationOKCode int = 200
/*GetMPIntegrationOK A successful response.
swagger:response getMPIntegrationOK
*/
type GetMPIntegrationOK struct {
/*
In: Body
*/
Payload *models.MpIntegration `json:"body,omitempty"`
}
// NewGetMPIntegrationOK creates GetMPIntegrationOK with default headers values
func NewGetMPIntegrationOK() *GetMPIntegrationOK {
return &GetMPIntegrationOK{}
}
// WithPayload adds the payload to the get m p integration o k response
func (o *GetMPIntegrationOK) WithPayload(payload *models.MpIntegration) *GetMPIntegrationOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the get m p integration o k response
func (o *GetMPIntegrationOK) SetPayload(payload *models.MpIntegration) {
o.Payload = payload
}
// WriteResponse to the client
func (o *GetMPIntegrationOK) 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
}
}
}
/*GetMPIntegrationDefault Generic error response.
swagger:response getMPIntegrationDefault
*/
type GetMPIntegrationDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewGetMPIntegrationDefault creates GetMPIntegrationDefault with default headers values
func NewGetMPIntegrationDefault(code int) *GetMPIntegrationDefault {
if code <= 0 {
code = 500
}
return &GetMPIntegrationDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the get m p integration default response
func (o *GetMPIntegrationDefault) WithStatusCode(code int) *GetMPIntegrationDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the get m p integration default response
func (o *GetMPIntegrationDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the get m p integration default response
func (o *GetMPIntegrationDefault) WithPayload(payload *models.Error) *GetMPIntegrationDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the get m p integration default response
func (o *GetMPIntegrationDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *GetMPIntegrationDefault) 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
}
}
}

View File

@@ -0,0 +1,104 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// GetMPIntegrationURL generates an URL for the get m p integration operation
type GetMPIntegrationURL 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 *GetMPIntegrationURL) WithBasePath(bp string) *GetMPIntegrationURL {
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 *GetMPIntegrationURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *GetMPIntegrationURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/mp-integration"
_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 *GetMPIntegrationURL) 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 *GetMPIntegrationURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *GetMPIntegrationURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on GetMPIntegrationURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on GetMPIntegrationURL")
}
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 *GetMPIntegrationURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// PatchMPIntegrationHandlerFunc turns a function with the right signature into a patch m p integration handler
type PatchMPIntegrationHandlerFunc func(PatchMPIntegrationParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn PatchMPIntegrationHandlerFunc) Handle(params PatchMPIntegrationParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// PatchMPIntegrationHandler interface for that can handle valid patch m p integration params
type PatchMPIntegrationHandler interface {
Handle(PatchMPIntegrationParams, *models.Principal) middleware.Responder
}
// NewPatchMPIntegration creates a new http.Handler for the patch m p integration operation
func NewPatchMPIntegration(ctx *middleware.Context, handler PatchMPIntegrationHandler) *PatchMPIntegration {
return &PatchMPIntegration{Context: ctx, Handler: handler}
}
/* PatchMPIntegration swagger:route PATCH /mp-integration OperatorAPI patchMPIntegration
Update email registered for marketplace integration
*/
type PatchMPIntegration struct {
Context *middleware.Context
Handler PatchMPIntegrationHandler
}
func (o *PatchMPIntegration) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewPatchMPIntegrationParams()
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)
}

View File

@@ -0,0 +1,102 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/validate"
"github.com/minio/console/models"
)
// NewPatchMPIntegrationParams creates a new PatchMPIntegrationParams object
//
// There are no default values defined in the spec.
func NewPatchMPIntegrationParams() PatchMPIntegrationParams {
return PatchMPIntegrationParams{}
}
// PatchMPIntegrationParams contains all the bound params for the patch m p integration operation
// typically these are obtained from a http.Request
//
// swagger:parameters PatchMPIntegration
type PatchMPIntegrationParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: body
*/
Body *models.MpIntegration
}
// 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 NewPatchMPIntegrationParams() beforehand.
func (o *PatchMPIntegrationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body models.MpIntegration
if err := route.Consumer.Consume(r.Body, &body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("body", "body", ""))
} else {
res = append(res, errors.NewParseError("body", "body", "", err))
}
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
} else {
res = append(res, errors.Required("body", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -0,0 +1,113 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// PatchMPIntegrationOKCode is the HTTP code returned for type PatchMPIntegrationOK
const PatchMPIntegrationOKCode int = 200
/*PatchMPIntegrationOK A successful response.
swagger:response patchMPIntegrationOK
*/
type PatchMPIntegrationOK struct {
}
// NewPatchMPIntegrationOK creates PatchMPIntegrationOK with default headers values
func NewPatchMPIntegrationOK() *PatchMPIntegrationOK {
return &PatchMPIntegrationOK{}
}
// WriteResponse to the client
func (o *PatchMPIntegrationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(200)
}
/*PatchMPIntegrationDefault Generic error response.
swagger:response patchMPIntegrationDefault
*/
type PatchMPIntegrationDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewPatchMPIntegrationDefault creates PatchMPIntegrationDefault with default headers values
func NewPatchMPIntegrationDefault(code int) *PatchMPIntegrationDefault {
if code <= 0 {
code = 500
}
return &PatchMPIntegrationDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the patch m p integration default response
func (o *PatchMPIntegrationDefault) WithStatusCode(code int) *PatchMPIntegrationDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the patch m p integration default response
func (o *PatchMPIntegrationDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the patch m p integration default response
func (o *PatchMPIntegrationDefault) WithPayload(payload *models.Error) *PatchMPIntegrationDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the patch m p integration default response
func (o *PatchMPIntegrationDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *PatchMPIntegrationDefault) 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
}
}
}

View File

@@ -0,0 +1,104 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// PatchMPIntegrationURL generates an URL for the patch m p integration operation
type PatchMPIntegrationURL 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 *PatchMPIntegrationURL) WithBasePath(bp string) *PatchMPIntegrationURL {
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 *PatchMPIntegrationURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *PatchMPIntegrationURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/mp-integration"
_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 *PatchMPIntegrationURL) 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 *PatchMPIntegrationURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *PatchMPIntegrationURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on PatchMPIntegrationURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on PatchMPIntegrationURL")
}
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 *PatchMPIntegrationURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// PostMPIntegrationHandlerFunc turns a function with the right signature into a post m p integration handler
type PostMPIntegrationHandlerFunc func(PostMPIntegrationParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn PostMPIntegrationHandlerFunc) Handle(params PostMPIntegrationParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// PostMPIntegrationHandler interface for that can handle valid post m p integration params
type PostMPIntegrationHandler interface {
Handle(PostMPIntegrationParams, *models.Principal) middleware.Responder
}
// NewPostMPIntegration creates a new http.Handler for the post m p integration operation
func NewPostMPIntegration(ctx *middleware.Context, handler PostMPIntegrationHandler) *PostMPIntegration {
return &PostMPIntegration{Context: ctx, Handler: handler}
}
/* PostMPIntegration swagger:route POST /mp-integration OperatorAPI postMPIntegration
Set email to register for marketplace integration
*/
type PostMPIntegration struct {
Context *middleware.Context
Handler PostMPIntegrationHandler
}
func (o *PostMPIntegration) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewPostMPIntegrationParams()
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)
}

View File

@@ -0,0 +1,102 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/validate"
"github.com/minio/console/models"
)
// NewPostMPIntegrationParams creates a new PostMPIntegrationParams object
//
// There are no default values defined in the spec.
func NewPostMPIntegrationParams() PostMPIntegrationParams {
return PostMPIntegrationParams{}
}
// PostMPIntegrationParams contains all the bound params for the post m p integration operation
// typically these are obtained from a http.Request
//
// swagger:parameters PostMPIntegration
type PostMPIntegrationParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: body
*/
Body *models.MpIntegration
}
// 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 NewPostMPIntegrationParams() beforehand.
func (o *PostMPIntegrationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body models.MpIntegration
if err := route.Consumer.Consume(r.Body, &body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("body", "body", ""))
} else {
res = append(res, errors.NewParseError("body", "body", "", err))
}
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
} else {
res = append(res, errors.Required("body", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -0,0 +1,113 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// PostMPIntegrationCreatedCode is the HTTP code returned for type PostMPIntegrationCreated
const PostMPIntegrationCreatedCode int = 201
/*PostMPIntegrationCreated A successful response.
swagger:response postMPIntegrationCreated
*/
type PostMPIntegrationCreated struct {
}
// NewPostMPIntegrationCreated creates PostMPIntegrationCreated with default headers values
func NewPostMPIntegrationCreated() *PostMPIntegrationCreated {
return &PostMPIntegrationCreated{}
}
// WriteResponse to the client
func (o *PostMPIntegrationCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(201)
}
/*PostMPIntegrationDefault Generic error response.
swagger:response postMPIntegrationDefault
*/
type PostMPIntegrationDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewPostMPIntegrationDefault creates PostMPIntegrationDefault with default headers values
func NewPostMPIntegrationDefault(code int) *PostMPIntegrationDefault {
if code <= 0 {
code = 500
}
return &PostMPIntegrationDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the post m p integration default response
func (o *PostMPIntegrationDefault) WithStatusCode(code int) *PostMPIntegrationDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the post m p integration default response
func (o *PostMPIntegrationDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the post m p integration default response
func (o *PostMPIntegrationDefault) WithPayload(payload *models.Error) *PostMPIntegrationDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the post m p integration default response
func (o *PostMPIntegrationDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *PostMPIntegrationDefault) 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
}
}
}

View File

@@ -0,0 +1,104 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_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"
)
// PostMPIntegrationURL generates an URL for the post m p integration operation
type PostMPIntegrationURL 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 *PostMPIntegrationURL) WithBasePath(bp string) *PostMPIntegrationURL {
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 *PostMPIntegrationURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *PostMPIntegrationURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/mp-integration"
_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 *PostMPIntegrationURL) 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 *PostMPIntegrationURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *PostMPIntegrationURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on PostMPIntegrationURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on PostMPIntegrationURL")
}
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 *PostMPIntegrationURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -30,6 +30,7 @@ var (
ErrDefault = errors.New("an error occurred, please try again")
ErrInvalidLogin = errors.New("invalid Login")
ErrForbidden = errors.New("403 Forbidden")
ErrBadRequest = errors.New("400 Bad Request")
ErrFileTooLarge = errors.New("413 File too Large")
ErrInvalidSession = errors.New("invalid session")
ErrNotFound = errors.New("not found")
@@ -81,6 +82,9 @@ func ErrorWithContext(ctx context.Context, err ...interface{}) *models.Error {
if err1.Error() == ErrForbidden.Error() {
errorCode = 403
}
if err1.Error() == ErrBadRequest.Error() {
errorCode = 400
}
if err1 == ErrNotFound {
errorCode = 404
errorMessage = ErrNotFound.Error()

View File

@@ -1232,6 +1232,70 @@ paths:
tags:
- OperatorAPI
/mp-integration:
get:
summary: Returns email registered for marketplace integration
operationId: GetMPIntegration
responses:
200:
description: A successful response.
schema:
$ref: "#/definitions/mpIntegration"
default:
description: Generic error response.
schema:
$ref: "#/definitions/error"
tags:
- OperatorAPI
delete:
summary: Delete email registered for marketplace integration
operationId: DeleteMPIntegration
responses:
204:
description: A successful response.
default:
description: Generic error response.
schema:
$ref: "#/definitions/error"
tags:
- OperatorAPI
post:
summary: Set email to register for marketplace integration
operationId: PostMPIntegration
parameters:
- name: body
in: body
required: true
schema:
$ref: "#/definitions/mpIntegration"
responses:
201:
description: A successful response.
default:
description: Generic error response.
schema:
$ref: "#/definitions/error"
tags:
- OperatorAPI
patch:
summary: Update email registered for marketplace integration
operationId: PatchMPIntegration
parameters:
- name: body
in: body
required: true
schema:
$ref: "#/definitions/mpIntegration"
responses:
200:
description: A successful response.
default:
description: Generic error response.
schema:
$ref: "#/definitions/error"
tags:
- OperatorAPI
/namespaces/{namespace}/tenants/{tenant}/pvc/{PVCName}:
delete:
summary: Delete PVC
@@ -3346,3 +3410,10 @@ definitions:
properties:
domains:
$ref: "#/definitions/domainsConfiguration"
mpIntegration:
type: object
properties:
email:
type: string