mirror of
https://github.com/OpenMaxIO/openmaxio-object-browser
synced 2026-07-01 07:41:18 -07:00
Call Home Enabled in console (#2248)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
70
models/call_home_get_response.go
Normal file
70
models/call_home_get_response.go
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package models
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CallHomeGetResponse call home get response
|
||||||
|
//
|
||||||
|
// swagger:model callHomeGetResponse
|
||||||
|
type CallHomeGetResponse struct {
|
||||||
|
|
||||||
|
// diagnostics status
|
||||||
|
DiagnosticsStatus bool `json:"diagnosticsStatus,omitempty"`
|
||||||
|
|
||||||
|
// logs status
|
||||||
|
LogsStatus bool `json:"logsStatus,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this call home get response
|
||||||
|
func (m *CallHomeGetResponse) Validate(formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this call home get response based on context it is used
|
||||||
|
func (m *CallHomeGetResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *CallHomeGetResponse) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *CallHomeGetResponse) UnmarshalBinary(b []byte) error {
|
||||||
|
var res CallHomeGetResponse
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
||||||
105
models/call_home_set_status.go
Normal file
105
models/call_home_set_status.go
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package models
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/go-openapi/errors"
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
"github.com/go-openapi/validate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CallHomeSetStatus call home set status
|
||||||
|
//
|
||||||
|
// swagger:model callHomeSetStatus
|
||||||
|
type CallHomeSetStatus struct {
|
||||||
|
|
||||||
|
// diag state
|
||||||
|
// Required: true
|
||||||
|
DiagState *bool `json:"diagState"`
|
||||||
|
|
||||||
|
// logs state
|
||||||
|
// Required: true
|
||||||
|
LogsState *bool `json:"logsState"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this call home set status
|
||||||
|
func (m *CallHomeSetStatus) Validate(formats strfmt.Registry) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if err := m.validateDiagState(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := m.validateLogsState(formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *CallHomeSetStatus) validateDiagState(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("diagState", "body", m.DiagState); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *CallHomeSetStatus) validateLogsState(formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := validate.Required("logsState", "body", m.LogsState); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContextValidate validates this call home set status based on context it is used
|
||||||
|
func (m *CallHomeSetStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *CallHomeSetStatus) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *CallHomeSetStatus) UnmarshalBinary(b []byte) error {
|
||||||
|
var res CallHomeSetStatus
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -60,6 +60,10 @@ func subnetAPIKeyURL() string {
|
|||||||
return subnetBaseURL() + "/api/auth/api-key"
|
return subnetBaseURL() + "/api/auth/api-key"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LogWebhookURL() string {
|
||||||
|
return subnetBaseURL() + "/api/logs"
|
||||||
|
}
|
||||||
|
|
||||||
func GenerateRegToken(clusterRegInfo mc.ClusterRegistrationInfo) (string, error) {
|
func GenerateRegToken(clusterRegInfo mc.ClusterRegistrationInfo) (string, error) {
|
||||||
token, e := json.Marshal(clusterRegInfo)
|
token, e := json.Marshal(clusterRegInfo)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -35,6 +51,7 @@ type ConfirmDialogProps = {
|
|||||||
cancelButtonProps?: ButtonProps &
|
cancelButtonProps?: ButtonProps &
|
||||||
React.ButtonHTMLAttributes<HTMLButtonElement>;
|
React.ButtonHTMLAttributes<HTMLButtonElement>;
|
||||||
titleIcon?: React.ReactNode;
|
titleIcon?: React.ReactNode;
|
||||||
|
confirmationButtonSimple?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ConfirmDialog = ({
|
const ConfirmDialog = ({
|
||||||
@@ -51,6 +68,7 @@ const ConfirmDialog = ({
|
|||||||
confirmButtonProps = undefined,
|
confirmButtonProps = undefined,
|
||||||
cancelButtonProps = undefined,
|
cancelButtonProps = undefined,
|
||||||
titleIcon = null,
|
titleIcon = null,
|
||||||
|
confirmationButtonSimple = false,
|
||||||
}: ConfirmDialogProps) => {
|
}: ConfirmDialogProps) => {
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
@@ -97,6 +115,7 @@ const ConfirmDialog = ({
|
|||||||
id={"confirm-cancel"}
|
id={"confirm-cancel"}
|
||||||
label={cancelText}
|
label={cancelText}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
id={"confirm-ok"}
|
id={"confirm-ok"}
|
||||||
onClick={onConfirm}
|
onClick={onConfirm}
|
||||||
|
|||||||
328
portal-ui/src/screens/Console/Support/CallHome.tsx
Normal file
328
portal-ui/src/screens/Console/Support/CallHome.tsx
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import React, { Fragment, useEffect, useState } from "react";
|
||||||
|
import { Box } from "@mui/material";
|
||||||
|
import { Button, CallHomeMenuIcon, HelpBox, Loader, PageHeader } from "mds";
|
||||||
|
import { Link, useNavigate } from "react-router-dom";
|
||||||
|
import PageLayout from "../Common/Layout/PageLayout";
|
||||||
|
import api from "../../../common/api";
|
||||||
|
import { ErrorResponseHandler } from "../../../common/types";
|
||||||
|
import { setErrorSnackMessage } from "../../../systemSlice";
|
||||||
|
import { useAppDispatch } from "../../../store";
|
||||||
|
import { ICallHomeResponse } from "./types";
|
||||||
|
import { registeredCluster } from "../../../config";
|
||||||
|
import CallHomeConfirmation from "./CallHomeConfirmation";
|
||||||
|
import RegisterCluster from "./RegisterCluster";
|
||||||
|
import FormSwitchWrapper from "../Common/FormComponents/FormSwitchWrapper/FormSwitchWrapper";
|
||||||
|
|
||||||
|
const PromoLabels = ({ title, text }: { title: string; text: string }) => {
|
||||||
|
return (
|
||||||
|
<div style={{ marginTop: 15 }}>
|
||||||
|
<div style={{ marginBottom: 10, fontWeight: "bold" }}>{title}</div>
|
||||||
|
<div style={{ color: "#969696", fontSize: 14, marginBottom: 40 }}>
|
||||||
|
{text}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const CallHome = () => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
|
const [showConfirmation, setShowConfirmation] = useState<boolean>(false);
|
||||||
|
const [diagEnabled, setDiagEnabled] = useState<boolean>(false);
|
||||||
|
const [oDiagEnabled, setODiagEnabled] = useState<boolean>(false);
|
||||||
|
const [oLogsEnabled, setOLogsEnabled] = useState<boolean>(false);
|
||||||
|
const [logsEnabled, setLogsEnabled] = useState<boolean>(false);
|
||||||
|
const [disableMode, setDisableMode] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const clusterRegistered = registeredCluster();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (loading) {
|
||||||
|
api
|
||||||
|
.invoke("GET", `/api/v1/support/callhome`)
|
||||||
|
.then((res: ICallHomeResponse) => {
|
||||||
|
setLoading(false);
|
||||||
|
|
||||||
|
setDiagEnabled(!!res.diagnosticsStatus);
|
||||||
|
setLogsEnabled(!!res.logsStatus);
|
||||||
|
|
||||||
|
setODiagEnabled(!!res.diagnosticsStatus);
|
||||||
|
setOLogsEnabled(!!res.logsStatus);
|
||||||
|
})
|
||||||
|
.catch((err: ErrorResponseHandler) => {
|
||||||
|
setLoading(false);
|
||||||
|
dispatch(setErrorSnackMessage(err));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [loading, dispatch]);
|
||||||
|
|
||||||
|
const callHomeClose = (refresh: boolean) => {
|
||||||
|
if (refresh) {
|
||||||
|
setLoading(true);
|
||||||
|
}
|
||||||
|
setShowConfirmation(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmCallHomeAction = () => {
|
||||||
|
if (!clusterRegistered) {
|
||||||
|
navigate("/support/register");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setDisableMode(false);
|
||||||
|
setShowConfirmation(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const disableCallHomeAction = () => {
|
||||||
|
setDisableMode(true);
|
||||||
|
setShowConfirmation(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
let mainVariant: "regular" | "callAction" = "regular";
|
||||||
|
|
||||||
|
if (
|
||||||
|
clusterRegistered &&
|
||||||
|
(diagEnabled !== oDiagEnabled || logsEnabled !== oLogsEnabled)
|
||||||
|
) {
|
||||||
|
mainVariant = "callAction";
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
{showConfirmation && (
|
||||||
|
<CallHomeConfirmation
|
||||||
|
onClose={callHomeClose}
|
||||||
|
open={showConfirmation}
|
||||||
|
logsStatus={logsEnabled}
|
||||||
|
diagStatus={diagEnabled}
|
||||||
|
disable={disableMode}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<PageHeader label="Call Home" />
|
||||||
|
<PageLayout>
|
||||||
|
{!clusterRegistered && <RegisterCluster compactMode />}
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "flex-start",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
border: "1px solid #eaeaea",
|
||||||
|
padding: {
|
||||||
|
lg: "40px",
|
||||||
|
xs: "15px",
|
||||||
|
},
|
||||||
|
flexWrap: "wrap",
|
||||||
|
gap: {
|
||||||
|
lg: "55px",
|
||||||
|
xs: "20px",
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
md: "calc(100vh - 120px)",
|
||||||
|
xs: "100%",
|
||||||
|
},
|
||||||
|
flexFlow: {
|
||||||
|
lg: "row",
|
||||||
|
xs: "column",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
border: "1px solid #eaeaea",
|
||||||
|
flex: {
|
||||||
|
md: 2,
|
||||||
|
xs: 1,
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
lg: "auto",
|
||||||
|
xs: "100%",
|
||||||
|
},
|
||||||
|
padding: {
|
||||||
|
lg: "40px",
|
||||||
|
xs: "15px",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{loading ? (
|
||||||
|
<span style={{ marginLeft: 5 }}>
|
||||||
|
<Loader style={{ width: 16, height: 16 }} />
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<Fragment>
|
||||||
|
<div style={{ marginBottom: 25 }}>
|
||||||
|
<FormSwitchWrapper
|
||||||
|
value="enableDiag"
|
||||||
|
id="enableDiag"
|
||||||
|
name="enableDiag"
|
||||||
|
checked={diagEnabled}
|
||||||
|
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setDiagEnabled(event.target.checked);
|
||||||
|
}}
|
||||||
|
label={"Send Diagnostics information"}
|
||||||
|
disabled={!clusterRegistered}
|
||||||
|
/>
|
||||||
|
<PromoLabels
|
||||||
|
title={"When you enable diagnostics"}
|
||||||
|
text={
|
||||||
|
"Understand your storage with MinIO and unlock the potential of efficient health diagnostics. Ensure\n" +
|
||||||
|
" seamless performance and identify potential issues before they escalate."
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<FormSwitchWrapper
|
||||||
|
value="enableLogs"
|
||||||
|
id="enableLogs"
|
||||||
|
name="enableLogs"
|
||||||
|
checked={logsEnabled}
|
||||||
|
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setLogsEnabled(event.target.checked);
|
||||||
|
}}
|
||||||
|
label={"Send Logs information"}
|
||||||
|
disabled={!clusterRegistered}
|
||||||
|
/>
|
||||||
|
<PromoLabels
|
||||||
|
title={"When you enable logs"}
|
||||||
|
text={
|
||||||
|
"Streamline your log management with MinIO's SUBNET! Upload your logs and easily access them from your\n" +
|
||||||
|
" SUBNET account. Get real-time insights and troubleshoot issues quickly."
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
marginTop: "55px",
|
||||||
|
gap: "0px 10px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{(oDiagEnabled || oLogsEnabled) && (
|
||||||
|
<Button
|
||||||
|
id={"callhome-action"}
|
||||||
|
variant={"secondary"}
|
||||||
|
data-test-id="call-home-toggle-button"
|
||||||
|
onClick={disableCallHomeAction}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
Disable Call Home
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
id={"callhome-action"}
|
||||||
|
type="button"
|
||||||
|
variant={mainVariant}
|
||||||
|
data-test-id="call-home-toggle-button"
|
||||||
|
onClick={confirmCallHomeAction}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
Save Configuration
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Fragment>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
flex: 1,
|
||||||
|
minWidth: {
|
||||||
|
md: "365px",
|
||||||
|
xs: "100%",
|
||||||
|
},
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<HelpBox
|
||||||
|
title={""}
|
||||||
|
iconComponent={null}
|
||||||
|
help={
|
||||||
|
<Fragment>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
marginTop: "-25px",
|
||||||
|
fontSize: "16px",
|
||||||
|
fontWeight: 600,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
padding: "2px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "#07193E",
|
||||||
|
height: "15px",
|
||||||
|
width: "15px",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
borderRadius: "50%",
|
||||||
|
marginRight: "18px",
|
||||||
|
padding: "3px",
|
||||||
|
"& .min-icon": {
|
||||||
|
height: "11px",
|
||||||
|
width: "11px",
|
||||||
|
fill: "#ffffff",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CallHomeMenuIcon />
|
||||||
|
</Box>
|
||||||
|
Learn more about Call Home
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
flexFlow: "column",
|
||||||
|
fontSize: "14px",
|
||||||
|
flex: "2",
|
||||||
|
marginTop: "10px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
Enabling Call Home sends cluster health & status to your
|
||||||
|
registered MinIO Subscription Network account every 24
|
||||||
|
hours.
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
This helps the MinIO support team to provide quick
|
||||||
|
incident responses along with suggestions for possible
|
||||||
|
improvements that can be made to your MinIO instances.
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
Your cluster must be{" "}
|
||||||
|
<Link to={"/support/register"}>registered</Link> in the
|
||||||
|
MinIO Subscription Network (SUBNET) before enabling this
|
||||||
|
feature.
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Fragment>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</PageLayout>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CallHome;
|
||||||
218
portal-ui/src/screens/Console/Support/CallHomeConfirmation.tsx
Normal file
218
portal-ui/src/screens/Console/Support/CallHomeConfirmation.tsx
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import React, { Fragment, useState } from "react";
|
||||||
|
import { Button, CallHomeMenuIcon, CircleIcon, Grid } from "mds";
|
||||||
|
import { LinearProgress } from "@mui/material";
|
||||||
|
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";
|
||||||
|
import InputBoxWrapper from "../Common/FormComponents/InputBoxWrapper/InputBoxWrapper";
|
||||||
|
|
||||||
|
interface ICallHomeConfirmation {
|
||||||
|
onClose: (refresh: boolean) => any;
|
||||||
|
open: boolean;
|
||||||
|
diagStatus: boolean;
|
||||||
|
logsStatus: boolean;
|
||||||
|
disable?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CallHomeConfirmation = ({
|
||||||
|
onClose,
|
||||||
|
diagStatus,
|
||||||
|
logsStatus,
|
||||||
|
open,
|
||||||
|
disable = false,
|
||||||
|
}: ICallHomeConfirmation) => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
|
const [confirmText, setConfirmText] = useState<string>("");
|
||||||
|
|
||||||
|
const onConfirmAction = () => {
|
||||||
|
setLoading(true);
|
||||||
|
api
|
||||||
|
.invoke("PUT", `/api/v1/support/callhome`, {
|
||||||
|
diagState: disable ? false : diagStatus,
|
||||||
|
logsState: disable ? false : logsStatus,
|
||||||
|
})
|
||||||
|
.then((res: ICallHomeResponse) => {
|
||||||
|
dispatch(setSnackBarMessage("Configuration saved successfully"));
|
||||||
|
setLoading(false);
|
||||||
|
onClose(true);
|
||||||
|
})
|
||||||
|
.catch((err: ErrorResponseHandler) => {
|
||||||
|
setLoading(false);
|
||||||
|
dispatch(setErrorSnackMessage(err));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModalWrapper
|
||||||
|
modalOpen={open}
|
||||||
|
title={disable ? "Disable Call Home" : "Edit Call Home Configurations"}
|
||||||
|
onClose={() => onClose(false)}
|
||||||
|
titleIcon={<CallHomeMenuIcon />}
|
||||||
|
>
|
||||||
|
{disable ? (
|
||||||
|
<Fragment>
|
||||||
|
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.
|
||||||
|
<Grid item xs={12} sx={{ margin: "15px 0" }}>
|
||||||
|
Are you sure you want to disable SUBNET Call Home?
|
||||||
|
</Grid>
|
||||||
|
<br />
|
||||||
|
{loading && (
|
||||||
|
<Grid
|
||||||
|
item
|
||||||
|
xs={12}
|
||||||
|
sx={{
|
||||||
|
marginBottom: 10,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LinearProgress />
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
|
<Grid
|
||||||
|
item
|
||||||
|
xs={12}
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
id={"reset"}
|
||||||
|
type="button"
|
||||||
|
variant="regular"
|
||||||
|
disabled={loading}
|
||||||
|
onClick={() => onClose(false)}
|
||||||
|
label={"Cancel"}
|
||||||
|
sx={{
|
||||||
|
marginRight: 10,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
id={"save-lifecycle"}
|
||||||
|
type="submit"
|
||||||
|
variant={"secondary"}
|
||||||
|
color="primary"
|
||||||
|
disabled={loading}
|
||||||
|
label={"Yes, Disable Call Home"}
|
||||||
|
onClick={onConfirmAction}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
</Fragment>
|
||||||
|
) : (
|
||||||
|
<Fragment>
|
||||||
|
Are you sure you want to change the following configurations for
|
||||||
|
SUBNET Call Home:
|
||||||
|
<Grid
|
||||||
|
item
|
||||||
|
sx={{
|
||||||
|
margin: "20px 0",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: 15,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Grid item sx={{ display: "flex", alignItems: "center", gap: 10 }}>
|
||||||
|
<CircleIcon
|
||||||
|
style={{ fill: diagStatus ? "#4CCB92" : "#C83B51", width: 20 }}
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
<strong>{diagStatus ? "Enable" : "Disable"}</strong> - Send
|
||||||
|
Diagnostics Information to SUBNET
|
||||||
|
</span>
|
||||||
|
</Grid>
|
||||||
|
<Grid item sx={{ display: "flex", alignItems: "center", gap: 10 }}>
|
||||||
|
<CircleIcon
|
||||||
|
style={{ fill: logsStatus ? "#4CCB92" : "#C83B51", width: 20 }}
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
<strong>{logsStatus ? "Enable" : "Disable"}</strong> - Send Logs
|
||||||
|
Information to SUBNET
|
||||||
|
</span>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={12} sx={{ margin: "15px 0" }}>
|
||||||
|
Please Acknowledge that the information provided will only be
|
||||||
|
available in your SUBNET Account and it will not be shared to other
|
||||||
|
persons or entities besides MinIO team and you.
|
||||||
|
</Grid>
|
||||||
|
To continue please type <b>CONFIRM</b> in the box.
|
||||||
|
<Grid item xs={12} sx={{ marginBottom: 10 }}>
|
||||||
|
<InputBoxWrapper
|
||||||
|
id="retype-tenant"
|
||||||
|
name="retype-tenant"
|
||||||
|
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setConfirmText(event.target.value);
|
||||||
|
}}
|
||||||
|
label=""
|
||||||
|
value={confirmText}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
{loading && (
|
||||||
|
<Grid
|
||||||
|
item
|
||||||
|
xs={12}
|
||||||
|
sx={{
|
||||||
|
marginBottom: 10,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LinearProgress />
|
||||||
|
</Grid>
|
||||||
|
)}
|
||||||
|
<Grid
|
||||||
|
item
|
||||||
|
xs={12}
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
id={"reset"}
|
||||||
|
type="button"
|
||||||
|
variant="regular"
|
||||||
|
disabled={loading}
|
||||||
|
onClick={() => onClose(false)}
|
||||||
|
label={"Cancel"}
|
||||||
|
sx={{
|
||||||
|
marginRight: 10,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
id={"save-lifecycle"}
|
||||||
|
type="submit"
|
||||||
|
variant={"callAction"}
|
||||||
|
color="primary"
|
||||||
|
disabled={loading || confirmText !== "CONFIRM"}
|
||||||
|
label={"Yes, Save this Configuration"}
|
||||||
|
onClick={onConfirmAction}
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
</Fragment>
|
||||||
|
)}
|
||||||
|
</ModalWrapper>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CallHomeConfirmation;
|
||||||
20
portal-ui/src/screens/Console/Support/types.ts
Normal file
20
portal-ui/src/screens/Console/Support/types.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
export interface ICallHomeResponse {
|
||||||
|
diagnosticsStatus?: boolean;
|
||||||
|
logsStatus?: boolean;
|
||||||
|
}
|
||||||
@@ -16,11 +16,10 @@
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Route, Routes } from "react-router-dom";
|
import { Route, Routes } from "react-router-dom";
|
||||||
import FeatureNotAvailablePage from "../Common/Components/FeatureNotAvailablePage";
|
|
||||||
import { SupportMenuIcon } from "mds";
|
|
||||||
|
|
||||||
import withSuspense from "../Common/Components/withSuspense";
|
import withSuspense from "../Common/Components/withSuspense";
|
||||||
import NotFoundPage from "../../NotFoundPage";
|
import NotFoundPage from "../../NotFoundPage";
|
||||||
|
import CallHome from "../Support/CallHome";
|
||||||
|
|
||||||
const Inspect = withSuspense(React.lazy(() => import("./Inspect")));
|
const Inspect = withSuspense(React.lazy(() => import("./Inspect")));
|
||||||
const Register = withSuspense(React.lazy(() => import("../Support/Register")));
|
const Register = withSuspense(React.lazy(() => import("../Support/Register")));
|
||||||
@@ -31,17 +30,7 @@ const Tools = () => {
|
|||||||
<Routes>
|
<Routes>
|
||||||
<Route path={"register"} element={<Register />} />
|
<Route path={"register"} element={<Register />} />
|
||||||
<Route path={"profile"} element={<Profile />} />
|
<Route path={"profile"} element={<Profile />} />
|
||||||
<Route
|
<Route path={"call-home"} element={<CallHome />} />
|
||||||
path={"call-home"}
|
|
||||||
element={
|
|
||||||
<FeatureNotAvailablePage
|
|
||||||
icon={<SupportMenuIcon />}
|
|
||||||
pageHeaderText={"Support"}
|
|
||||||
title={"Call Home"}
|
|
||||||
message={<div>This feature is currently not available.</div>}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Route path={"inspect"} element={<Inspect />} />
|
<Route path={"inspect"} element={<Inspect />} />
|
||||||
<Route path={"*"} element={<NotFoundPage />} />
|
<Route path={"*"} element={<NotFoundPage />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import {
|
|||||||
BucketsMenuIcon,
|
BucketsMenuIcon,
|
||||||
ClustersIcon,
|
ClustersIcon,
|
||||||
DocumentationIcon,
|
DocumentationIcon,
|
||||||
|
CallHomeMenuIcon,
|
||||||
DrivesMenuIcon,
|
DrivesMenuIcon,
|
||||||
GroupsMenuIcon,
|
GroupsMenuIcon,
|
||||||
HealthMenuIcon,
|
HealthMenuIcon,
|
||||||
@@ -48,7 +49,6 @@ import {
|
|||||||
RegisterMenuIcon,
|
RegisterMenuIcon,
|
||||||
SettingsIcon,
|
SettingsIcon,
|
||||||
StorageIcon,
|
StorageIcon,
|
||||||
SupportMenuIcon,
|
|
||||||
TenantsOutlineIcon,
|
TenantsOutlineIcon,
|
||||||
TiersIcon,
|
TiersIcon,
|
||||||
TraceMenuIcon,
|
TraceMenuIcon,
|
||||||
@@ -280,12 +280,6 @@ export const validRoutes = (
|
|||||||
badge: LicenseBadge,
|
badge: LicenseBadge,
|
||||||
forceDisplay: true,
|
forceDisplay: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
group: "Subscription",
|
|
||||||
name: "Support",
|
|
||||||
id: "support",
|
|
||||||
icon: SupportMenuIcon,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
group: "Subscription",
|
group: "Subscription",
|
||||||
name: "Health",
|
name: "Health",
|
||||||
@@ -318,6 +312,14 @@ export const validRoutes = (
|
|||||||
icon: InspectMenuIcon,
|
icon: InspectMenuIcon,
|
||||||
component: NavLink,
|
component: NavLink,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
group: "Subscription",
|
||||||
|
name: "Call Home",
|
||||||
|
id: "callhome",
|
||||||
|
component: NavLink,
|
||||||
|
icon: CallHomeMenuIcon,
|
||||||
|
to: IAM_PAGES.CALL_HOME,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let operatorMenus: IMenuItem[] = [
|
let operatorMenus: IMenuItem[] = [
|
||||||
|
|||||||
@@ -31,10 +31,11 @@ var (
|
|||||||
MinioServerInfoMock func(ctx context.Context) (madmin.InfoMessage, error)
|
MinioServerInfoMock func(ctx context.Context) (madmin.InfoMessage, error)
|
||||||
minioChangePasswordMock func(ctx context.Context, accessKey, secretKey string) error
|
minioChangePasswordMock func(ctx context.Context, accessKey, secretKey string) error
|
||||||
|
|
||||||
minioHelpConfigKVMock func(subSys, key string, envOnly bool) (madmin.Help, error)
|
minioHelpConfigKVMock func(subSys, key string, envOnly bool) (madmin.Help, error)
|
||||||
minioGetConfigKVMock func(key string) ([]byte, error)
|
minioGetConfigKVMock func(key string) ([]byte, error)
|
||||||
minioSetConfigKVMock func(kv string) (restart bool, err error)
|
minioSetConfigKVMock func(kv string) (restart bool, err error)
|
||||||
minioDelConfigKVMock func(name string) (err error)
|
minioDelConfigKVMock func(name string) (err error)
|
||||||
|
minioHelpConfigKVGlobalMock func(envOnly bool) (madmin.Help, error)
|
||||||
|
|
||||||
minioGetLogsMock func(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo
|
minioGetLogsMock func(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo
|
||||||
|
|
||||||
@@ -133,6 +134,11 @@ func (ac AdminClientMock) setConfigKV(ctx context.Context, kv string) (restart b
|
|||||||
return minioSetConfigKVMock(kv)
|
return minioSetConfigKVMock(kv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mock function helpConfigKV()
|
||||||
|
func (ac AdminClientMock) helpConfigKVGlobal(ctx context.Context, envOnly bool) (madmin.Help, error) {
|
||||||
|
return minioHelpConfigKVGlobalMock(envOnly)
|
||||||
|
}
|
||||||
|
|
||||||
func (ac AdminClientMock) delConfigKV(ctx context.Context, name string) (err error) {
|
func (ac AdminClientMock) delConfigKV(ctx context.Context, name string) (err error) {
|
||||||
return minioDelConfigKVMock(name)
|
return minioDelConfigKVMock(name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,8 +83,10 @@ type MinioAdmin interface {
|
|||||||
setPolicy(ctx context.Context, policyName, entityName string, isGroup bool) error
|
setPolicy(ctx context.Context, policyName, entityName string, isGroup bool) error
|
||||||
getConfigKV(ctx context.Context, key string) ([]byte, error)
|
getConfigKV(ctx context.Context, key string) ([]byte, error)
|
||||||
helpConfigKV(ctx context.Context, subSys, key string, envOnly bool) (madmin.Help, error)
|
helpConfigKV(ctx context.Context, subSys, key string, envOnly bool) (madmin.Help, error)
|
||||||
|
helpConfigKVGlobal(ctx context.Context, envOnly bool) (madmin.Help, error)
|
||||||
setConfigKV(ctx context.Context, kv string) (restart bool, err error)
|
setConfigKV(ctx context.Context, kv string) (restart bool, err error)
|
||||||
delConfigKV(ctx context.Context, kv string) (err error)
|
delConfigKV(ctx context.Context, kv string) (err error)
|
||||||
|
|
||||||
serviceRestart(ctx context.Context) error
|
serviceRestart(ctx context.Context) error
|
||||||
serverInfo(ctx context.Context) (madmin.InfoMessage, error)
|
serverInfo(ctx context.Context) (madmin.InfoMessage, error)
|
||||||
startProfiling(ctx context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error)
|
startProfiling(ctx context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error)
|
||||||
@@ -269,6 +271,11 @@ func (ac AdminClient) helpConfigKV(ctx context.Context, subSys, key string, envO
|
|||||||
return ac.Client.HelpConfigKV(ctx, subSys, key, envOnly)
|
return ac.Client.HelpConfigKV(ctx, subSys, key, envOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// implements madmin.helpConfigKVGlobal()
|
||||||
|
func (ac AdminClient) helpConfigKVGlobal(ctx context.Context, envOnly bool) (madmin.Help, error) {
|
||||||
|
return ac.Client.HelpConfigKV(ctx, "", "", envOnly)
|
||||||
|
}
|
||||||
|
|
||||||
// implements madmin.SetConfigKV()
|
// implements madmin.SetConfigKV()
|
||||||
func (ac AdminClient) setConfigKV(ctx context.Context, kv string) (restart bool, err error) {
|
func (ac AdminClient) setConfigKV(ctx context.Context, kv string) (restart bool, err error) {
|
||||||
return ac.Client.SetConfigKV(ctx, kv)
|
return ac.Client.SetConfigKV(ctx, kv)
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler {
|
|||||||
|
|
||||||
registerSiteReplicationHandler(api)
|
registerSiteReplicationHandler(api)
|
||||||
registerSiteReplicationStatusHandler(api)
|
registerSiteReplicationStatusHandler(api)
|
||||||
|
// Register Support Handler
|
||||||
|
registerSupportHandlers(api)
|
||||||
|
|
||||||
// Operator Console
|
// Operator Console
|
||||||
|
|
||||||
|
|||||||
@@ -4725,6 +4725,57 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/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/error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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/error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/user/policy": {
|
"/user/policy": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -5828,6 +5879,32 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"callHomeGetResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"diagnosticsStatus": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"logsStatus": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callHomeSetStatus": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"diagState",
|
||||||
|
"logsState"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"diagState": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"logsState": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"changeUserPasswordRequest": {
|
"changeUserPasswordRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@@ -13418,6 +13495,57 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/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/error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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/error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/user/policy": {
|
"/user/policy": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -14647,6 +14775,32 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"callHomeGetResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"diagnosticsStatus": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"logsStatus": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"callHomeSetStatus": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"diagState",
|
||||||
|
"logsState"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"diagState": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"logsState": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"changeUserPasswordRequest": {
|
"changeUserPasswordRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import (
|
|||||||
"github.com/minio/console/restapi/operations/service_account"
|
"github.com/minio/console/restapi/operations/service_account"
|
||||||
"github.com/minio/console/restapi/operations/site_replication"
|
"github.com/minio/console/restapi/operations/site_replication"
|
||||||
"github.com/minio/console/restapi/operations/subnet"
|
"github.com/minio/console/restapi/operations/subnet"
|
||||||
|
"github.com/minio/console/restapi/operations/support"
|
||||||
"github.com/minio/console/restapi/operations/system"
|
"github.com/minio/console/restapi/operations/system"
|
||||||
"github.com/minio/console/restapi/operations/tiering"
|
"github.com/minio/console/restapi/operations/tiering"
|
||||||
"github.com/minio/console/restapi/operations/user"
|
"github.com/minio/console/restapi/operations/user"
|
||||||
@@ -243,6 +244,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
|||||||
BucketGetBucketVersioningHandler: bucket.GetBucketVersioningHandlerFunc(func(params bucket.GetBucketVersioningParams, principal *models.Principal) middleware.Responder {
|
BucketGetBucketVersioningHandler: bucket.GetBucketVersioningHandlerFunc(func(params bucket.GetBucketVersioningParams, principal *models.Principal) middleware.Responder {
|
||||||
return middleware.NotImplemented("operation bucket.GetBucketVersioning has not yet been implemented")
|
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 {
|
IdpGetConfigurationHandler: idp.GetConfigurationHandlerFunc(func(params idp.GetConfigurationParams, principal *models.Principal) middleware.Responder {
|
||||||
return middleware.NotImplemented("operation idp.GetConfiguration has not yet been implemented")
|
return middleware.NotImplemented("operation idp.GetConfiguration has not yet been implemented")
|
||||||
}),
|
}),
|
||||||
@@ -471,6 +475,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
|||||||
BucketSetBucketVersioningHandler: bucket.SetBucketVersioningHandlerFunc(func(params bucket.SetBucketVersioningParams, principal *models.Principal) middleware.Responder {
|
BucketSetBucketVersioningHandler: bucket.SetBucketVersioningHandlerFunc(func(params bucket.SetBucketVersioningParams, principal *models.Principal) middleware.Responder {
|
||||||
return middleware.NotImplemented("operation bucket.SetBucketVersioning has not yet been implemented")
|
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 {
|
ConfigurationSetConfigHandler: configuration.SetConfigHandlerFunc(func(params configuration.SetConfigParams, principal *models.Principal) middleware.Responder {
|
||||||
return middleware.NotImplemented("operation configuration.SetConfig has not yet been implemented")
|
return middleware.NotImplemented("operation configuration.SetConfig has not yet been implemented")
|
||||||
}),
|
}),
|
||||||
@@ -707,6 +714,8 @@ type ConsoleAPI struct {
|
|||||||
BucketGetBucketRewindHandler bucket.GetBucketRewindHandler
|
BucketGetBucketRewindHandler bucket.GetBucketRewindHandler
|
||||||
// BucketGetBucketVersioningHandler sets the operation handler for the get bucket versioning operation
|
// BucketGetBucketVersioningHandler sets the operation handler for the get bucket versioning operation
|
||||||
BucketGetBucketVersioningHandler bucket.GetBucketVersioningHandler
|
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 sets the operation handler for the get configuration operation
|
||||||
IdpGetConfigurationHandler idp.GetConfigurationHandler
|
IdpGetConfigurationHandler idp.GetConfigurationHandler
|
||||||
// ObjectGetObjectMetadataHandler sets the operation handler for the get object metadata operation
|
// ObjectGetObjectMetadataHandler sets the operation handler for the get object metadata operation
|
||||||
@@ -859,6 +868,8 @@ type ConsoleAPI struct {
|
|||||||
BucketSetBucketRetentionConfigHandler bucket.SetBucketRetentionConfigHandler
|
BucketSetBucketRetentionConfigHandler bucket.SetBucketRetentionConfigHandler
|
||||||
// BucketSetBucketVersioningHandler sets the operation handler for the set bucket versioning operation
|
// BucketSetBucketVersioningHandler sets the operation handler for the set bucket versioning operation
|
||||||
BucketSetBucketVersioningHandler bucket.SetBucketVersioningHandler
|
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 sets the operation handler for the set config operation
|
||||||
ConfigurationSetConfigHandler configuration.SetConfigHandler
|
ConfigurationSetConfigHandler configuration.SetConfigHandler
|
||||||
// BucketSetMultiBucketReplicationHandler sets the operation handler for the set multi bucket replication operation
|
// BucketSetMultiBucketReplicationHandler sets the operation handler for the set multi bucket replication operation
|
||||||
@@ -1152,6 +1163,9 @@ func (o *ConsoleAPI) Validate() error {
|
|||||||
if o.BucketGetBucketVersioningHandler == nil {
|
if o.BucketGetBucketVersioningHandler == nil {
|
||||||
unregistered = append(unregistered, "bucket.GetBucketVersioningHandler")
|
unregistered = append(unregistered, "bucket.GetBucketVersioningHandler")
|
||||||
}
|
}
|
||||||
|
if o.SupportGetCallHomeOptionValueHandler == nil {
|
||||||
|
unregistered = append(unregistered, "support.GetCallHomeOptionValueHandler")
|
||||||
|
}
|
||||||
if o.IdpGetConfigurationHandler == nil {
|
if o.IdpGetConfigurationHandler == nil {
|
||||||
unregistered = append(unregistered, "idp.GetConfigurationHandler")
|
unregistered = append(unregistered, "idp.GetConfigurationHandler")
|
||||||
}
|
}
|
||||||
@@ -1380,6 +1394,9 @@ func (o *ConsoleAPI) Validate() error {
|
|||||||
if o.BucketSetBucketVersioningHandler == nil {
|
if o.BucketSetBucketVersioningHandler == nil {
|
||||||
unregistered = append(unregistered, "bucket.SetBucketVersioningHandler")
|
unregistered = append(unregistered, "bucket.SetBucketVersioningHandler")
|
||||||
}
|
}
|
||||||
|
if o.SupportSetCallHomeStatusHandler == nil {
|
||||||
|
unregistered = append(unregistered, "support.SetCallHomeStatusHandler")
|
||||||
|
}
|
||||||
if o.ConfigurationSetConfigHandler == nil {
|
if o.ConfigurationSetConfigHandler == nil {
|
||||||
unregistered = append(unregistered, "configuration.SetConfigHandler")
|
unregistered = append(unregistered, "configuration.SetConfigHandler")
|
||||||
}
|
}
|
||||||
@@ -1767,6 +1784,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
|||||||
if o.handlers["GET"] == nil {
|
if o.handlers["GET"] == nil {
|
||||||
o.handlers["GET"] = make(map[string]http.Handler)
|
o.handlers["GET"] = make(map[string]http.Handler)
|
||||||
}
|
}
|
||||||
|
o.handlers["GET"]["/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)
|
o.handlers["GET"]["/idp/{type}/{name}"] = idp.NewGetConfiguration(o.context, o.IdpGetConfigurationHandler)
|
||||||
if o.handlers["GET"] == nil {
|
if o.handlers["GET"] == nil {
|
||||||
o.handlers["GET"] = make(map[string]http.Handler)
|
o.handlers["GET"] = make(map[string]http.Handler)
|
||||||
@@ -2071,6 +2092,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
|||||||
if o.handlers["PUT"] == nil {
|
if o.handlers["PUT"] == nil {
|
||||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
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)
|
o.handlers["PUT"]["/configs/{name}"] = configuration.NewSetConfig(o.context, o.ConfigurationSetConfigHandler)
|
||||||
if o.handlers["POST"] == nil {
|
if o.handlers["POST"] == nil {
|
||||||
o.handlers["POST"] = make(map[string]http.Handler)
|
o.handlers["POST"] = make(map[string]http.Handler)
|
||||||
|
|||||||
88
restapi/operations/support/get_call_home_option_value.go
Normal file
88
restapi/operations/support/get_call_home_option_value.go
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package 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)
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package 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
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package 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.Error `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.Error) *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.Error) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package 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()
|
||||||
|
}
|
||||||
88
restapi/operations/support/set_call_home_status.go
Normal file
88
restapi/operations/support/set_call_home_status.go
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package 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)
|
||||||
|
|
||||||
|
}
|
||||||
101
restapi/operations/support/set_call_home_status_parameters.go
Normal file
101
restapi/operations/support/set_call_home_status_parameters.go
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package 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
|
||||||
|
}
|
||||||
115
restapi/operations/support/set_call_home_status_responses.go
Normal file
115
restapi/operations/support/set_call_home_status_responses.go
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package 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.Error `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.Error) *SetCallHomeStatusDefault {
|
||||||
|
o.Payload = payload
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPayload sets the payload to the set call home status default response
|
||||||
|
func (o *SetCallHomeStatusDefault) SetPayload(payload *models.Error) {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
104
restapi/operations/support/set_call_home_status_urlbuilder.go
Normal file
104
restapi/operations/support/set_call_home_status_urlbuilder.go
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
package 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()
|
||||||
|
}
|
||||||
235
restapi/user_support.go
Normal file
235
restapi/user_support.go
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package restapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/go-openapi/runtime/middleware"
|
||||||
|
"github.com/minio/console/models"
|
||||||
|
"github.com/minio/console/pkg/subnet"
|
||||||
|
"github.com/minio/console/restapi/operations"
|
||||||
|
"github.com/minio/console/restapi/operations/support"
|
||||||
|
"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(int(err.Code)).WithPayload(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
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(int(err.Code)).WithPayload(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return support.NewSetCallHomeStatusNoContent()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// getCallHomeOptionResponse returns the selected option value
|
||||||
|
func getCallHomeOptionResponse(session *models.Principal, params support.GetCallHomeOptionValueParams) (*models.CallHomeGetResponse, *models.Error) {
|
||||||
|
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
mAdmin, err := NewMinioAdminClient(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) *models.Error {
|
||||||
|
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
mAdmin, err := NewMinioAdminClient(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
|
||||||
|
}
|
||||||
382
restapi/user_support_test.go
Normal file
382
restapi/user_support_test.go
Normal file
@@ -0,0 +1,382 @@
|
|||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2023 MinIO, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package restapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/minio/console/models"
|
||||||
|
"github.com/minio/madmin-go/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
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(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||||
|
return madmin.Help{}, errors.New("feature is not supported")
|
||||||
|
},
|
||||||
|
getConfigKV: func(key string) ([]byte, error) {
|
||||||
|
return []byte{}, nil
|
||||||
|
},
|
||||||
|
helpConfigKVGlobal: func(envOnly 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(envOnly 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(subSys, key string, envOnly 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(key 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(envOnly 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(subSys, key string, envOnly 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(key 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(t *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(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||||
|
return madmin.Help{}, errors.New("feature is not supported")
|
||||||
|
},
|
||||||
|
getConfigKV: func(key string) ([]byte, error) {
|
||||||
|
return []byte{}, nil
|
||||||
|
},
|
||||||
|
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||||
|
return madmin.Help{
|
||||||
|
SubSys: "",
|
||||||
|
Description: "",
|
||||||
|
MultipleTargets: false,
|
||||||
|
KeysHelp: madmin.HelpKVS{},
|
||||||
|
}, nil
|
||||||
|
},
|
||||||
|
setConfigEnv: func(kv 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(subSys, key string, envOnly 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(key string) ([]byte, error) {
|
||||||
|
return []byte(`subnet license= api_key= proxy=http://127.0.0.1 `), nil
|
||||||
|
},
|
||||||
|
helpConfigKVGlobal: func(envOnly 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(kv 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(subSys, key string, envOnly 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(key string) ([]byte, error) {
|
||||||
|
return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil
|
||||||
|
},
|
||||||
|
helpConfigKVGlobal: func(envOnly 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(kv 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(subSys, key string, envOnly 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(key string) ([]byte, error) {
|
||||||
|
return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil
|
||||||
|
},
|
||||||
|
helpConfigKVGlobal: func(envOnly 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(kv 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(subSys, key string, envOnly 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(key string) ([]byte, error) {
|
||||||
|
return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil
|
||||||
|
},
|
||||||
|
helpConfigKVGlobal: func(envOnly 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(kv 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(t *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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3452,6 +3452,41 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- release
|
- 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/error"
|
||||||
|
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/error"
|
||||||
|
tags:
|
||||||
|
- Support
|
||||||
|
|
||||||
definitions:
|
definitions:
|
||||||
accountChangePasswordRequest:
|
accountChangePasswordRequest:
|
||||||
type: object
|
type: object
|
||||||
@@ -5840,6 +5875,7 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
restart:
|
restart:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
|
||||||
releaseListResponse:
|
releaseListResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -5862,6 +5898,7 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
newFeaturesContent:
|
newFeaturesContent:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
releaseMetadata:
|
releaseMetadata:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -5935,4 +5972,23 @@ definitions:
|
|||||||
starred_url:
|
starred_url:
|
||||||
type: string
|
type: string
|
||||||
subscriptions_url:
|
subscriptions_url:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
callHomeGetResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
diagnosticsStatus:
|
||||||
|
type: boolean
|
||||||
|
logsStatus:
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
callHomeSetStatus:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- diagState
|
||||||
|
- logsState
|
||||||
|
properties:
|
||||||
|
diagState:
|
||||||
|
type: boolean
|
||||||
|
logsState:
|
||||||
|
type: boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user