From 76665c997bc3524d501bd774b40baac155cad10b Mon Sep 17 00:00:00 2001 From: Benjamin Perez Date: Mon, 4 Nov 2024 22:28:00 -0600 Subject: [PATCH] Removed Tools support - Removed Menu links for Support tools - Removed support in UI for registering cluster - Removed Subnet support - Removed Websockets for tools support - Removed Support endpoint - Removed Subnet support endpoints Signed-off-by: Benjamin Perez --- api/admin_health_info.go | 153 ---- api/admin_health_info_test.go | 147 ---- api/admin_speedtest.go | 118 --- api/admin_subnet.go | 435 ---------- api/admin_subnet_test.go | 233 ------ api/config.go | 4 - api/configure_console.go | 9 - api/doc.go | 1 - api/embedded_spec.go | 772 +----------------- api/license.go | 81 -- api/operations/console_api.go | 135 --- api/operations/profile/profiling_start.go | 88 -- .../profile/profiling_start_parameters.go | 101 --- .../profile/profiling_start_responses.go | 135 --- .../profile/profiling_start_urlbuilder.go | 104 --- api/operations/profile/profiling_stop.go | 88 -- .../profile/profiling_stop_parameters.go | 63 -- .../profile/profiling_stop_responses.go | 134 --- .../profile/profiling_stop_urlbuilder.go | 104 --- api/operations/subnet/subnet_api_key.go | 88 -- .../subnet/subnet_api_key_parameters.go | 99 --- .../subnet/subnet_api_key_responses.go | 135 --- .../subnet/subnet_api_key_urlbuilder.go | 117 --- api/operations/subnet/subnet_info.go | 88 -- .../subnet/subnet_info_parameters.go | 63 -- .../subnet/subnet_info_responses.go | 135 --- .../subnet/subnet_info_urlbuilder.go | 104 --- api/operations/subnet/subnet_login.go | 88 -- api/operations/subnet/subnet_login_m_f_a.go | 88 -- .../subnet/subnet_login_m_f_a_parameters.go | 101 --- .../subnet/subnet_login_m_f_a_responses.go | 135 --- .../subnet/subnet_login_m_f_a_urlbuilder.go | 104 --- .../subnet/subnet_login_parameters.go | 101 --- .../subnet/subnet_login_responses.go | 135 --- .../subnet/subnet_login_urlbuilder.go | 104 --- api/operations/subnet/subnet_reg_token.go | 88 -- .../subnet/subnet_reg_token_parameters.go | 63 -- .../subnet/subnet_reg_token_responses.go | 135 --- .../subnet/subnet_reg_token_urlbuilder.go | 104 --- api/operations/subnet/subnet_register.go | 88 -- .../subnet/subnet_register_parameters.go | 101 --- .../subnet/subnet_register_responses.go | 115 --- .../subnet/subnet_register_urlbuilder.go | 104 --- .../support/get_call_home_option_value.go | 88 -- .../get_call_home_option_value_parameters.go | 63 -- .../get_call_home_option_value_responses.go | 135 --- .../get_call_home_option_value_urlbuilder.go | 104 --- .../support/set_call_home_status.go | 88 -- .../set_call_home_status_parameters.go | 101 --- .../support/set_call_home_status_responses.go | 115 --- .../set_call_home_status_urlbuilder.go | 104 --- api/user_support.go | 232 ------ api/user_support_test.go | 382 --------- api/ws_handle.go | 203 +---- models/add_bucket_lifecycle.go | 2 +- models/add_multi_bucket_lifecycle.go | 2 +- models/admin_info_response.go | 2 +- models/bucket.go | 2 +- models/bucket_quota.go | 2 +- models/bucket_replication_rule.go | 4 +- models/create_remote_bucket.go | 2 +- models/login_details.go | 2 +- models/multi_bucket_replication.go | 2 +- models/remote_bucket.go | 2 +- models/session_response.go | 2 +- models/set_bucket_quota.go | 2 +- models/subnet_login_m_f_a_request.go | 122 --- models/subnet_login_request.go | 73 -- models/subnet_login_response.go | 147 ---- models/subnet_organization.go | 82 -- models/subnet_reg_token_response.go | 67 -- models/subnet_register_request.go | 105 --- models/tier.go | 2 +- models/update_bucket_lifecycle.go | 2 +- pkg/subnet/config.go | 57 -- pkg/subnet/config_test.go | 90 -- pkg/subnet/const.go | 30 - pkg/subnet/subnet.go | 131 --- pkg/subnet/utils.go | 223 ----- pkg/subnet/utils_test.go | 481 ----------- swagger.yml | 260 ------ web-app/package.json | 1 - web-app/src/api/consoleApi.ts | 233 ------ .../src/common/SecureComponent/permissions.ts | 30 - web-app/src/common/utils.ts | 9 - .../BucketDetails/SummaryItems/BucketTags.tsx | 10 +- .../Common/TestWrapper/TestWrapper.tsx | 140 ---- web-app/src/screens/Console/Console.tsx | 28 - .../screens/Console/HealthInfo/HealthInfo.tsx | 342 -------- .../Console/HealthInfo/healthInfoSlice.ts | 46 -- .../src/screens/Console/HealthInfo/types.ts | 528 ------------ .../src/screens/Console/License/License.tsx | 38 +- web-app/src/screens/Console/License/types.tsx | 39 - .../screens/Console/Speedtest/STResults.tsx | 455 ----------- .../Console/Speedtest/SpeedTestUnit.tsx | 99 --- .../screens/Console/Speedtest/Speedtest.tsx | 331 -------- .../src/screens/Console/Speedtest/types.ts | 48 -- .../src/screens/Console/Speedtest/utils.ts | 32 - .../Console/Support/ApiKeyRegister.tsx | 142 ---- .../src/screens/Console/Support/CallHome.tsx | 212 ----- .../Console/Support/CallHomeConfirmation.tsx | 193 ----- .../Support/ClusterRegistrationForm.tsx | 86 -- .../Console/Support/GetApiKeyModal.tsx | 215 ----- .../Console/Support/OfflineRegistration.tsx | 193 ----- .../Console/Support/OnlineRegistration.tsx | 118 --- .../src/screens/Console/Support/Profile.tsx | 186 ----- .../src/screens/Console/Support/Register.tsx | 213 ----- .../Console/Support/RegisterCluster.tsx | 162 ---- .../Console/Support/RegisterHelpBox.tsx | 100 --- .../Support/RegistrationStatusBanner.tsx | 81 -- .../Console/Support/SubnetMFAToken.tsx | 83 -- .../screens/Console/Support/registerSlice.ts | 125 --- .../screens/Console/Support/registerThunks.ts | 215 ----- web-app/src/screens/Console/Support/types.ts | 20 - web-app/src/screens/Console/Support/utils.tsx | 130 --- web-app/src/screens/Console/Tools/Inspect.tsx | 465 ----------- web-app/src/screens/Console/Tools/Tools.tsx | 40 - web-app/src/screens/Console/Trace/Trace.tsx | 502 ------------ .../src/screens/Console/Trace/traceSlice.ts | 49 -- web-app/src/screens/Console/Trace/types.ts | 36 - web-app/src/screens/Console/Watch/Watch.tsx | 234 ------ web-app/src/screens/Console/Watch/types.ts | 41 - .../src/screens/Console/Watch/watchSlice.ts | 43 - web-app/src/screens/Console/valid-routes.tsx | 56 +- web-app/src/store.ts | 8 - web-app/src/systemSlice.ts | 1 - web-app/src/utils/wsUtils.ts | 5 - 127 files changed, 32 insertions(+), 15232 deletions(-) delete mode 100644 api/admin_health_info.go delete mode 100644 api/admin_health_info_test.go delete mode 100644 api/admin_speedtest.go delete mode 100644 api/admin_subnet.go delete mode 100644 api/admin_subnet_test.go delete mode 100644 api/license.go delete mode 100644 api/operations/profile/profiling_start.go delete mode 100644 api/operations/profile/profiling_start_parameters.go delete mode 100644 api/operations/profile/profiling_start_responses.go delete mode 100644 api/operations/profile/profiling_start_urlbuilder.go delete mode 100644 api/operations/profile/profiling_stop.go delete mode 100644 api/operations/profile/profiling_stop_parameters.go delete mode 100644 api/operations/profile/profiling_stop_responses.go delete mode 100644 api/operations/profile/profiling_stop_urlbuilder.go delete mode 100644 api/operations/subnet/subnet_api_key.go delete mode 100644 api/operations/subnet/subnet_api_key_parameters.go delete mode 100644 api/operations/subnet/subnet_api_key_responses.go delete mode 100644 api/operations/subnet/subnet_api_key_urlbuilder.go delete mode 100644 api/operations/subnet/subnet_info.go delete mode 100644 api/operations/subnet/subnet_info_parameters.go delete mode 100644 api/operations/subnet/subnet_info_responses.go delete mode 100644 api/operations/subnet/subnet_info_urlbuilder.go delete mode 100644 api/operations/subnet/subnet_login.go delete mode 100644 api/operations/subnet/subnet_login_m_f_a.go delete mode 100644 api/operations/subnet/subnet_login_m_f_a_parameters.go delete mode 100644 api/operations/subnet/subnet_login_m_f_a_responses.go delete mode 100644 api/operations/subnet/subnet_login_m_f_a_urlbuilder.go delete mode 100644 api/operations/subnet/subnet_login_parameters.go delete mode 100644 api/operations/subnet/subnet_login_responses.go delete mode 100644 api/operations/subnet/subnet_login_urlbuilder.go delete mode 100644 api/operations/subnet/subnet_reg_token.go delete mode 100644 api/operations/subnet/subnet_reg_token_parameters.go delete mode 100644 api/operations/subnet/subnet_reg_token_responses.go delete mode 100644 api/operations/subnet/subnet_reg_token_urlbuilder.go delete mode 100644 api/operations/subnet/subnet_register.go delete mode 100644 api/operations/subnet/subnet_register_parameters.go delete mode 100644 api/operations/subnet/subnet_register_responses.go delete mode 100644 api/operations/subnet/subnet_register_urlbuilder.go delete mode 100644 api/operations/support/get_call_home_option_value.go delete mode 100644 api/operations/support/get_call_home_option_value_parameters.go delete mode 100644 api/operations/support/get_call_home_option_value_responses.go delete mode 100644 api/operations/support/get_call_home_option_value_urlbuilder.go delete mode 100644 api/operations/support/set_call_home_status.go delete mode 100644 api/operations/support/set_call_home_status_parameters.go delete mode 100644 api/operations/support/set_call_home_status_responses.go delete mode 100644 api/operations/support/set_call_home_status_urlbuilder.go delete mode 100644 api/user_support.go delete mode 100644 api/user_support_test.go delete mode 100644 models/subnet_login_m_f_a_request.go delete mode 100644 models/subnet_login_request.go delete mode 100644 models/subnet_login_response.go delete mode 100644 models/subnet_organization.go delete mode 100644 models/subnet_reg_token_response.go delete mode 100644 models/subnet_register_request.go delete mode 100644 pkg/subnet/config.go delete mode 100644 pkg/subnet/config_test.go delete mode 100644 pkg/subnet/const.go delete mode 100644 pkg/subnet/subnet.go delete mode 100644 pkg/subnet/utils.go delete mode 100644 pkg/subnet/utils_test.go delete mode 100644 web-app/src/screens/Console/Common/TestWrapper/TestWrapper.tsx delete mode 100644 web-app/src/screens/Console/HealthInfo/HealthInfo.tsx delete mode 100644 web-app/src/screens/Console/HealthInfo/healthInfoSlice.ts delete mode 100644 web-app/src/screens/Console/HealthInfo/types.ts delete mode 100644 web-app/src/screens/Console/Speedtest/STResults.tsx delete mode 100644 web-app/src/screens/Console/Speedtest/SpeedTestUnit.tsx delete mode 100644 web-app/src/screens/Console/Speedtest/Speedtest.tsx delete mode 100644 web-app/src/screens/Console/Speedtest/types.ts delete mode 100644 web-app/src/screens/Console/Speedtest/utils.ts delete mode 100644 web-app/src/screens/Console/Support/ApiKeyRegister.tsx delete mode 100644 web-app/src/screens/Console/Support/CallHome.tsx delete mode 100644 web-app/src/screens/Console/Support/CallHomeConfirmation.tsx delete mode 100644 web-app/src/screens/Console/Support/ClusterRegistrationForm.tsx delete mode 100644 web-app/src/screens/Console/Support/GetApiKeyModal.tsx delete mode 100644 web-app/src/screens/Console/Support/OfflineRegistration.tsx delete mode 100644 web-app/src/screens/Console/Support/OnlineRegistration.tsx delete mode 100644 web-app/src/screens/Console/Support/Profile.tsx delete mode 100644 web-app/src/screens/Console/Support/Register.tsx delete mode 100644 web-app/src/screens/Console/Support/RegisterCluster.tsx delete mode 100644 web-app/src/screens/Console/Support/RegisterHelpBox.tsx delete mode 100644 web-app/src/screens/Console/Support/RegistrationStatusBanner.tsx delete mode 100644 web-app/src/screens/Console/Support/SubnetMFAToken.tsx delete mode 100644 web-app/src/screens/Console/Support/registerSlice.ts delete mode 100644 web-app/src/screens/Console/Support/registerThunks.ts delete mode 100644 web-app/src/screens/Console/Support/types.ts delete mode 100644 web-app/src/screens/Console/Support/utils.tsx delete mode 100644 web-app/src/screens/Console/Tools/Inspect.tsx delete mode 100644 web-app/src/screens/Console/Tools/Tools.tsx delete mode 100644 web-app/src/screens/Console/Trace/Trace.tsx delete mode 100644 web-app/src/screens/Console/Trace/traceSlice.ts delete mode 100644 web-app/src/screens/Console/Trace/types.ts delete mode 100644 web-app/src/screens/Console/Watch/Watch.tsx delete mode 100644 web-app/src/screens/Console/Watch/types.ts delete mode 100644 web-app/src/screens/Console/Watch/watchSlice.ts diff --git a/api/admin_health_info.go b/api/admin_health_info.go deleted file mode 100644 index 38b133388d..0000000000 --- a/api/admin_health_info.go +++ /dev/null @@ -1,153 +0,0 @@ -// 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 . - -package api - -import ( - "context" - b64 "encoding/base64" - "encoding/json" - "errors" - "fmt" - "net/http" - "net/url" - "os" - "time" - - "github.com/minio/console/pkg/logger" - "github.com/minio/console/pkg/utils" - - subnet "github.com/minio/console/pkg/subnet" - mc "github.com/minio/mc/cmd" - "github.com/minio/websocket" -) - -// startHealthInfo starts fetching mc.ServerHealthInfo and -// sends messages with the corresponding data on the websocket connection -func startHealthInfo(ctx context.Context, conn WSConn, client MinioAdmin, deadline *time.Duration) error { - if deadline == nil { - return errors.New("duration can't be nil on startHealthInfo") - } - - // Fetch info of all servers (cluster or single server) - healthInfo, version, err := client.serverHealthInfo(ctx, *deadline) - if err != nil { - return err - } - - compressedDiag, err := mc.TarGZHealthInfo(healthInfo, version) - if err != nil { - return err - } - encodedDiag := b64.StdEncoding.EncodeToString(compressedDiag) - type messageReport struct { - Encoded string `json:"encoded"` - ServerHealthInfo interface{} `json:"serverHealthInfo"` - SubnetResponse string `json:"subnetResponse"` - } - - ctx = context.WithValue(ctx, utils.ContextClientIP, conn.remoteAddress()) - err = sendHealthInfoToSubnet(ctx, compressedDiag, client) - report := messageReport{ - Encoded: encodedDiag, - ServerHealthInfo: healthInfo, - SubnetResponse: mc.SubnetBaseURL() + "/health", - } - if err != nil { - report.SubnetResponse = fmt.Sprintf("Error: %s", err.Error()) - } - - message, err := json.Marshal(report) - if err != nil { - return err - } - - // Send Message through websocket connection - return conn.writeMessage(websocket.TextMessage, message) -} - -// getHealthInfoOptionsFromReq gets duration for startHealthInfo request -// path come as : `/health-info?deadline=2h` -func getHealthInfoOptionsFromReq(req *http.Request) (*time.Duration, error) { - deadlineDuration, err := time.ParseDuration(req.FormValue("deadline")) - if err != nil { - return nil, err - } - return &deadlineDuration, nil -} - -func updateMcGlobals(subnetTokenConfig subnet.LicenseTokenConfig) error { - mc.GlobalDevMode = getConsoleDevMode() - if len(subnetTokenConfig.Proxy) > 0 { - proxyURL, e := url.Parse(subnetTokenConfig.Proxy) - if e != nil { - return e - } - mc.GlobalSubnetProxyURL = proxyURL - } - return nil -} - -func sendHealthInfoToSubnet(ctx context.Context, compressedHealthInfo []byte, client MinioAdmin) error { - filename := fmt.Sprintf("health_%d.json.gz", time.Now().Unix()) - subnetTokenConfig, e := GetSubnetKeyFromMinIOConfig(ctx, client) - if e != nil { - return e - } - e = updateMcGlobals(*subnetTokenConfig) - if e != nil { - return e - } - var apiKey string - if len(subnetTokenConfig.APIKey) != 0 { - apiKey = subnetTokenConfig.APIKey - } else { - apiKey, e = subnet.GetSubnetAPIKeyUsingLicense(subnetTokenConfig.License) - if e != nil { - return e - } - } - e = os.WriteFile(filename, compressedHealthInfo, 0o666) - if e != nil { - return e - } - headers := mc.SubnetAPIKeyAuthHeaders(apiKey) - resp, e := (&mc.SubnetFileUploader{ - FilePath: filename, - ReqURL: mc.SubnetUploadURL("health"), - Headers: headers, - DeleteAfterUpload: true, - }).UploadFileToSubnet() - if e != nil { - // file gets deleted only if upload is successful - // so we delete explicitly here as we already have the bytes - logger.LogIf(ctx, os.Remove(filename)) - return e - } - - type SubnetResponse struct { - LicenseV2 string `json:"license_v2,omitempty"` - APIKey string `json:"api_key,omitempty"` - } - - var subnetResp SubnetResponse - e = json.Unmarshal([]byte(resp), &subnetResp) - if e != nil { - return e - } - - return nil -} diff --git a/api/admin_health_info_test.go b/api/admin_health_info_test.go deleted file mode 100644 index d565731371..0000000000 --- a/api/admin_health_info_test.go +++ /dev/null @@ -1,147 +0,0 @@ -// 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 . - -package api - -import ( - "context" - "encoding/json" - "errors" - "reflect" - "testing" - "time" - - madmin "github.com/minio/madmin-go/v3" -) - -func Test_serverHealthInfo(t *testing.T) { - var testReceiver chan madmin.HealthInfo - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - client := AdminClientMock{} - mockWSConn := mockConn{} - deadlineDuration, _ := time.ParseDuration("1h") - - type args struct { - deadline time.Duration - wsWriteMock func(messageType int, data []byte) error - mockMessages []madmin.HealthInfo - } - tests := []struct { - test string - args args - wantError error - }{ - { - test: "Return simple health info, no errors", - args: args{ - deadline: deadlineDuration, - mockMessages: []madmin.HealthInfo{{}, {}}, - wsWriteMock: func(_ int, data []byte) error { - // mock connection WriteMessage() no error - // emulate that receiver gets the message written - var t madmin.HealthInfo - _ = json.Unmarshal(data, &t) - testReceiver <- t - return nil - }, - }, - wantError: nil, - }, - { - test: "Return simple health info2, no errors", - args: args{ - deadline: deadlineDuration, - mockMessages: []madmin.HealthInfo{{}}, - wsWriteMock: func(_ int, data []byte) error { - // mock connection WriteMessage() no error - // emulate that receiver gets the message written - var t madmin.HealthInfo - _ = json.Unmarshal(data, &t) - testReceiver <- t - return nil - }, - }, - wantError: nil, - }, - { - test: "Handle error on ws write", - args: args{ - deadline: deadlineDuration, - mockMessages: []madmin.HealthInfo{{}}, - wsWriteMock: func(_ int, data []byte) error { - // mock connection WriteMessage() no error - // emulate that receiver gets the message written - var t madmin.HealthInfo - _ = json.Unmarshal(data, &t) - return errors.New("error on write") - }, - }, - wantError: errors.New("error on write"), - }, - { - test: "Handle error on health function", - args: args{ - deadline: deadlineDuration, - mockMessages: []madmin.HealthInfo{ - { - Error: "error on healthInfo", - }, - }, - wsWriteMock: func(_ int, data []byte) error { - // mock connection WriteMessage() no error - // emulate that receiver gets the message written - var t madmin.HealthInfo - _ = json.Unmarshal(data, &t) - return nil - }, - }, - wantError: nil, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.test, func(_ *testing.T) { - // make testReceiver channel - testReceiver = make(chan madmin.HealthInfo, len(tt.args.mockMessages)) - // mock function same for all tests, changes mockMessages - minioServerHealthInfoMock = func(_ context.Context, - _ time.Duration, - ) (interface{}, string, error) { - info := tt.args.mockMessages[0] - return info, madmin.HealthInfoVersion, nil - } - connWriteMessageMock = tt.args.wsWriteMock - err := startHealthInfo(ctx, mockWSConn, client, &deadlineDuration) - // close test mock channel - close(testReceiver) - // check that the TestReceiver got the same number of data from Console. - index := 0 - for info := range testReceiver { - if !reflect.DeepEqual(info, tt.args.mockMessages[index]) { - t.Errorf("startHealthInfo() got: %v, want: %v", info, tt.args.mockMessages[index]) - return - } - index++ - } - if !reflect.DeepEqual(err, tt.wantError) { - t.Errorf("startHealthInfo() error: %v, wantError: %v", err, tt.wantError) - return - } - }) - } -} diff --git a/api/admin_speedtest.go b/api/admin_speedtest.go deleted file mode 100644 index fd29706b6b..0000000000 --- a/api/admin_speedtest.go +++ /dev/null @@ -1,118 +0,0 @@ -// 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 . - -package api - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "strconv" - "time" - - "github.com/dustin/go-humanize" - "github.com/minio/madmin-go/v3" - "github.com/minio/websocket" -) - -// getSpeedtesthOptionsFromReq gets duration, size & concurrent requests from a websocket -// path come as : `/speedtest?duration=2h&size=12MiB&concurrent=10` -func getSpeedtestOptionsFromReq(req *http.Request) (*madmin.SpeedtestOpts, error) { - optionsSet := madmin.SpeedtestOpts{} - - queryPairs := req.URL.Query() - - paramDuration := queryPairs.Get("duration") - - if paramDuration == "" { - paramDuration = "10s" - } - - duration, err := time.ParseDuration(paramDuration) - if err != nil { - return nil, fmt.Errorf("unable to parse duration: %s", paramDuration) - } - - if duration <= 0 { - return nil, fmt.Errorf("duration cannot be 0 or negative") - } - - optionsSet.Duration = duration - - paramSize := queryPairs.Get("size") - - if paramSize == "" { - paramSize = "64MiB" - } - - size, err := humanize.ParseBytes(paramSize) - if err != nil { - return nil, fmt.Errorf("unable to parse object size") - } - - optionsSet.Size = int(size) - - paramConcurrent := queryPairs.Get("concurrent") - - if paramConcurrent == "" { - paramConcurrent = "32" - } - - concurrent, err := strconv.Atoi(paramConcurrent) - if err != nil { - return nil, fmt.Errorf("invalid concurrent value: %s", paramConcurrent) - } - - if concurrent <= 0 { - return nil, fmt.Errorf("concurrency cannot be '0' or negative") - } - - optionsSet.Concurrency = concurrent - - autotune := queryPairs.Get("autotune") - - if autotune == "true" { - optionsSet.Autotune = true - } - - return &optionsSet, nil -} - -func startSpeedtest(ctx context.Context, conn WSConn, client MinioAdmin, speedtestOpts *madmin.SpeedtestOpts) error { - speedtestRes, err := client.speedtest(ctx, *speedtestOpts) - if err != nil { - LogError("error initializing speedtest: %v", err) - return err - } - - for result := range speedtestRes { - // Serializing message - bytes, err := json.Marshal(result) - if err != nil { - LogError("error serializing json: %v", err) - return err - } - // Send Message through websocket connection - err = conn.writeMessage(websocket.TextMessage, bytes) - if err != nil { - LogError("error writing speedtest response: %v", err) - return err - } - } - - return nil -} diff --git a/api/admin_subnet.go b/api/admin_subnet.go deleted file mode 100644 index 80820677c7..0000000000 --- a/api/admin_subnet.go +++ /dev/null @@ -1,435 +0,0 @@ -// 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 . -// - -package api - -import ( - "context" - "errors" - "fmt" - "net/http" - "net/url" - "os" - - "github.com/minio/console/pkg/utils" - - xhttp "github.com/minio/console/pkg/http" - - "github.com/go-openapi/runtime/middleware" - "github.com/minio/console/api/operations" - subnetApi "github.com/minio/console/api/operations/subnet" - "github.com/minio/console/models" - "github.com/minio/console/pkg/subnet" - "github.com/minio/madmin-go/v3" -) - -func registerSubnetHandlers(api *operations.ConsoleAPI) { - // Get subnet login handler - api.SubnetSubnetLoginHandler = subnetApi.SubnetLoginHandlerFunc(func(params subnetApi.SubnetLoginParams, session *models.Principal) middleware.Responder { - resp, err := GetSubnetLoginResponse(session, params) - if err != nil { - return subnetApi.NewSubnetLoginDefault(err.Code).WithPayload(err.APIError) - } - return subnetApi.NewSubnetLoginOK().WithPayload(resp) - }) - // Get subnet login with MFA handler - api.SubnetSubnetLoginMFAHandler = subnetApi.SubnetLoginMFAHandlerFunc(func(params subnetApi.SubnetLoginMFAParams, session *models.Principal) middleware.Responder { - resp, err := GetSubnetLoginWithMFAResponse(session, params) - if err != nil { - return subnetApi.NewSubnetLoginMFADefault(err.Code).WithPayload(err.APIError) - } - return subnetApi.NewSubnetLoginMFAOK().WithPayload(resp) - }) - // Get subnet register - api.SubnetSubnetRegisterHandler = subnetApi.SubnetRegisterHandlerFunc(func(params subnetApi.SubnetRegisterParams, session *models.Principal) middleware.Responder { - err := GetSubnetRegisterResponse(session, params) - if err != nil { - return subnetApi.NewSubnetRegisterDefault(err.Code).WithPayload(err.APIError) - } - return subnetApi.NewSubnetRegisterOK() - }) - // Get subnet info - api.SubnetSubnetInfoHandler = subnetApi.SubnetInfoHandlerFunc(func(params subnetApi.SubnetInfoParams, session *models.Principal) middleware.Responder { - resp, err := GetSubnetInfoResponse(session, params) - if err != nil { - return subnetApi.NewSubnetInfoDefault(err.Code).WithPayload(err.APIError) - } - return subnetApi.NewSubnetInfoOK().WithPayload(resp) - }) - // Get subnet registration token - api.SubnetSubnetRegTokenHandler = subnetApi.SubnetRegTokenHandlerFunc(func(params subnetApi.SubnetRegTokenParams, session *models.Principal) middleware.Responder { - resp, err := GetSubnetRegTokenResponse(session, params) - if err != nil { - return subnetApi.NewSubnetRegTokenDefault(err.Code).WithPayload(err.APIError) - } - return subnetApi.NewSubnetRegTokenOK().WithPayload(resp) - }) - - api.SubnetSubnetAPIKeyHandler = subnetApi.SubnetAPIKeyHandlerFunc(func(params subnetApi.SubnetAPIKeyParams, session *models.Principal) middleware.Responder { - resp, err := GetSubnetAPIKeyResponse(session, params) - if err != nil { - return subnetApi.NewSubnetAPIKeyDefault(err.Code).WithPayload(err.APIError) - } - return subnetApi.NewSubnetAPIKeyOK().WithPayload(resp) - }) -} - -const EnvSubnetLicense = "CONSOLE_SUBNET_LICENSE" - -func SubnetRegisterWithAPIKey(ctx context.Context, minioClient MinioAdmin, apiKey string) (bool, error) { - serverInfo, err := minioClient.serverInfo(ctx) - if err != nil { - return false, err - } - clientIP := utils.ClientIPFromContext(ctx) - registerResult, err := subnet.Register(GetConsoleHTTPClient(clientIP), serverInfo, apiKey, "", "") - if err != nil { - return false, err - } - // Keep existing subnet proxy if exists - subnetKey, err := GetSubnetKeyFromMinIOConfig(ctx, minioClient) - if err != nil { - return false, err - } - configStr := fmt.Sprintf("subnet license=%s api_key=%s proxy=%s", registerResult.License, registerResult.APIKey, subnetKey.Proxy) - _, err = minioClient.setConfigKV(ctx, configStr) - if err != nil { - return false, err - } - // cluster registered correctly - return true, nil -} - -func SubnetLogin(client xhttp.ClientI, username, password string) (string, string, error) { - tokens, err := subnet.Login(client, username, password) - if err != nil { - return "", "", err - } - if tokens.MfaToken != "" { - // user needs to complete login flow using mfa - return "", tokens.MfaToken, nil - } - if tokens.AccessToken != "" { - // register token to minio - return tokens.AccessToken, "", nil - } - return "", "", errors.New("something went wrong") -} - -func GetSubnetLoginResponse(session *models.Principal, params subnetApi.SubnetLoginParams) (*models.SubnetLoginResponse, *CodedAPIError) { - ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) - defer cancel() - mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - return subnetLoginResponse(ctx, AdminClient{Client: mAdmin}, params) -} - -func subnetLoginResponse(ctx context.Context, minioClient MinioAdmin, params subnetApi.SubnetLoginParams) (*models.SubnetLoginResponse, *CodedAPIError) { - subnetHTTPClient, err := GetSubnetHTTPClient(ctx, minioClient) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - apiKey := params.Body.APIKey - if apiKey != "" { - registered, err := SubnetRegisterWithAPIKey(ctx, minioClient, apiKey) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - return &models.SubnetLoginResponse{ - Registered: registered, - Organizations: []*models.SubnetOrganization{}, - }, nil - } - username := params.Body.Username - password := params.Body.Password - if username != "" && password != "" { - token, mfa, err := SubnetLogin(subnetHTTPClient, username, password) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - return &models.SubnetLoginResponse{ - MfaToken: mfa, - AccessToken: token, - Organizations: []*models.SubnetOrganization{}, - }, nil - } - return nil, ErrorWithContext(ctx, ErrDefault) -} - -type SubnetRegistration struct { - AccessToken string - MFAToken string - Organizations []models.SubnetOrganization -} - -func SubnetLoginWithMFA(client xhttp.ClientI, username, mfaToken, otp string) (*models.SubnetLoginResponse, error) { - tokens, err := subnet.LoginWithMFA(client, username, mfaToken, otp) - if err != nil { - return nil, err - } - if tokens.AccessToken != "" { - organizations, errOrg := subnet.GetOrganizations(client, tokens.AccessToken) - if errOrg != nil { - return nil, errOrg - } - return &models.SubnetLoginResponse{ - AccessToken: tokens.AccessToken, - Organizations: organizations, - }, nil - } - return nil, errors.New("something went wrong") -} - -// GetSubnetHTTPClient will return a client with proxy if configured, otherwise will return the default console http client -func GetSubnetHTTPClient(ctx context.Context, minioClient MinioAdmin) (*xhttp.Client, error) { - clientIP := utils.ClientIPFromContext(ctx) - subnetKey, err := GetSubnetKeyFromMinIOConfig(ctx, minioClient) - if err != nil { - return nil, err - } - - proxy := getSubnetProxy() - if subnetKey.Proxy != "" { - proxy = subnetKey.Proxy - } - - tr := GlobalTransport.Clone() - if proxy != "" { - u, err := url.Parse(proxy) - if err != nil { - return nil, err - } - tr.Proxy = http.ProxyURL(u) - } - - return &xhttp.Client{ - Client: &http.Client{ - Transport: &ConsoleTransport{ - Transport: tr, - ClientIP: clientIP, - }, - }, - }, nil -} - -func GetSubnetLoginWithMFAResponse(session *models.Principal, params subnetApi.SubnetLoginMFAParams) (*models.SubnetLoginResponse, *CodedAPIError) { - ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) - defer cancel() - mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - minioClient := AdminClient{Client: mAdmin} - return subnetLoginWithMFAResponse(ctx, minioClient, params) -} - -func subnetLoginWithMFAResponse(ctx context.Context, minioClient MinioAdmin, params subnetApi.SubnetLoginMFAParams) (*models.SubnetLoginResponse, *CodedAPIError) { - subnetHTTPClient, err := GetSubnetHTTPClient(ctx, minioClient) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - resp, err := SubnetLoginWithMFA(subnetHTTPClient, *params.Body.Username, *params.Body.MfaToken, *params.Body.Otp) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - return resp, nil -} - -func GetSubnetKeyFromMinIOConfig(ctx context.Context, minioClient MinioAdmin) (*subnet.LicenseTokenConfig, error) { - buf, err := minioClient.getConfigKV(ctx, madmin.SubnetSubSys) - if err != nil { - return nil, err - } - - subSysConfigs, err := madmin.ParseServerConfigOutput(string(buf)) - if err != nil { - return nil, err - } - - for _, scfg := range subSysConfigs { - if scfg.Target == "" { - res := subnet.LicenseTokenConfig{} - res.APIKey, _ = scfg.Lookup("api_key") - res.License, _ = scfg.Lookup("license") - res.Proxy, _ = scfg.Lookup("proxy") - return &res, nil - } - } - - return nil, errors.New("unable to find subnet configuration") -} - -func GetSubnetRegister(ctx context.Context, minioClient MinioAdmin, httpClient xhttp.ClientI, params subnetApi.SubnetRegisterParams) error { - serverInfo, err := minioClient.serverInfo(ctx) - if err != nil { - return err - } - registerResult, err := subnet.Register(httpClient, serverInfo, "", *params.Body.Token, *params.Body.AccountID) - if err != nil { - return err - } - // Keep existing subnet proxy if exists - subnetKey, err := GetSubnetKeyFromMinIOConfig(ctx, minioClient) - if err != nil { - return err - } - configStr := fmt.Sprintf("subnet license=%s api_key=%s proxy=%s", registerResult.License, registerResult.APIKey, subnetKey.Proxy) - _, err = minioClient.setConfigKV(ctx, configStr) - if err != nil { - return err - } - return nil -} - -func GetSubnetRegisterResponse(session *models.Principal, params subnetApi.SubnetRegisterParams) *CodedAPIError { - ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) - defer cancel() - mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session) - if err != nil { - return ErrorWithContext(ctx, err) - } - adminClient := AdminClient{Client: mAdmin} - return subnetRegisterResponse(ctx, adminClient, params) -} - -func subnetRegisterResponse(ctx context.Context, minioClient MinioAdmin, params subnetApi.SubnetRegisterParams) *CodedAPIError { - subnetHTTPClient, err := GetSubnetHTTPClient(ctx, minioClient) - if err != nil { - return ErrorWithContext(ctx, err) - } - err = GetSubnetRegister(ctx, minioClient, subnetHTTPClient, params) - if err != nil { - return ErrorWithContext(ctx, err) - } - return nil -} - -var ErrSubnetLicenseNotFound = errors.New("license not found") - -func GetSubnetInfoResponse(session *models.Principal, params subnetApi.SubnetInfoParams) (*models.License, *CodedAPIError) { - ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) - defer cancel() - clientIP := utils.ClientIPFromContext(ctx) - client := &xhttp.Client{ - Client: GetConsoleHTTPClient(clientIP), - } - // license gets seeded to us by MinIO - seededLicense := os.Getenv(EnvSubnetLicense) - // if it's missing, we will gracefully fallback to attempt to fetch it from MinIO - if seededLicense == "" { - mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - adminClient := AdminClient{Client: mAdmin} - - configBytes, err := adminClient.getConfigKV(params.HTTPRequest.Context(), "subnet") - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - subSysConfigs, err := madmin.ParseServerConfigOutput(string(configBytes)) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - // search for licese - for _, v := range subSysConfigs { - for _, sv := range v.KV { - if sv.Key == "license" { - seededLicense = sv.Value - } - } - } - } - // still empty means not found - if seededLicense == "" { - return nil, ErrorWithContext(ctx, ErrSubnetLicenseNotFound) - } - - licenseInfo, err := getLicenseInfo(*client.Client, seededLicense) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - license := &models.License{ - Email: licenseInfo.Email, - AccountID: licenseInfo.AccountID, - StorageCapacity: licenseInfo.StorageCapacity, - Plan: licenseInfo.Plan, - ExpiresAt: licenseInfo.ExpiresAt.String(), - Organization: licenseInfo.Organization, - } - return license, nil -} - -func GetSubnetRegToken(ctx context.Context, minioClient MinioAdmin) (string, error) { - serverInfo, err := minioClient.serverInfo(ctx) - if err != nil { - return "", err - } - regInfo := subnet.GetClusterRegInfo(serverInfo) - regToken, err := subnet.GenerateRegToken(regInfo) - if err != nil { - return "", err - } - return regToken, nil -} - -func GetSubnetRegTokenResponse(session *models.Principal, params subnetApi.SubnetRegTokenParams) (*models.SubnetRegTokenResponse, *CodedAPIError) { - ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) - defer cancel() - mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - adminClient := AdminClient{Client: mAdmin} - return subnetRegTokenResponse(ctx, adminClient) -} - -func subnetRegTokenResponse(ctx context.Context, minioClient MinioAdmin) (*models.SubnetRegTokenResponse, *CodedAPIError) { - token, err := GetSubnetRegToken(ctx, minioClient) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - return &models.SubnetRegTokenResponse{ - RegToken: token, - }, nil -} - -func GetSubnetAPIKeyResponse(session *models.Principal, params subnetApi.SubnetAPIKeyParams) (*models.APIKey, *CodedAPIError) { - ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) - defer cancel() - mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - adminClient := AdminClient{Client: mAdmin} - return subnetAPIKeyResponse(ctx, adminClient, params) -} - -func subnetAPIKeyResponse(ctx context.Context, minioClient MinioAdmin, params subnetApi.SubnetAPIKeyParams) (*models.APIKey, *CodedAPIError) { - subnetHTTPClient, err := GetSubnetHTTPClient(ctx, minioClient) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - token := params.HTTPRequest.URL.Query().Get("token") - apiKey, err := subnet.GetAPIKey(subnetHTTPClient, token) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - return &models.APIKey{APIKey: apiKey}, nil -} diff --git a/api/admin_subnet_test.go b/api/admin_subnet_test.go deleted file mode 100644 index c7da4f3a83..0000000000 --- a/api/admin_subnet_test.go +++ /dev/null @@ -1,233 +0,0 @@ -// 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 api - -import ( - "context" - "net/http" - "net/http/httptest" - "net/url" - "os" - "testing" - - "github.com/minio/console/api/operations" - subnetApi "github.com/minio/console/api/operations/subnet" - "github.com/minio/console/models" - "github.com/minio/madmin-go/v3" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" -) - -type AdminSubnetTestSuite struct { - suite.Suite - assert *assert.Assertions - currentServer string - isServerSet bool - server *httptest.Server - adminClient AdminClientMock -} - -func (suite *AdminSubnetTestSuite) SetupSuite() { - suite.assert = assert.New(suite.T()) - suite.adminClient = AdminClientMock{} - minioGetConfigKVMock = func(_ string) ([]byte, error) { - return []byte("subnet license=mock api_key=mock proxy=http://mock.com"), nil - } - MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) { - return madmin.InfoMessage{Servers: []madmin.ServerProperties{{}}}, nil - } -} - -func (suite *AdminSubnetTestSuite) SetupTest() { - suite.server = httptest.NewServer(http.HandlerFunc(suite.serverHandler)) - suite.currentServer, suite.isServerSet = os.LookupEnv(ConsoleMinIOServer) - os.Setenv(ConsoleMinIOServer, suite.server.URL) -} - -func (suite *AdminSubnetTestSuite) serverHandler(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(400) -} - -func (suite *AdminSubnetTestSuite) TearDownSuite() { -} - -func (suite *AdminSubnetTestSuite) TearDownTest() { - if suite.isServerSet { - os.Setenv(ConsoleMinIOServer, suite.currentServer) - } else { - os.Unsetenv(ConsoleMinIOServer) - } -} - -func (suite *AdminSubnetTestSuite) TestRegisterSubnetHandlers() { - api := &operations.ConsoleAPI{} - suite.assertHandlersAreNil(api) - registerSubnetHandlers(api) - suite.assertHandlersAreNotNil(api) -} - -func (suite *AdminSubnetTestSuite) assertHandlersAreNil(api *operations.ConsoleAPI) { - suite.assert.Nil(api.SubnetSubnetLoginHandler) - suite.assert.Nil(api.SubnetSubnetLoginMFAHandler) - suite.assert.Nil(api.SubnetSubnetRegisterHandler) - suite.assert.Nil(api.SubnetSubnetInfoHandler) - suite.assert.Nil(api.SubnetSubnetRegTokenHandler) - suite.assert.Nil(api.SubnetSubnetAPIKeyHandler) -} - -func (suite *AdminSubnetTestSuite) assertHandlersAreNotNil(api *operations.ConsoleAPI) { - suite.assert.NotNil(api.SubnetSubnetLoginHandler) - suite.assert.NotNil(api.SubnetSubnetLoginMFAHandler) - suite.assert.NotNil(api.SubnetSubnetRegisterHandler) - suite.assert.NotNil(api.SubnetSubnetInfoHandler) - suite.assert.NotNil(api.SubnetSubnetRegTokenHandler) - suite.assert.NotNil(api.SubnetSubnetAPIKeyHandler) -} - -func (suite *AdminSubnetTestSuite) TestSubnetLoginWithSubnetClientError() { - params, api := suite.initSubnetLoginRequest("", "", "") - response := api.SubnetSubnetLoginHandler.Handle(params, &models.Principal{}) - _, ok := response.(*subnetApi.SubnetLoginDefault) - suite.assert.True(ok) -} - -func (suite *AdminSubnetTestSuite) TestSubnetLoginResponseWithApiKeyError() { - params, _ := suite.initSubnetLoginRequest("mock", "", "") - res, err := subnetLoginResponse(context.TODO(), suite.adminClient, params) - suite.assert.NotNil(err) - suite.assert.Nil(res) -} - -func (suite *AdminSubnetTestSuite) TestSubnetLoginResponseWithCredentialsError() { - params, _ := suite.initSubnetLoginRequest("", "mock", "mock") - res, err := subnetLoginResponse(context.TODO(), suite.adminClient, params) - suite.assert.NotNil(err) - suite.assert.Nil(res) -} - -func (suite *AdminSubnetTestSuite) initSubnetLoginRequest(apiKey, username, password string) (params subnetApi.SubnetLoginParams, api operations.ConsoleAPI) { - registerSubnetHandlers(&api) - params.HTTPRequest = &http.Request{} - params.Body = &models.SubnetLoginRequest{} - params.Body.APIKey = apiKey - params.Body.Username = username - params.Body.Password = password - return params, api -} - -func (suite *AdminSubnetTestSuite) TestSubnetLoginMFAWithSubnetClientError() { - params, api := suite.initSubnetLoginMFARequest("", "", "") - response := api.SubnetSubnetLoginMFAHandler.Handle(params, &models.Principal{}) - _, ok := response.(*subnetApi.SubnetLoginMFADefault) - suite.assert.True(ok) -} - -func (suite *AdminSubnetTestSuite) TestSubnetLoginWithMFAResponseError() { - params, _ := suite.initSubnetLoginMFARequest("mock", "mock", "mock") - res, err := subnetLoginWithMFAResponse(context.TODO(), suite.adminClient, params) - suite.assert.NotNil(err) - suite.assert.Nil(res) -} - -func (suite *AdminSubnetTestSuite) initSubnetLoginMFARequest(username, mfaToken, otp string) (params subnetApi.SubnetLoginMFAParams, api operations.ConsoleAPI) { - registerSubnetHandlers(&api) - params.HTTPRequest = &http.Request{} - params.Body = &models.SubnetLoginMFARequest{} - params.Body.Username = &username - params.Body.MfaToken = &mfaToken - params.Body.Otp = &otp - return params, api -} - -func (suite *AdminSubnetTestSuite) TestSubnetRegisterClientError() { - params, api := suite.initSubnetRegisterRequest("", "") - response := api.SubnetSubnetRegisterHandler.Handle(params, &models.Principal{}) - _, ok := response.(*subnetApi.SubnetRegisterDefault) - suite.assert.True(ok) -} - -func (suite *AdminSubnetTestSuite) TestSubnetRegisterResponseError() { - params, _ := suite.initSubnetRegisterRequest("mock", "mock") - err := subnetRegisterResponse(context.TODO(), suite.adminClient, params) - suite.assert.NotNil(err) -} - -func (suite *AdminSubnetTestSuite) initSubnetRegisterRequest(token, accountID string) (params subnetApi.SubnetRegisterParams, api operations.ConsoleAPI) { - registerSubnetHandlers(&api) - params.HTTPRequest = &http.Request{} - params.Body = &models.SubnetRegisterRequest{} - params.Body.Token = &token - params.Body.AccountID = &accountID - return params, api -} - -func (suite *AdminSubnetTestSuite) TestSubnetInfoError() { - params, api := suite.initSubnetInfoRequest() - response := api.SubnetSubnetInfoHandler.Handle(params, &models.Principal{}) - _, ok := response.(*subnetApi.SubnetInfoDefault) - suite.assert.True(ok) -} - -func (suite *AdminSubnetTestSuite) initSubnetInfoRequest() (params subnetApi.SubnetInfoParams, api operations.ConsoleAPI) { - registerSubnetHandlers(&api) - params.HTTPRequest = &http.Request{} - return params, api -} - -func (suite *AdminSubnetTestSuite) TestSubnetRegTokenError() { - params, api := suite.initSubnetRegTokenRequest() - response := api.SubnetSubnetRegTokenHandler.Handle(params, &models.Principal{}) - _, ok := response.(*subnetApi.SubnetRegTokenDefault) - suite.assert.True(ok) -} - -func (suite *AdminSubnetTestSuite) TestSubnetRegTokenResponse() { - res, err := subnetRegTokenResponse(context.TODO(), suite.adminClient) - suite.assert.Nil(err) - suite.assert.NotEqual("", res) -} - -func (suite *AdminSubnetTestSuite) initSubnetRegTokenRequest() (params subnetApi.SubnetRegTokenParams, api operations.ConsoleAPI) { - registerSubnetHandlers(&api) - params.HTTPRequest = &http.Request{} - return params, api -} - -func (suite *AdminSubnetTestSuite) TestSubnetAPIKeyWithClientError() { - params, api := suite.initSubnetAPIKeyRequest() - response := api.SubnetSubnetAPIKeyHandler.Handle(params, &models.Principal{}) - _, ok := response.(*subnetApi.SubnetAPIKeyDefault) - suite.assert.True(ok) -} - -func (suite *AdminSubnetTestSuite) TestSubnetAPIKeyResponseError() { - params, _ := suite.initSubnetAPIKeyRequest() - res, err := subnetAPIKeyResponse(context.TODO(), suite.adminClient, params) - suite.assert.NotNil(err) - suite.assert.Nil(res) -} - -func (suite *AdminSubnetTestSuite) initSubnetAPIKeyRequest() (params subnetApi.SubnetAPIKeyParams, api operations.ConsoleAPI) { - registerSubnetHandlers(&api) - params.HTTPRequest = &http.Request{} - params.HTTPRequest.URL = &url.URL{} - return params, api -} - -func TestAdminSubnet(t *testing.T) { - suite.Run(t, new(AdminSubnetTestSuite)) -} diff --git a/api/config.go b/api/config.go index 06193e080e..0596647bc8 100644 --- a/api/config.go +++ b/api/config.go @@ -98,10 +98,6 @@ func getMinIOServer() string { return strings.TrimSpace(env.Get(ConsoleMinIOServer, "http://localhost:9000")) } -func getSubnetProxy() string { - return strings.TrimSpace(env.Get(ConsoleSubnetProxy, "")) -} - func GetMinIORegion() string { return strings.TrimSpace(env.Get(ConsoleMinIORegion, "")) } diff --git a/api/configure_console.go b/api/configure_console.go index e699e8db74..4cdad7f2cb 100644 --- a/api/configure_console.go +++ b/api/configure_console.go @@ -143,8 +143,6 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler { registerAdminBucketRemoteHandlers(api) // Register admin log search registerLogSearchHandlers(api) - // Register admin subnet handlers - registerSubnetHandlers(api) // Register admin KMS handlers registerKMSHandlers(api) // Register admin IDP handlers @@ -158,8 +156,6 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler { registerSiteReplicationHandler(api) registerSiteReplicationStatusHandler(api) - // Register Support Handler - registerSupportHandlers(api) // Operator Console @@ -178,9 +174,6 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler { api.ServerShutdown = func() {} - // do an initial subnet plan caching - fetchLicensePlan() - return setupGlobalMiddleware(api.Serve(setupMiddlewares)) } @@ -601,8 +594,6 @@ func replaceBaseInIndex(indexPageBytes []byte, basePath string) []byte { func replaceLicense(indexPageBytes []byte) []byte { indexPageStr := string(indexPageBytes) - newPlan := fmt.Sprintf("", InstanceLicensePlan.String()) - indexPageStr = strings.Replace(indexPageStr, "", newPlan, 1) indexPageBytes = []byte(indexPageStr) return indexPageBytes } diff --git a/api/doc.go b/api/doc.go index 8458030e33..db7367d28e 100644 --- a/api/doc.go +++ b/api/doc.go @@ -30,7 +30,6 @@ // - multipart/form-data // // Produces: -// - application/zip // - application/octet-stream // - application/json // diff --git a/api/embedded_spec.go b/api/embedded_spec.go index 3c14a95f03..2de8b4533d 100644 --- a/api/embedded_spec.go +++ b/api/embedded_spec.go @@ -3829,65 +3829,6 @@ func init() { } } }, - "/profiling/start": { - "post": { - "tags": [ - "Profile" - ], - "summary": "Start recording profile data", - "operationId": "ProfilingStart", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/profilingStartRequest" - } - } - ], - "responses": { - "201": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/startProfilingList" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/profiling/stop": { - "post": { - "produces": [ - "application/zip" - ], - "tags": [ - "Profile" - ], - "summary": "Stop and download profile data", - "operationId": "ProfilingStop", - "responses": { - "201": { - "description": "A successful response.", - "schema": { - "type": "file" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, "/releases": { "get": { "tags": [ @@ -4373,230 +4314,6 @@ func init() { } } }, - "/subnet/apikey": { - "get": { - "tags": [ - "Subnet" - ], - "summary": "Subnet api key", - "operationId": "SubnetApiKey", - "parameters": [ - { - "type": "string", - "name": "token", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/apiKey" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/info": { - "get": { - "tags": [ - "Subnet" - ], - "summary": "Subnet info", - "operationId": "SubnetInfo", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/license" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/login": { - "post": { - "tags": [ - "Subnet" - ], - "summary": "Login to SUBNET", - "operationId": "SubnetLogin", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/subnetLoginRequest" - } - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/subnetLoginResponse" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/login/mfa": { - "post": { - "tags": [ - "Subnet" - ], - "summary": "Login to SUBNET using mfa", - "operationId": "SubnetLoginMFA", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/subnetLoginMFARequest" - } - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/subnetLoginResponse" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/register": { - "post": { - "tags": [ - "Subnet" - ], - "summary": "Register cluster with Subnet", - "operationId": "SubnetRegister", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/subnetRegisterRequest" - } - } - ], - "responses": { - "200": { - "description": "A successful response." - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/registration-token": { - "get": { - "tags": [ - "Subnet" - ], - "summary": "SUBNET registraton token", - "operationId": "SubnetRegToken", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/SubnetRegTokenResponse" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/support/callhome": { - "get": { - "tags": [ - "Support" - ], - "summary": "Get Callhome current status", - "operationId": "GetCallHomeOptionValue", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/callHomeGetResponse" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - }, - "put": { - "tags": [ - "Support" - ], - "summary": "Sets callhome status", - "operationId": "SetCallHomeStatus", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/callHomeSetStatus" - } - } - ], - "responses": { - "204": { - "description": "A successful response." - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, "/user/policy": { "get": { "tags": [ @@ -5049,14 +4766,6 @@ func init() { } } }, - "SubnetRegTokenResponse": { - "type": "object", - "properties": { - "regToken": { - "type": "string" - } - } - }, "aUserPolicyResponse": { "type": "object", "properties": { @@ -8075,97 +7784,6 @@ func init() { } } }, - "subnetLoginMFARequest": { - "type": "object", - "required": [ - "username", - "otp", - "mfa_token" - ], - "properties": { - "mfa_token": { - "type": "string" - }, - "otp": { - "type": "string" - }, - "username": { - "type": "string" - } - } - }, - "subnetLoginRequest": { - "type": "object", - "properties": { - "apiKey": { - "type": "string" - }, - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - } - }, - "subnetLoginResponse": { - "type": "object", - "properties": { - "access_token": { - "type": "string" - }, - "mfa_token": { - "type": "string" - }, - "organizations": { - "type": "array", - "items": { - "$ref": "#/definitions/subnetOrganization" - } - }, - "registered": { - "type": "boolean" - } - } - }, - "subnetOrganization": { - "type": "object", - "properties": { - "accountId": { - "type": "integer" - }, - "company": { - "type": "string" - }, - "isAccountOwner": { - "type": "boolean" - }, - "shortName": { - "type": "string" - }, - "subscriptionStatus": { - "type": "string" - }, - "userId": { - "type": "integer" - } - } - }, - "subnetRegisterRequest": { - "type": "object", - "required": [ - "token", - "account_id" - ], - "properties": { - "account_id": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, "tier": { "type": "object", "properties": { @@ -12579,69 +12197,10 @@ func init() { "in": "path", "required": true } - ], - "responses": { - "204": { - "description": "A successful response." - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/profiling/start": { - "post": { - "tags": [ - "Profile" - ], - "summary": "Start recording profile data", - "operationId": "ProfilingStart", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/profilingStartRequest" - } - } - ], - "responses": { - "201": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/startProfilingList" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/profiling/stop": { - "post": { - "produces": [ - "application/zip" - ], - "tags": [ - "Profile" - ], - "summary": "Stop and download profile data", - "operationId": "ProfilingStop", - "responses": { - "201": { - "description": "A successful response.", - "schema": { - "type": "file" - } + ], + "responses": { + "204": { + "description": "A successful response." }, "default": { "description": "Generic error response.", @@ -13145,230 +12704,6 @@ func init() { } } }, - "/subnet/apikey": { - "get": { - "tags": [ - "Subnet" - ], - "summary": "Subnet api key", - "operationId": "SubnetApiKey", - "parameters": [ - { - "type": "string", - "name": "token", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/apiKey" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/info": { - "get": { - "tags": [ - "Subnet" - ], - "summary": "Subnet info", - "operationId": "SubnetInfo", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/license" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/login": { - "post": { - "tags": [ - "Subnet" - ], - "summary": "Login to SUBNET", - "operationId": "SubnetLogin", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/subnetLoginRequest" - } - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/subnetLoginResponse" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/login/mfa": { - "post": { - "tags": [ - "Subnet" - ], - "summary": "Login to SUBNET using mfa", - "operationId": "SubnetLoginMFA", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/subnetLoginMFARequest" - } - } - ], - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/subnetLoginResponse" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/register": { - "post": { - "tags": [ - "Subnet" - ], - "summary": "Register cluster with Subnet", - "operationId": "SubnetRegister", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/subnetRegisterRequest" - } - } - ], - "responses": { - "200": { - "description": "A successful response." - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/subnet/registration-token": { - "get": { - "tags": [ - "Subnet" - ], - "summary": "SUBNET registraton token", - "operationId": "SubnetRegToken", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/SubnetRegTokenResponse" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, - "/support/callhome": { - "get": { - "tags": [ - "Support" - ], - "summary": "Get Callhome current status", - "operationId": "GetCallHomeOptionValue", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/callHomeGetResponse" - } - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - }, - "put": { - "tags": [ - "Support" - ], - "summary": "Sets callhome status", - "operationId": "SetCallHomeStatus", - "parameters": [ - { - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/callHomeSetStatus" - } - } - ], - "responses": { - "204": { - "description": "A successful response." - }, - "default": { - "description": "Generic error response.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } - } - }, "/user/policy": { "get": { "tags": [ @@ -13929,14 +13264,6 @@ func init() { } } }, - "SubnetRegTokenResponse": { - "type": "object", - "properties": { - "regToken": { - "type": "string" - } - } - }, "WidgetDetailsOptions": { "type": "object", "properties": { @@ -16987,97 +16314,6 @@ func init() { } } }, - "subnetLoginMFARequest": { - "type": "object", - "required": [ - "username", - "otp", - "mfa_token" - ], - "properties": { - "mfa_token": { - "type": "string" - }, - "otp": { - "type": "string" - }, - "username": { - "type": "string" - } - } - }, - "subnetLoginRequest": { - "type": "object", - "properties": { - "apiKey": { - "type": "string" - }, - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - } - }, - "subnetLoginResponse": { - "type": "object", - "properties": { - "access_token": { - "type": "string" - }, - "mfa_token": { - "type": "string" - }, - "organizations": { - "type": "array", - "items": { - "$ref": "#/definitions/subnetOrganization" - } - }, - "registered": { - "type": "boolean" - } - } - }, - "subnetOrganization": { - "type": "object", - "properties": { - "accountId": { - "type": "integer" - }, - "company": { - "type": "string" - }, - "isAccountOwner": { - "type": "boolean" - }, - "shortName": { - "type": "string" - }, - "subscriptionStatus": { - "type": "string" - }, - "userId": { - "type": "integer" - } - } - }, - "subnetRegisterRequest": { - "type": "object", - "required": [ - "token", - "account_id" - ], - "properties": { - "account_id": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, "tier": { "type": "object", "properties": { diff --git a/api/license.go b/api/license.go deleted file mode 100644 index 54ab0574e6..0000000000 --- a/api/license.go +++ /dev/null @@ -1,81 +0,0 @@ -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package api - -import ( - "net/http" - "os" - - "github.com/minio/pkg/v3/licverifier" - "github.com/minio/pkg/v3/subnet" -) - -type SubnetPlan int - -const ( - PlanAGPL SubnetPlan = iota - PlanStandard - PlanEnterprise - PlanEnterpriseLite - PlanEnterprisePlus -) - -func (sp SubnetPlan) String() string { - switch sp { - case PlanStandard: - return "standard" - case PlanEnterprise: - return "enterprise" - case PlanEnterpriseLite: - return "enterprise-lite" - case PlanEnterprisePlus: - return "enterprise-plus" - default: - return "agpl" - } -} - -var InstanceLicensePlan = PlanAGPL - -func getLicenseInfo(client http.Client, license string) (*licverifier.LicenseInfo, error) { - lv := subnet.LicenseValidator{ - Client: client, - ExpiryGracePeriod: 0, - } - lv.Init(getConsoleDevMode()) - return lv.ParseLicense(license) -} - -func fetchLicensePlan() { - client := GetConsoleHTTPClient("127.0.0.1") - licenseInfo, err := getLicenseInfo(*client, os.Getenv(EnvSubnetLicense)) - if err != nil { - return - } - switch licenseInfo.Plan { - case "STANDARD": - InstanceLicensePlan = PlanStandard - case "ENTERPRISE": - InstanceLicensePlan = PlanEnterprise - case "ENTERPRISE-LITE": - InstanceLicensePlan = PlanEnterpriseLite - case "ENTERPRISE-PLUS": - InstanceLicensePlan = PlanEnterprisePlus - default: - InstanceLicensePlan = PlanAGPL - } -} diff --git a/api/operations/console_api.go b/api/operations/console_api.go index 71851fedd6..bfb847734c 100644 --- a/api/operations/console_api.go +++ b/api/operations/console_api.go @@ -24,7 +24,6 @@ package operations import ( "fmt" - "io" "net/http" "strings" @@ -48,14 +47,11 @@ import ( "github.com/minio/console/api/operations/logging" "github.com/minio/console/api/operations/object" "github.com/minio/console/api/operations/policy" - "github.com/minio/console/api/operations/profile" "github.com/minio/console/api/operations/public" "github.com/minio/console/api/operations/release" "github.com/minio/console/api/operations/service" "github.com/minio/console/api/operations/service_account" "github.com/minio/console/api/operations/site_replication" - "github.com/minio/console/api/operations/subnet" - "github.com/minio/console/api/operations/support" "github.com/minio/console/api/operations/system" "github.com/minio/console/api/operations/tiering" "github.com/minio/console/api/operations/user" @@ -83,9 +79,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI { JSONConsumer: runtime.JSONConsumer(), MultipartformConsumer: runtime.DiscardConsumer, - ApplicationZipProducer: runtime.ProducerFunc(func(w io.Writer, data interface{}) error { - return errors.NotImplemented("applicationZip producer has not yet been implemented") - }), BinProducer: runtime.ByteStreamProducer(), JSONProducer: runtime.JSONProducer(), @@ -251,9 +244,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI { BucketGetBucketVersioningHandler: bucket.GetBucketVersioningHandlerFunc(func(params bucket.GetBucketVersioningParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation bucket.GetBucketVersioning has not yet been implemented") }), - SupportGetCallHomeOptionValueHandler: support.GetCallHomeOptionValueHandlerFunc(func(params support.GetCallHomeOptionValueParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation support.GetCallHomeOptionValue has not yet been implemented") - }), IdpGetConfigurationHandler: idp.GetConfigurationHandlerFunc(func(params idp.GetConfigurationParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation idp.GetConfiguration has not yet been implemented") }), @@ -401,12 +391,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI { ConfigurationPostConfigsImportHandler: configuration.PostConfigsImportHandlerFunc(func(params configuration.PostConfigsImportParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation configuration.PostConfigsImport has not yet been implemented") }), - ProfileProfilingStartHandler: profile.ProfilingStartHandlerFunc(func(params profile.ProfilingStartParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation profile.ProfilingStart has not yet been implemented") - }), - ProfileProfilingStopHandler: profile.ProfilingStopHandlerFunc(func(params profile.ProfilingStopParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation profile.ProfilingStop has not yet been implemented") - }), BucketPutBucketTagsHandler: bucket.PutBucketTagsHandlerFunc(func(params bucket.PutBucketTagsParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation bucket.PutBucketTags has not yet been implemented") }), @@ -458,9 +442,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI { BucketSetBucketVersioningHandler: bucket.SetBucketVersioningHandlerFunc(func(params bucket.SetBucketVersioningParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation bucket.SetBucketVersioning has not yet been implemented") }), - SupportSetCallHomeStatusHandler: support.SetCallHomeStatusHandlerFunc(func(params support.SetCallHomeStatusParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation support.SetCallHomeStatus has not yet been implemented") - }), ConfigurationSetConfigHandler: configuration.SetConfigHandlerFunc(func(params configuration.SetConfigParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation configuration.SetConfig has not yet been implemented") }), @@ -485,24 +466,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI { SiteReplicationSiteReplicationRemoveHandler: site_replication.SiteReplicationRemoveHandlerFunc(func(params site_replication.SiteReplicationRemoveParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation site_replication.SiteReplicationRemove has not yet been implemented") }), - SubnetSubnetAPIKeyHandler: subnet.SubnetAPIKeyHandlerFunc(func(params subnet.SubnetAPIKeyParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation subnet.SubnetAPIKey has not yet been implemented") - }), - SubnetSubnetInfoHandler: subnet.SubnetInfoHandlerFunc(func(params subnet.SubnetInfoParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation subnet.SubnetInfo has not yet been implemented") - }), - SubnetSubnetLoginHandler: subnet.SubnetLoginHandlerFunc(func(params subnet.SubnetLoginParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation subnet.SubnetLogin has not yet been implemented") - }), - SubnetSubnetLoginMFAHandler: subnet.SubnetLoginMFAHandlerFunc(func(params subnet.SubnetLoginMFAParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation subnet.SubnetLoginMFA has not yet been implemented") - }), - SubnetSubnetRegTokenHandler: subnet.SubnetRegTokenHandlerFunc(func(params subnet.SubnetRegTokenParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation subnet.SubnetRegToken has not yet been implemented") - }), - SubnetSubnetRegisterHandler: subnet.SubnetRegisterHandlerFunc(func(params subnet.SubnetRegisterParams, principal *models.Principal) middleware.Responder { - return middleware.NotImplemented("operation subnet.SubnetRegister has not yet been implemented") - }), TieringTiersListHandler: tiering.TiersListHandlerFunc(func(params tiering.TiersListParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation tiering.TiersList has not yet been implemented") }), @@ -575,9 +538,6 @@ type ConsoleAPI struct { // - multipart/form-data MultipartformConsumer runtime.Consumer - // ApplicationZipProducer registers a producer for the following mime types: - // - application/zip - ApplicationZipProducer runtime.Producer // BinProducer registers a producer for the following mime types: // - application/octet-stream BinProducer runtime.Producer @@ -704,8 +664,6 @@ type ConsoleAPI struct { BucketGetBucketRewindHandler bucket.GetBucketRewindHandler // BucketGetBucketVersioningHandler sets the operation handler for the get bucket versioning operation BucketGetBucketVersioningHandler bucket.GetBucketVersioningHandler - // SupportGetCallHomeOptionValueHandler sets the operation handler for the get call home option value operation - SupportGetCallHomeOptionValueHandler support.GetCallHomeOptionValueHandler // IdpGetConfigurationHandler sets the operation handler for the get configuration operation IdpGetConfigurationHandler idp.GetConfigurationHandler // IdpGetLDAPEntitiesHandler sets the operation handler for the get l d a p entities operation @@ -804,10 +762,6 @@ type ConsoleAPI struct { ObjectPostBucketsBucketNameObjectsUploadHandler object.PostBucketsBucketNameObjectsUploadHandler // ConfigurationPostConfigsImportHandler sets the operation handler for the post configs import operation ConfigurationPostConfigsImportHandler configuration.PostConfigsImportHandler - // ProfileProfilingStartHandler sets the operation handler for the profiling start operation - ProfileProfilingStartHandler profile.ProfilingStartHandler - // ProfileProfilingStopHandler sets the operation handler for the profiling stop operation - ProfileProfilingStopHandler profile.ProfilingStopHandler // BucketPutBucketTagsHandler sets the operation handler for the put bucket tags operation BucketPutBucketTagsHandler bucket.PutBucketTagsHandler // ObjectPutObjectLegalHoldHandler sets the operation handler for the put object legal hold operation @@ -842,8 +796,6 @@ type ConsoleAPI struct { BucketSetBucketRetentionConfigHandler bucket.SetBucketRetentionConfigHandler // BucketSetBucketVersioningHandler sets the operation handler for the set bucket versioning operation BucketSetBucketVersioningHandler bucket.SetBucketVersioningHandler - // SupportSetCallHomeStatusHandler sets the operation handler for the set call home status operation - SupportSetCallHomeStatusHandler support.SetCallHomeStatusHandler // ConfigurationSetConfigHandler sets the operation handler for the set config operation ConfigurationSetConfigHandler configuration.SetConfigHandler // BucketSetMultiBucketReplicationHandler sets the operation handler for the set multi bucket replication operation @@ -860,18 +812,6 @@ type ConsoleAPI struct { SiteReplicationSiteReplicationInfoAddHandler site_replication.SiteReplicationInfoAddHandler // SiteReplicationSiteReplicationRemoveHandler sets the operation handler for the site replication remove operation SiteReplicationSiteReplicationRemoveHandler site_replication.SiteReplicationRemoveHandler - // SubnetSubnetAPIKeyHandler sets the operation handler for the subnet Api key operation - SubnetSubnetAPIKeyHandler subnet.SubnetAPIKeyHandler - // SubnetSubnetInfoHandler sets the operation handler for the subnet info operation - SubnetSubnetInfoHandler subnet.SubnetInfoHandler - // SubnetSubnetLoginHandler sets the operation handler for the subnet login operation - SubnetSubnetLoginHandler subnet.SubnetLoginHandler - // SubnetSubnetLoginMFAHandler sets the operation handler for the subnet login m f a operation - SubnetSubnetLoginMFAHandler subnet.SubnetLoginMFAHandler - // SubnetSubnetRegTokenHandler sets the operation handler for the subnet reg token operation - SubnetSubnetRegTokenHandler subnet.SubnetRegTokenHandler - // SubnetSubnetRegisterHandler sets the operation handler for the subnet register operation - SubnetSubnetRegisterHandler subnet.SubnetRegisterHandler // TieringTiersListHandler sets the operation handler for the tiers list operation TieringTiersListHandler tiering.TiersListHandler // TieringTiersListNamesHandler sets the operation handler for the tiers list names operation @@ -966,9 +906,6 @@ func (o *ConsoleAPI) Validate() error { unregistered = append(unregistered, "MultipartformConsumer") } - if o.ApplicationZipProducer == nil { - unregistered = append(unregistered, "ApplicationZipProducer") - } if o.BinProducer == nil { unregistered = append(unregistered, "BinProducer") } @@ -1145,9 +1082,6 @@ func (o *ConsoleAPI) Validate() error { if o.BucketGetBucketVersioningHandler == nil { unregistered = append(unregistered, "bucket.GetBucketVersioningHandler") } - if o.SupportGetCallHomeOptionValueHandler == nil { - unregistered = append(unregistered, "support.GetCallHomeOptionValueHandler") - } if o.IdpGetConfigurationHandler == nil { unregistered = append(unregistered, "idp.GetConfigurationHandler") } @@ -1295,12 +1229,6 @@ func (o *ConsoleAPI) Validate() error { if o.ConfigurationPostConfigsImportHandler == nil { unregistered = append(unregistered, "configuration.PostConfigsImportHandler") } - if o.ProfileProfilingStartHandler == nil { - unregistered = append(unregistered, "profile.ProfilingStartHandler") - } - if o.ProfileProfilingStopHandler == nil { - unregistered = append(unregistered, "profile.ProfilingStopHandler") - } if o.BucketPutBucketTagsHandler == nil { unregistered = append(unregistered, "bucket.PutBucketTagsHandler") } @@ -1352,9 +1280,6 @@ func (o *ConsoleAPI) Validate() error { if o.BucketSetBucketVersioningHandler == nil { unregistered = append(unregistered, "bucket.SetBucketVersioningHandler") } - if o.SupportSetCallHomeStatusHandler == nil { - unregistered = append(unregistered, "support.SetCallHomeStatusHandler") - } if o.ConfigurationSetConfigHandler == nil { unregistered = append(unregistered, "configuration.SetConfigHandler") } @@ -1379,24 +1304,6 @@ func (o *ConsoleAPI) Validate() error { if o.SiteReplicationSiteReplicationRemoveHandler == nil { unregistered = append(unregistered, "site_replication.SiteReplicationRemoveHandler") } - if o.SubnetSubnetAPIKeyHandler == nil { - unregistered = append(unregistered, "subnet.SubnetAPIKeyHandler") - } - if o.SubnetSubnetInfoHandler == nil { - unregistered = append(unregistered, "subnet.SubnetInfoHandler") - } - if o.SubnetSubnetLoginHandler == nil { - unregistered = append(unregistered, "subnet.SubnetLoginHandler") - } - if o.SubnetSubnetLoginMFAHandler == nil { - unregistered = append(unregistered, "subnet.SubnetLoginMFAHandler") - } - if o.SubnetSubnetRegTokenHandler == nil { - unregistered = append(unregistered, "subnet.SubnetRegTokenHandler") - } - if o.SubnetSubnetRegisterHandler == nil { - unregistered = append(unregistered, "subnet.SubnetRegisterHandler") - } if o.TieringTiersListHandler == nil { unregistered = append(unregistered, "tiering.TiersListHandler") } @@ -1488,8 +1395,6 @@ func (o *ConsoleAPI) ProducersFor(mediaTypes []string) map[string]runtime.Produc result := make(map[string]runtime.Producer, len(mediaTypes)) for _, mt := range mediaTypes { switch mt { - case "application/zip": - result["application/zip"] = o.ApplicationZipProducer case "application/octet-stream": result["application/octet-stream"] = o.BinProducer case "application/json": @@ -1753,10 +1658,6 @@ func (o *ConsoleAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } - o.handlers["GET"]["/support/callhome"] = support.NewGetCallHomeOptionValue(o.context, o.SupportGetCallHomeOptionValueHandler) - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) - } o.handlers["GET"]["/idp/{type}/{name}"] = idp.NewGetConfiguration(o.context, o.IdpGetConfigurationHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) @@ -1950,14 +1851,6 @@ func (o *ConsoleAPI) initHandlerCache() { o.handlers["POST"] = make(map[string]http.Handler) } o.handlers["POST"]["/configs/import"] = configuration.NewPostConfigsImport(o.context, o.ConfigurationPostConfigsImportHandler) - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) - } - o.handlers["POST"]["/profiling/start"] = profile.NewProfilingStart(o.context, o.ProfileProfilingStartHandler) - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) - } - o.handlers["POST"]["/profiling/stop"] = profile.NewProfilingStop(o.context, o.ProfileProfilingStopHandler) if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } @@ -2029,10 +1922,6 @@ func (o *ConsoleAPI) initHandlerCache() { if o.handlers["PUT"] == nil { o.handlers["PUT"] = make(map[string]http.Handler) } - o.handlers["PUT"]["/support/callhome"] = support.NewSetCallHomeStatus(o.context, o.SupportSetCallHomeStatusHandler) - if o.handlers["PUT"] == nil { - o.handlers["PUT"] = make(map[string]http.Handler) - } o.handlers["PUT"]["/configs/{name}"] = configuration.NewSetConfig(o.context, o.ConfigurationSetConfigHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) @@ -2065,30 +1954,6 @@ func (o *ConsoleAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } - o.handlers["GET"]["/subnet/apikey"] = subnet.NewSubnetAPIKey(o.context, o.SubnetSubnetAPIKeyHandler) - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) - } - o.handlers["GET"]["/subnet/info"] = subnet.NewSubnetInfo(o.context, o.SubnetSubnetInfoHandler) - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) - } - o.handlers["POST"]["/subnet/login"] = subnet.NewSubnetLogin(o.context, o.SubnetSubnetLoginHandler) - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) - } - o.handlers["POST"]["/subnet/login/mfa"] = subnet.NewSubnetLoginMFA(o.context, o.SubnetSubnetLoginMFAHandler) - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) - } - o.handlers["GET"]["/subnet/registration-token"] = subnet.NewSubnetRegToken(o.context, o.SubnetSubnetRegTokenHandler) - if o.handlers["POST"] == nil { - o.handlers["POST"] = make(map[string]http.Handler) - } - o.handlers["POST"]["/subnet/register"] = subnet.NewSubnetRegister(o.context, o.SubnetSubnetRegisterHandler) - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) - } o.handlers["GET"]["/admin/tiers"] = tiering.NewTiersList(o.context, o.TieringTiersListHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) diff --git a/api/operations/profile/profiling_start.go b/api/operations/profile/profiling_start.go deleted file mode 100644 index 010607d48a..0000000000 --- a/api/operations/profile/profiling_start.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package profile - -// 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" -) - -// ProfilingStartHandlerFunc turns a function with the right signature into a profiling start handler -type ProfilingStartHandlerFunc func(ProfilingStartParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn ProfilingStartHandlerFunc) Handle(params ProfilingStartParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// ProfilingStartHandler interface for that can handle valid profiling start params -type ProfilingStartHandler interface { - Handle(ProfilingStartParams, *models.Principal) middleware.Responder -} - -// NewProfilingStart creates a new http.Handler for the profiling start operation -func NewProfilingStart(ctx *middleware.Context, handler ProfilingStartHandler) *ProfilingStart { - return &ProfilingStart{Context: ctx, Handler: handler} -} - -/* - ProfilingStart swagger:route POST /profiling/start Profile profilingStart - -Start recording profile data -*/ -type ProfilingStart struct { - Context *middleware.Context - Handler ProfilingStartHandler -} - -func (o *ProfilingStart) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewProfilingStartParams() - 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/api/operations/profile/profiling_start_parameters.go b/api/operations/profile/profiling_start_parameters.go deleted file mode 100644 index 48f7e89301..0000000000 --- a/api/operations/profile/profiling_start_parameters.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package profile - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "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" -) - -// NewProfilingStartParams creates a new ProfilingStartParams object -// -// There are no default values defined in the spec. -func NewProfilingStartParams() ProfilingStartParams { - - return ProfilingStartParams{} -} - -// ProfilingStartParams contains all the bound params for the profiling start operation -// typically these are obtained from a http.Request -// -// swagger:parameters ProfilingStart -type ProfilingStartParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Body *models.ProfilingStartRequest -} - -// 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 NewProfilingStartParams() beforehand. -func (o *ProfilingStartParams) 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.ProfilingStartRequest - 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(r.Context()) - 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/api/operations/profile/profiling_start_responses.go b/api/operations/profile/profiling_start_responses.go deleted file mode 100644 index cecb78b582..0000000000 --- a/api/operations/profile/profiling_start_responses.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package profile - -// 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" -) - -// ProfilingStartCreatedCode is the HTTP code returned for type ProfilingStartCreated -const ProfilingStartCreatedCode int = 201 - -/* -ProfilingStartCreated A successful response. - -swagger:response profilingStartCreated -*/ -type ProfilingStartCreated struct { - - /* - In: Body - */ - Payload *models.StartProfilingList `json:"body,omitempty"` -} - -// NewProfilingStartCreated creates ProfilingStartCreated with default headers values -func NewProfilingStartCreated() *ProfilingStartCreated { - - return &ProfilingStartCreated{} -} - -// WithPayload adds the payload to the profiling start created response -func (o *ProfilingStartCreated) WithPayload(payload *models.StartProfilingList) *ProfilingStartCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the profiling start created response -func (o *ProfilingStartCreated) SetPayload(payload *models.StartProfilingList) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ProfilingStartCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -/* -ProfilingStartDefault Generic error response. - -swagger:response profilingStartDefault -*/ -type ProfilingStartDefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewProfilingStartDefault creates ProfilingStartDefault with default headers values -func NewProfilingStartDefault(code int) *ProfilingStartDefault { - if code <= 0 { - code = 500 - } - - return &ProfilingStartDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the profiling start default response -func (o *ProfilingStartDefault) WithStatusCode(code int) *ProfilingStartDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the profiling start default response -func (o *ProfilingStartDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the profiling start default response -func (o *ProfilingStartDefault) WithPayload(payload *models.APIError) *ProfilingStartDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the profiling start default response -func (o *ProfilingStartDefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ProfilingStartDefault) 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/api/operations/profile/profiling_start_urlbuilder.go b/api/operations/profile/profiling_start_urlbuilder.go deleted file mode 100644 index 2d81ca8c77..0000000000 --- a/api/operations/profile/profiling_start_urlbuilder.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package profile - -// 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" -) - -// ProfilingStartURL generates an URL for the profiling start operation -type ProfilingStartURL 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 *ProfilingStartURL) WithBasePath(bp string) *ProfilingStartURL { - 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 *ProfilingStartURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ProfilingStartURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/profiling/start" - - _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 *ProfilingStartURL) 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 *ProfilingStartURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ProfilingStartURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ProfilingStartURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ProfilingStartURL") - } - - 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 *ProfilingStartURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/operations/profile/profiling_stop.go b/api/operations/profile/profiling_stop.go deleted file mode 100644 index 8de3e2f93b..0000000000 --- a/api/operations/profile/profiling_stop.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package profile - -// 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" -) - -// ProfilingStopHandlerFunc turns a function with the right signature into a profiling stop handler -type ProfilingStopHandlerFunc func(ProfilingStopParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn ProfilingStopHandlerFunc) Handle(params ProfilingStopParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// ProfilingStopHandler interface for that can handle valid profiling stop params -type ProfilingStopHandler interface { - Handle(ProfilingStopParams, *models.Principal) middleware.Responder -} - -// NewProfilingStop creates a new http.Handler for the profiling stop operation -func NewProfilingStop(ctx *middleware.Context, handler ProfilingStopHandler) *ProfilingStop { - return &ProfilingStop{Context: ctx, Handler: handler} -} - -/* - ProfilingStop swagger:route POST /profiling/stop Profile profilingStop - -Stop and download profile data -*/ -type ProfilingStop struct { - Context *middleware.Context - Handler ProfilingStopHandler -} - -func (o *ProfilingStop) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewProfilingStopParams() - 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/api/operations/profile/profiling_stop_parameters.go b/api/operations/profile/profiling_stop_parameters.go deleted file mode 100644 index f7a375f861..0000000000 --- a/api/operations/profile/profiling_stop_parameters.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package profile - -// 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" -) - -// NewProfilingStopParams creates a new ProfilingStopParams object -// -// There are no default values defined in the spec. -func NewProfilingStopParams() ProfilingStopParams { - - return ProfilingStopParams{} -} - -// ProfilingStopParams contains all the bound params for the profiling stop operation -// typically these are obtained from a http.Request -// -// swagger:parameters ProfilingStop -type ProfilingStopParams 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 NewProfilingStopParams() beforehand. -func (o *ProfilingStopParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/api/operations/profile/profiling_stop_responses.go b/api/operations/profile/profiling_stop_responses.go deleted file mode 100644 index 8310000191..0000000000 --- a/api/operations/profile/profiling_stop_responses.go +++ /dev/null @@ -1,134 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package profile - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "io" - "net/http" - - "github.com/go-openapi/runtime" - - "github.com/minio/console/models" -) - -// ProfilingStopCreatedCode is the HTTP code returned for type ProfilingStopCreated -const ProfilingStopCreatedCode int = 201 - -/* -ProfilingStopCreated A successful response. - -swagger:response profilingStopCreated -*/ -type ProfilingStopCreated struct { - - /* - In: Body - */ - Payload io.ReadCloser `json:"body,omitempty"` -} - -// NewProfilingStopCreated creates ProfilingStopCreated with default headers values -func NewProfilingStopCreated() *ProfilingStopCreated { - - return &ProfilingStopCreated{} -} - -// WithPayload adds the payload to the profiling stop created response -func (o *ProfilingStopCreated) WithPayload(payload io.ReadCloser) *ProfilingStopCreated { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the profiling stop created response -func (o *ProfilingStopCreated) SetPayload(payload io.ReadCloser) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ProfilingStopCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(201) - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } -} - -/* -ProfilingStopDefault Generic error response. - -swagger:response profilingStopDefault -*/ -type ProfilingStopDefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewProfilingStopDefault creates ProfilingStopDefault with default headers values -func NewProfilingStopDefault(code int) *ProfilingStopDefault { - if code <= 0 { - code = 500 - } - - return &ProfilingStopDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the profiling stop default response -func (o *ProfilingStopDefault) WithStatusCode(code int) *ProfilingStopDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the profiling stop default response -func (o *ProfilingStopDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the profiling stop default response -func (o *ProfilingStopDefault) WithPayload(payload *models.APIError) *ProfilingStopDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the profiling stop default response -func (o *ProfilingStopDefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ProfilingStopDefault) 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/api/operations/profile/profiling_stop_urlbuilder.go b/api/operations/profile/profiling_stop_urlbuilder.go deleted file mode 100644 index 4da8798c65..0000000000 --- a/api/operations/profile/profiling_stop_urlbuilder.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package profile - -// 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" -) - -// ProfilingStopURL generates an URL for the profiling stop operation -type ProfilingStopURL 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 *ProfilingStopURL) WithBasePath(bp string) *ProfilingStopURL { - 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 *ProfilingStopURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ProfilingStopURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/profiling/stop" - - _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 *ProfilingStopURL) 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 *ProfilingStopURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ProfilingStopURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ProfilingStopURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ProfilingStopURL") - } - - 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 *ProfilingStopURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/operations/subnet/subnet_api_key.go b/api/operations/subnet/subnet_api_key.go deleted file mode 100644 index ff7fbddfad..0000000000 --- a/api/operations/subnet/subnet_api_key.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetAPIKeyHandlerFunc turns a function with the right signature into a subnet Api key handler -type SubnetAPIKeyHandlerFunc func(SubnetAPIKeyParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn SubnetAPIKeyHandlerFunc) Handle(params SubnetAPIKeyParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// SubnetAPIKeyHandler interface for that can handle valid subnet Api key params -type SubnetAPIKeyHandler interface { - Handle(SubnetAPIKeyParams, *models.Principal) middleware.Responder -} - -// NewSubnetAPIKey creates a new http.Handler for the subnet Api key operation -func NewSubnetAPIKey(ctx *middleware.Context, handler SubnetAPIKeyHandler) *SubnetAPIKey { - return &SubnetAPIKey{Context: ctx, Handler: handler} -} - -/* - SubnetAPIKey swagger:route GET /subnet/apikey Subnet subnetApiKey - -Subnet api key -*/ -type SubnetAPIKey struct { - Context *middleware.Context - Handler SubnetAPIKeyHandler -} - -func (o *SubnetAPIKey) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewSubnetAPIKeyParams() - 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/api/operations/subnet/subnet_api_key_parameters.go b/api/operations/subnet/subnet_api_key_parameters.go deleted file mode 100644 index a827bf9a97..0000000000 --- a/api/operations/subnet/subnet_api_key_parameters.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// NewSubnetAPIKeyParams creates a new SubnetAPIKeyParams object -// -// There are no default values defined in the spec. -func NewSubnetAPIKeyParams() SubnetAPIKeyParams { - - return SubnetAPIKeyParams{} -} - -// SubnetAPIKeyParams contains all the bound params for the subnet Api key operation -// typically these are obtained from a http.Request -// -// swagger:parameters SubnetApiKey -type SubnetAPIKeyParams 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 NewSubnetAPIKeyParams() beforehand. -func (o *SubnetAPIKeyParams) 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 *SubnetAPIKeyParams) 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/api/operations/subnet/subnet_api_key_responses.go b/api/operations/subnet/subnet_api_key_responses.go deleted file mode 100644 index f263100669..0000000000 --- a/api/operations/subnet/subnet_api_key_responses.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetAPIKeyOKCode is the HTTP code returned for type SubnetAPIKeyOK -const SubnetAPIKeyOKCode int = 200 - -/* -SubnetAPIKeyOK A successful response. - -swagger:response subnetApiKeyOK -*/ -type SubnetAPIKeyOK struct { - - /* - In: Body - */ - Payload *models.APIKey `json:"body,omitempty"` -} - -// NewSubnetAPIKeyOK creates SubnetAPIKeyOK with default headers values -func NewSubnetAPIKeyOK() *SubnetAPIKeyOK { - - return &SubnetAPIKeyOK{} -} - -// WithPayload adds the payload to the subnet Api key o k response -func (o *SubnetAPIKeyOK) WithPayload(payload *models.APIKey) *SubnetAPIKeyOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet Api key o k response -func (o *SubnetAPIKeyOK) SetPayload(payload *models.APIKey) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetAPIKeyOK) 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 - } - } -} - -/* -SubnetAPIKeyDefault Generic error response. - -swagger:response subnetApiKeyDefault -*/ -type SubnetAPIKeyDefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewSubnetAPIKeyDefault creates SubnetAPIKeyDefault with default headers values -func NewSubnetAPIKeyDefault(code int) *SubnetAPIKeyDefault { - if code <= 0 { - code = 500 - } - - return &SubnetAPIKeyDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the subnet Api key default response -func (o *SubnetAPIKeyDefault) WithStatusCode(code int) *SubnetAPIKeyDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the subnet Api key default response -func (o *SubnetAPIKeyDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the subnet Api key default response -func (o *SubnetAPIKeyDefault) WithPayload(payload *models.APIError) *SubnetAPIKeyDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet Api key default response -func (o *SubnetAPIKeyDefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetAPIKeyDefault) 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/api/operations/subnet/subnet_api_key_urlbuilder.go b/api/operations/subnet/subnet_api_key_urlbuilder.go deleted file mode 100644 index a34203a190..0000000000 --- a/api/operations/subnet/subnet_api_key_urlbuilder.go +++ /dev/null @@ -1,117 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetAPIKeyURL generates an URL for the subnet Api key operation -type SubnetAPIKeyURL 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 *SubnetAPIKeyURL) WithBasePath(bp string) *SubnetAPIKeyURL { - 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 *SubnetAPIKeyURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *SubnetAPIKeyURL) 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 *SubnetAPIKeyURL) 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 *SubnetAPIKeyURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *SubnetAPIKeyURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on SubnetAPIKeyURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on SubnetAPIKeyURL") - } - - 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 *SubnetAPIKeyURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/operations/subnet/subnet_info.go b/api/operations/subnet/subnet_info.go deleted file mode 100644 index dbf4ebd8fa..0000000000 --- a/api/operations/subnet/subnet_info.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetInfoHandlerFunc turns a function with the right signature into a subnet info handler -type SubnetInfoHandlerFunc func(SubnetInfoParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn SubnetInfoHandlerFunc) Handle(params SubnetInfoParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// SubnetInfoHandler interface for that can handle valid subnet info params -type SubnetInfoHandler interface { - Handle(SubnetInfoParams, *models.Principal) middleware.Responder -} - -// NewSubnetInfo creates a new http.Handler for the subnet info operation -func NewSubnetInfo(ctx *middleware.Context, handler SubnetInfoHandler) *SubnetInfo { - return &SubnetInfo{Context: ctx, Handler: handler} -} - -/* - SubnetInfo swagger:route GET /subnet/info Subnet subnetInfo - -Subnet info -*/ -type SubnetInfo struct { - Context *middleware.Context - Handler SubnetInfoHandler -} - -func (o *SubnetInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewSubnetInfoParams() - 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/api/operations/subnet/subnet_info_parameters.go b/api/operations/subnet/subnet_info_parameters.go deleted file mode 100644 index 3431a6b2d6..0000000000 --- a/api/operations/subnet/subnet_info_parameters.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// NewSubnetInfoParams creates a new SubnetInfoParams object -// -// There are no default values defined in the spec. -func NewSubnetInfoParams() SubnetInfoParams { - - return SubnetInfoParams{} -} - -// SubnetInfoParams contains all the bound params for the subnet info operation -// typically these are obtained from a http.Request -// -// swagger:parameters SubnetInfo -type SubnetInfoParams 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 NewSubnetInfoParams() beforehand. -func (o *SubnetInfoParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/api/operations/subnet/subnet_info_responses.go b/api/operations/subnet/subnet_info_responses.go deleted file mode 100644 index a063e586e0..0000000000 --- a/api/operations/subnet/subnet_info_responses.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetInfoOKCode is the HTTP code returned for type SubnetInfoOK -const SubnetInfoOKCode int = 200 - -/* -SubnetInfoOK A successful response. - -swagger:response subnetInfoOK -*/ -type SubnetInfoOK struct { - - /* - In: Body - */ - Payload *models.License `json:"body,omitempty"` -} - -// NewSubnetInfoOK creates SubnetInfoOK with default headers values -func NewSubnetInfoOK() *SubnetInfoOK { - - return &SubnetInfoOK{} -} - -// WithPayload adds the payload to the subnet info o k response -func (o *SubnetInfoOK) WithPayload(payload *models.License) *SubnetInfoOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet info o k response -func (o *SubnetInfoOK) SetPayload(payload *models.License) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetInfoOK) 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 - } - } -} - -/* -SubnetInfoDefault Generic error response. - -swagger:response subnetInfoDefault -*/ -type SubnetInfoDefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewSubnetInfoDefault creates SubnetInfoDefault with default headers values -func NewSubnetInfoDefault(code int) *SubnetInfoDefault { - if code <= 0 { - code = 500 - } - - return &SubnetInfoDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the subnet info default response -func (o *SubnetInfoDefault) WithStatusCode(code int) *SubnetInfoDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the subnet info default response -func (o *SubnetInfoDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the subnet info default response -func (o *SubnetInfoDefault) WithPayload(payload *models.APIError) *SubnetInfoDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet info default response -func (o *SubnetInfoDefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetInfoDefault) 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/api/operations/subnet/subnet_info_urlbuilder.go b/api/operations/subnet/subnet_info_urlbuilder.go deleted file mode 100644 index 4da4309e5e..0000000000 --- a/api/operations/subnet/subnet_info_urlbuilder.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetInfoURL generates an URL for the subnet info operation -type SubnetInfoURL 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 *SubnetInfoURL) WithBasePath(bp string) *SubnetInfoURL { - 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 *SubnetInfoURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *SubnetInfoURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/subnet/info" - - _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 *SubnetInfoURL) 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 *SubnetInfoURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *SubnetInfoURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on SubnetInfoURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on SubnetInfoURL") - } - - 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 *SubnetInfoURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/operations/subnet/subnet_login.go b/api/operations/subnet/subnet_login.go deleted file mode 100644 index 4f7546f552..0000000000 --- a/api/operations/subnet/subnet_login.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetLoginHandlerFunc turns a function with the right signature into a subnet login handler -type SubnetLoginHandlerFunc func(SubnetLoginParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn SubnetLoginHandlerFunc) Handle(params SubnetLoginParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// SubnetLoginHandler interface for that can handle valid subnet login params -type SubnetLoginHandler interface { - Handle(SubnetLoginParams, *models.Principal) middleware.Responder -} - -// NewSubnetLogin creates a new http.Handler for the subnet login operation -func NewSubnetLogin(ctx *middleware.Context, handler SubnetLoginHandler) *SubnetLogin { - return &SubnetLogin{Context: ctx, Handler: handler} -} - -/* - SubnetLogin swagger:route POST /subnet/login Subnet subnetLogin - -Login to SUBNET -*/ -type SubnetLogin struct { - Context *middleware.Context - Handler SubnetLoginHandler -} - -func (o *SubnetLogin) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewSubnetLoginParams() - 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/api/operations/subnet/subnet_login_m_f_a.go b/api/operations/subnet/subnet_login_m_f_a.go deleted file mode 100644 index 026a48f2fd..0000000000 --- a/api/operations/subnet/subnet_login_m_f_a.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetLoginMFAHandlerFunc turns a function with the right signature into a subnet login m f a handler -type SubnetLoginMFAHandlerFunc func(SubnetLoginMFAParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn SubnetLoginMFAHandlerFunc) Handle(params SubnetLoginMFAParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// SubnetLoginMFAHandler interface for that can handle valid subnet login m f a params -type SubnetLoginMFAHandler interface { - Handle(SubnetLoginMFAParams, *models.Principal) middleware.Responder -} - -// NewSubnetLoginMFA creates a new http.Handler for the subnet login m f a operation -func NewSubnetLoginMFA(ctx *middleware.Context, handler SubnetLoginMFAHandler) *SubnetLoginMFA { - return &SubnetLoginMFA{Context: ctx, Handler: handler} -} - -/* - SubnetLoginMFA swagger:route POST /subnet/login/mfa Subnet subnetLoginMFA - -Login to SUBNET using mfa -*/ -type SubnetLoginMFA struct { - Context *middleware.Context - Handler SubnetLoginMFAHandler -} - -func (o *SubnetLoginMFA) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewSubnetLoginMFAParams() - 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/api/operations/subnet/subnet_login_m_f_a_parameters.go b/api/operations/subnet/subnet_login_m_f_a_parameters.go deleted file mode 100644 index 396e386ae8..0000000000 --- a/api/operations/subnet/subnet_login_m_f_a_parameters.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "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" -) - -// NewSubnetLoginMFAParams creates a new SubnetLoginMFAParams object -// -// There are no default values defined in the spec. -func NewSubnetLoginMFAParams() SubnetLoginMFAParams { - - return SubnetLoginMFAParams{} -} - -// SubnetLoginMFAParams contains all the bound params for the subnet login m f a operation -// typically these are obtained from a http.Request -// -// swagger:parameters SubnetLoginMFA -type SubnetLoginMFAParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Body *models.SubnetLoginMFARequest -} - -// 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 NewSubnetLoginMFAParams() beforehand. -func (o *SubnetLoginMFAParams) 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.SubnetLoginMFARequest - 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(r.Context()) - 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/api/operations/subnet/subnet_login_m_f_a_responses.go b/api/operations/subnet/subnet_login_m_f_a_responses.go deleted file mode 100644 index cd2aca9ce3..0000000000 --- a/api/operations/subnet/subnet_login_m_f_a_responses.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetLoginMFAOKCode is the HTTP code returned for type SubnetLoginMFAOK -const SubnetLoginMFAOKCode int = 200 - -/* -SubnetLoginMFAOK A successful response. - -swagger:response subnetLoginMFAOK -*/ -type SubnetLoginMFAOK struct { - - /* - In: Body - */ - Payload *models.SubnetLoginResponse `json:"body,omitempty"` -} - -// NewSubnetLoginMFAOK creates SubnetLoginMFAOK with default headers values -func NewSubnetLoginMFAOK() *SubnetLoginMFAOK { - - return &SubnetLoginMFAOK{} -} - -// WithPayload adds the payload to the subnet login m f a o k response -func (o *SubnetLoginMFAOK) WithPayload(payload *models.SubnetLoginResponse) *SubnetLoginMFAOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet login m f a o k response -func (o *SubnetLoginMFAOK) SetPayload(payload *models.SubnetLoginResponse) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetLoginMFAOK) 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 - } - } -} - -/* -SubnetLoginMFADefault Generic error response. - -swagger:response subnetLoginMFADefault -*/ -type SubnetLoginMFADefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewSubnetLoginMFADefault creates SubnetLoginMFADefault with default headers values -func NewSubnetLoginMFADefault(code int) *SubnetLoginMFADefault { - if code <= 0 { - code = 500 - } - - return &SubnetLoginMFADefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the subnet login m f a default response -func (o *SubnetLoginMFADefault) WithStatusCode(code int) *SubnetLoginMFADefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the subnet login m f a default response -func (o *SubnetLoginMFADefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the subnet login m f a default response -func (o *SubnetLoginMFADefault) WithPayload(payload *models.APIError) *SubnetLoginMFADefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet login m f a default response -func (o *SubnetLoginMFADefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetLoginMFADefault) 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/api/operations/subnet/subnet_login_m_f_a_urlbuilder.go b/api/operations/subnet/subnet_login_m_f_a_urlbuilder.go deleted file mode 100644 index 4aa1edcf8a..0000000000 --- a/api/operations/subnet/subnet_login_m_f_a_urlbuilder.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetLoginMFAURL generates an URL for the subnet login m f a operation -type SubnetLoginMFAURL 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 *SubnetLoginMFAURL) WithBasePath(bp string) *SubnetLoginMFAURL { - 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 *SubnetLoginMFAURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *SubnetLoginMFAURL) 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 *SubnetLoginMFAURL) 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 *SubnetLoginMFAURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *SubnetLoginMFAURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on SubnetLoginMFAURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on SubnetLoginMFAURL") - } - - 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 *SubnetLoginMFAURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/operations/subnet/subnet_login_parameters.go b/api/operations/subnet/subnet_login_parameters.go deleted file mode 100644 index cfc35674f1..0000000000 --- a/api/operations/subnet/subnet_login_parameters.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "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" -) - -// NewSubnetLoginParams creates a new SubnetLoginParams object -// -// There are no default values defined in the spec. -func NewSubnetLoginParams() SubnetLoginParams { - - return SubnetLoginParams{} -} - -// SubnetLoginParams contains all the bound params for the subnet login operation -// typically these are obtained from a http.Request -// -// swagger:parameters SubnetLogin -type SubnetLoginParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Body *models.SubnetLoginRequest -} - -// 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 NewSubnetLoginParams() beforehand. -func (o *SubnetLoginParams) 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.SubnetLoginRequest - 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(r.Context()) - 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/api/operations/subnet/subnet_login_responses.go b/api/operations/subnet/subnet_login_responses.go deleted file mode 100644 index 889ca69e4f..0000000000 --- a/api/operations/subnet/subnet_login_responses.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetLoginOKCode is the HTTP code returned for type SubnetLoginOK -const SubnetLoginOKCode int = 200 - -/* -SubnetLoginOK A successful response. - -swagger:response subnetLoginOK -*/ -type SubnetLoginOK struct { - - /* - In: Body - */ - Payload *models.SubnetLoginResponse `json:"body,omitempty"` -} - -// NewSubnetLoginOK creates SubnetLoginOK with default headers values -func NewSubnetLoginOK() *SubnetLoginOK { - - return &SubnetLoginOK{} -} - -// WithPayload adds the payload to the subnet login o k response -func (o *SubnetLoginOK) WithPayload(payload *models.SubnetLoginResponse) *SubnetLoginOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet login o k response -func (o *SubnetLoginOK) SetPayload(payload *models.SubnetLoginResponse) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetLoginOK) 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 - } - } -} - -/* -SubnetLoginDefault Generic error response. - -swagger:response subnetLoginDefault -*/ -type SubnetLoginDefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewSubnetLoginDefault creates SubnetLoginDefault with default headers values -func NewSubnetLoginDefault(code int) *SubnetLoginDefault { - if code <= 0 { - code = 500 - } - - return &SubnetLoginDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the subnet login default response -func (o *SubnetLoginDefault) WithStatusCode(code int) *SubnetLoginDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the subnet login default response -func (o *SubnetLoginDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the subnet login default response -func (o *SubnetLoginDefault) WithPayload(payload *models.APIError) *SubnetLoginDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet login default response -func (o *SubnetLoginDefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetLoginDefault) 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/api/operations/subnet/subnet_login_urlbuilder.go b/api/operations/subnet/subnet_login_urlbuilder.go deleted file mode 100644 index 0a797f5b59..0000000000 --- a/api/operations/subnet/subnet_login_urlbuilder.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetLoginURL generates an URL for the subnet login operation -type SubnetLoginURL 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 *SubnetLoginURL) WithBasePath(bp string) *SubnetLoginURL { - 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 *SubnetLoginURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *SubnetLoginURL) 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 *SubnetLoginURL) 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 *SubnetLoginURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *SubnetLoginURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on SubnetLoginURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on SubnetLoginURL") - } - - 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 *SubnetLoginURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/operations/subnet/subnet_reg_token.go b/api/operations/subnet/subnet_reg_token.go deleted file mode 100644 index 2aa659e07d..0000000000 --- a/api/operations/subnet/subnet_reg_token.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetRegTokenHandlerFunc turns a function with the right signature into a subnet reg token handler -type SubnetRegTokenHandlerFunc func(SubnetRegTokenParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn SubnetRegTokenHandlerFunc) Handle(params SubnetRegTokenParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// SubnetRegTokenHandler interface for that can handle valid subnet reg token params -type SubnetRegTokenHandler interface { - Handle(SubnetRegTokenParams, *models.Principal) middleware.Responder -} - -// NewSubnetRegToken creates a new http.Handler for the subnet reg token operation -func NewSubnetRegToken(ctx *middleware.Context, handler SubnetRegTokenHandler) *SubnetRegToken { - return &SubnetRegToken{Context: ctx, Handler: handler} -} - -/* - SubnetRegToken swagger:route GET /subnet/registration-token Subnet subnetRegToken - -SUBNET registraton token -*/ -type SubnetRegToken struct { - Context *middleware.Context - Handler SubnetRegTokenHandler -} - -func (o *SubnetRegToken) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewSubnetRegTokenParams() - 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/api/operations/subnet/subnet_reg_token_parameters.go b/api/operations/subnet/subnet_reg_token_parameters.go deleted file mode 100644 index 7b9fc66b9e..0000000000 --- a/api/operations/subnet/subnet_reg_token_parameters.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// NewSubnetRegTokenParams creates a new SubnetRegTokenParams object -// -// There are no default values defined in the spec. -func NewSubnetRegTokenParams() SubnetRegTokenParams { - - return SubnetRegTokenParams{} -} - -// SubnetRegTokenParams contains all the bound params for the subnet reg token operation -// typically these are obtained from a http.Request -// -// swagger:parameters SubnetRegToken -type SubnetRegTokenParams 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 NewSubnetRegTokenParams() beforehand. -func (o *SubnetRegTokenParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/api/operations/subnet/subnet_reg_token_responses.go b/api/operations/subnet/subnet_reg_token_responses.go deleted file mode 100644 index 36eb9b62fd..0000000000 --- a/api/operations/subnet/subnet_reg_token_responses.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetRegTokenOKCode is the HTTP code returned for type SubnetRegTokenOK -const SubnetRegTokenOKCode int = 200 - -/* -SubnetRegTokenOK A successful response. - -swagger:response subnetRegTokenOK -*/ -type SubnetRegTokenOK struct { - - /* - In: Body - */ - Payload *models.SubnetRegTokenResponse `json:"body,omitempty"` -} - -// NewSubnetRegTokenOK creates SubnetRegTokenOK with default headers values -func NewSubnetRegTokenOK() *SubnetRegTokenOK { - - return &SubnetRegTokenOK{} -} - -// WithPayload adds the payload to the subnet reg token o k response -func (o *SubnetRegTokenOK) WithPayload(payload *models.SubnetRegTokenResponse) *SubnetRegTokenOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet reg token o k response -func (o *SubnetRegTokenOK) SetPayload(payload *models.SubnetRegTokenResponse) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetRegTokenOK) 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 - } - } -} - -/* -SubnetRegTokenDefault Generic error response. - -swagger:response subnetRegTokenDefault -*/ -type SubnetRegTokenDefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewSubnetRegTokenDefault creates SubnetRegTokenDefault with default headers values -func NewSubnetRegTokenDefault(code int) *SubnetRegTokenDefault { - if code <= 0 { - code = 500 - } - - return &SubnetRegTokenDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the subnet reg token default response -func (o *SubnetRegTokenDefault) WithStatusCode(code int) *SubnetRegTokenDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the subnet reg token default response -func (o *SubnetRegTokenDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the subnet reg token default response -func (o *SubnetRegTokenDefault) WithPayload(payload *models.APIError) *SubnetRegTokenDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet reg token default response -func (o *SubnetRegTokenDefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetRegTokenDefault) 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/api/operations/subnet/subnet_reg_token_urlbuilder.go b/api/operations/subnet/subnet_reg_token_urlbuilder.go deleted file mode 100644 index 428afd541a..0000000000 --- a/api/operations/subnet/subnet_reg_token_urlbuilder.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetRegTokenURL generates an URL for the subnet reg token operation -type SubnetRegTokenURL 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 *SubnetRegTokenURL) WithBasePath(bp string) *SubnetRegTokenURL { - 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 *SubnetRegTokenURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *SubnetRegTokenURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/subnet/registration-token" - - _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 *SubnetRegTokenURL) 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 *SubnetRegTokenURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *SubnetRegTokenURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on SubnetRegTokenURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on SubnetRegTokenURL") - } - - 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 *SubnetRegTokenURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/operations/subnet/subnet_register.go b/api/operations/subnet/subnet_register.go deleted file mode 100644 index 3c75c93a8f..0000000000 --- a/api/operations/subnet/subnet_register.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetRegisterHandlerFunc turns a function with the right signature into a subnet register handler -type SubnetRegisterHandlerFunc func(SubnetRegisterParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn SubnetRegisterHandlerFunc) Handle(params SubnetRegisterParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// SubnetRegisterHandler interface for that can handle valid subnet register params -type SubnetRegisterHandler interface { - Handle(SubnetRegisterParams, *models.Principal) middleware.Responder -} - -// NewSubnetRegister creates a new http.Handler for the subnet register operation -func NewSubnetRegister(ctx *middleware.Context, handler SubnetRegisterHandler) *SubnetRegister { - return &SubnetRegister{Context: ctx, Handler: handler} -} - -/* - SubnetRegister swagger:route POST /subnet/register Subnet subnetRegister - -Register cluster with Subnet -*/ -type SubnetRegister struct { - Context *middleware.Context - Handler SubnetRegisterHandler -} - -func (o *SubnetRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewSubnetRegisterParams() - 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/api/operations/subnet/subnet_register_parameters.go b/api/operations/subnet/subnet_register_parameters.go deleted file mode 100644 index ef904378f1..0000000000 --- a/api/operations/subnet/subnet_register_parameters.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "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" -) - -// NewSubnetRegisterParams creates a new SubnetRegisterParams object -// -// There are no default values defined in the spec. -func NewSubnetRegisterParams() SubnetRegisterParams { - - return SubnetRegisterParams{} -} - -// SubnetRegisterParams contains all the bound params for the subnet register operation -// typically these are obtained from a http.Request -// -// swagger:parameters SubnetRegister -type SubnetRegisterParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Body *models.SubnetRegisterRequest -} - -// 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 NewSubnetRegisterParams() beforehand. -func (o *SubnetRegisterParams) 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.SubnetRegisterRequest - 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(r.Context()) - 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/api/operations/subnet/subnet_register_responses.go b/api/operations/subnet/subnet_register_responses.go deleted file mode 100644 index 78de6f8fdc..0000000000 --- a/api/operations/subnet/subnet_register_responses.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetRegisterOKCode is the HTTP code returned for type SubnetRegisterOK -const SubnetRegisterOKCode int = 200 - -/* -SubnetRegisterOK A successful response. - -swagger:response subnetRegisterOK -*/ -type SubnetRegisterOK struct { -} - -// NewSubnetRegisterOK creates SubnetRegisterOK with default headers values -func NewSubnetRegisterOK() *SubnetRegisterOK { - - return &SubnetRegisterOK{} -} - -// WriteResponse to the client -func (o *SubnetRegisterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(200) -} - -/* -SubnetRegisterDefault Generic error response. - -swagger:response subnetRegisterDefault -*/ -type SubnetRegisterDefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewSubnetRegisterDefault creates SubnetRegisterDefault with default headers values -func NewSubnetRegisterDefault(code int) *SubnetRegisterDefault { - if code <= 0 { - code = 500 - } - - return &SubnetRegisterDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the subnet register default response -func (o *SubnetRegisterDefault) WithStatusCode(code int) *SubnetRegisterDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the subnet register default response -func (o *SubnetRegisterDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the subnet register default response -func (o *SubnetRegisterDefault) WithPayload(payload *models.APIError) *SubnetRegisterDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the subnet register default response -func (o *SubnetRegisterDefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SubnetRegisterDefault) 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/api/operations/subnet/subnet_register_urlbuilder.go b/api/operations/subnet/subnet_register_urlbuilder.go deleted file mode 100644 index 66c5218f3b..0000000000 --- a/api/operations/subnet/subnet_register_urlbuilder.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package subnet - -// 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" -) - -// SubnetRegisterURL generates an URL for the subnet register operation -type SubnetRegisterURL 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 *SubnetRegisterURL) WithBasePath(bp string) *SubnetRegisterURL { - 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 *SubnetRegisterURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *SubnetRegisterURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/subnet/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 *SubnetRegisterURL) 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 *SubnetRegisterURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *SubnetRegisterURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on SubnetRegisterURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on SubnetRegisterURL") - } - - 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 *SubnetRegisterURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/operations/support/get_call_home_option_value.go b/api/operations/support/get_call_home_option_value.go deleted file mode 100644 index 54d60453ae..0000000000 --- a/api/operations/support/get_call_home_option_value.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package support - -// 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" -) - -// GetCallHomeOptionValueHandlerFunc turns a function with the right signature into a get call home option value handler -type GetCallHomeOptionValueHandlerFunc func(GetCallHomeOptionValueParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn GetCallHomeOptionValueHandlerFunc) Handle(params GetCallHomeOptionValueParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// GetCallHomeOptionValueHandler interface for that can handle valid get call home option value params -type GetCallHomeOptionValueHandler interface { - Handle(GetCallHomeOptionValueParams, *models.Principal) middleware.Responder -} - -// NewGetCallHomeOptionValue creates a new http.Handler for the get call home option value operation -func NewGetCallHomeOptionValue(ctx *middleware.Context, handler GetCallHomeOptionValueHandler) *GetCallHomeOptionValue { - return &GetCallHomeOptionValue{Context: ctx, Handler: handler} -} - -/* - GetCallHomeOptionValue swagger:route GET /support/callhome Support getCallHomeOptionValue - -Get Callhome current status -*/ -type GetCallHomeOptionValue struct { - Context *middleware.Context - Handler GetCallHomeOptionValueHandler -} - -func (o *GetCallHomeOptionValue) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewGetCallHomeOptionValueParams() - 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/api/operations/support/get_call_home_option_value_parameters.go b/api/operations/support/get_call_home_option_value_parameters.go deleted file mode 100644 index 3b8b39d109..0000000000 --- a/api/operations/support/get_call_home_option_value_parameters.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package support - -// 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" -) - -// NewGetCallHomeOptionValueParams creates a new GetCallHomeOptionValueParams object -// -// There are no default values defined in the spec. -func NewGetCallHomeOptionValueParams() GetCallHomeOptionValueParams { - - return GetCallHomeOptionValueParams{} -} - -// GetCallHomeOptionValueParams contains all the bound params for the get call home option value operation -// typically these are obtained from a http.Request -// -// swagger:parameters GetCallHomeOptionValue -type GetCallHomeOptionValueParams 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 NewGetCallHomeOptionValueParams() beforehand. -func (o *GetCallHomeOptionValueParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/api/operations/support/get_call_home_option_value_responses.go b/api/operations/support/get_call_home_option_value_responses.go deleted file mode 100644 index 22bc6dc9f2..0000000000 --- a/api/operations/support/get_call_home_option_value_responses.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package support - -// 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" -) - -// GetCallHomeOptionValueOKCode is the HTTP code returned for type GetCallHomeOptionValueOK -const GetCallHomeOptionValueOKCode int = 200 - -/* -GetCallHomeOptionValueOK A successful response. - -swagger:response getCallHomeOptionValueOK -*/ -type GetCallHomeOptionValueOK struct { - - /* - In: Body - */ - Payload *models.CallHomeGetResponse `json:"body,omitempty"` -} - -// NewGetCallHomeOptionValueOK creates GetCallHomeOptionValueOK with default headers values -func NewGetCallHomeOptionValueOK() *GetCallHomeOptionValueOK { - - return &GetCallHomeOptionValueOK{} -} - -// WithPayload adds the payload to the get call home option value o k response -func (o *GetCallHomeOptionValueOK) WithPayload(payload *models.CallHomeGetResponse) *GetCallHomeOptionValueOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get call home option value o k response -func (o *GetCallHomeOptionValueOK) SetPayload(payload *models.CallHomeGetResponse) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetCallHomeOptionValueOK) 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 - } - } -} - -/* -GetCallHomeOptionValueDefault Generic error response. - -swagger:response getCallHomeOptionValueDefault -*/ -type GetCallHomeOptionValueDefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewGetCallHomeOptionValueDefault creates GetCallHomeOptionValueDefault with default headers values -func NewGetCallHomeOptionValueDefault(code int) *GetCallHomeOptionValueDefault { - if code <= 0 { - code = 500 - } - - return &GetCallHomeOptionValueDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the get call home option value default response -func (o *GetCallHomeOptionValueDefault) WithStatusCode(code int) *GetCallHomeOptionValueDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the get call home option value default response -func (o *GetCallHomeOptionValueDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the get call home option value default response -func (o *GetCallHomeOptionValueDefault) WithPayload(payload *models.APIError) *GetCallHomeOptionValueDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the get call home option value default response -func (o *GetCallHomeOptionValueDefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *GetCallHomeOptionValueDefault) 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/api/operations/support/get_call_home_option_value_urlbuilder.go b/api/operations/support/get_call_home_option_value_urlbuilder.go deleted file mode 100644 index b73f7372d3..0000000000 --- a/api/operations/support/get_call_home_option_value_urlbuilder.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package support - -// 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" -) - -// GetCallHomeOptionValueURL generates an URL for the get call home option value operation -type GetCallHomeOptionValueURL 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 *GetCallHomeOptionValueURL) WithBasePath(bp string) *GetCallHomeOptionValueURL { - 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 *GetCallHomeOptionValueURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *GetCallHomeOptionValueURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/support/callhome" - - _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 *GetCallHomeOptionValueURL) 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 *GetCallHomeOptionValueURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *GetCallHomeOptionValueURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on GetCallHomeOptionValueURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on GetCallHomeOptionValueURL") - } - - 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 *GetCallHomeOptionValueURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/operations/support/set_call_home_status.go b/api/operations/support/set_call_home_status.go deleted file mode 100644 index befe3e853c..0000000000 --- a/api/operations/support/set_call_home_status.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package support - -// 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" -) - -// SetCallHomeStatusHandlerFunc turns a function with the right signature into a set call home status handler -type SetCallHomeStatusHandlerFunc func(SetCallHomeStatusParams, *models.Principal) middleware.Responder - -// Handle executing the request and returning a response -func (fn SetCallHomeStatusHandlerFunc) Handle(params SetCallHomeStatusParams, principal *models.Principal) middleware.Responder { - return fn(params, principal) -} - -// SetCallHomeStatusHandler interface for that can handle valid set call home status params -type SetCallHomeStatusHandler interface { - Handle(SetCallHomeStatusParams, *models.Principal) middleware.Responder -} - -// NewSetCallHomeStatus creates a new http.Handler for the set call home status operation -func NewSetCallHomeStatus(ctx *middleware.Context, handler SetCallHomeStatusHandler) *SetCallHomeStatus { - return &SetCallHomeStatus{Context: ctx, Handler: handler} -} - -/* - SetCallHomeStatus swagger:route PUT /support/callhome Support setCallHomeStatus - -Sets callhome status -*/ -type SetCallHomeStatus struct { - Context *middleware.Context - Handler SetCallHomeStatusHandler -} - -func (o *SetCallHomeStatus) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewSetCallHomeStatusParams() - 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/api/operations/support/set_call_home_status_parameters.go b/api/operations/support/set_call_home_status_parameters.go deleted file mode 100644 index 8d587a388e..0000000000 --- a/api/operations/support/set_call_home_status_parameters.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package support - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "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" -) - -// NewSetCallHomeStatusParams creates a new SetCallHomeStatusParams object -// -// There are no default values defined in the spec. -func NewSetCallHomeStatusParams() SetCallHomeStatusParams { - - return SetCallHomeStatusParams{} -} - -// SetCallHomeStatusParams contains all the bound params for the set call home status operation -// typically these are obtained from a http.Request -// -// swagger:parameters SetCallHomeStatus -type SetCallHomeStatusParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /* - Required: true - In: body - */ - Body *models.CallHomeSetStatus -} - -// 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 NewSetCallHomeStatusParams() beforehand. -func (o *SetCallHomeStatusParams) 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.CallHomeSetStatus - 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(r.Context()) - 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/api/operations/support/set_call_home_status_responses.go b/api/operations/support/set_call_home_status_responses.go deleted file mode 100644 index 8304632255..0000000000 --- a/api/operations/support/set_call_home_status_responses.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package support - -// 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" -) - -// SetCallHomeStatusNoContentCode is the HTTP code returned for type SetCallHomeStatusNoContent -const SetCallHomeStatusNoContentCode int = 204 - -/* -SetCallHomeStatusNoContent A successful response. - -swagger:response setCallHomeStatusNoContent -*/ -type SetCallHomeStatusNoContent struct { -} - -// NewSetCallHomeStatusNoContent creates SetCallHomeStatusNoContent with default headers values -func NewSetCallHomeStatusNoContent() *SetCallHomeStatusNoContent { - - return &SetCallHomeStatusNoContent{} -} - -// WriteResponse to the client -func (o *SetCallHomeStatusNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses - - rw.WriteHeader(204) -} - -/* -SetCallHomeStatusDefault Generic error response. - -swagger:response setCallHomeStatusDefault -*/ -type SetCallHomeStatusDefault struct { - _statusCode int - - /* - In: Body - */ - Payload *models.APIError `json:"body,omitempty"` -} - -// NewSetCallHomeStatusDefault creates SetCallHomeStatusDefault with default headers values -func NewSetCallHomeStatusDefault(code int) *SetCallHomeStatusDefault { - if code <= 0 { - code = 500 - } - - return &SetCallHomeStatusDefault{ - _statusCode: code, - } -} - -// WithStatusCode adds the status to the set call home status default response -func (o *SetCallHomeStatusDefault) WithStatusCode(code int) *SetCallHomeStatusDefault { - o._statusCode = code - return o -} - -// SetStatusCode sets the status to the set call home status default response -func (o *SetCallHomeStatusDefault) SetStatusCode(code int) { - o._statusCode = code -} - -// WithPayload adds the payload to the set call home status default response -func (o *SetCallHomeStatusDefault) WithPayload(payload *models.APIError) *SetCallHomeStatusDefault { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the set call home status default response -func (o *SetCallHomeStatusDefault) SetPayload(payload *models.APIError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *SetCallHomeStatusDefault) 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/api/operations/support/set_call_home_status_urlbuilder.go b/api/operations/support/set_call_home_status_urlbuilder.go deleted file mode 100644 index a24c2b8aa4..0000000000 --- a/api/operations/support/set_call_home_status_urlbuilder.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package support - -// 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" -) - -// SetCallHomeStatusURL generates an URL for the set call home status operation -type SetCallHomeStatusURL 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 *SetCallHomeStatusURL) WithBasePath(bp string) *SetCallHomeStatusURL { - 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 *SetCallHomeStatusURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *SetCallHomeStatusURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/support/callhome" - - _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 *SetCallHomeStatusURL) 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 *SetCallHomeStatusURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *SetCallHomeStatusURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on SetCallHomeStatusURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on SetCallHomeStatusURL") - } - - 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 *SetCallHomeStatusURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/api/user_support.go b/api/user_support.go deleted file mode 100644 index b3fd2b9ed3..0000000000 --- a/api/user_support.go +++ /dev/null @@ -1,232 +0,0 @@ -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package api - -import ( - "errors" - "fmt" - - "github.com/go-openapi/runtime/middleware" - "github.com/minio/console/api/operations" - "github.com/minio/console/api/operations/support" - "github.com/minio/console/models" - "github.com/minio/console/pkg/subnet" - "golang.org/x/net/context" -) - -type ConfigurationSetItem struct { - Value string - Enable bool -} - -func registerSupportHandlers(api *operations.ConsoleAPI) { - // callhome handlers - api.SupportGetCallHomeOptionValueHandler = support.GetCallHomeOptionValueHandlerFunc(func(params support.GetCallHomeOptionValueParams, session *models.Principal) middleware.Responder { - callhomeResp, err := getCallHomeOptionResponse(session, params) - if err != nil { - return support.NewGetCallHomeOptionValueDefault(err.Code).WithPayload(err.APIError) - } - - return support.NewGetCallHomeOptionValueOK().WithPayload(callhomeResp) - }) - - api.SupportSetCallHomeStatusHandler = support.SetCallHomeStatusHandlerFunc(func(params support.SetCallHomeStatusParams, session *models.Principal) middleware.Responder { - err := editCallHomeOptionResponse(session, params) - if err != nil { - return support.NewSetCallHomeStatusDefault(err.Code).WithPayload(err.APIError) - } - - return support.NewSetCallHomeStatusNoContent() - }) -} - -// getCallHomeOptionResponse returns the selected option value -func getCallHomeOptionResponse(session *models.Principal, params support.GetCallHomeOptionValueParams) (*models.CallHomeGetResponse, *CodedAPIError) { - ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) - defer cancel() - - mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - - minioClient := AdminClient{Client: mAdmin} - - response, err := getCallHomeRule(ctx, minioClient) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - - return response, nil -} - -func getCallHomeRule(ctx context.Context, client MinioAdmin) (*models.CallHomeGetResponse, error) { - // We verify if callhome SubSys is supported - supportedSubSys, err := minioConfigSupportsSubSys(ctx, client, "callhome") - if err != nil { - return nil, err - } - - var returnResponse models.CallHomeGetResponse - - // SubSys is not supported, hence callhome is disabled. - if !supportedSubSys { - returnResponse.DiagnosticsStatus = false - returnResponse.LogsStatus = false - - return &returnResponse, nil - } - - diagnosticsProps, err := getConfig(ctx, client, "callhome") - if err != nil { - return nil, err - } - - diagnosticsSt := true - - for _, properties := range diagnosticsProps { - for _, property := range properties.KeyValues { - if property.Key == "enable" { - diagnosticsSt = property.Value == "on" - } - } - } - - loggerSt := true - - loggerProps, err := getConfig(ctx, client, "logger_webhook:subnet") - - // Logger not defined, then it is disabled. - if err != nil { - loggerSt = false - } else { - for _, logger := range loggerProps { - for _, property := range logger.KeyValues { - if property.Key == "enable" { - loggerSt = property.Value == "on" - } - } - } - } - - returnModel := models.CallHomeGetResponse{DiagnosticsStatus: diagnosticsSt, LogsStatus: loggerSt} - - return &returnModel, nil -} - -// editCallHomeOptionResponse returns if there was an error setting the option -func editCallHomeOptionResponse(session *models.Principal, params support.SetCallHomeStatusParams) *CodedAPIError { - ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) - defer cancel() - - mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session) - if err != nil { - return ErrorWithContext(ctx, err) - } - - minioClient := AdminClient{Client: mAdmin} - - err = setCallHomeConfiguration(ctx, minioClient, *params.Body.DiagState, *params.Body.LogsState) - if err != nil { - return ErrorWithContext(ctx, err) - } - - return nil -} - -func configureCallHomeDiagnostics(ctx context.Context, client MinioAdmin, diagState bool) error { - // We verify if callhome SubSys is supported - supportedSubSys, err := minioConfigSupportsSubSys(ctx, client, "callhome") - if err != nil { - return err - } - - // SubSys is not supported, hence callhome not available - if !supportedSubSys { - return errors.New("your version of MinIO doesn't support this configuration") - } - - enableStr := "off" - if diagState { - enableStr = "on" - } - configStr := "callhome enable=" + enableStr - _, err = client.setConfigKV(ctx, configStr) - if err != nil { - return err - } - - return nil -} - -func configureCallHomeLogs(ctx context.Context, client MinioAdmin, logState bool, apiKey string) error { - var configStr string - if logState { - configStr = fmt.Sprintf("logger_webhook:subnet endpoint=%s auth_token=%s enable=on", - subnet.LogWebhookURL(), apiKey) - } else { - configStr = "logger_webhook:subnet enable=off" - } - - // Call set config API - _, err := client.setConfigKV(ctx, configStr) - if err != nil { - return err - } - - return nil -} - -func setCallHomeConfiguration(ctx context.Context, client MinioAdmin, diagState, logsState bool) error { - tokenConfig, err := GetSubnetKeyFromMinIOConfig(ctx, client) - if err != nil { - return err - } - - apiKey := tokenConfig.APIKey - - if len(apiKey) == 0 { - return errors.New("please register this cluster in subnet to continue") - } - - err = configureCallHomeDiagnostics(ctx, client, diagState) - if err != nil { - return err - } - - err = configureCallHomeLogs(ctx, client, logsState, apiKey) - if err != nil { - return err - } - - return nil -} - -func minioConfigSupportsSubSys(ctx context.Context, client MinioAdmin, subSys string) (bool, error) { - help, err := client.helpConfigKVGlobal(ctx, false) - if err != nil { - return false, err - } - - for _, h := range help.KeysHelp { - if h.Key == subSys { - return true, nil - } - } - - return false, nil -} diff --git a/api/user_support_test.go b/api/user_support_test.go deleted file mode 100644 index f7891c8b9b..0000000000 --- a/api/user_support_test.go +++ /dev/null @@ -1,382 +0,0 @@ -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package api - -import ( - "context" - "errors" - "testing" - - "github.com/minio/console/models" - "github.com/minio/madmin-go/v3" -) - -func Test_getCallHomeRule(t *testing.T) { - type args struct { - ctx context.Context - session *models.Principal - } - ctx := context.Background() - tests := []struct { - name string - args args - helpConfigKVGlobal func(envOnly bool) (madmin.Help, error) - helpConfigKV func(subSys, key string, envOnly bool) (madmin.Help, error) - getConfigKV func(key string) ([]byte, error) - want *models.CallHomeGetResponse - wantErr bool - }{ - { - name: "subsys is not supported, dont crash / return anything", - args: args{ - ctx: ctx, - session: nil, - }, - helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) { - return madmin.Help{}, errors.New("feature is not supported") - }, - getConfigKV: func(_ string) ([]byte, error) { - return []byte{}, nil - }, - helpConfigKVGlobal: func(_ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "", - Description: "", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{}, - }, nil - }, - want: nil, - wantErr: false, - }, - { - name: "callhome enabled", - args: args{ - ctx: ctx, - session: nil, - }, - helpConfigKVGlobal: func(_ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "", - Description: "", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false}, - }, - }, nil - }, - helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "callhome", - Description: "enable callhome for the cluster", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "frequency", Type: "duration", Optional: true, MultipleTargets: false}, - {Key: "enable", Type: "on|off", Optional: true, MultipleTargets: false}, - }, - }, nil - }, - getConfigKV: func(_ string) ([]byte, error) { - return []byte(`callhome:_ frequency=24h enable=on`), nil - }, - want: &models.CallHomeGetResponse{ - DiagnosticsStatus: true, - }, - wantErr: false, - }, - { - name: "callhome is disabled", - args: args{ - ctx: ctx, - session: nil, - }, - helpConfigKVGlobal: func(_ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "", - Description: "", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false}, - }, - }, nil - }, - helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "callhome", - Description: "enable callhome for the cluster", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "frequency", Type: "duration", Optional: true, MultipleTargets: false}, - {Key: "enable", Type: "on|off", Optional: true, MultipleTargets: false}, - }, - }, nil - }, - getConfigKV: func(_ string) ([]byte, error) { - return []byte(`callhome:_ frequency=24h enable=off`), nil - }, - want: &models.CallHomeGetResponse{ - DiagnosticsStatus: false, - }, - wantErr: false, - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(_ *testing.T) { - adminClient := AdminClientMock{} - - minioGetConfigKVMock = tt.getConfigKV - minioHelpConfigKVMock = tt.helpConfigKV - minioHelpConfigKVGlobalMock = tt.helpConfigKVGlobal - - response, err := getCallHomeRule(tt.args.ctx, adminClient) - if (err != nil) != tt.wantErr { - t.Errorf("getCallHomeRule() error = %v, wantErr %v", err, tt.wantErr) - return - } - if tt.want != nil { - if response.DiagnosticsStatus != tt.want.DiagnosticsStatus { - t.Errorf("getCallHomeRule() got status = %v, want status %v", response.DiagnosticsStatus, tt.want.DiagnosticsStatus) - } - } - }) - } -} - -func Test_setCallHomeConfiguration(t *testing.T) { - type args struct { - ctx context.Context - session *models.Principal - diagState bool - } - ctx := context.Background() - tests := []struct { - name string - args args - helpConfigKVGlobal func(envOnly bool) (madmin.Help, error) - helpConfigKV func(subSys, key string, envOnly bool) (madmin.Help, error) - getConfigKV func(key string) ([]byte, error) - setConfigEnv func(kv string) (restart bool, err error) - wantErr bool - error error - }{ - { - name: "subsys is not supported, return error", - args: args{ - ctx: ctx, - session: nil, - diagState: false, - }, - helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) { - return madmin.Help{}, errors.New("feature is not supported") - }, - getConfigKV: func(_ string) ([]byte, error) { - return []byte{}, nil - }, - helpConfigKVGlobal: func(_ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "", - Description: "", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{}, - }, nil - }, - setConfigEnv: func(_ string) (restart bool, err error) { - return false, nil - }, - wantErr: true, - error: errors.New("unable to find subnet configuration"), - }, - { - name: "cluster not registered", - args: args{ - ctx: ctx, - session: nil, - diagState: false, - }, - helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "subnet", - Description: "set subnet config for the cluster e.g. api key", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "license", Type: "string", Optional: true, MultipleTargets: false}, - {Key: "api_key", Type: "string", Optional: true, MultipleTargets: false}, - {Key: "proxy", Type: "string", Optional: true, MultipleTargets: false}, - }, - }, nil - }, - getConfigKV: func(_ string) ([]byte, error) { - return []byte(`subnet license= api_key= proxy=http://127.0.0.1 `), nil - }, - helpConfigKVGlobal: func(_ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "", - Description: "", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false}, - }, - }, nil - }, - setConfigEnv: func(_ string) (restart bool, err error) { - return false, nil - }, - wantErr: true, - error: errors.New("please register this cluster in subnet to continue"), - }, - { - name: "enable without errors", - args: args{ - ctx: ctx, - session: nil, - diagState: true, - }, - helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "subnet", - Description: "set subnet config for the cluster e.g. api key", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "license", Type: "string", Optional: true, MultipleTargets: false}, - {Key: "api_key", Type: "string", Optional: true, MultipleTargets: false}, - {Key: "proxy", Type: "string", Optional: true, MultipleTargets: false}, - }, - }, nil - }, - getConfigKV: func(_ string) ([]byte, error) { - return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil - }, - helpConfigKVGlobal: func(_ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "", - Description: "", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false}, - }, - }, nil - }, - setConfigEnv: func(_ string) (restart bool, err error) { - return false, nil - }, - wantErr: false, - error: nil, - }, - { - name: "disable without errors", - args: args{ - ctx: ctx, - session: nil, - diagState: false, - }, - helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "subnet", - Description: "set subnet config for the cluster e.g. api key", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "license", Type: "string", Optional: true, MultipleTargets: false}, - {Key: "api_key", Type: "string", Optional: true, MultipleTargets: false}, - {Key: "proxy", Type: "string", Optional: true, MultipleTargets: false}, - }, - }, nil - }, - getConfigKV: func(_ string) ([]byte, error) { - return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil - }, - helpConfigKVGlobal: func(_ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "", - Description: "", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false}, - }, - }, nil - }, - setConfigEnv: func(_ string) (restart bool, err error) { - return false, nil - }, - wantErr: false, - error: nil, - }, - { - name: "Error setting diagState", - args: args{ - ctx: ctx, - session: nil, - diagState: false, - }, - helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "subnet", - Description: "set subnet config for the cluster e.g. api key", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "license", Type: "string", Optional: true, MultipleTargets: false}, - {Key: "api_key", Type: "string", Optional: true, MultipleTargets: false}, - {Key: "proxy", Type: "string", Optional: true, MultipleTargets: false}, - }, - }, nil - }, - getConfigKV: func(_ string) ([]byte, error) { - return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil - }, - helpConfigKVGlobal: func(_ bool) (madmin.Help, error) { - return madmin.Help{ - SubSys: "", - Description: "", - MultipleTargets: false, - KeysHelp: madmin.HelpKVS{ - {Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false}, - }, - }, nil - }, - setConfigEnv: func(_ string) (restart bool, err error) { - return false, errors.New("new error detected") - }, - wantErr: true, - error: errors.New("new error detected"), - }, - } - for _, tt := range tests { - tt := tt - t.Run(tt.name, func(_ *testing.T) { - adminClient := AdminClientMock{} - - minioGetConfigKVMock = tt.getConfigKV - minioHelpConfigKVMock = tt.helpConfigKV - minioHelpConfigKVGlobalMock = tt.helpConfigKVGlobal - minioSetConfigKVMock = tt.setConfigEnv - - err := setCallHomeConfiguration(tt.args.ctx, adminClient, tt.args.diagState, false) - - if (err != nil) != tt.wantErr { - t.Errorf("setCallHomeConfiguration() error = %v, wantErr %v", err, tt.wantErr) - return - } - - if tt.wantErr { - if tt.error.Error() != err.Error() { - t.Errorf("setCallHomeConfiguration() error mismatch, error = %v, wantErr %v", err.Error(), tt.error.Error()) - return - } - } - }) - } -} diff --git a/api/ws_handle.go b/api/ws_handle.go index bca31457d2..a6dedc9ebc 100644 --- a/api/ws_handle.go +++ b/api/ws_handle.go @@ -23,17 +23,12 @@ import ( "log" "net" "net/http" - "strconv" "strings" - "time" - - "github.com/minio/madmin-go/v3" - - "github.com/minio/console/pkg/utils" errorsApi "github.com/go-openapi/errors" "github.com/minio/console/models" "github.com/minio/console/pkg/auth" + "github.com/minio/console/pkg/utils" "github.com/minio/websocket" ) @@ -65,13 +60,6 @@ type ConsoleWebsocket interface { watch(options watchOptions) } -type wsS3Client struct { - // websocket connection. - conn wsConn - // mcClient - client MCClient -} - // ConsoleWebSocketMClient interface of a Websocket Client type ConsoleWebsocketMClient interface { objectManager(options objectsListOpts) @@ -188,42 +176,6 @@ func serveWS(w http.ResponseWriter, req *http.Request) { } switch { - case strings.HasPrefix(wsPath, `/trace`): - wsAdminClient, err := newWebSocketAdminClient(conn, session, clientIP) - if err != nil { - ErrorWithContext(ctx, err) - closeWsConn(conn) - return - } - - calls := req.URL.Query().Get("calls") - threshold, _ := strconv.ParseInt(req.URL.Query().Get("threshold"), 10, 64) - onlyErrors := req.URL.Query().Get("onlyErrors") - stCode, errorStCode := strconv.ParseInt(req.URL.Query().Get("statusCode"), 10, 64) - method := req.URL.Query().Get("method") - funcName := req.URL.Query().Get("funcname") - path := req.URL.Query().Get("path") - - statusCode := int64(0) - - if errorStCode == nil { - statusCode = stCode - } - - traceRequestItem := TraceRequest{ - s3: strings.Contains(calls, "s3") || strings.Contains(calls, "all"), - internal: strings.Contains(calls, "internal") || strings.Contains(calls, "all"), - storage: strings.Contains(calls, "storage") || strings.Contains(calls, "all"), - os: strings.Contains(calls, "os") || strings.Contains(calls, "all"), - onlyErrors: onlyErrors == "yes", - threshold: threshold, - statusCode: statusCode, - method: method, - funcName: funcName, - path: path, - } - - go wsAdminClient.trace(ctx, traceRequestItem) case strings.HasPrefix(wsPath, `/console`): wsAdminClient, err := newWebSocketAdminClient(conn, session, clientIP) @@ -240,63 +192,6 @@ func serveWS(w http.ResponseWriter, req *http.Request) { logType: logType, } go wsAdminClient.console(ctx, logRequestItem) - case strings.HasPrefix(wsPath, `/health-info`): - deadline, err := getHealthInfoOptionsFromReq(req) - if err != nil { - ErrorWithContext(ctx, fmt.Errorf("error getting health info options: %v", err)) - closeWsConn(conn) - return - } - wsAdminClient, err := newWebSocketAdminClient(conn, session, clientIP) - if err != nil { - ErrorWithContext(ctx, err) - closeWsConn(conn) - return - } - go wsAdminClient.healthInfo(ctx, deadline) - case strings.HasPrefix(wsPath, `/watch`): - wOptions, err := getWatchOptionsFromReq(req) - if err != nil { - ErrorWithContext(ctx, fmt.Errorf("error getting watch options: %v", err)) - closeWsConn(conn) - return - } - wsS3Client, err := newWebSocketS3Client(conn, session, wOptions.BucketName, "", clientIP) - if err != nil { - ErrorWithContext(ctx, err) - closeWsConn(conn) - return - } - go wsS3Client.watch(ctx, wOptions) - case strings.HasPrefix(wsPath, `/speedtest`): - speedtestOpts, err := getSpeedtestOptionsFromReq(req) - if err != nil { - ErrorWithContext(ctx, fmt.Errorf("error getting speedtest options: %v", err)) - closeWsConn(conn) - return - } - wsAdminClient, err := newWebSocketAdminClient(conn, session, clientIP) - if err != nil { - ErrorWithContext(ctx, err) - closeWsConn(conn) - return - } - go wsAdminClient.speedtest(ctx, speedtestOpts) - case strings.HasPrefix(wsPath, `/profile`): - pOptions, err := getProfileOptionsFromReq(req) - if err != nil { - ErrorWithContext(ctx, fmt.Errorf("error getting profile options: %v", err)) - closeWsConn(conn) - return - } - wsAdminClient, err := newWebSocketAdminClient(conn, session, clientIP) - if err != nil { - ErrorWithContext(ctx, err) - closeWsConn(conn) - return - } - go wsAdminClient.profile(ctx, pOptions) - case strings.HasPrefix(wsPath, `/objectManager`): wsMinioClient, err := newWebSocketMinioClient(conn, session, clientIP) if err != nil { @@ -334,26 +229,6 @@ func newWebSocketAdminClient(conn *websocket.Conn, autClaims *models.Principal, return wsAdminClient, nil } -// newWebSocketS3Client returns a wsAdminClient authenticated as Console admin -func newWebSocketS3Client(conn *websocket.Conn, claims *models.Principal, bucketName, prefix, clientIP string) (*wsS3Client, error) { - // Only start Websocket Interaction after user has been - // authenticated with MinIO - s3Client, err := newS3BucketClient(claims, bucketName, prefix, clientIP) - if err != nil { - LogError("error creating S3Client:", err) - return nil, err - } - // create a websocket connection interface implementation - // defining the connection to be used - wsConnection := wsConn{conn: conn} - // create a s3Client interface implementation - // defining the client to be used - mcS3C := mcClient{client: s3Client} - // create websocket client and handle request - wsS3Client := &wsS3Client{conn: wsConnection, client: mcS3C} - return wsS3Client, nil -} - func newWebSocketMinioClient(conn *websocket.Conn, claims *models.Principal, clientIP string) (*wsMinioClient, error) { mClient, err := newMinioClient(claims, clientIP) if err != nil { @@ -438,23 +313,6 @@ func closeWsConn(conn *websocket.Conn) { conn.Close() } -// trace serves madmin.ServiceTraceInfo -// on a Websocket connection. -func (wsc *wsAdminClient) trace(ctx context.Context, traceRequestItem TraceRequest) { - defer func() { - LogInfo("trace stopped") - // close connection after return - wsc.conn.close() - }() - LogInfo("trace started") - - ctx = wsReadClientCtx(ctx, wsc.conn) - - err := startTraceInfo(ctx, wsc.conn, wsc.client, traceRequestItem) - - sendWsCloseMessage(wsc.conn, err) -} - // console serves madmin.GetLogs // on a Websocket connection. func (wsc *wsAdminClient) console(ctx context.Context, logRequestItem LogRequest) { @@ -472,65 +330,6 @@ func (wsc *wsAdminClient) console(ctx context.Context, logRequestItem LogRequest sendWsCloseMessage(wsc.conn, err) } -func (wsc *wsS3Client) watch(ctx context.Context, params *watchOptions) { - defer func() { - LogInfo("watch stopped") - // close connection after return - wsc.conn.close() - }() - LogInfo("watch started") - - ctx = wsReadClientCtx(ctx, wsc.conn) - - err := startWatch(ctx, wsc.conn, wsc.client, params) - - sendWsCloseMessage(wsc.conn, err) -} - -func (wsc *wsAdminClient) healthInfo(ctx context.Context, deadline *time.Duration) { - defer func() { - LogInfo("health info stopped") - // close connection after return - wsc.conn.close() - }() - LogInfo("health info started") - - ctx = wsReadClientCtx(ctx, wsc.conn) - err := startHealthInfo(ctx, wsc.conn, wsc.client, deadline) - - sendWsCloseMessage(wsc.conn, err) -} - -func (wsc *wsAdminClient) speedtest(ctx context.Context, opts *madmin.SpeedtestOpts) { - defer func() { - LogInfo("speedtest stopped") - // close connection after return - wsc.conn.close() - }() - LogInfo("speedtest started") - - ctx = wsReadClientCtx(ctx, wsc.conn) - - err := startSpeedtest(ctx, wsc.conn, wsc.client, opts) - - sendWsCloseMessage(wsc.conn, err) -} - -func (wsc *wsAdminClient) profile(ctx context.Context, opts *profileOptions) { - defer func() { - LogInfo("profile stopped") - // close connection after return - wsc.conn.close() - }() - LogInfo("profile started") - - ctx = wsReadClientCtx(ctx, wsc.conn) - - err := startProfiling(ctx, wsc.conn, wsc.client, opts) - - sendWsCloseMessage(wsc.conn, err) -} - // sendWsCloseMessage sends Websocket Connection Close Message indicating the Status Code // see https://tools.ietf.org/html/rfc6455#page-45 func sendWsCloseMessage(conn WSConn, err error) { diff --git a/models/add_bucket_lifecycle.go b/models/add_bucket_lifecycle.go index 9302ce792b..6aacadd790 100644 --- a/models/add_bucket_lifecycle.go +++ b/models/add_bucket_lifecycle.go @@ -74,7 +74,7 @@ type AddBucketLifecycle struct { TransitionDays int32 `json:"transition_days,omitempty"` // ILM Rule type (Expiry or transition) - // Enum: ["expiry","transition"] + // Enum: [expiry transition] Type string `json:"type,omitempty"` } diff --git a/models/add_multi_bucket_lifecycle.go b/models/add_multi_bucket_lifecycle.go index f3e742f22f..a51ff48cb4 100644 --- a/models/add_multi_bucket_lifecycle.go +++ b/models/add_multi_bucket_lifecycle.go @@ -73,7 +73,7 @@ type AddMultiBucketLifecycle struct { // ILM Rule type (Expiry or transition) // Required: true - // Enum: ["expiry","transition"] + // Enum: [expiry transition] Type *string `json:"type"` } diff --git a/models/admin_info_response.go b/models/admin_info_response.go index 8f9855d1ac..1349867c18 100644 --- a/models/admin_info_response.go +++ b/models/admin_info_response.go @@ -39,7 +39,7 @@ import ( type AdminInfoResponse struct { // advanced metrics status - // Enum: ["not configured","available","unavailable"] + // Enum: [not configured available unavailable] AdvancedMetricsStatus string `json:"advancedMetricsStatus,omitempty"` // backend diff --git a/models/bucket.go b/models/bucket.go index e2456a5975..2fc06bca45 100644 --- a/models/bucket.go +++ b/models/bucket.go @@ -382,7 +382,7 @@ type BucketDetailsQuota struct { Quota int64 `json:"quota,omitempty"` // type - // Enum: ["hard"] + // Enum: [hard] Type string `json:"type,omitempty"` } diff --git a/models/bucket_quota.go b/models/bucket_quota.go index 4f606f4d26..51b5b3dc28 100644 --- a/models/bucket_quota.go +++ b/models/bucket_quota.go @@ -41,7 +41,7 @@ type BucketQuota struct { Quota int64 `json:"quota,omitempty"` // type - // Enum: ["hard"] + // Enum: [hard] Type string `json:"type,omitempty"` } diff --git a/models/bucket_replication_rule.go b/models/bucket_replication_rule.go index f13e00e9a6..6a68308763 100644 --- a/models/bucket_replication_rule.go +++ b/models/bucket_replication_rule.go @@ -68,14 +68,14 @@ type BucketReplicationRule struct { Priority int32 `json:"priority,omitempty"` // status - // Enum: ["Enabled","Disabled"] + // Enum: [Enabled Disabled] Status string `json:"status,omitempty"` // storage class StorageClass string `json:"storageClass,omitempty"` // sync mode - // Enum: ["async","sync"] + // Enum: [async sync] SyncMode *string `json:"syncMode,omitempty"` // tags diff --git a/models/create_remote_bucket.go b/models/create_remote_bucket.go index 4469c2c627..f595a95296 100644 --- a/models/create_remote_bucket.go +++ b/models/create_remote_bucket.go @@ -61,7 +61,7 @@ type CreateRemoteBucket struct { SourceBucket *string `json:"sourceBucket"` // sync mode - // Enum: ["async","sync"] + // Enum: [async sync] SyncMode *string `json:"syncMode,omitempty"` // target bucket diff --git a/models/login_details.go b/models/login_details.go index 9e908335ff..3055f7336f 100644 --- a/models/login_details.go +++ b/models/login_details.go @@ -45,7 +45,7 @@ type LoginDetails struct { IsK8S bool `json:"isK8S,omitempty"` // login strategy - // Enum: ["form","redirect","service-account","redirect-service-account"] + // Enum: [form redirect service-account redirect-service-account] LoginStrategy string `json:"loginStrategy,omitempty"` // redirect rules diff --git a/models/multi_bucket_replication.go b/models/multi_bucket_replication.go index 44896c624a..728e66b612 100644 --- a/models/multi_bucket_replication.go +++ b/models/multi_bucket_replication.go @@ -83,7 +83,7 @@ type MultiBucketReplication struct { StorageClass string `json:"storageClass,omitempty"` // sync mode - // Enum: ["async","sync"] + // Enum: [async sync] SyncMode *string `json:"syncMode,omitempty"` // tags diff --git a/models/remote_bucket.go b/models/remote_bucket.go index fdeda43bcf..2473f2ac57 100644 --- a/models/remote_bucket.go +++ b/models/remote_bucket.go @@ -57,7 +57,7 @@ type RemoteBucket struct { SecretKey string `json:"secretKey,omitempty"` // service - // Enum: ["replication"] + // Enum: [replication] Service string `json:"service,omitempty"` // source bucket diff --git a/models/session_response.go b/models/session_response.go index 819d8aa677..ece2c13f5e 100644 --- a/models/session_response.go +++ b/models/session_response.go @@ -63,7 +63,7 @@ type SessionResponse struct { ServerEndPoint string `json:"serverEndPoint,omitempty"` // status - // Enum: ["ok"] + // Enum: [ok] Status string `json:"status,omitempty"` } diff --git a/models/set_bucket_quota.go b/models/set_bucket_quota.go index 739e7f65a3..01668ab6e5 100644 --- a/models/set_bucket_quota.go +++ b/models/set_bucket_quota.go @@ -45,7 +45,7 @@ type SetBucketQuota struct { Enabled *bool `json:"enabled"` // quota type - // Enum: ["hard"] + // Enum: [hard] QuotaType string `json:"quota_type,omitempty"` } diff --git a/models/subnet_login_m_f_a_request.go b/models/subnet_login_m_f_a_request.go deleted file mode 100644 index 61184a3bf6..0000000000 --- a/models/subnet_login_m_f_a_request.go +++ /dev/null @@ -1,122 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -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" -) - -// SubnetLoginMFARequest subnet login m f a request -// -// swagger:model subnetLoginMFARequest -type SubnetLoginMFARequest 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 subnet login m f a request -func (m *SubnetLoginMFARequest) 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 *SubnetLoginMFARequest) validateMfaToken(formats strfmt.Registry) error { - - if err := validate.Required("mfa_token", "body", m.MfaToken); err != nil { - return err - } - - return nil -} - -func (m *SubnetLoginMFARequest) validateOtp(formats strfmt.Registry) error { - - if err := validate.Required("otp", "body", m.Otp); err != nil { - return err - } - - return nil -} - -func (m *SubnetLoginMFARequest) validateUsername(formats strfmt.Registry) error { - - if err := validate.Required("username", "body", m.Username); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this subnet login m f a request based on context it is used -func (m *SubnetLoginMFARequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *SubnetLoginMFARequest) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SubnetLoginMFARequest) UnmarshalBinary(b []byte) error { - var res SubnetLoginMFARequest - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/models/subnet_login_request.go b/models/subnet_login_request.go deleted file mode 100644 index fa4cb41ef3..0000000000 --- a/models/subnet_login_request.go +++ /dev/null @@ -1,73 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -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" -) - -// SubnetLoginRequest subnet login request -// -// swagger:model subnetLoginRequest -type SubnetLoginRequest struct { - - // api key - APIKey string `json:"apiKey,omitempty"` - - // password - Password string `json:"password,omitempty"` - - // username - Username string `json:"username,omitempty"` -} - -// Validate validates this subnet login request -func (m *SubnetLoginRequest) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this subnet login request based on context it is used -func (m *SubnetLoginRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *SubnetLoginRequest) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SubnetLoginRequest) UnmarshalBinary(b []byte) error { - var res SubnetLoginRequest - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/models/subnet_login_response.go b/models/subnet_login_response.go deleted file mode 100644 index 56df2b7caa..0000000000 --- a/models/subnet_login_response.go +++ /dev/null @@ -1,147 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -package models - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "strconv" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// SubnetLoginResponse subnet login response -// -// swagger:model subnetLoginResponse -type SubnetLoginResponse struct { - - // access token - AccessToken string `json:"access_token,omitempty"` - - // mfa token - MfaToken string `json:"mfa_token,omitempty"` - - // organizations - Organizations []*SubnetOrganization `json:"organizations"` - - // registered - Registered bool `json:"registered,omitempty"` -} - -// Validate validates this subnet login response -func (m *SubnetLoginResponse) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateOrganizations(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SubnetLoginResponse) validateOrganizations(formats strfmt.Registry) error { - if swag.IsZero(m.Organizations) { // not required - return nil - } - - for i := 0; i < len(m.Organizations); i++ { - if swag.IsZero(m.Organizations[i]) { // not required - continue - } - - if m.Organizations[i] != nil { - if err := m.Organizations[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("organizations" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("organizations" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// ContextValidate validate this subnet login response based on the context it is used -func (m *SubnetLoginResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateOrganizations(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SubnetLoginResponse) contextValidateOrganizations(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.Organizations); i++ { - - if m.Organizations[i] != nil { - - if swag.IsZero(m.Organizations[i]) { // not required - return nil - } - - if err := m.Organizations[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("organizations" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("organizations" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - -// MarshalBinary interface implementation -func (m *SubnetLoginResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SubnetLoginResponse) UnmarshalBinary(b []byte) error { - var res SubnetLoginResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/models/subnet_organization.go b/models/subnet_organization.go deleted file mode 100644 index 143507325b..0000000000 --- a/models/subnet_organization.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -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" -) - -// SubnetOrganization subnet organization -// -// swagger:model subnetOrganization -type SubnetOrganization struct { - - // account Id - AccountID int64 `json:"accountId,omitempty"` - - // company - Company string `json:"company,omitempty"` - - // is account owner - IsAccountOwner bool `json:"isAccountOwner,omitempty"` - - // short name - ShortName string `json:"shortName,omitempty"` - - // subscription status - SubscriptionStatus string `json:"subscriptionStatus,omitempty"` - - // user Id - UserID int64 `json:"userId,omitempty"` -} - -// Validate validates this subnet organization -func (m *SubnetOrganization) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this subnet organization based on context it is used -func (m *SubnetOrganization) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *SubnetOrganization) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SubnetOrganization) UnmarshalBinary(b []byte) error { - var res SubnetOrganization - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/models/subnet_reg_token_response.go b/models/subnet_reg_token_response.go deleted file mode 100644 index 7927ec2eb7..0000000000 --- a/models/subnet_reg_token_response.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -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" -) - -// SubnetRegTokenResponse subnet reg token response -// -// swagger:model SubnetRegTokenResponse -type SubnetRegTokenResponse struct { - - // reg token - RegToken string `json:"regToken,omitempty"` -} - -// Validate validates this subnet reg token response -func (m *SubnetRegTokenResponse) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this subnet reg token response based on context it is used -func (m *SubnetRegTokenResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *SubnetRegTokenResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SubnetRegTokenResponse) UnmarshalBinary(b []byte) error { - var res SubnetRegTokenResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/models/subnet_register_request.go b/models/subnet_register_request.go deleted file mode 100644 index 7b9687f63d..0000000000 --- a/models/subnet_register_request.go +++ /dev/null @@ -1,105 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -// - -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" -) - -// SubnetRegisterRequest subnet register request -// -// swagger:model subnetRegisterRequest -type SubnetRegisterRequest struct { - - // account id - // Required: true - AccountID *string `json:"account_id"` - - // token - // Required: true - Token *string `json:"token"` -} - -// Validate validates this subnet register request -func (m *SubnetRegisterRequest) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateAccountID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateToken(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *SubnetRegisterRequest) validateAccountID(formats strfmt.Registry) error { - - if err := validate.Required("account_id", "body", m.AccountID); err != nil { - return err - } - - return nil -} - -func (m *SubnetRegisterRequest) validateToken(formats strfmt.Registry) error { - - if err := validate.Required("token", "body", m.Token); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this subnet register request based on context it is used -func (m *SubnetRegisterRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *SubnetRegisterRequest) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *SubnetRegisterRequest) UnmarshalBinary(b []byte) error { - var res SubnetRegisterRequest - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/models/tier.go b/models/tier.go index 1c48c44e75..0034ca1955 100644 --- a/models/tier.go +++ b/models/tier.go @@ -53,7 +53,7 @@ type Tier struct { Status bool `json:"status,omitempty"` // type - // Enum: ["s3","gcs","azure","minio","unsupported"] + // Enum: [s3 gcs azure minio unsupported] Type string `json:"type,omitempty"` } diff --git a/models/update_bucket_lifecycle.go b/models/update_bucket_lifecycle.go index c69ebd75e3..0e862998a2 100644 --- a/models/update_bucket_lifecycle.go +++ b/models/update_bucket_lifecycle.go @@ -72,7 +72,7 @@ type UpdateBucketLifecycle struct { // ILM Rule type (Expiry or transition) // Required: true - // Enum: ["expiry","transition"] + // Enum: [expiry transition] Type *string `json:"type"` } diff --git a/pkg/subnet/config.go b/pkg/subnet/config.go deleted file mode 100644 index bcc77e5ba3..0000000000 --- a/pkg/subnet/config.go +++ /dev/null @@ -1,57 +0,0 @@ -// 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 . - -package subnet - -import ( - "errors" - "log" - - "github.com/minio/pkg/v3/licverifier" -) - -// GetLicenseInfoFromJWT will return license metadata from a jwt string license -func GetLicenseInfoFromJWT(license string, publicKeys []string) (*licverifier.LicenseInfo, error) { - if license == "" { - return nil, errors.New("license is not present") - } - for _, publicKey := range publicKeys { - lv, err := licverifier.NewLicenseVerifier([]byte(publicKey)) - if err != nil { - log.Print(err) - continue - } - licInfo, err := lv.Verify(license) - if err != nil { - log.Print(err) - continue - } - return &licInfo, nil - } - return nil, errors.New("invalid license key") -} - -// MfaReq - JSON payload of the SUBNET mfa api -type MfaReq struct { - Username string `json:"username"` - OTP string `json:"otp"` - Token string `json:"token"` -} - -type LoginResp struct { - AccessToken string - MfaToken string -} diff --git a/pkg/subnet/config_test.go b/pkg/subnet/config_test.go deleted file mode 100644 index 81f0607161..0000000000 --- a/pkg/subnet/config_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// 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 . - -package subnet - -import ( - "reflect" - "testing" - - "github.com/minio/pkg/v3/licverifier" -) - -var ( - license = "eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJrYW5hZ2FyYWorYzFAbWluaW8uaW8iLCJjYXAiOjUwLCJvcmciOiJHcmluZ290dHMgSW5jLiIsImV4cCI6MS42NDE0NDYxNjkwMDExOTg4OTRlOSwicGxhbiI6IlNUQU5EQVJEIiwiaXNzIjoic3VibmV0QG1pbi5pbyIsImFpZCI6MSwiaWF0IjoxLjYwOTkxMDE2OTAwMTE5ODg5NGU5fQ.EhTL2xwMHnUoLQF4UR-5bjUCja3whseLU5mb9XEj7PvAae6HEIDCOMEF8Hhh20DN_v_LRE283j2ZlA5zulcXSZXS0CLcrKqbVy6QLvZfvvLuerOjJI-NBa9dSJWJ0WoN" - - publicKeys = []string{`-----BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEbo+e1wpBY4tBq9AONKww3Kq7m6QP/TBQ -mr/cKCUyBL7rcAvg0zNq1vcSrUSGlAmY3SEDCu3GOKnjG/U4E7+p957ocWSV+mQU -9NKlTdQFGF3+aO6jbQ4hX/S5qPyF+a3z ------END PUBLIC KEY-----`} -) - -func TestGetLicenseInfoFromJWT(t *testing.T) { - mockLicense, _ := GetLicenseInfoFromJWT(license, publicKeys) - - type args struct { - license string - publicKeys []string - } - tests := []struct { - name string - args args - want *licverifier.LicenseInfo - wantErr bool - }{ - { - name: "error because missing license", - args: args{ - license: "", - publicKeys: OfflinePublicKeys, - }, - wantErr: true, - }, - { - name: "error because invalid license", - args: args{ - license: license, - publicKeys: []string{"eaeaeae"}, - }, - wantErr: true, - }, - { - name: "license successfully verified", - args: args{ - license: license, - publicKeys: publicKeys, - }, - wantErr: false, - want: mockLicense, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := GetLicenseInfoFromJWT(tt.args.license, tt.args.publicKeys) - if !tt.wantErr { - t.Skip() - } - if (err != nil) != tt.wantErr { - t.Errorf("GetLicenseInfoFromJWT() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetLicenseInfoFromJWT() got = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/subnet/const.go b/pkg/subnet/const.go deleted file mode 100644 index 8e0fadb167..0000000000 --- a/pkg/subnet/const.go +++ /dev/null @@ -1,30 +0,0 @@ -// 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 . - -package subnet - -var OfflinePublicKeys = []string{ - `-----BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEaK31xujr6/rZ7ZfXZh3SlwovjC+X8wGq -qkltaKyTLRENd4w3IRktYYCRgzpDLPn/nrf7snV/ERO5qcI7fkEES34IVEr+2Uff -JkO2PfyyAYEO/5dBlPh1Undu9WQl6J7B ------END PUBLIC KEY-----`, // https://subnet.min.io/downloads/license-pubkey.pem -} - -const ( - // Constants for subnet configuration - ConsoleSubnetURL = "CONSOLE_SUBNET_URL" -) diff --git a/pkg/subnet/subnet.go b/pkg/subnet/subnet.go deleted file mode 100644 index c3c833f747..0000000000 --- a/pkg/subnet/subnet.go +++ /dev/null @@ -1,131 +0,0 @@ -// 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 . -// - -package subnet - -import ( - "encoding/json" - "errors" - - "github.com/minio/console/pkg/http" - - "github.com/minio/console/models" - "github.com/minio/madmin-go/v3" - mc "github.com/minio/mc/cmd" - "github.com/tidwall/gjson" -) - -func LoginWithMFA(client http.ClientI, username, mfaToken, otp string) (*LoginResp, error) { - mfaLoginReq := MfaReq{Username: username, OTP: otp, Token: mfaToken} - resp, err := subnetPostReq(client, subnetMFAURL(), mfaLoginReq, nil) - if err != nil { - return nil, err - } - token := gjson.Get(resp, "token_info.access_token") - if token.Exists() { - return &LoginResp{AccessToken: token.String(), MfaToken: ""}, nil - } - return nil, errors.New("access token not found in response") -} - -func Login(client http.ClientI, username, password string) (*LoginResp, error) { - loginReq := map[string]string{ - "username": username, - "password": password, - } - respStr, err := subnetPostReq(client, subnetLoginURL(), loginReq, nil) - if err != nil { - return nil, err - } - mfaRequired := gjson.Get(respStr, "mfa_required").Bool() - if mfaRequired { - mfaToken := gjson.Get(respStr, "mfa_token").String() - if mfaToken == "" { - return nil, errors.New("missing mfa token") - } - return &LoginResp{AccessToken: "", MfaToken: mfaToken}, nil - } - token := gjson.Get(respStr, "token_info.access_token") - if token.Exists() { - return &LoginResp{AccessToken: token.String(), MfaToken: ""}, nil - } - return nil, errors.New("access token not found in response") -} - -func GetOrganizations(client http.ClientI, token string) ([]*models.SubnetOrganization, error) { - headers := subnetAuthHeaders(token) - respStr, err := subnetGetReq(client, subnetOrgsURL(), headers) - if err != nil { - return nil, err - } - var organizations []*models.SubnetOrganization - if err = json.Unmarshal([]byte(respStr), &organizations); err != nil { - return nil, err - } - return organizations, nil -} - -type LicenseTokenConfig struct { - APIKey string - License string - Proxy string -} - -func Register(client http.ClientI, admInfo madmin.InfoMessage, apiKey, token, accountID string) (*LicenseTokenConfig, error) { - var headers map[string]string - regInfo := GetClusterRegInfo(admInfo) - regURL := subnetRegisterURL() - if apiKey != "" { - regURL += "?api_key=" + apiKey - } else { - if accountID == "" || token == "" { - return nil, errors.New("missing accountID or authentication token") - } - headers = subnetAuthHeaders(token) - regURL += "?aid=" + accountID - } - regToken, err := GenerateRegToken(regInfo) - if err != nil { - return nil, err - } - reqPayload := mc.ClusterRegistrationReq{Token: regToken} - resp, err := subnetPostReq(client, regURL, reqPayload, headers) - if err != nil { - return nil, err - } - respJSON := gjson.Parse(resp) - subnetAPIKey := respJSON.Get("api_key").String() - licenseJwt := respJSON.Get("license").String() - - if subnetAPIKey != "" || licenseJwt != "" { - return &LicenseTokenConfig{ - APIKey: subnetAPIKey, - License: licenseJwt, - }, nil - } - return nil, errors.New("subnet api key not found") -} - -func GetAPIKey(client http.ClientI, token string) (string, error) { - resp, err := subnetGetReq(client, subnetAPIKeyURL(), subnetAuthHeaders(token)) - if err != nil { - return "", err - } - respJSON := gjson.Parse(resp) - apiKey := respJSON.Get("api_key").String() - return apiKey, nil -} diff --git a/pkg/subnet/utils.go b/pkg/subnet/utils.go deleted file mode 100644 index ad2ef17f54..0000000000 --- a/pkg/subnet/utils.go +++ /dev/null @@ -1,223 +0,0 @@ -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package subnet - -import ( - "bytes" - "crypto/tls" - "encoding/base64" - "encoding/json" - "fmt" - "io" - "net" - "net/http" - "time" - - "github.com/mattn/go-ieproxy" - xhttp "github.com/minio/console/pkg/http" - "github.com/tidwall/gjson" - - "github.com/minio/madmin-go/v3" - mc "github.com/minio/mc/cmd" - "github.com/minio/pkg/v3/env" -) - -const ( - subnetRespBodyLimit = 1 << 20 // 1 MiB -) - -func subnetBaseURL() string { - return env.Get(ConsoleSubnetURL, "https://subnet.min.io") -} - -func subnetRegisterURL() string { - return subnetBaseURL() + "/api/cluster/register" -} - -func subnetLoginURL() string { - return subnetBaseURL() + "/api/auth/login" -} - -func subnetOrgsURL() string { - return subnetBaseURL() + "/api/auth/organizations" -} - -func subnetMFAURL() string { - return subnetBaseURL() + "/api/auth/mfa-login" -} - -func subnetAPIKeyURL() string { - return subnetBaseURL() + "/api/auth/api-key" -} - -func LogWebhookURL() string { - return subnetBaseURL() + "/api/logs" -} - -func UploadURL(uploadType string, filename string) string { - return fmt.Sprintf("%s/api/%s/upload?filename=%s", subnetBaseURL(), uploadType, filename) -} - -func UploadAuthHeaders(apiKey string) map[string]string { - return map[string]string{"x-subnet-api-key": apiKey} -} - -func GenerateRegToken(clusterRegInfo mc.ClusterRegistrationInfo) (string, error) { - token, e := json.Marshal(clusterRegInfo) - if e != nil { - return "", e - } - - return base64.StdEncoding.EncodeToString(token), nil -} - -func subnetAuthHeaders(authToken string) map[string]string { - return map[string]string{"Authorization": "Bearer " + authToken} -} - -func httpDo(client xhttp.ClientI, req *http.Request) (*http.Response, error) { - return client.Do(req) -} - -func subnetReqDo(client xhttp.ClientI, r *http.Request, headers map[string]string) (string, error) { - for k, v := range headers { - r.Header.Add(k, v) - } - - ct := r.Header.Get("Content-Type") - if len(ct) == 0 { - r.Header.Add("Content-Type", "application/json") - } - - resp, e := httpDo(client, r) - if e != nil { - return "", e - } - - defer resp.Body.Close() - respBytes, e := io.ReadAll(io.LimitReader(resp.Body, subnetRespBodyLimit)) - if e != nil { - return "", e - } - respStr := string(respBytes) - - if resp.StatusCode == http.StatusOK { - return respStr, nil - } - return respStr, fmt.Errorf("Request failed with code %d and errors: %s", resp.StatusCode, respStr) -} - -func subnetGetReq(client xhttp.ClientI, reqURL string, headers map[string]string) (string, error) { - r, e := http.NewRequest(http.MethodGet, reqURL, nil) - if e != nil { - return "", e - } - return subnetReqDo(client, r, headers) -} - -func subnetPostReq(client xhttp.ClientI, reqURL string, payload interface{}, headers map[string]string) (string, error) { - body, e := json.Marshal(payload) - if e != nil { - return "", e - } - r, e := http.NewRequest(http.MethodPost, reqURL, bytes.NewReader(body)) - if e != nil { - return "", e - } - return subnetReqDo(client, r, headers) -} - -func GetClusterRegInfo(admInfo madmin.InfoMessage) mc.ClusterRegistrationInfo { - return mc.GetClusterRegInfo(admInfo, admInfo.DeploymentID) -} - -func GetSubnetAPIKeyUsingLicense(lic string) (string, error) { - return getSubnetAPIKeyUsingAuthHeaders(map[string]string{"x-subnet-license": lic}) -} - -func getSubnetAPIKeyUsingAuthHeaders(authHeaders map[string]string) (string, error) { - resp, e := subnetGetReqMC(subnetAPIKeyURL(), authHeaders) - if e != nil { - return "", e - } - return extractSubnetCred("api_key", gjson.Parse(resp)) -} - -func extractSubnetCred(key string, resp gjson.Result) (string, error) { - result := resp.Get(key) - if result.Index == 0 { - return "", fmt.Errorf("Couldn't extract %s from SUBNET response: %s", key, resp) - } - return result.String(), nil -} - -func subnetGetReqMC(reqURL string, headers map[string]string) (string, error) { - r, e := http.NewRequest(http.MethodGet, reqURL, nil) - if e != nil { - return "", e - } - return subnetReqDoMC(r, headers) -} - -func subnetReqDoMC(r *http.Request, headers map[string]string) (string, error) { - for k, v := range headers { - r.Header.Add(k, v) - } - - ct := r.Header.Get("Content-Type") - if len(ct) == 0 { - r.Header.Add("Content-Type", "application/json") - } - - resp, e := httpClientSubnet(0).Do(r) - if e != nil { - return "", e - } - - defer resp.Body.Close() - respBytes, e := io.ReadAll(io.LimitReader(resp.Body, subnetRespBodyLimit)) - if e != nil { - return "", e - } - respStr := string(respBytes) - - if resp.StatusCode == http.StatusOK { - return respStr, nil - } - return respStr, fmt.Errorf("Request failed with code %d with error: %s", resp.StatusCode, respStr) -} - -func httpClientSubnet(reqTimeout time.Duration) *http.Client { - return &http.Client{ - Timeout: reqTimeout, - Transport: &http.Transport{ - DialContext: (&net.Dialer{ - Timeout: 10 * time.Second, - }).DialContext, - Proxy: ieproxy.GetProxyFunc(), - TLSClientConfig: &tls.Config{ - // Can't use SSLv3 because of POODLE and BEAST - // Can't use TLSv1.0 because of POODLE and BEAST using CBC cipher - // Can't use TLSv1.1 because of RC4 cipher usage - MinVersion: tls.VersionTLS12, - }, - IdleConnTimeout: 90 * time.Second, - TLSHandshakeTimeout: 10 * time.Second, - ExpectContinueTimeout: 10 * time.Second, - }, - } -} diff --git a/pkg/subnet/utils_test.go b/pkg/subnet/utils_test.go deleted file mode 100644 index 692d15fe53..0000000000 --- a/pkg/subnet/utils_test.go +++ /dev/null @@ -1,481 +0,0 @@ -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package subnet - -import ( - "os" - "reflect" - "testing" - - "github.com/minio/mc/cmd" -) - -func Test_subnetBaseURL(t *testing.T) { - type args struct { - env map[string]string - } - tests := []struct { - name string - args args - want string - }{ - { - name: "default", - args: args{ - env: nil, - }, - want: "https://subnet.min.io", - }, - { - name: "with env", - args: args{ - env: map[string]string{ - "CONSOLE_SUBNET_URL": "http://oorgle", - }, - }, - want: "http://oorgle", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(_ *testing.T) { - if tt.args.env != nil { - for k, v := range tt.args.env { - os.Setenv(k, v) - } - } - if got := subnetBaseURL(); got != tt.want { - t.Errorf("subnetBaseURL() = %v, want %v", got, tt.want) - } - if tt.args.env != nil { - for k := range tt.args.env { - os.Unsetenv(k) - } - } - }) - } -} - -func Test_subnetRegisterURL(t *testing.T) { - type args struct { - env map[string]string - } - tests := []struct { - name string - args args - want string - }{ - { - name: "default", - args: args{ - env: nil, - }, - want: "https://subnet.min.io/api/cluster/register", - }, - { - name: "with env", - args: args{ - env: map[string]string{ - "CONSOLE_SUBNET_URL": "http://oorgle", - }, - }, - want: "http://oorgle/api/cluster/register", - }, - } - for _, tt := range tests { - if tt.args.env != nil { - for k, v := range tt.args.env { - os.Setenv(k, v) - } - } - t.Run(tt.name, func(_ *testing.T) { - if got := subnetRegisterURL(); got != tt.want { - t.Errorf("subnetRegisterURL() = %v, want %v", got, tt.want) - } - }) - if tt.args.env != nil { - for k := range tt.args.env { - os.Unsetenv(k) - } - } - } -} - -func Test_subnetLoginURL(t *testing.T) { - type args struct { - env map[string]string - } - tests := []struct { - name string - args args - want string - }{ - { - name: "default", - args: args{ - env: nil, - }, - want: "https://subnet.min.io/api/auth/login", - }, - { - name: "with env", - args: args{ - env: map[string]string{ - "CONSOLE_SUBNET_URL": "http://oorgle", - }, - }, - want: "http://oorgle/api/auth/login", - }, - } - for _, tt := range tests { - if tt.args.env != nil { - for k, v := range tt.args.env { - os.Setenv(k, v) - } - } - t.Run(tt.name, func(_ *testing.T) { - if got := subnetLoginURL(); got != tt.want { - t.Errorf("subnetLoginURL() = %v, want %v", got, tt.want) - } - }) - if tt.args.env != nil { - for k := range tt.args.env { - os.Unsetenv(k) - } - } - } -} - -func Test_subnetOrgsURL(t *testing.T) { - type args struct { - env map[string]string - } - tests := []struct { - name string - args args - want string - }{ - { - name: "default", - args: args{ - env: nil, - }, - want: "https://subnet.min.io/api/auth/organizations", - }, - { - name: "with env", - args: args{ - env: map[string]string{ - "CONSOLE_SUBNET_URL": "http://oorgle", - }, - }, - want: "http://oorgle/api/auth/organizations", - }, - } - for _, tt := range tests { - if tt.args.env != nil { - for k, v := range tt.args.env { - os.Setenv(k, v) - } - } - t.Run(tt.name, func(_ *testing.T) { - if got := subnetOrgsURL(); got != tt.want { - t.Errorf("subnetOrgsURL() = %v, want %v", got, tt.want) - } - }) - if tt.args.env != nil { - for k := range tt.args.env { - os.Unsetenv(k) - } - } - } -} - -func Test_subnetMFAURL(t *testing.T) { - type args struct { - env map[string]string - } - tests := []struct { - name string - args args - want string - }{ - { - name: "default", - args: args{ - env: nil, - }, - want: "https://subnet.min.io/api/auth/mfa-login", - }, - { - name: "with env", - args: args{ - env: map[string]string{ - "CONSOLE_SUBNET_URL": "http://oorgle", - }, - }, - want: "http://oorgle/api/auth/mfa-login", - }, - } - for _, tt := range tests { - if tt.args.env != nil { - for k, v := range tt.args.env { - os.Setenv(k, v) - } - } - t.Run(tt.name, func(_ *testing.T) { - if got := subnetMFAURL(); got != tt.want { - t.Errorf("subnetMFAURL() = %v, want %v", got, tt.want) - } - }) - if tt.args.env != nil { - for k := range tt.args.env { - os.Unsetenv(k) - } - } - } -} - -func Test_subnetAPIKeyURL(t *testing.T) { - type args struct { - env map[string]string - } - tests := []struct { - name string - args args - want string - }{ - { - name: "default", - args: args{ - env: nil, - }, - want: "https://subnet.min.io/api/auth/api-key", - }, - { - name: "with env", - args: args{ - env: map[string]string{ - "CONSOLE_SUBNET_URL": "http://oorgle", - }, - }, - want: "http://oorgle/api/auth/api-key", - }, - } - for _, tt := range tests { - if tt.args.env != nil { - for k, v := range tt.args.env { - os.Setenv(k, v) - } - } - t.Run(tt.name, func(_ *testing.T) { - if got := subnetAPIKeyURL(); got != tt.want { - t.Errorf("subnetAPIKeyURL() = %v, want %v", got, tt.want) - } - }) - if tt.args.env != nil { - for k := range tt.args.env { - os.Unsetenv(k) - } - } - } -} - -func TestLogWebhookURL(t *testing.T) { - type args struct { - env map[string]string - } - tests := []struct { - name string - args args - want string - }{ - { - name: "default", - args: args{ - env: nil, - }, - want: "https://subnet.min.io/api/logs", - }, - { - name: "with env", - args: args{ - env: map[string]string{ - "CONSOLE_SUBNET_URL": "http://oorgle", - }, - }, - want: "http://oorgle/api/logs", - }, - } - for _, tt := range tests { - if tt.args.env != nil { - for k, v := range tt.args.env { - os.Setenv(k, v) - } - } - t.Run(tt.name, func(_ *testing.T) { - if got := LogWebhookURL(); got != tt.want { - t.Errorf("LogWebhookURL() = %v, want %v", got, tt.want) - } - }) - if tt.args.env != nil { - for k := range tt.args.env { - os.Unsetenv(k) - } - } - } -} - -func TestUploadURL(t *testing.T) { - type args struct { - env map[string]string - uploadType string - filename string - } - tests := []struct { - name string - args args - want string - }{ - { - name: "default", - args: args{ - env: nil, - uploadType: "x", - filename: "y.jpg", - }, - want: "https://subnet.min.io/api/x/upload?filename=y.jpg", - }, - { - name: "with env", - args: args{ - env: map[string]string{ - "CONSOLE_SUBNET_URL": "http://oorgle", - }, - uploadType: "x", - filename: "y.jpg", - }, - want: "http://oorgle/api/x/upload?filename=y.jpg", - }, - } - for _, tt := range tests { - if tt.args.env != nil { - for k, v := range tt.args.env { - os.Setenv(k, v) - } - } - t.Run(tt.name, func(_ *testing.T) { - if got := UploadURL(tt.args.uploadType, tt.args.filename); got != tt.want { - t.Errorf("UploadURL() = %v, want %v", got, tt.want) - } - }) - if tt.args.env != nil { - for k := range tt.args.env { - os.Unsetenv(k) - } - } - } -} - -func TestUploadAuthHeaders(t *testing.T) { - type args struct { - apiKey string - } - tests := []struct { - name string - args args - want map[string]string - }{ - { - name: "basic", - args: args{ - apiKey: "xx", - }, - want: map[string]string{"x-subnet-api-key": "xx"}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(_ *testing.T) { - if got := UploadAuthHeaders(tt.args.apiKey); !reflect.DeepEqual(got, tt.want) { - t.Errorf("UploadAuthHeaders() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestGenerateRegToken(t *testing.T) { - type args struct { - clusterRegInfo cmd.ClusterRegistrationInfo - } - tests := []struct { - name string - args args - want string - wantErr bool - }{ - { - name: "basic", - args: args{ - clusterRegInfo: cmd.ClusterRegistrationInfo{ - DeploymentID: "x", - ClusterName: "y", - UsedCapacity: 1, - Info: cmd.ClusterInfo{}, - }, - }, - want: "eyJkZXBsb3ltZW50X2lkIjoieCIsImNsdXN0ZXJfbmFtZSI6InkiLCJ1c2VkX2NhcGFjaXR5IjoxLCJpbmZvIjp7Im1pbmlvX3ZlcnNpb24iOiIiLCJub19vZl9zZXJ2ZXJfcG9vbHMiOjAsIm5vX29mX3NlcnZlcnMiOjAsIm5vX29mX2RyaXZlcyI6MCwibm9fb2ZfYnVja2V0cyI6MCwibm9fb2Zfb2JqZWN0cyI6MCwidG90YWxfZHJpdmVfc3BhY2UiOjAsInVzZWRfZHJpdmVfc3BhY2UiOjB9fQ==", - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(_ *testing.T) { - got, err := GenerateRegToken(tt.args.clusterRegInfo) - if (err != nil) != tt.wantErr { - t.Errorf("GenerateRegToken() error = %v, wantErr %v", err, tt.wantErr) - return - } - if got != tt.want { - t.Errorf("GenerateRegToken() got = %v, want %v", got, tt.want) - } - }) - } -} - -func Test_subnetAuthHeaders(t *testing.T) { - type args struct { - authToken string - } - tests := []struct { - name string - args args - want map[string]string - }{ - { - name: "basic", - args: args{ - authToken: "x", - }, - want: map[string]string{"Authorization": "Bearer x"}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(_ *testing.T) { - if got := subnetAuthHeaders(tt.args.authToken); !reflect.DeepEqual(got, tt.want) { - t.Errorf("subnetAuthHeaders() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/swagger.yml b/swagger.yml index b00153c535..166a1e76ea 100644 --- a/swagger.yml +++ b/swagger.yml @@ -2287,160 +2287,6 @@ paths: $ref: "#/definitions/ApiError" tags: - Service - /profiling/start: - post: - summary: Start recording profile data - operationId: ProfilingStart - parameters: - - name: body - in: body - required: true - schema: - $ref: "#/definitions/profilingStartRequest" - responses: - 201: - description: A successful response. - schema: - $ref: "#/definitions/startProfilingList" - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Profile - - /profiling/stop: - post: - summary: Stop and download profile data - operationId: ProfilingStop - produces: - - application/zip - responses: - 201: - description: A successful response. - schema: - type: file - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Profile - /subnet/registration-token: - get: - summary: SUBNET registraton token - operationId: SubnetRegToken - responses: - 200: - description: A successful response. - schema: - $ref: "#/definitions/SubnetRegTokenResponse" - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Subnet - /subnet/info: - get: - summary: Subnet info - operationId: SubnetInfo - responses: - 200: - description: A successful response. - schema: - $ref: "#/definitions/license" - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Subnet - /subnet/apikey: - get: - summary: Subnet api key - operationId: SubnetApiKey - parameters: - - name: token - in: query - required: true - type: string - responses: - 200: - description: A successful response. - schema: - $ref: "#/definitions/apiKey" - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Subnet - /subnet/register: - post: - summary: Register cluster with Subnet - operationId: SubnetRegister - parameters: - - name: body - in: body - required: true - schema: - $ref: "#/definitions/subnetRegisterRequest" - responses: - 200: - description: A successful response. - # schema: - # $ref: "#/definitions/subnetRegisterResponse" - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Subnet - - /subnet/login: - post: - summary: Login to SUBNET - operationId: SubnetLogin - parameters: - - name: body - in: body - required: true - schema: - $ref: "#/definitions/subnetLoginRequest" - responses: - 200: - description: A successful response. - schema: - $ref: "#/definitions/subnetLoginResponse" - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Subnet - - /subnet/login/mfa: - post: - summary: Login to SUBNET using mfa - operationId: SubnetLoginMFA - parameters: - - name: body - in: body - required: true - schema: - $ref: "#/definitions/subnetLoginMFARequest" - responses: - 200: - description: A successful response. - schema: - $ref: "#/definitions/subnetLoginResponse" - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Subnet /admin/info: get: @@ -3280,41 +3126,6 @@ paths: tags: - release - /support/callhome: - get: - summary: Get Callhome current status - operationId: GetCallHomeOptionValue - responses: - 200: - description: A successful response. - schema: - $ref: "#/definitions/callHomeGetResponse" - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Support - - put: - summary: Sets callhome status - operationId: SetCallHomeStatus - parameters: - - name: body - in: body - required: true - schema: - $ref: "#/definitions/callHomeSetStatus" - responses: - 204: - description: A successful response. - default: - description: Generic error response. - schema: - $ref: "#/definitions/ApiError" - tags: - - Support - /download-shared-object/{url}: get: summary: Downloads an object from a presigned url @@ -5455,77 +5266,6 @@ definitions: type: object additionalProperties: true - subnetLoginResponse: - type: object - properties: - access_token: - type: string - organizations: - type: array - items: - $ref: "#/definitions/subnetOrganization" - mfa_token: - type: string - registered: - type: boolean - - subnetLoginRequest: - type: object - properties: - username: - type: string - password: - type: string - apiKey: - type: string - - subnetLoginMFARequest: - type: object - required: - - username - - otp - - mfa_token - properties: - username: - type: string - otp: - type: string - mfa_token: - type: string - - subnetRegisterRequest: - type: object - required: - - token - - account_id - properties: - token: - type: string - account_id: - type: string - - SubnetRegTokenResponse: - type: object - properties: - regToken: - type: string - - subnetOrganization: - type: object - properties: - userId: - type: integer - accountId: - type: integer - subscriptionStatus: - type: string - isAccountOwner: - type: boolean - company: - type: string - shortName: - type: string - permissionResource: type: object properties: diff --git a/web-app/package.json b/web-app/package.json index 8e2f009859..b3352d1830 100644 --- a/web-app/package.json +++ b/web-app/package.json @@ -22,7 +22,6 @@ "react-pdf": "^9.1.0", "react-redux": "^8.1.3", "react-router-dom": "6.25.1", - "react-use-websocket": "^4.8.1", "react-virtualized": "^9.22.5", "react-window": "^1.8.10", "react-window-infinite-loader": "^1.0.9", diff --git a/web-app/src/api/consoleApi.ts b/web-app/src/api/consoleApi.ts index 197b30c02f..a74be27882 100644 --- a/web-app/src/api/consoleApi.ts +++ b/web-app/src/api/consoleApi.ts @@ -1236,43 +1236,6 @@ export interface Metadata { objectMetadata?: Record; } -export interface SubnetLoginResponse { - access_token?: string; - organizations?: SubnetOrganization[]; - mfa_token?: string; - registered?: boolean; -} - -export interface SubnetLoginRequest { - username?: string; - password?: string; - apiKey?: string; -} - -export interface SubnetLoginMFARequest { - username: string; - otp: string; - mfa_token: string; -} - -export interface SubnetRegisterRequest { - token: string; - account_id: string; -} - -export interface SubnetRegTokenResponse { - regToken?: string; -} - -export interface SubnetOrganization { - userId?: number; - accountId?: number; - subscriptionStatus?: string; - isAccountOwner?: boolean; - company?: string; - shortName?: string; -} - export interface PermissionResource { resource?: string; conditionOperator?: string; @@ -3997,164 +3960,6 @@ export class Api< ...params, }), }; - profiling = { - /** - * No description - * - * @tags Profile - * @name ProfilingStart - * @summary Start recording profile data - * @request POST:/profiling/start - * @secure - */ - profilingStart: (body: ProfilingStartRequest, params: RequestParams = {}) => - this.request({ - path: `/profiling/start`, - method: "POST", - body: body, - secure: true, - type: ContentType.Json, - format: "json", - ...params, - }), - - /** - * No description - * - * @tags Profile - * @name ProfilingStop - * @summary Stop and download profile data - * @request POST:/profiling/stop - * @secure - */ - profilingStop: (params: RequestParams = {}) => - this.request({ - path: `/profiling/stop`, - method: "POST", - secure: true, - ...params, - }), - }; - subnet = { - /** - * No description - * - * @tags Subnet - * @name SubnetRegToken - * @summary SUBNET registraton token - * @request GET:/subnet/registration-token - * @secure - */ - subnetRegToken: (params: RequestParams = {}) => - this.request({ - path: `/subnet/registration-token`, - method: "GET", - secure: true, - format: "json", - ...params, - }), - - /** - * No description - * - * @tags Subnet - * @name SubnetInfo - * @summary Subnet info - * @request GET:/subnet/info - * @secure - */ - subnetInfo: (params: RequestParams = {}) => - this.request({ - path: `/subnet/info`, - method: "GET", - secure: true, - format: "json", - ...params, - }), - - /** - * No description - * - * @tags Subnet - * @name SubnetApiKey - * @summary Subnet api key - * @request GET:/subnet/apikey - * @secure - */ - subnetApiKey: ( - query: { - token: string; - }, - params: RequestParams = {}, - ) => - this.request({ - path: `/subnet/apikey`, - method: "GET", - query: query, - secure: true, - format: "json", - ...params, - }), - - /** - * No description - * - * @tags Subnet - * @name SubnetRegister - * @summary Register cluster with Subnet - * @request POST:/subnet/register - * @secure - */ - subnetRegister: (body: SubnetRegisterRequest, params: RequestParams = {}) => - this.request({ - path: `/subnet/register`, - method: "POST", - body: body, - secure: true, - type: ContentType.Json, - ...params, - }), - - /** - * No description - * - * @tags Subnet - * @name SubnetLogin - * @summary Login to SUBNET - * @request POST:/subnet/login - * @secure - */ - subnetLogin: (body: SubnetLoginRequest, params: RequestParams = {}) => - this.request({ - path: `/subnet/login`, - method: "POST", - body: body, - secure: true, - type: ContentType.Json, - format: "json", - ...params, - }), - - /** - * No description - * - * @tags Subnet - * @name SubnetLoginMfa - * @summary Login to SUBNET using mfa - * @request POST:/subnet/login/mfa - * @secure - */ - subnetLoginMfa: (body: SubnetLoginMFARequest, params: RequestParams = {}) => - this.request({ - path: `/subnet/login/mfa`, - method: "POST", - body: body, - secure: true, - type: ContentType.Json, - format: "json", - ...params, - }), - }; admin = { /** * No description @@ -4975,44 +4780,6 @@ export class Api< ...params, }), }; - support = { - /** - * No description - * - * @tags Support - * @name GetCallHomeOptionValue - * @summary Get Callhome current status - * @request GET:/support/callhome - * @secure - */ - getCallHomeOptionValue: (params: RequestParams = {}) => - this.request({ - path: `/support/callhome`, - method: "GET", - secure: true, - format: "json", - ...params, - }), - - /** - * No description - * - * @tags Support - * @name SetCallHomeStatus - * @summary Sets callhome status - * @request PUT:/support/callhome - * @secure - */ - setCallHomeStatus: (body: CallHomeSetStatus, params: RequestParams = {}) => - this.request({ - path: `/support/callhome`, - method: "PUT", - body: body, - secure: true, - type: ContentType.Json, - ...params, - }), - }; downloadSharedObject = { /** * No description diff --git a/web-app/src/common/SecureComponent/permissions.ts b/web-app/src/common/SecureComponent/permissions.ts index 3ce03a6386..9cdcb50a5f 100644 --- a/web-app/src/common/SecureComponent/permissions.ts +++ b/web-app/src/common/SecureComponent/permissions.ts @@ -183,15 +183,6 @@ export const IAM_PAGES = { KMS_KEYS_ADD: "/kms/add-key/", KMS_KEYS_IMPORT: "/kms/import-key/", - /* Support */ - TOOLS: "/support", - REGISTER_SUPPORT: "/support/register", - TOOLS_DIAGNOSTICS: "/support/diagnostics", - TOOLS_SPEEDTEST: "/support/speedtest", - CALL_HOME: "/support/call-home", - PROFILE: "/support/profile", - SUPPORT_INSPECT: "/support/inspect", - /** License **/ LICENSE: "/license", /* Settings **/ @@ -389,15 +380,6 @@ export const IAM_PAGES_PERMISSIONS = { IAM_SCOPES.ADMIN_SET_TIER, // display "add tier" button / shows add service tier page IAM_SCOPES.ADMIN_LIST_TIERS, // display tiers list ], - [IAM_PAGES.TOOLS]: [ - IAM_SCOPES.S3_LISTEN_NOTIFICATIONS, // displays watch notifications - IAM_SCOPES.S3_LISTEN_BUCKET_NOTIFICATIONS, // display watch notifications - IAM_SCOPES.ADMIN_GET_CONSOLE_LOG, // display minio console logs - IAM_SCOPES.ADMIN_SERVER_TRACE, // display minio trace - IAM_SCOPES.ADMIN_HEAL, // display heal - IAM_SCOPES.ADMIN_HEALTH_INFO, // display diagnostics / display speedtest / display audit log - IAM_SCOPES.ADMIN_SERVER_INFO, // display diagnostics - ], [IAM_PAGES.TOOLS_LOGS]: [IAM_SCOPES.ADMIN_GET_CONSOLE_LOG], [IAM_PAGES.TOOLS_AUDITLOGS]: [IAM_SCOPES.ADMIN_HEALTH_INFO], [IAM_PAGES.TOOLS_WATCH]: [ @@ -405,18 +387,6 @@ export const IAM_PAGES_PERMISSIONS = { IAM_SCOPES.S3_LISTEN_BUCKET_NOTIFICATIONS, // display watch notifications ], [IAM_PAGES.TOOLS_TRACE]: [IAM_SCOPES.ADMIN_SERVER_TRACE], - [IAM_PAGES.TOOLS_DIAGNOSTICS]: [ - IAM_SCOPES.ADMIN_HEALTH_INFO, - IAM_SCOPES.ADMIN_SERVER_INFO, - ], - [IAM_PAGES.TOOLS_SPEEDTEST]: [IAM_SCOPES.ADMIN_HEALTH_INFO], - [IAM_PAGES.REGISTER_SUPPORT]: [ - IAM_SCOPES.ADMIN_SERVER_INFO, - IAM_SCOPES.ADMIN_CONFIG_UPDATE, - ], - [IAM_PAGES.CALL_HOME]: [IAM_SCOPES.ADMIN_HEALTH_INFO], - [IAM_PAGES.PROFILE]: [IAM_SCOPES.ADMIN_HEALTH_INFO], - [IAM_PAGES.SUPPORT_INSPECT]: [IAM_SCOPES.ADMIN_HEALTH_INFO], [IAM_PAGES.LICENSE]: [ IAM_SCOPES.ADMIN_SERVER_INFO, IAM_SCOPES.ADMIN_CONFIG_UPDATE, diff --git a/web-app/src/common/utils.ts b/web-app/src/common/utils.ts index b02e659855..6f37551083 100644 --- a/web-app/src/common/utils.ts +++ b/web-app/src/common/utils.ts @@ -64,15 +64,6 @@ export const clearSession = () => { deleteCookie("idp-refresh-token"); }; -// timeFromDate gets time string from date input -export const timeFromDate = (d: Date) => { - let h = d.getHours() < 10 ? `0${d.getHours()}` : `${d.getHours()}`; - let m = d.getMinutes() < 10 ? `0${d.getMinutes()}` : `${d.getMinutes()}`; - let s = d.getSeconds() < 10 ? `0${d.getSeconds()}` : `${d.getSeconds()}`; - - return `${h}:${m}:${s}:${d.getMilliseconds()}`; -}; - // units to be used in a dropdown export const k8sScalarUnitsExcluding = (exclude?: string[]) => { return k8sUnits diff --git a/web-app/src/screens/Console/Buckets/BucketDetails/SummaryItems/BucketTags.tsx b/web-app/src/screens/Console/Buckets/BucketDetails/SummaryItems/BucketTags.tsx index 85b97f14da..afcee05d30 100644 --- a/web-app/src/screens/Console/Buckets/BucketDetails/SummaryItems/BucketTags.tsx +++ b/web-app/src/screens/Console/Buckets/BucketDetails/SummaryItems/BucketTags.tsx @@ -17,7 +17,6 @@ import React, { useEffect, useState } from "react"; import get from "lodash/get"; import { AddIcon, Box, Loader, Tag } from "mds"; -import { Bucket } from "../../../Watch/types"; import { ErrorResponseHandler } from "../../../../../common/types"; import { IAM_SCOPES } from "../../../../../common/SecureComponent/permissions"; import { SecureComponent } from "../../../../../common/SecureComponent"; @@ -37,6 +36,15 @@ type BucketTagProps = { bucketName: string; }; +interface Details { + tags: object; +} + +interface Bucket { + details: Details; + name: string; +} + const BucketTags = ({ bucketName }: BucketTagProps) => { const dispatch = useAppDispatch(); diff --git a/web-app/src/screens/Console/Common/TestWrapper/TestWrapper.tsx b/web-app/src/screens/Console/Common/TestWrapper/TestWrapper.tsx deleted file mode 100644 index 4620b7d3e6..0000000000 --- a/web-app/src/screens/Console/Common/TestWrapper/TestWrapper.tsx +++ /dev/null @@ -1,140 +0,0 @@ -// 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 . - -import React, { Fragment, useEffect, useState } from "react"; -import { DrivesIcon, Loader, SectionTitle, VersionIcon, Grid } from "mds"; -import { api } from "api"; -import { ServerProperties } from "api/consoleApi"; - -interface ITestWrapper { - title: any; - children: any; -} - -const TestWrapper = ({ title, children }: ITestWrapper) => { - const [version, setVersion] = useState("N/A"); - const [totalNodes, setTotalNodes] = useState(0); - const [totalDrives, setTotalDrives] = useState(0); - const [loading, setLoading] = useState(true); - - useEffect(() => { - if (loading) { - api.admin - .adminInfo({ - defaultOnly: true, - }) - .then((res) => { - const totalServers = res.data.servers?.length; - setTotalNodes(totalServers || 0); - - if (res.data.servers && res.data.servers.length > 0) { - setVersion(res.data.servers[0].version || "N/A"); - - const totalServers = res.data.servers.reduce( - (prevTotal: number, currentElement: ServerProperties) => { - let c = currentElement.drives - ? currentElement.drives.length - : 0; - return prevTotal + c; - }, - 0, - ); - setTotalDrives(totalServers); - } - - setLoading(false); - }) - .catch(() => { - setLoading(false); - }); - } - }, [loading]); - - return ( - - {title} - - - - {!loading ? ( - - - {totalNodes} -  nodes,  - {totalDrives}  drives - - - - - {" "} - MinIO VERSION {version} - - - ) : ( - - - - - - )} - - - {children} - - - ); -}; - -export default TestWrapper; diff --git a/web-app/src/screens/Console/Console.tsx b/web-app/src/screens/Console/Console.tsx index c4f9f2648d..790398ad34 100644 --- a/web-app/src/screens/Console/Console.tsx +++ b/web-app/src/screens/Console/Console.tsx @@ -49,10 +49,6 @@ import MenuWrapper from "./Menu/MenuWrapper"; import LoadingComponent from "../../common/LoadingComponent"; import ComponentsScreen from "./Common/ComponentsScreen"; -const Trace = React.lazy(() => import("./Trace/Trace")); -const Watch = React.lazy(() => import("./Watch/Watch")); -const HealthInfo = React.lazy(() => import("./HealthInfo/HealthInfo")); - const EventDestinations = React.lazy( () => import("./EventDestinations/EventDestinations"), ); @@ -79,11 +75,8 @@ const LogsSearchMain = React.lazy( ); const GroupsDetails = React.lazy(() => import("./Groups/GroupsDetails")); -const Tools = React.lazy(() => import("./Tools/Tools")); const IconsScreen = React.lazy(() => import("./Common/IconsScreen")); -const Speedtest = React.lazy(() => import("./Speedtest/Speedtest")); - const ObjectManager = React.lazy( () => import("./Common/ObjectManager/ObjectManager"), ); @@ -278,15 +271,6 @@ const Console = () => { ); }, }, - - { - component: Watch, - path: IAM_PAGES.TOOLS_WATCH, - }, - { - component: Speedtest, - path: IAM_PAGES.TOOLS_SPEEDTEST, - }, { component: Users, path: IAM_PAGES.USERS, @@ -336,14 +320,6 @@ const Console = () => { component: IDPOpenIDConfigurationDetails, path: IAM_PAGES.IDP_OPENID_CONFIGURATIONS_VIEW, }, - { - component: Trace, - path: IAM_PAGES.TOOLS_TRACE, - }, - { - component: HealthInfo, - path: IAM_PAGES.TOOLS_DIAGNOSTICS, - }, { component: ErrorLogs, path: IAM_PAGES.TOOLS_LOGS, @@ -352,10 +328,6 @@ const Console = () => { component: LogsSearchMain, path: IAM_PAGES.TOOLS_AUDITLOGS, }, - { - component: Tools, - path: IAM_PAGES.TOOLS, - }, { component: ConfigurationOptions, path: IAM_PAGES.SETTINGS, diff --git a/web-app/src/screens/Console/HealthInfo/HealthInfo.tsx b/web-app/src/screens/Console/HealthInfo/HealthInfo.tsx deleted file mode 100644 index 21aab41535..0000000000 --- a/web-app/src/screens/Console/HealthInfo/HealthInfo.tsx +++ /dev/null @@ -1,342 +0,0 @@ -// 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 . -import React, { Fragment, useEffect, useState } from "react"; -import { useSelector } from "react-redux"; -import { useNavigate } from "react-router-dom"; -import { Box, Button, Grid, HelpBox, InfoIcon, Loader, PageLayout } from "mds"; -import { - DiagStatError, - DiagStatInProgress, - DiagStatSuccess, - HealthInfoMessage, - ReportMessage, -} from "./types"; -import { AppState, useAppDispatch } from "../../../store"; -import { - WSCloseAbnormalClosure, - WSCloseInternalServerErr, - WSClosePolicyViolation, - wsProtocol, -} from "../../../utils/wsUtils"; -import { setHelpName, setServerDiagStat } from "../../../systemSlice"; -import { - healthInfoMessageReceived, - healthInfoResetMessage, -} from "./healthInfoSlice"; -import { registeredCluster } from "../../../config"; -import TestWrapper from "../Common/TestWrapper/TestWrapper"; -import RegisterCluster from "../Support/RegisterCluster"; -import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper"; -import HelpMenu from "../HelpMenu"; - -const HealthInfo = () => { - const dispatch = useAppDispatch(); - const navigate = useNavigate(); - - const message = useSelector((state: AppState) => state.healthInfo.message); - - const serverDiagnosticStatus = useSelector( - (state: AppState) => state.system.serverDiagnosticStatus, - ); - const [startDiagnostic, setStartDiagnostic] = useState(false); - - const [downloadDisabled, setDownloadDisabled] = useState(true); - const [localMessage, setMessage] = useState(""); - const [buttonStartText, setButtonStartText] = useState( - "Start Health Report", - ); - const [title, setTitle] = useState("Health Report"); - const [diagFileContent, setDiagFileContent] = useState(""); - const [subnetResponse, setSubnetResponse] = useState(""); - const clusterRegistered = registeredCluster(); - - const download = () => { - let element = document.createElement("a"); - element.setAttribute( - "href", - `data:application/gzip;base64,${diagFileContent}`, - ); - element.setAttribute("download", "diagnostic.json.gz"); - - element.style.display = "none"; - document.body.appendChild(element); - - element.click(); - - document.body.removeChild(element); - }; - - useEffect(() => { - if (serverDiagnosticStatus === DiagStatInProgress) { - setTitle("Health Report in progress..."); - setMessage( - "Health Report started. Please do not refresh page during diagnosis.", - ); - return; - } - - if (serverDiagnosticStatus === DiagStatSuccess) { - setTitle("Health Report complete"); - setMessage("Health Report file is ready to be downloaded."); - setButtonStartText("Start Health Report"); - return; - } - - if (serverDiagnosticStatus === DiagStatError) { - setTitle("Error"); - setMessage("An error occurred while getting the Health Report file."); - setButtonStartText("Retry Health Report"); - return; - } - }, [serverDiagnosticStatus, startDiagnostic]); - - useEffect(() => { - if ( - serverDiagnosticStatus === DiagStatSuccess && - message !== ({} as HealthInfoMessage) - ) { - // Allow download of diagnostics file only when - // it succeded fetching all the results and info is not empty. - setDownloadDisabled(false); - } - if (serverDiagnosticStatus === DiagStatInProgress) { - // Disable Start Health Report and Disable Download buttons - // if a Diagnosis is in progress. - setDownloadDisabled(true); - } - setStartDiagnostic(false); - }, [serverDiagnosticStatus, message]); - - useEffect(() => { - if (startDiagnostic) { - dispatch(healthInfoResetMessage()); - setDiagFileContent(""); - const url = new URL(window.location.toString()); - const isDev = process.env.NODE_ENV === "development"; - const port = isDev ? "9090" : url.port; - - const wsProt = wsProtocol(url.protocol); - - // check if we are using base path, if not this always is `/` - const baseLocation = new URL(document.baseURI); - const baseUrl = baseLocation.pathname; - - const socket = new WebSocket( - `${wsProt}://${url.hostname}:${port}${baseUrl}ws/health-info?deadline=1h`, - ); - let interval: any | null = null; - if (socket !== null) { - socket.onopen = () => { - console.log("WebSocket Client Connected"); - socket.send("ok"); - interval = setInterval(() => { - socket.send("ok"); - }, 10 * 1000); - setMessage( - "Health Report started. Please do not refresh page during diagnosis.", - ); - dispatch(setServerDiagStat(DiagStatInProgress)); - }; - socket.onmessage = (message: MessageEvent) => { - let m: ReportMessage = JSON.parse(message.data.toString()); - if (m.serverHealthInfo) { - dispatch(healthInfoMessageReceived(m.serverHealthInfo)); - } - if (m.encoded !== "") { - setDiagFileContent(m.encoded); - } - if (m.subnetResponse) { - setSubnetResponse(m.subnetResponse); - } - }; - socket.onerror = (error) => { - console.error("error closing websocket:", error); - socket.close(1000); - clearInterval(interval); - dispatch(setServerDiagStat(DiagStatError)); - }; - socket.onclose = (event: CloseEvent) => { - clearInterval(interval); - if ( - event.code === WSCloseInternalServerErr || - event.code === WSClosePolicyViolation || - event.code === WSCloseAbnormalClosure - ) { - // handle close with error - console.log("connection closed by server with code:", event.code); - setMessage( - "An error occurred while getting the Health Report file.", - ); - dispatch(setServerDiagStat(DiagStatError)); - } else { - console.log("connection closed by server"); - - setMessage("Health Report file is ready to be downloaded."); - dispatch(setServerDiagStat(DiagStatSuccess)); - } - }; - } - } else { - // reset start status - setStartDiagnostic(false); - } - }, [startDiagnostic, dispatch]); - - const startDiagnosticAction = () => { - if (!clusterRegistered) { - navigate("/support/register"); - return; - } - setStartDiagnostic(true); - }; - - useEffect(() => { - dispatch(setHelpName("health_info")); - }, [dispatch]); - - return ( - - } /> - - - {!clusterRegistered && } - - - - -

