diff --git a/models/operator_subnet_api_key.go b/models/operator_subnet_api_key.go new file mode 100644 index 000000000..28f67bb56 --- /dev/null +++ b/models/operator_subnet_api_key.go @@ -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 . +// + +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" +) + +// OperatorSubnetAPIKey operator subnet API key +// +// swagger:model operatorSubnetAPIKey +type OperatorSubnetAPIKey struct { + + // api key + APIKey string `json:"apiKey,omitempty"` +} + +// Validate validates this operator subnet API key +func (m *OperatorSubnetAPIKey) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this operator subnet API key based on context it is used +func (m *OperatorSubnetAPIKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OperatorSubnetAPIKey) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OperatorSubnetAPIKey) UnmarshalBinary(b []byte) error { + var res OperatorSubnetAPIKey + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/operator_subnet_login_m_f_a_request.go b/models/operator_subnet_login_m_f_a_request.go new file mode 100644 index 000000000..c72fb382d --- /dev/null +++ b/models/operator_subnet_login_m_f_a_request.go @@ -0,0 +1,122 @@ +// 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 . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// OperatorSubnetLoginMFARequest operator subnet login m f a request +// +// swagger:model operatorSubnetLoginMFARequest +type OperatorSubnetLoginMFARequest struct { + + // mfa token + // Required: true + MfaToken *string `json:"mfa_token"` + + // otp + // Required: true + Otp *string `json:"otp"` + + // username + // Required: true + Username *string `json:"username"` +} + +// Validate validates this operator subnet login m f a request +func (m *OperatorSubnetLoginMFARequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateMfaToken(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOtp(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsername(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OperatorSubnetLoginMFARequest) validateMfaToken(formats strfmt.Registry) error { + + if err := validate.Required("mfa_token", "body", m.MfaToken); err != nil { + return err + } + + return nil +} + +func (m *OperatorSubnetLoginMFARequest) validateOtp(formats strfmt.Registry) error { + + if err := validate.Required("otp", "body", m.Otp); err != nil { + return err + } + + return nil +} + +func (m *OperatorSubnetLoginMFARequest) validateUsername(formats strfmt.Registry) error { + + if err := validate.Required("username", "body", m.Username); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this operator subnet login m f a request based on context it is used +func (m *OperatorSubnetLoginMFARequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OperatorSubnetLoginMFARequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OperatorSubnetLoginMFARequest) UnmarshalBinary(b []byte) error { + var res OperatorSubnetLoginMFARequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/operator_subnet_login_request.go b/models/operator_subnet_login_request.go new file mode 100644 index 000000000..342c79982 --- /dev/null +++ b/models/operator_subnet_login_request.go @@ -0,0 +1,70 @@ +// 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 . +// + +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" +) + +// OperatorSubnetLoginRequest operator subnet login request +// +// swagger:model operatorSubnetLoginRequest +type OperatorSubnetLoginRequest struct { + + // password + Password string `json:"password,omitempty"` + + // username + Username string `json:"username,omitempty"` +} + +// Validate validates this operator subnet login request +func (m *OperatorSubnetLoginRequest) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this operator subnet login request based on context it is used +func (m *OperatorSubnetLoginRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OperatorSubnetLoginRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OperatorSubnetLoginRequest) UnmarshalBinary(b []byte) error { + var res OperatorSubnetLoginRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/operator_subnet_login_response.go b/models/operator_subnet_login_response.go new file mode 100644 index 000000000..e3aa72939 --- /dev/null +++ b/models/operator_subnet_login_response.go @@ -0,0 +1,70 @@ +// 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 . +// + +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" +) + +// OperatorSubnetLoginResponse operator subnet login response +// +// swagger:model operatorSubnetLoginResponse +type OperatorSubnetLoginResponse struct { + + // access token + AccessToken string `json:"access_token,omitempty"` + + // mfa token + MfaToken string `json:"mfa_token,omitempty"` +} + +// Validate validates this operator subnet login response +func (m *OperatorSubnetLoginResponse) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this operator subnet login response based on context it is used +func (m *OperatorSubnetLoginResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OperatorSubnetLoginResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OperatorSubnetLoginResponse) UnmarshalBinary(b []byte) error { + var res OperatorSubnetLoginResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/operatorapi/configure_operator.go b/operatorapi/configure_operator.go index 1cbe36405..52a532281 100644 --- a/operatorapi/configure_operator.go +++ b/operatorapi/configure_operator.go @@ -90,6 +90,7 @@ func configureAPI(api *operations.OperatorAPI) http.Handler { // Namespaces handlers registerNamespaceHandlers(api) registerMarketplaceHandlers(api) + registerOperatorSubnetHandlers(api) api.PreServerShutdown = func() {} diff --git a/operatorapi/embedded_spec.go b/operatorapi/embedded_spec.go index 4eced0d80..a7d783410 100644 --- a/operatorapi/embedded_spec.go +++ b/operatorapi/embedded_spec.go @@ -1906,6 +1906,133 @@ func init() { } } }, + "/subnet/apikey": { + "get": { + "tags": [ + "OperatorAPI" + ], + "summary": "Subnet api key", + "operationId": "OperatorSubnetApiKey", + "parameters": [ + { + "type": "string", + "name": "token", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/operatorSubnetAPIKey" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, + "/subnet/apikey/register": { + "post": { + "tags": [ + "OperatorAPI" + ], + "summary": "Register Operator with Subnet", + "operationId": "OperatorSubnetRegisterAPIKey", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/operatorSubnetAPIKey" + } + } + ], + "responses": { + "200": { + "description": "A successful response." + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, + "/subnet/login": { + "post": { + "tags": [ + "OperatorAPI" + ], + "summary": "Login to subnet", + "operationId": "OperatorSubnetLogin", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/operatorSubnetLoginRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/operatorSubnetLoginResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, + "/subnet/login/mfa": { + "post": { + "tags": [ + "OperatorAPI" + ], + "summary": "Login to subnet using mfa", + "operationId": "OperatorSubnetLoginMFA", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/operatorSubnetLoginMFARequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/operatorSubnetLoginResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/subscription/info": { "get": { "tags": [ @@ -3547,6 +3674,55 @@ func init() { } } }, + "operatorSubnetAPIKey": { + "type": "object", + "properties": { + "apiKey": { + "type": "string" + } + } + }, + "operatorSubnetLoginMFARequest": { + "type": "object", + "required": [ + "username", + "otp", + "mfa_token" + ], + "properties": { + "mfa_token": { + "type": "string" + }, + "otp": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "operatorSubnetLoginRequest": { + "type": "object", + "properties": { + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "operatorSubnetLoginResponse": { + "type": "object", + "properties": { + "access_token": { + "type": "string" + }, + "mfa_token": { + "type": "string" + } + } + }, "parityResponse": { "type": "array", "items": { @@ -6658,6 +6834,133 @@ func init() { } } }, + "/subnet/apikey": { + "get": { + "tags": [ + "OperatorAPI" + ], + "summary": "Subnet api key", + "operationId": "OperatorSubnetApiKey", + "parameters": [ + { + "type": "string", + "name": "token", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/operatorSubnetAPIKey" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, + "/subnet/apikey/register": { + "post": { + "tags": [ + "OperatorAPI" + ], + "summary": "Register Operator with Subnet", + "operationId": "OperatorSubnetRegisterAPIKey", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/operatorSubnetAPIKey" + } + } + ], + "responses": { + "200": { + "description": "A successful response." + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, + "/subnet/login": { + "post": { + "tags": [ + "OperatorAPI" + ], + "summary": "Login to subnet", + "operationId": "OperatorSubnetLogin", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/operatorSubnetLoginRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/operatorSubnetLoginResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, + "/subnet/login/mfa": { + "post": { + "tags": [ + "OperatorAPI" + ], + "summary": "Login to subnet using mfa", + "operationId": "OperatorSubnetLoginMFA", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/operatorSubnetLoginMFARequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/operatorSubnetLoginResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/subscription/info": { "get": { "tags": [ @@ -9086,6 +9389,55 @@ func init() { } } }, + "operatorSubnetAPIKey": { + "type": "object", + "properties": { + "apiKey": { + "type": "string" + } + } + }, + "operatorSubnetLoginMFARequest": { + "type": "object", + "required": [ + "username", + "otp", + "mfa_token" + ], + "properties": { + "mfa_token": { + "type": "string" + }, + "otp": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "operatorSubnetLoginRequest": { + "type": "object", + "properties": { + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "operatorSubnetLoginResponse": { + "type": "object", + "properties": { + "access_token": { + "type": "string" + }, + "mfa_token": { + "type": "string" + } + } + }, "parityResponse": { "type": "array", "items": { diff --git a/operatorapi/operations/operator_api.go b/operatorapi/operations/operator_api.go index 059dada6b..233024448 100644 --- a/operatorapi/operations/operator_api.go +++ b/operatorapi/operations/operator_api.go @@ -166,6 +166,18 @@ 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") }), + OperatorAPIOperatorSubnetAPIKeyHandler: operator_api.OperatorSubnetAPIKeyHandlerFunc(func(params operator_api.OperatorSubnetAPIKeyParams, principal *models.Principal) middleware.Responder { + return middleware.NotImplemented("operation operator_api.OperatorSubnetAPIKey has not yet been implemented") + }), + OperatorAPIOperatorSubnetLoginHandler: operator_api.OperatorSubnetLoginHandlerFunc(func(params operator_api.OperatorSubnetLoginParams, principal *models.Principal) middleware.Responder { + return middleware.NotImplemented("operation operator_api.OperatorSubnetLogin has not yet been implemented") + }), + OperatorAPIOperatorSubnetLoginMFAHandler: operator_api.OperatorSubnetLoginMFAHandlerFunc(func(params operator_api.OperatorSubnetLoginMFAParams, principal *models.Principal) middleware.Responder { + return middleware.NotImplemented("operation operator_api.OperatorSubnetLoginMFA has not yet been implemented") + }), + OperatorAPIOperatorSubnetRegisterAPIKeyHandler: operator_api.OperatorSubnetRegisterAPIKeyHandlerFunc(func(params operator_api.OperatorSubnetRegisterAPIKeyParams, principal *models.Principal) middleware.Responder { + return middleware.NotImplemented("operation operator_api.OperatorSubnetRegisterAPIKey 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") }), @@ -352,6 +364,14 @@ type OperatorAPI struct { AuthLoginOperatorHandler auth.LoginOperatorHandler // AuthLogoutHandler sets the operation handler for the logout operation AuthLogoutHandler auth.LogoutHandler + // OperatorAPIOperatorSubnetAPIKeyHandler sets the operation handler for the operator subnet Api key operation + OperatorAPIOperatorSubnetAPIKeyHandler operator_api.OperatorSubnetAPIKeyHandler + // OperatorAPIOperatorSubnetLoginHandler sets the operation handler for the operator subnet login operation + OperatorAPIOperatorSubnetLoginHandler operator_api.OperatorSubnetLoginHandler + // OperatorAPIOperatorSubnetLoginMFAHandler sets the operation handler for the operator subnet login m f a operation + OperatorAPIOperatorSubnetLoginMFAHandler operator_api.OperatorSubnetLoginMFAHandler + // OperatorAPIOperatorSubnetRegisterAPIKeyHandler sets the operation handler for the operator subnet register API key operation + OperatorAPIOperatorSubnetRegisterAPIKeyHandler operator_api.OperatorSubnetRegisterAPIKeyHandler // 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 @@ -581,6 +601,18 @@ func (o *OperatorAPI) Validate() error { if o.AuthLogoutHandler == nil { unregistered = append(unregistered, "auth.LogoutHandler") } + if o.OperatorAPIOperatorSubnetAPIKeyHandler == nil { + unregistered = append(unregistered, "operator_api.OperatorSubnetAPIKeyHandler") + } + if o.OperatorAPIOperatorSubnetLoginHandler == nil { + unregistered = append(unregistered, "operator_api.OperatorSubnetLoginHandler") + } + if o.OperatorAPIOperatorSubnetLoginMFAHandler == nil { + unregistered = append(unregistered, "operator_api.OperatorSubnetLoginMFAHandler") + } + if o.OperatorAPIOperatorSubnetRegisterAPIKeyHandler == nil { + unregistered = append(unregistered, "operator_api.OperatorSubnetRegisterAPIKeyHandler") + } if o.OperatorAPIPostMPIntegrationHandler == nil { unregistered = append(unregistered, "operator_api.PostMPIntegrationHandler") } @@ -884,6 +916,22 @@ 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["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/subnet/apikey"] = operator_api.NewOperatorSubnetAPIKey(o.context, o.OperatorAPIOperatorSubnetAPIKeyHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/subnet/login"] = operator_api.NewOperatorSubnetLogin(o.context, o.OperatorAPIOperatorSubnetLoginHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/subnet/login/mfa"] = operator_api.NewOperatorSubnetLoginMFA(o.context, o.OperatorAPIOperatorSubnetLoginMFAHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/subnet/apikey/register"] = operator_api.NewOperatorSubnetRegisterAPIKey(o.context, o.OperatorAPIOperatorSubnetRegisterAPIKeyHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } diff --git a/operatorapi/operations/operator_api/operator_subnet_api_key.go b/operatorapi/operations/operator_api/operator_subnet_api_key.go new file mode 100644 index 000000000..44ddeb803 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_api_key.go @@ -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 . +// + +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" +) + +// OperatorSubnetAPIKeyHandlerFunc turns a function with the right signature into a operator subnet Api key handler +type OperatorSubnetAPIKeyHandlerFunc func(OperatorSubnetAPIKeyParams, *models.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn OperatorSubnetAPIKeyHandlerFunc) Handle(params OperatorSubnetAPIKeyParams, principal *models.Principal) middleware.Responder { + return fn(params, principal) +} + +// OperatorSubnetAPIKeyHandler interface for that can handle valid operator subnet Api key params +type OperatorSubnetAPIKeyHandler interface { + Handle(OperatorSubnetAPIKeyParams, *models.Principal) middleware.Responder +} + +// NewOperatorSubnetAPIKey creates a new http.Handler for the operator subnet Api key operation +func NewOperatorSubnetAPIKey(ctx *middleware.Context, handler OperatorSubnetAPIKeyHandler) *OperatorSubnetAPIKey { + return &OperatorSubnetAPIKey{Context: ctx, Handler: handler} +} + +/* OperatorSubnetAPIKey swagger:route GET /subnet/apikey OperatorAPI operatorSubnetApiKey + +Subnet api key + +*/ +type OperatorSubnetAPIKey struct { + Context *middleware.Context + Handler OperatorSubnetAPIKeyHandler +} + +func (o *OperatorSubnetAPIKey) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewOperatorSubnetAPIKeyParams() + 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) + +} diff --git a/operatorapi/operations/operator_api/operator_subnet_api_key_parameters.go b/operatorapi/operations/operator_api/operator_subnet_api_key_parameters.go new file mode 100644 index 000000000..7b90e042b --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_api_key_parameters.go @@ -0,0 +1,99 @@ +// 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 . +// + +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" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewOperatorSubnetAPIKeyParams creates a new OperatorSubnetAPIKeyParams object +// +// There are no default values defined in the spec. +func NewOperatorSubnetAPIKeyParams() OperatorSubnetAPIKeyParams { + + return OperatorSubnetAPIKeyParams{} +} + +// OperatorSubnetAPIKeyParams contains all the bound params for the operator subnet Api key operation +// typically these are obtained from a http.Request +// +// swagger:parameters OperatorSubnetApiKey +type OperatorSubnetAPIKeyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: query + */ + Token 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 NewOperatorSubnetAPIKeyParams() beforehand. +func (o *OperatorSubnetAPIKeyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qToken, qhkToken, _ := qs.GetOK("token") + if err := o.bindToken(qToken, qhkToken, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindToken binds and validates parameter Token from query. +func (o *OperatorSubnetAPIKeyParams) bindToken(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("token", "query", rawData) + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // AllowEmptyValue: false + + if err := validate.RequiredString("token", "query", raw); err != nil { + return err + } + o.Token = raw + + return nil +} diff --git a/operatorapi/operations/operator_api/operator_subnet_api_key_responses.go b/operatorapi/operations/operator_api/operator_subnet_api_key_responses.go new file mode 100644 index 000000000..e86054e17 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_api_key_responses.go @@ -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 . +// + +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" +) + +// OperatorSubnetAPIKeyOKCode is the HTTP code returned for type OperatorSubnetAPIKeyOK +const OperatorSubnetAPIKeyOKCode int = 200 + +/*OperatorSubnetAPIKeyOK A successful response. + +swagger:response operatorSubnetApiKeyOK +*/ +type OperatorSubnetAPIKeyOK struct { + + /* + In: Body + */ + Payload *models.OperatorSubnetAPIKey `json:"body,omitempty"` +} + +// NewOperatorSubnetAPIKeyOK creates OperatorSubnetAPIKeyOK with default headers values +func NewOperatorSubnetAPIKeyOK() *OperatorSubnetAPIKeyOK { + + return &OperatorSubnetAPIKeyOK{} +} + +// WithPayload adds the payload to the operator subnet Api key o k response +func (o *OperatorSubnetAPIKeyOK) WithPayload(payload *models.OperatorSubnetAPIKey) *OperatorSubnetAPIKeyOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operator subnet Api key o k response +func (o *OperatorSubnetAPIKeyOK) SetPayload(payload *models.OperatorSubnetAPIKey) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperatorSubnetAPIKeyOK) 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 + } + } +} + +/*OperatorSubnetAPIKeyDefault Generic error response. + +swagger:response operatorSubnetApiKeyDefault +*/ +type OperatorSubnetAPIKeyDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewOperatorSubnetAPIKeyDefault creates OperatorSubnetAPIKeyDefault with default headers values +func NewOperatorSubnetAPIKeyDefault(code int) *OperatorSubnetAPIKeyDefault { + if code <= 0 { + code = 500 + } + + return &OperatorSubnetAPIKeyDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the operator subnet Api key default response +func (o *OperatorSubnetAPIKeyDefault) WithStatusCode(code int) *OperatorSubnetAPIKeyDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the operator subnet Api key default response +func (o *OperatorSubnetAPIKeyDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the operator subnet Api key default response +func (o *OperatorSubnetAPIKeyDefault) WithPayload(payload *models.Error) *OperatorSubnetAPIKeyDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operator subnet Api key default response +func (o *OperatorSubnetAPIKeyDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperatorSubnetAPIKeyDefault) 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 + } + } +} diff --git a/operatorapi/operations/operator_api/operator_subnet_api_key_urlbuilder.go b/operatorapi/operations/operator_api/operator_subnet_api_key_urlbuilder.go new file mode 100644 index 000000000..5937d4865 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_api_key_urlbuilder.go @@ -0,0 +1,117 @@ +// 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 . +// + +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" +) + +// OperatorSubnetAPIKeyURL generates an URL for the operator subnet Api key operation +type OperatorSubnetAPIKeyURL struct { + Token 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 *OperatorSubnetAPIKeyURL) WithBasePath(bp string) *OperatorSubnetAPIKeyURL { + 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 *OperatorSubnetAPIKeyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *OperatorSubnetAPIKeyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/subnet/apikey" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + tokenQ := o.Token + if tokenQ != "" { + qs.Set("token", tokenQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *OperatorSubnetAPIKeyURL) 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 *OperatorSubnetAPIKeyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *OperatorSubnetAPIKeyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on OperatorSubnetAPIKeyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on OperatorSubnetAPIKeyURL") + } + + 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 *OperatorSubnetAPIKeyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operatorapi/operations/operator_api/operator_subnet_login.go b/operatorapi/operations/operator_api/operator_subnet_login.go new file mode 100644 index 000000000..16eec27b2 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_login.go @@ -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 . +// + +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" +) + +// OperatorSubnetLoginHandlerFunc turns a function with the right signature into a operator subnet login handler +type OperatorSubnetLoginHandlerFunc func(OperatorSubnetLoginParams, *models.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn OperatorSubnetLoginHandlerFunc) Handle(params OperatorSubnetLoginParams, principal *models.Principal) middleware.Responder { + return fn(params, principal) +} + +// OperatorSubnetLoginHandler interface for that can handle valid operator subnet login params +type OperatorSubnetLoginHandler interface { + Handle(OperatorSubnetLoginParams, *models.Principal) middleware.Responder +} + +// NewOperatorSubnetLogin creates a new http.Handler for the operator subnet login operation +func NewOperatorSubnetLogin(ctx *middleware.Context, handler OperatorSubnetLoginHandler) *OperatorSubnetLogin { + return &OperatorSubnetLogin{Context: ctx, Handler: handler} +} + +/* OperatorSubnetLogin swagger:route POST /subnet/login OperatorAPI operatorSubnetLogin + +Login to subnet + +*/ +type OperatorSubnetLogin struct { + Context *middleware.Context + Handler OperatorSubnetLoginHandler +} + +func (o *OperatorSubnetLogin) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewOperatorSubnetLoginParams() + 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) + +} diff --git a/operatorapi/operations/operator_api/operator_subnet_login_m_f_a.go b/operatorapi/operations/operator_api/operator_subnet_login_m_f_a.go new file mode 100644 index 000000000..92cf7cef9 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_login_m_f_a.go @@ -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 . +// + +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" +) + +// OperatorSubnetLoginMFAHandlerFunc turns a function with the right signature into a operator subnet login m f a handler +type OperatorSubnetLoginMFAHandlerFunc func(OperatorSubnetLoginMFAParams, *models.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn OperatorSubnetLoginMFAHandlerFunc) Handle(params OperatorSubnetLoginMFAParams, principal *models.Principal) middleware.Responder { + return fn(params, principal) +} + +// OperatorSubnetLoginMFAHandler interface for that can handle valid operator subnet login m f a params +type OperatorSubnetLoginMFAHandler interface { + Handle(OperatorSubnetLoginMFAParams, *models.Principal) middleware.Responder +} + +// NewOperatorSubnetLoginMFA creates a new http.Handler for the operator subnet login m f a operation +func NewOperatorSubnetLoginMFA(ctx *middleware.Context, handler OperatorSubnetLoginMFAHandler) *OperatorSubnetLoginMFA { + return &OperatorSubnetLoginMFA{Context: ctx, Handler: handler} +} + +/* OperatorSubnetLoginMFA swagger:route POST /subnet/login/mfa OperatorAPI operatorSubnetLoginMFA + +Login to subnet using mfa + +*/ +type OperatorSubnetLoginMFA struct { + Context *middleware.Context + Handler OperatorSubnetLoginMFAHandler +} + +func (o *OperatorSubnetLoginMFA) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewOperatorSubnetLoginMFAParams() + 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) + +} diff --git a/operatorapi/operations/operator_api/operator_subnet_login_m_f_a_parameters.go b/operatorapi/operations/operator_api/operator_subnet_login_m_f_a_parameters.go new file mode 100644 index 000000000..4ca89fdc1 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_login_m_f_a_parameters.go @@ -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 . +// + +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" +) + +// NewOperatorSubnetLoginMFAParams creates a new OperatorSubnetLoginMFAParams object +// +// There are no default values defined in the spec. +func NewOperatorSubnetLoginMFAParams() OperatorSubnetLoginMFAParams { + + return OperatorSubnetLoginMFAParams{} +} + +// OperatorSubnetLoginMFAParams contains all the bound params for the operator subnet login m f a operation +// typically these are obtained from a http.Request +// +// swagger:parameters OperatorSubnetLoginMFA +type OperatorSubnetLoginMFAParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Body *models.OperatorSubnetLoginMFARequest +} + +// 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 NewOperatorSubnetLoginMFAParams() beforehand. +func (o *OperatorSubnetLoginMFAParams) 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.OperatorSubnetLoginMFARequest + 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 +} diff --git a/operatorapi/operations/operator_api/operator_subnet_login_m_f_a_responses.go b/operatorapi/operations/operator_api/operator_subnet_login_m_f_a_responses.go new file mode 100644 index 000000000..cbb181134 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_login_m_f_a_responses.go @@ -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 . +// + +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" +) + +// OperatorSubnetLoginMFAOKCode is the HTTP code returned for type OperatorSubnetLoginMFAOK +const OperatorSubnetLoginMFAOKCode int = 200 + +/*OperatorSubnetLoginMFAOK A successful response. + +swagger:response operatorSubnetLoginMFAOK +*/ +type OperatorSubnetLoginMFAOK struct { + + /* + In: Body + */ + Payload *models.OperatorSubnetLoginResponse `json:"body,omitempty"` +} + +// NewOperatorSubnetLoginMFAOK creates OperatorSubnetLoginMFAOK with default headers values +func NewOperatorSubnetLoginMFAOK() *OperatorSubnetLoginMFAOK { + + return &OperatorSubnetLoginMFAOK{} +} + +// WithPayload adds the payload to the operator subnet login m f a o k response +func (o *OperatorSubnetLoginMFAOK) WithPayload(payload *models.OperatorSubnetLoginResponse) *OperatorSubnetLoginMFAOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operator subnet login m f a o k response +func (o *OperatorSubnetLoginMFAOK) SetPayload(payload *models.OperatorSubnetLoginResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperatorSubnetLoginMFAOK) 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 + } + } +} + +/*OperatorSubnetLoginMFADefault Generic error response. + +swagger:response operatorSubnetLoginMFADefault +*/ +type OperatorSubnetLoginMFADefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewOperatorSubnetLoginMFADefault creates OperatorSubnetLoginMFADefault with default headers values +func NewOperatorSubnetLoginMFADefault(code int) *OperatorSubnetLoginMFADefault { + if code <= 0 { + code = 500 + } + + return &OperatorSubnetLoginMFADefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the operator subnet login m f a default response +func (o *OperatorSubnetLoginMFADefault) WithStatusCode(code int) *OperatorSubnetLoginMFADefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the operator subnet login m f a default response +func (o *OperatorSubnetLoginMFADefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the operator subnet login m f a default response +func (o *OperatorSubnetLoginMFADefault) WithPayload(payload *models.Error) *OperatorSubnetLoginMFADefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operator subnet login m f a default response +func (o *OperatorSubnetLoginMFADefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperatorSubnetLoginMFADefault) 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 + } + } +} diff --git a/operatorapi/operations/operator_api/operator_subnet_login_m_f_a_urlbuilder.go b/operatorapi/operations/operator_api/operator_subnet_login_m_f_a_urlbuilder.go new file mode 100644 index 000000000..85d3f3602 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_login_m_f_a_urlbuilder.go @@ -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 . +// + +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" +) + +// OperatorSubnetLoginMFAURL generates an URL for the operator subnet login m f a operation +type OperatorSubnetLoginMFAURL 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 *OperatorSubnetLoginMFAURL) WithBasePath(bp string) *OperatorSubnetLoginMFAURL { + 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 *OperatorSubnetLoginMFAURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *OperatorSubnetLoginMFAURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/subnet/login/mfa" + + _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 *OperatorSubnetLoginMFAURL) 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 *OperatorSubnetLoginMFAURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *OperatorSubnetLoginMFAURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on OperatorSubnetLoginMFAURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on OperatorSubnetLoginMFAURL") + } + + 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 *OperatorSubnetLoginMFAURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operatorapi/operations/operator_api/operator_subnet_login_parameters.go b/operatorapi/operations/operator_api/operator_subnet_login_parameters.go new file mode 100644 index 000000000..85e99df54 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_login_parameters.go @@ -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 . +// + +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" +) + +// NewOperatorSubnetLoginParams creates a new OperatorSubnetLoginParams object +// +// There are no default values defined in the spec. +func NewOperatorSubnetLoginParams() OperatorSubnetLoginParams { + + return OperatorSubnetLoginParams{} +} + +// OperatorSubnetLoginParams contains all the bound params for the operator subnet login operation +// typically these are obtained from a http.Request +// +// swagger:parameters OperatorSubnetLogin +type OperatorSubnetLoginParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Body *models.OperatorSubnetLoginRequest +} + +// 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 NewOperatorSubnetLoginParams() beforehand. +func (o *OperatorSubnetLoginParams) 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.OperatorSubnetLoginRequest + 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 +} diff --git a/operatorapi/operations/operator_api/operator_subnet_login_responses.go b/operatorapi/operations/operator_api/operator_subnet_login_responses.go new file mode 100644 index 000000000..8dbf6e538 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_login_responses.go @@ -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 . +// + +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" +) + +// OperatorSubnetLoginOKCode is the HTTP code returned for type OperatorSubnetLoginOK +const OperatorSubnetLoginOKCode int = 200 + +/*OperatorSubnetLoginOK A successful response. + +swagger:response operatorSubnetLoginOK +*/ +type OperatorSubnetLoginOK struct { + + /* + In: Body + */ + Payload *models.OperatorSubnetLoginResponse `json:"body,omitempty"` +} + +// NewOperatorSubnetLoginOK creates OperatorSubnetLoginOK with default headers values +func NewOperatorSubnetLoginOK() *OperatorSubnetLoginOK { + + return &OperatorSubnetLoginOK{} +} + +// WithPayload adds the payload to the operator subnet login o k response +func (o *OperatorSubnetLoginOK) WithPayload(payload *models.OperatorSubnetLoginResponse) *OperatorSubnetLoginOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operator subnet login o k response +func (o *OperatorSubnetLoginOK) SetPayload(payload *models.OperatorSubnetLoginResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperatorSubnetLoginOK) 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 + } + } +} + +/*OperatorSubnetLoginDefault Generic error response. + +swagger:response operatorSubnetLoginDefault +*/ +type OperatorSubnetLoginDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewOperatorSubnetLoginDefault creates OperatorSubnetLoginDefault with default headers values +func NewOperatorSubnetLoginDefault(code int) *OperatorSubnetLoginDefault { + if code <= 0 { + code = 500 + } + + return &OperatorSubnetLoginDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the operator subnet login default response +func (o *OperatorSubnetLoginDefault) WithStatusCode(code int) *OperatorSubnetLoginDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the operator subnet login default response +func (o *OperatorSubnetLoginDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the operator subnet login default response +func (o *OperatorSubnetLoginDefault) WithPayload(payload *models.Error) *OperatorSubnetLoginDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operator subnet login default response +func (o *OperatorSubnetLoginDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperatorSubnetLoginDefault) 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 + } + } +} diff --git a/operatorapi/operations/operator_api/operator_subnet_login_urlbuilder.go b/operatorapi/operations/operator_api/operator_subnet_login_urlbuilder.go new file mode 100644 index 000000000..2d8bd2c68 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_login_urlbuilder.go @@ -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 . +// + +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" +) + +// OperatorSubnetLoginURL generates an URL for the operator subnet login operation +type OperatorSubnetLoginURL 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 *OperatorSubnetLoginURL) WithBasePath(bp string) *OperatorSubnetLoginURL { + 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 *OperatorSubnetLoginURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *OperatorSubnetLoginURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/subnet/login" + + _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 *OperatorSubnetLoginURL) 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 *OperatorSubnetLoginURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *OperatorSubnetLoginURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on OperatorSubnetLoginURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on OperatorSubnetLoginURL") + } + + 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 *OperatorSubnetLoginURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operatorapi/operations/operator_api/operator_subnet_register_api_key.go b/operatorapi/operations/operator_api/operator_subnet_register_api_key.go new file mode 100644 index 000000000..2d1d1de94 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_register_api_key.go @@ -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 . +// + +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" +) + +// OperatorSubnetRegisterAPIKeyHandlerFunc turns a function with the right signature into a operator subnet register API key handler +type OperatorSubnetRegisterAPIKeyHandlerFunc func(OperatorSubnetRegisterAPIKeyParams, *models.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn OperatorSubnetRegisterAPIKeyHandlerFunc) Handle(params OperatorSubnetRegisterAPIKeyParams, principal *models.Principal) middleware.Responder { + return fn(params, principal) +} + +// OperatorSubnetRegisterAPIKeyHandler interface for that can handle valid operator subnet register API key params +type OperatorSubnetRegisterAPIKeyHandler interface { + Handle(OperatorSubnetRegisterAPIKeyParams, *models.Principal) middleware.Responder +} + +// NewOperatorSubnetRegisterAPIKey creates a new http.Handler for the operator subnet register API key operation +func NewOperatorSubnetRegisterAPIKey(ctx *middleware.Context, handler OperatorSubnetRegisterAPIKeyHandler) *OperatorSubnetRegisterAPIKey { + return &OperatorSubnetRegisterAPIKey{Context: ctx, Handler: handler} +} + +/* OperatorSubnetRegisterAPIKey swagger:route POST /subnet/apikey/register OperatorAPI operatorSubnetRegisterApiKey + +Register Operator with Subnet + +*/ +type OperatorSubnetRegisterAPIKey struct { + Context *middleware.Context + Handler OperatorSubnetRegisterAPIKeyHandler +} + +func (o *OperatorSubnetRegisterAPIKey) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewOperatorSubnetRegisterAPIKeyParams() + 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) + +} diff --git a/operatorapi/operations/operator_api/operator_subnet_register_api_key_parameters.go b/operatorapi/operations/operator_api/operator_subnet_register_api_key_parameters.go new file mode 100644 index 000000000..8256fe25f --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_register_api_key_parameters.go @@ -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 . +// + +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" +) + +// NewOperatorSubnetRegisterAPIKeyParams creates a new OperatorSubnetRegisterAPIKeyParams object +// +// There are no default values defined in the spec. +func NewOperatorSubnetRegisterAPIKeyParams() OperatorSubnetRegisterAPIKeyParams { + + return OperatorSubnetRegisterAPIKeyParams{} +} + +// OperatorSubnetRegisterAPIKeyParams contains all the bound params for the operator subnet register API key operation +// typically these are obtained from a http.Request +// +// swagger:parameters OperatorSubnetRegisterAPIKey +type OperatorSubnetRegisterAPIKeyParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: body + */ + Body *models.OperatorSubnetAPIKey +} + +// 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 NewOperatorSubnetRegisterAPIKeyParams() beforehand. +func (o *OperatorSubnetRegisterAPIKeyParams) 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.OperatorSubnetAPIKey + 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 +} diff --git a/operatorapi/operations/operator_api/operator_subnet_register_api_key_responses.go b/operatorapi/operations/operator_api/operator_subnet_register_api_key_responses.go new file mode 100644 index 000000000..ddbb9c5d5 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_register_api_key_responses.go @@ -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 . +// + +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" +) + +// OperatorSubnetRegisterAPIKeyOKCode is the HTTP code returned for type OperatorSubnetRegisterAPIKeyOK +const OperatorSubnetRegisterAPIKeyOKCode int = 200 + +/*OperatorSubnetRegisterAPIKeyOK A successful response. + +swagger:response operatorSubnetRegisterApiKeyOK +*/ +type OperatorSubnetRegisterAPIKeyOK struct { +} + +// NewOperatorSubnetRegisterAPIKeyOK creates OperatorSubnetRegisterAPIKeyOK with default headers values +func NewOperatorSubnetRegisterAPIKeyOK() *OperatorSubnetRegisterAPIKeyOK { + + return &OperatorSubnetRegisterAPIKeyOK{} +} + +// WriteResponse to the client +func (o *OperatorSubnetRegisterAPIKeyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +/*OperatorSubnetRegisterAPIKeyDefault Generic error response. + +swagger:response operatorSubnetRegisterApiKeyDefault +*/ +type OperatorSubnetRegisterAPIKeyDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewOperatorSubnetRegisterAPIKeyDefault creates OperatorSubnetRegisterAPIKeyDefault with default headers values +func NewOperatorSubnetRegisterAPIKeyDefault(code int) *OperatorSubnetRegisterAPIKeyDefault { + if code <= 0 { + code = 500 + } + + return &OperatorSubnetRegisterAPIKeyDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the operator subnet register API key default response +func (o *OperatorSubnetRegisterAPIKeyDefault) WithStatusCode(code int) *OperatorSubnetRegisterAPIKeyDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the operator subnet register API key default response +func (o *OperatorSubnetRegisterAPIKeyDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the operator subnet register API key default response +func (o *OperatorSubnetRegisterAPIKeyDefault) WithPayload(payload *models.Error) *OperatorSubnetRegisterAPIKeyDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the operator subnet register API key default response +func (o *OperatorSubnetRegisterAPIKeyDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OperatorSubnetRegisterAPIKeyDefault) 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 + } + } +} diff --git a/operatorapi/operations/operator_api/operator_subnet_register_api_key_urlbuilder.go b/operatorapi/operations/operator_api/operator_subnet_register_api_key_urlbuilder.go new file mode 100644 index 000000000..a23e8f292 --- /dev/null +++ b/operatorapi/operations/operator_api/operator_subnet_register_api_key_urlbuilder.go @@ -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 . +// + +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" +) + +// OperatorSubnetRegisterAPIKeyURL generates an URL for the operator subnet register API key operation +type OperatorSubnetRegisterAPIKeyURL 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 *OperatorSubnetRegisterAPIKeyURL) WithBasePath(bp string) *OperatorSubnetRegisterAPIKeyURL { + 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 *OperatorSubnetRegisterAPIKeyURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *OperatorSubnetRegisterAPIKeyURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/subnet/apikey/register" + + _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 *OperatorSubnetRegisterAPIKeyURL) 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 *OperatorSubnetRegisterAPIKeyURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *OperatorSubnetRegisterAPIKeyURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on OperatorSubnetRegisterAPIKeyURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on OperatorSubnetRegisterAPIKeyURL") + } + + 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 *OperatorSubnetRegisterAPIKeyURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/operatorapi/subnet.go b/operatorapi/subnet.go new file mode 100644 index 000000000..1455564bb --- /dev/null +++ b/operatorapi/subnet.go @@ -0,0 +1,43 @@ +// 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 . + +package operatorapi + +import ( + "github.com/go-openapi/runtime/middleware" + "github.com/minio/console/models" + "github.com/minio/console/operatorapi/operations" + "github.com/minio/console/operatorapi/operations/operator_api" +) + +func registerOperatorSubnetHandlers(api *operations.OperatorAPI) { + api.OperatorAPIOperatorSubnetLoginHandler = operator_api.OperatorSubnetLoginHandlerFunc(func(params operator_api.OperatorSubnetLoginParams, session *models.Principal) middleware.Responder { + // TODO: Implement + return operator_api.NewOperatorSubnetLoginOK() + }) + api.OperatorAPIOperatorSubnetLoginMFAHandler = operator_api.OperatorSubnetLoginMFAHandlerFunc(func(params operator_api.OperatorSubnetLoginMFAParams, session *models.Principal) middleware.Responder { + // TODO: Implement + return operator_api.NewOperatorSubnetLoginMFAOK() + }) + api.OperatorAPIOperatorSubnetAPIKeyHandler = operator_api.OperatorSubnetAPIKeyHandlerFunc(func(params operator_api.OperatorSubnetAPIKeyParams, session *models.Principal) middleware.Responder { + // TODO: Implement + return operator_api.NewOperatorSubnetAPIKeyOK() + }) + api.OperatorAPIOperatorSubnetRegisterAPIKeyHandler = operator_api.OperatorSubnetRegisterAPIKeyHandlerFunc(func(params operator_api.OperatorSubnetRegisterAPIKeyParams, session *models.Principal) middleware.Responder { + // TODO: Implement + return operator_api.NewOperatorSubnetRegisterAPIKeyOK() + }) +} diff --git a/swagger-operator.yml b/swagger-operator.yml index 375d00805..6773b756f 100644 --- a/swagger-operator.yml +++ b/swagger-operator.yml @@ -1397,6 +1397,87 @@ paths: $ref: "#/definitions/error" tags: - OperatorAPI + /subnet/login: + post: + summary: Login to subnet + operationId: OperatorSubnetLogin + parameters: + - name: body + in: body + required: true + schema: + $ref: "#/definitions/operatorSubnetLoginRequest" + responses: + 200: + description: A successful response. + schema: + $ref: "#/definitions/operatorSubnetLoginResponse" + default: + description: Generic error response. + schema: + $ref: "#/definitions/error" + tags: + - OperatorAPI + /subnet/login/mfa: + post: + summary: Login to subnet using mfa + operationId: OperatorSubnetLoginMFA + parameters: + - name: body + in: body + required: true + schema: + $ref: "#/definitions/operatorSubnetLoginMFARequest" + responses: + 200: + description: A successful response. + schema: + $ref: "#/definitions/operatorSubnetLoginResponse" + default: + description: Generic error response. + schema: + $ref: "#/definitions/error" + tags: + - OperatorAPI + /subnet/apikey: + get: + summary: Subnet api key + operationId: OperatorSubnetApiKey + parameters: + - name: token + in: query + required: true + type: string + responses: + 200: + description: A successful response. + schema: + $ref: "#/definitions/operatorSubnetAPIKey" + default: + description: Generic error response. + schema: + $ref: "#/definitions/error" + tags: + - OperatorAPI + /subnet/apikey/register: + post: + summary: Register Operator with Subnet + operationId: OperatorSubnetRegisterAPIKey + parameters: + - name: body + in: body + required: true + schema: + $ref: "#/definitions/operatorSubnetAPIKey" + responses: + 200: + description: A successful response. + default: + description: Generic error response. + schema: + $ref: "#/definitions/error" + tags: + - OperatorAPI definitions: error: @@ -3449,3 +3530,38 @@ definitions: isInEU: type: boolean + operatorSubnetLoginRequest: + type: object + properties: + username: + type: string + password: + type: string + + operatorSubnetLoginResponse: + type: object + properties: + access_token: + type: string + mfa_token: + type: string + + operatorSubnetLoginMFARequest: + type: object + required: + - username + - otp + - mfa_token + properties: + username: + type: string + otp: + type: string + mfa_token: + type: string + + operatorSubnetAPIKey: + type: object + properties: + apiKey: + type: string