{localMessage}

- - {" "} - {subnetResponse !== "" && - !subnetResponse.toLowerCase().includes("error") && ( - - - Health report uploaded to SUBNET successfully! - -  {" "} - - See the results on your{" "} - SUBNET Dashboard{" "} - - - )} - {(subnetResponse === "" || - subnetResponse.toLowerCase().includes("error")) && - serverDiagnosticStatus === DiagStatSuccess && ( - - - Something went wrong uploading your Health report to - SUBNET. - -  {" "} - - Log into your{" "} - SUBNET Account to - manually upload your Health report. - - - )} - - {serverDiagnosticStatus === DiagStatInProgress ? ( - - - - ) : ( - - - - {serverDiagnosticStatus !== DiagStatError && - !downloadDisabled && ( - - )} - - - } - /> + - - {isRegistered && ( - - )} - - . - -import React, { Fragment, useState } from "react"; -import get from "lodash/get"; -import { - Button, - ComputerLineIcon, - DownloadIcon, - DownloadStatIcon, - JSONIcon, - StorageIcon, - UploadStatIcon, - VersionIcon, - Grid, - Box, -} from "mds"; -import { IndvServerMetric, SpeedTestResponse, STServer } from "./types"; -import { calculateBytes, prettyNumber } from "../../../common/utils"; -import { Area, AreaChart, CartesianGrid, ResponsiveContainer } from "recharts"; -import { cleanMetrics } from "./utils"; -import CodeMirrorWrapper from "../Common/FormComponents/CodeMirrorWrapper/CodeMirrorWrapper"; -import SpeedTestUnit from "./SpeedTestUnit"; -import styled from "styled-components"; - -const STResultsContainer = styled.div(({ theme }) => ({ - "& .actionButtons": { - textAlign: "right", - }, - "& .descriptorLabel": { - fontWeight: "bold", - fontSize: 14, - }, - "& .resultsContainer": { - backgroundColor: get(theme, "boxBackground", "#FBFAFA"), - borderTop: `${get(theme, "borderColor", "#E2E2E2")} 1px solid`, - marginTop: 30, - padding: 25, - }, - "& .resultsIcon": { - display: "flex", - alignItems: "center", - "& svg": { - fill: get(theme, `screenTitle.iconColor`, "#07193E"), - }, - }, - "& .detailedItem": { - display: "flex", - alignItems: "center", - justifyContent: "flex-start", - }, - "& .detailedVersion": { - display: "flex", - alignItems: "center", - justifyContent: "flex-end", - }, - "& .serversTable": { - width: "100%", - marginTop: 15, - "& thead > tr > th": { - textAlign: "left", - padding: 15, - fontSize: 14, - fontWeight: "bold", - }, - "& tbody > tr": { - "&:last-of-type": { - "& > td": { - borderBottom: `${get(theme, "borderColor", "#E2E2E2")} 1px solid`, - }, - }, - "& > td": { - borderTop: `${get(theme, "borderColor", "#E2E2E2")} 1px solid`, - padding: 15, - fontSize: 14, - "&:first-of-type": { - borderLeft: `${get(theme, "borderColor", "#E2E2E2")} 1px solid`, - }, - "&:last-of-type": { - borderRight: `${get(theme, "borderColor", "#E2E2E2")} 1px solid`, - }, - }, - }, - }, - "& .serverIcon": { - width: 55, - }, - "& .serverValue": { - width: 140, - }, - "& .serverHost": { - maxWidth: 540, - overflow: "hidden", - textOverflow: "ellipsis", - whiteSpace: "nowrap", - }, - "& .tableOverflow": { - overflowX: "auto", - paddingBottom: 15, - }, - "& .objectGeneral": { - marginTop: 15, - }, - "& .download": { - "& .min-icon": { - width: 35, - height: 35, - color: get(theme, "signalColors.good", "#4CCB92"), - }, - }, - "& .upload": { - "& .min-icon": { - width: 35, - height: 35, - color: get(theme, "signalColors.info", "#2781B0"), - }, - }, - "& .versionIcon": { - color: get(theme, `screenTitle.iconColor`, "#07193E"), - marginRight: 20, - }, -})); - -interface ISTResults { - results: SpeedTestResponse[]; - start: boolean; -} - -const STResults = ({ results, start }: ISTResults) => { - const [jsonView, setJsonView] = useState(false); - - const finalRes = results[results.length - 1] || []; - - const getServers: STServer[] = get(finalRes, "GETStats.servers", []) || []; - const putServers: STServer[] = get(finalRes, "PUTStats.servers", []) || []; - - const getThroughput = get(finalRes, "GETStats.throughputPerSec", 0); - const getObjects = get(finalRes, "GETStats.objectsPerSec", 0); - - const putThroughput = get(finalRes, "PUTStats.throughputPerSec", 0); - const putObjects = get(finalRes, "PUTStats.objectsPerSec", 0); - - let statJoin: IndvServerMetric[] = []; - - getServers.forEach((item) => { - const hostName = item.endpoint; - const putMetric = putServers.find((item) => item.endpoint === hostName); - - let itemJoin: IndvServerMetric = { - getUnit: "-", - getValue: "N/A", - host: item.endpoint, - putUnit: "-", - putValue: "N/A", - }; - - if (item.err && item.err !== "") { - itemJoin.getError = item.err; - itemJoin.getUnit = "-"; - itemJoin.getValue = "N/A"; - } else { - const niceGet = calculateBytes(item.throughputPerSec.toString()); - - itemJoin.getUnit = niceGet.unit; - itemJoin.getValue = niceGet.total.toString(); - } - - if (putMetric) { - if (putMetric.err && putMetric.err !== "") { - itemJoin.putError = putMetric.err; - itemJoin.putUnit = "-"; - itemJoin.putValue = "N/A"; - } else { - const nicePut = calculateBytes(putMetric.throughputPerSec.toString()); - - itemJoin.putUnit = nicePut.unit; - itemJoin.putValue = nicePut.total.toString(); - } - } - - statJoin.push(itemJoin); - }); - - const downloadResults = () => { - const date = new Date(); - let element = document.createElement("a"); - element.setAttribute( - "href", - "data:text/plain;charset=utf-8," + JSON.stringify(finalRes), - ); - element.setAttribute( - "download", - `speedtest_results-${date.toISOString()}.log`, - ); - - element.style.display = "none"; - document.body.appendChild(element); - - element.click(); - - document.body.removeChild(element); - }; - - const toggleJSONView = () => { - setJsonView(!jsonView); - }; - - const finalResJSON = finalRes ? JSON.stringify(finalRes, null, 4) : ""; - const clnMetrics = cleanMetrics(results); - - return ( - - - - - - - - - } - title={"GET"} - throughput={`${getThroughput}`} - objects={getObjects} - /> - - - - - - } - title={"PUT"} - throughput={`${putThroughput}`} - objects={putObjects} - /> - - - - - - - - - - - - - - - - - - - - - - - - - -
- {clnMetrics.length > 1 && ( - - - - {start ? ( - Preliminar Results: - ) : ( - - {jsonView ? "JSON Results:" : "Detailed Results:"} - - )} - - - {!start && ( - - - )} - -
-
- )} - - - - ); -}; - -export default CallHome; diff --git a/web-app/src/screens/Console/Support/CallHomeConfirmation.tsx b/web-app/src/screens/Console/Support/CallHomeConfirmation.tsx deleted file mode 100644 index 018ee478e5..0000000000 --- a/web-app/src/screens/Console/Support/CallHomeConfirmation.tsx +++ /dev/null @@ -1,193 +0,0 @@ -// This file is part of MinIO Console Server -// Copyright (c) 2023 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import React, { Fragment, useState } from "react"; -import { Button, CallHomeMenuIcon, CircleIcon, Grid, ProgressBar } from "mds"; - -import api from "../../../common/api"; -import { ICallHomeResponse } from "./types"; -import { ErrorResponseHandler } from "../../../common/types"; -import { setErrorSnackMessage, setSnackBarMessage } from "../../../systemSlice"; -import { useAppDispatch } from "../../../store"; -import ModalWrapper from "../Common/ModalWrapper/ModalWrapper"; - -interface ICallHomeConfirmation { - onClose: (refresh: boolean) => any; - open: boolean; - diagStatus: boolean; - disable?: boolean; -} - -const CallHomeConfirmation = ({ - onClose, - diagStatus, - open, - disable = false, -}: ICallHomeConfirmation) => { - const dispatch = useAppDispatch(); - - const [loading, setLoading] = useState(false); - - const onConfirmAction = () => { - setLoading(true); - api - .invoke("PUT", `/api/v1/support/callhome`, { - diagState: disable ? false : diagStatus, - logsState: false, - }) - .then((res: ICallHomeResponse) => { - dispatch(setSnackBarMessage("Configuration saved successfully")); - setLoading(false); - onClose(true); - }) - .catch((err: ErrorResponseHandler) => { - setLoading(false); - dispatch(setErrorSnackMessage(err)); - }); - }; - - return ( - onClose(false)} - titleIcon={} - > - {disable ? ( - - Please Acknowledge that after doing this action, we will no longer - receive updated cluster information automatically, losing the - potential benefits that Call Home provides to your MinIO cluster. - - Are you sure you want to disable SUBNET Call Home? - -
- {loading && ( - - - - )} - -