From 9587e4105f4db557bb21f3fd0cd4bd589af5f4f3 Mon Sep 17 00:00:00 2001 From: Javier Adriel Date: Wed, 12 Oct 2022 14:00:48 -0500 Subject: [PATCH] Add missing KMS handlers for version, apis and metrics (#2376) --- go.mod | 4 +- go.sum | 8 +- models/kms_a_p_is_response.go | 133 +++++++ models/kms_api.go | 76 ++++ models/kms_latency_histogram.go | 67 ++++ models/kms_metrics_response.go | 331 +++++++++++++++++ models/kms_version_response.go | 67 ++++ restapi/admin_kms.go | 177 +++++++-- restapi/admin_kms_test.go | 78 ++++ restapi/client-admin.go | 15 + restapi/embedded_spec.go | 350 ++++++++++++++++++ restapi/operations/console_api.go | 36 ++ restapi/operations/k_m_s/k_m_s_a_p_is.go | 88 +++++ .../k_m_s/k_m_s_a_p_is_parameters.go | 63 ++++ .../k_m_s/k_m_s_a_p_is_responses.go | 135 +++++++ .../k_m_s/k_m_s_a_p_is_urlbuilder.go | 104 ++++++ restapi/operations/k_m_s/k_m_s_metrics.go | 88 +++++ .../k_m_s/k_m_s_metrics_parameters.go | 63 ++++ .../k_m_s/k_m_s_metrics_responses.go | 135 +++++++ .../k_m_s/k_m_s_metrics_urlbuilder.go | 104 ++++++ restapi/operations/k_m_s/k_m_s_version.go | 88 +++++ .../k_m_s/k_m_s_version_parameters.go | 63 ++++ .../k_m_s/k_m_s_version_responses.go | 135 +++++++ .../k_m_s/k_m_s_version_urlbuilder.go | 104 ++++++ swagger-console.yml | 118 ++++++ 25 files changed, 2592 insertions(+), 38 deletions(-) create mode 100644 models/kms_a_p_is_response.go create mode 100644 models/kms_api.go create mode 100644 models/kms_latency_histogram.go create mode 100644 models/kms_metrics_response.go create mode 100644 models/kms_version_response.go create mode 100644 restapi/operations/k_m_s/k_m_s_a_p_is.go create mode 100644 restapi/operations/k_m_s/k_m_s_a_p_is_parameters.go create mode 100644 restapi/operations/k_m_s/k_m_s_a_p_is_responses.go create mode 100644 restapi/operations/k_m_s/k_m_s_a_p_is_urlbuilder.go create mode 100644 restapi/operations/k_m_s/k_m_s_metrics.go create mode 100644 restapi/operations/k_m_s/k_m_s_metrics_parameters.go create mode 100644 restapi/operations/k_m_s/k_m_s_metrics_responses.go create mode 100644 restapi/operations/k_m_s/k_m_s_metrics_urlbuilder.go create mode 100644 restapi/operations/k_m_s/k_m_s_version.go create mode 100644 restapi/operations/k_m_s/k_m_s_version_parameters.go create mode 100644 restapi/operations/k_m_s/k_m_s_version_responses.go create mode 100644 restapi/operations/k_m_s/k_m_s_version_urlbuilder.go diff --git a/go.mod b/go.mod index b3ba3ed49..ab443d968 100644 --- a/go.mod +++ b/go.mod @@ -23,11 +23,11 @@ require ( github.com/minio/directpv v1.4.4-0.20220805090942-948ca4731651 github.com/minio/highwayhash v1.0.2 github.com/minio/kes v0.21.0 - github.com/minio/madmin-go v1.6.1 + github.com/minio/madmin-go v1.6.3 github.com/minio/mc v0.0.0-20221007160339-ec8687d57e36 github.com/minio/minio-go/v7 v7.0.40 github.com/minio/operator v0.0.0-20220902184351-21e4073132b0 - github.com/minio/pkg v1.5.0 + github.com/minio/pkg v1.5.1 github.com/minio/selfupdate v0.5.0 github.com/mitchellh/go-homedir v1.1.0 github.com/rs/xid v1.4.0 diff --git a/go.sum b/go.sum index 90e578784..7cd027ca1 100644 --- a/go.sum +++ b/go.sum @@ -512,8 +512,8 @@ github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLT github.com/minio/kes v0.21.0 h1:Xe0vNRyBgC35TZkbOnU4hAgJRBEaFcT6KiI9/29BdUo= github.com/minio/kes v0.21.0/go.mod h1:3FW1BQkMGQW78yhy+69tUq5bdcf5rnXJizyeKB9a/tc= github.com/minio/madmin-go v1.3.5/go.mod h1:vGKGboQgGIWx4DuDUaXixjlIEZOCIp6ivJkQoiVaACc= -github.com/minio/madmin-go v1.6.1 h1:vVyz83CNxbc1h3cbAMiWjun7OXoWTFJ+YZi6UaFEb0k= -github.com/minio/madmin-go v1.6.1/go.mod h1:FVl1TS8T79779KZEboPHL5byffHJ6DyrAAavqgsG6UQ= +github.com/minio/madmin-go v1.6.3 h1:JNF1NqS0EfDzGmNaKTLYnJhT7b/35+JpBSburE/u1q8= +github.com/minio/madmin-go v1.6.3/go.mod h1:FVl1TS8T79779KZEboPHL5byffHJ6DyrAAavqgsG6UQ= github.com/minio/mc v0.0.0-20221007160339-ec8687d57e36 h1:PZBesSP8+opPLIEtQVfFKM4kKCOP68vNXws5nsXZG44= github.com/minio/mc v0.0.0-20221007160339-ec8687d57e36/go.mod h1:pE0JlsioQpQKBFZf9dRO0V06t0jXhBuHR5p+rFxA2i8= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw= @@ -525,8 +525,8 @@ github.com/minio/minio-go/v7 v7.0.40/go.mod h1:nCrRzjoSUQh8hgKKtu3Y708OLvRLtuASM github.com/minio/operator v0.0.0-20220902184351-21e4073132b0 h1:Ak/IkcWaY/ntGIzpeZIw43hwFKMh1242qIELpk4bVqI= github.com/minio/operator v0.0.0-20220902184351-21e4073132b0/go.mod h1:pMMJ+WzD3znzYC3Ae/clcKocdSRyenK4kzdstibdafk= github.com/minio/pkg v1.1.20/go.mod h1:Xo7LQshlxGa9shKwJ7NzQbgW4s8T/Wc1cOStR/eUiMY= -github.com/minio/pkg v1.5.0 h1:517jxphvCLSNE8vbctMY4avaRDZXiGT7lX+cXPXFb98= -github.com/minio/pkg v1.5.0/go.mod h1:koF2J2Ep/zpd//k+3UYdh6ySZKjqzy9C6RCZRX7uRY8= +github.com/minio/pkg v1.5.1 h1:XwuoZMqC+VXYGRFFALO5JGacQxut6iUTJP76UGPzsek= +github.com/minio/pkg v1.5.1/go.mod h1:koF2J2Ep/zpd//k+3UYdh6ySZKjqzy9C6RCZRX7uRY8= github.com/minio/selfupdate v0.5.0 h1:0UH1HlL49+2XByhovKl5FpYTjKfvrQ2sgL1zEXK6mfI= github.com/minio/selfupdate v0.5.0/go.mod h1:mcDkzMgq8PRcpCRJo/NlPY7U45O5dfYl2Y0Rg7IustY= github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= diff --git a/models/kms_a_p_is_response.go b/models/kms_a_p_is_response.go new file mode 100644 index 000000000..aa0da7cdc --- /dev/null +++ b/models/kms_a_p_is_response.go @@ -0,0 +1,133 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// KmsAPIsResponse kms a p is response +// +// swagger:model kmsAPIsResponse +type KmsAPIsResponse struct { + + // results + Results []*KmsAPI `json:"results"` +} + +// Validate validates this kms a p is response +func (m *KmsAPIsResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateResults(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *KmsAPIsResponse) validateResults(formats strfmt.Registry) error { + if swag.IsZero(m.Results) { // not required + return nil + } + + for i := 0; i < len(m.Results); i++ { + if swag.IsZero(m.Results[i]) { // not required + continue + } + + if m.Results[i] != nil { + if err := m.Results[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("results" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("results" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this kms a p is response based on the context it is used +func (m *KmsAPIsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateResults(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *KmsAPIsResponse) contextValidateResults(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Results); i++ { + + if m.Results[i] != nil { + if err := m.Results[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("results" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("results" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *KmsAPIsResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *KmsAPIsResponse) UnmarshalBinary(b []byte) error { + var res KmsAPIsResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/kms_api.go b/models/kms_api.go new file mode 100644 index 000000000..0f95a8eae --- /dev/null +++ b/models/kms_api.go @@ -0,0 +1,76 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// KmsAPI kms API +// +// swagger:model kmsAPI +type KmsAPI struct { + + // max body + MaxBody int64 `json:"maxBody,omitempty"` + + // method + Method string `json:"method,omitempty"` + + // path + Path string `json:"path,omitempty"` + + // timeout + Timeout int64 `json:"timeout,omitempty"` +} + +// Validate validates this kms API +func (m *KmsAPI) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this kms API based on context it is used +func (m *KmsAPI) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *KmsAPI) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *KmsAPI) UnmarshalBinary(b []byte) error { + var res KmsAPI + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/kms_latency_histogram.go b/models/kms_latency_histogram.go new file mode 100644 index 000000000..07b6dc21d --- /dev/null +++ b/models/kms_latency_histogram.go @@ -0,0 +1,67 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// KmsLatencyHistogram kms latency histogram +// +// swagger:model kmsLatencyHistogram +type KmsLatencyHistogram struct { + + // duration + Duration int64 `json:"duration,omitempty"` +} + +// Validate validates this kms latency histogram +func (m *KmsLatencyHistogram) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this kms latency histogram based on context it is used +func (m *KmsLatencyHistogram) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *KmsLatencyHistogram) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *KmsLatencyHistogram) UnmarshalBinary(b []byte) error { + var res KmsLatencyHistogram + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/kms_metrics_response.go b/models/kms_metrics_response.go new file mode 100644 index 000000000..67da3ad53 --- /dev/null +++ b/models/kms_metrics_response.go @@ -0,0 +1,331 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// KmsMetricsResponse kms metrics response +// +// swagger:model kmsMetricsResponse +type KmsMetricsResponse struct { + + // audit events + // Required: true + AuditEvents *int64 `json:"auditEvents"` + + // cpus + // Required: true + Cpus *int64 `json:"cpus"` + + // error events + // Required: true + ErrorEvents *int64 `json:"errorEvents"` + + // heap alloc + // Required: true + HeapAlloc *int64 `json:"heapAlloc"` + + // heap objects + HeapObjects int64 `json:"heapObjects,omitempty"` + + // latency histogram + // Required: true + LatencyHistogram *KmsLatencyHistogram `json:"latencyHistogram"` + + // request active + // Required: true + RequestActive *int64 `json:"requestActive"` + + // request err + // Required: true + RequestErr *int64 `json:"requestErr"` + + // request fail + // Required: true + RequestFail *int64 `json:"requestFail"` + + // request o k + // Required: true + RequestOK *int64 `json:"requestOK"` + + // stack alloc + // Required: true + StackAlloc *int64 `json:"stackAlloc"` + + // threads + // Required: true + Threads *int64 `json:"threads"` + + // uptime + // Required: true + Uptime *int64 `json:"uptime"` + + // usable c p us + // Required: true + UsableCPUs *int64 `json:"usableCPUs"` +} + +// Validate validates this kms metrics response +func (m *KmsMetricsResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuditEvents(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCpus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateErrorEvents(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHeapAlloc(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLatencyHistogram(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRequestActive(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRequestErr(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRequestFail(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRequestOK(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStackAlloc(formats); err != nil { + res = append(res, err) + } + + if err := m.validateThreads(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUptime(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUsableCPUs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *KmsMetricsResponse) validateAuditEvents(formats strfmt.Registry) error { + + if err := validate.Required("auditEvents", "body", m.AuditEvents); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateCpus(formats strfmt.Registry) error { + + if err := validate.Required("cpus", "body", m.Cpus); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateErrorEvents(formats strfmt.Registry) error { + + if err := validate.Required("errorEvents", "body", m.ErrorEvents); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateHeapAlloc(formats strfmt.Registry) error { + + if err := validate.Required("heapAlloc", "body", m.HeapAlloc); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateLatencyHistogram(formats strfmt.Registry) error { + + if err := validate.Required("latencyHistogram", "body", m.LatencyHistogram); err != nil { + return err + } + + if m.LatencyHistogram != nil { + if err := m.LatencyHistogram.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("latencyHistogram") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("latencyHistogram") + } + return err + } + } + + return nil +} + +func (m *KmsMetricsResponse) validateRequestActive(formats strfmt.Registry) error { + + if err := validate.Required("requestActive", "body", m.RequestActive); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateRequestErr(formats strfmt.Registry) error { + + if err := validate.Required("requestErr", "body", m.RequestErr); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateRequestFail(formats strfmt.Registry) error { + + if err := validate.Required("requestFail", "body", m.RequestFail); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateRequestOK(formats strfmt.Registry) error { + + if err := validate.Required("requestOK", "body", m.RequestOK); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateStackAlloc(formats strfmt.Registry) error { + + if err := validate.Required("stackAlloc", "body", m.StackAlloc); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateThreads(formats strfmt.Registry) error { + + if err := validate.Required("threads", "body", m.Threads); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateUptime(formats strfmt.Registry) error { + + if err := validate.Required("uptime", "body", m.Uptime); err != nil { + return err + } + + return nil +} + +func (m *KmsMetricsResponse) validateUsableCPUs(formats strfmt.Registry) error { + + if err := validate.Required("usableCPUs", "body", m.UsableCPUs); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this kms metrics response based on the context it is used +func (m *KmsMetricsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLatencyHistogram(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *KmsMetricsResponse) contextValidateLatencyHistogram(ctx context.Context, formats strfmt.Registry) error { + + if m.LatencyHistogram != nil { + if err := m.LatencyHistogram.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("latencyHistogram") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("latencyHistogram") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *KmsMetricsResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *KmsMetricsResponse) UnmarshalBinary(b []byte) error { + var res KmsMetricsResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/kms_version_response.go b/models/kms_version_response.go new file mode 100644 index 000000000..3a60834b4 --- /dev/null +++ b/models/kms_version_response.go @@ -0,0 +1,67 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// KmsVersionResponse kms version response +// +// swagger:model kmsVersionResponse +type KmsVersionResponse struct { + + // version + Version string `json:"version,omitempty"` +} + +// Validate validates this kms version response +func (m *KmsVersionResponse) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this kms version response based on context it is used +func (m *KmsVersionResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *KmsVersionResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *KmsVersionResponse) UnmarshalBinary(b []byte) error { + var res KmsVersionResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/restapi/admin_kms.go b/restapi/admin_kms.go index 6de7c4325..775e54985 100644 --- a/restapi/admin_kms.go +++ b/restapi/admin_kms.go @@ -29,6 +29,13 @@ import ( ) func registerKMSHandlers(api *operations.ConsoleAPI) { + registerKMSStatusHandlers(api) + registerKMSKeyHandlers(api) + registerKMSPolicyHandlers(api) + registerKMSIdentityHandlers(api) +} + +func registerKMSStatusHandlers(api *operations.ConsoleAPI) { api.KmsKMSStatusHandler = kmsAPI.KMSStatusHandlerFunc(func(params kmsAPI.KMSStatusParams, session *models.Principal) middleware.Responder { resp, err := GetKMSStatusResponse(session, params) if err != nil { @@ -36,9 +43,144 @@ func registerKMSHandlers(api *operations.ConsoleAPI) { } return kmsAPI.NewKMSStatusOK().WithPayload(resp) }) - registerKMSKeyHandlers(api) - registerKMSPolicyHandlers(api) - registerKMSIdentityHandlers(api) + + api.KmsKMSMetricsHandler = kmsAPI.KMSMetricsHandlerFunc(func(params kmsAPI.KMSMetricsParams, session *models.Principal) middleware.Responder { + resp, err := GetKMSMetricsResponse(session, params) + if err != nil { + return kmsAPI.NewKMSMetricsDefault(int(err.Code)).WithPayload(err) + } + return kmsAPI.NewKMSMetricsOK().WithPayload(resp) + }) + + api.KmsKMSAPIsHandler = kmsAPI.KMSAPIsHandlerFunc(func(params kmsAPI.KMSAPIsParams, session *models.Principal) middleware.Responder { + resp, err := GetKMSAPIsResponse(session, params) + if err != nil { + return kmsAPI.NewKMSAPIsDefault(int(err.Code)).WithPayload(err) + } + return kmsAPI.NewKMSAPIsOK().WithPayload(resp) + }) + + api.KmsKMSVersionHandler = kmsAPI.KMSVersionHandlerFunc(func(params kmsAPI.KMSVersionParams, session *models.Principal) middleware.Responder { + resp, err := GetKMSVersionResponse(session, params) + if err != nil { + return kmsAPI.NewKMSVersionDefault(int(err.Code)).WithPayload(err) + } + return kmsAPI.NewKMSVersionOK().WithPayload(resp) + }) +} + +func GetKMSStatusResponse(session *models.Principal, params kmsAPI.KMSStatusParams) (*models.KmsStatusResponse, *models.Error) { + ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) + defer cancel() + mAdmin, err := NewMinioAdminClient(session) + if err != nil { + return nil, ErrorWithContext(ctx, err) + } + return kmsStatus(ctx, AdminClient{Client: mAdmin}) +} + +func kmsStatus(ctx context.Context, minioClient MinioAdmin) (*models.KmsStatusResponse, *models.Error) { + st, err := minioClient.kmsStatus(ctx) + if err != nil { + return nil, ErrorWithContext(ctx, err) + } + return &models.KmsStatusResponse{ + DefaultKeyID: st.DefaultKeyID, + Name: st.Name, + Endpoints: parseStatusEndpoints(st.Endpoints), + }, nil +} + +func parseStatusEndpoints(endpoints map[string]madmin.ItemState) (kmsEndpoints []*models.KmsEndpoint) { + for key, value := range endpoints { + kmsEndpoints = append(kmsEndpoints, &models.KmsEndpoint{URL: key, Status: string(value)}) + } + return kmsEndpoints +} + +func GetKMSMetricsResponse(session *models.Principal, params kmsAPI.KMSMetricsParams) (*models.KmsMetricsResponse, *models.Error) { + ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) + defer cancel() + mAdmin, err := NewMinioAdminClient(session) + if err != nil { + return nil, ErrorWithContext(ctx, err) + } + return kmsMetrics(ctx, AdminClient{Client: mAdmin}) +} + +func kmsMetrics(ctx context.Context, minioClient MinioAdmin) (*models.KmsMetricsResponse, *models.Error) { + metrics, err := minioClient.kmsMetrics(ctx) + if err != nil { + return nil, ErrorWithContext(ctx, err) + } + return &models.KmsMetricsResponse{ + RequestOK: &metrics.RequestOK, + RequestErr: &metrics.RequestErr, + RequestFail: &metrics.RequestFail, + RequestActive: &metrics.RequestActive, + AuditEvents: &metrics.AuditEvents, + ErrorEvents: &metrics.ErrorEvents, + LatencyHistogram: nil, + Uptime: &metrics.UpTime, + Cpus: &metrics.CPUs, + UsableCPUs: &metrics.UsableCPUs, + Threads: &metrics.Threads, + HeapAlloc: &metrics.HeapAlloc, + HeapObjects: metrics.HeapObjects, + StackAlloc: &metrics.StackAlloc, + }, nil +} + +func GetKMSAPIsResponse(session *models.Principal, params kmsAPI.KMSAPIsParams) (*models.KmsAPIsResponse, *models.Error) { + ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) + defer cancel() + mAdmin, err := NewMinioAdminClient(session) + if err != nil { + return nil, ErrorWithContext(ctx, err) + } + return kmsAPIs(ctx, AdminClient{Client: mAdmin}) +} + +func kmsAPIs(ctx context.Context, minioClient MinioAdmin) (*models.KmsAPIsResponse, *models.Error) { + apis, err := minioClient.kmsAPIs(ctx) + if err != nil { + return nil, ErrorWithContext(ctx, err) + } + return &models.KmsAPIsResponse{ + Results: parseApis(apis), + }, nil +} + +func parseApis(apis []madmin.KMSAPI) (data []*models.KmsAPI) { + for _, api := range apis { + data = append(data, &models.KmsAPI{ + Method: api.Method, + Path: api.Path, + MaxBody: api.MaxBody, + Timeout: api.Timeout, + }) + } + return data +} + +func GetKMSVersionResponse(session *models.Principal, params kmsAPI.KMSVersionParams) (*models.KmsVersionResponse, *models.Error) { + ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) + defer cancel() + mAdmin, err := NewMinioAdminClient(session) + if err != nil { + return nil, ErrorWithContext(ctx, err) + } + return kmsVersion(ctx, AdminClient{Client: mAdmin}) +} + +func kmsVersion(ctx context.Context, minioClient MinioAdmin) (*models.KmsVersionResponse, *models.Error) { + version, err := minioClient.kmsVersion(ctx) + if err != nil { + return nil, ErrorWithContext(ctx, err) + } + return &models.KmsVersionResponse{ + Version: version.Version, + }, nil } func registerKMSKeyHandlers(api *operations.ConsoleAPI) { @@ -83,35 +225,6 @@ func registerKMSKeyHandlers(api *operations.ConsoleAPI) { }) } -func GetKMSStatusResponse(session *models.Principal, params kmsAPI.KMSStatusParams) (*models.KmsStatusResponse, *models.Error) { - ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) - defer cancel() - mAdmin, err := NewMinioAdminClient(session) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - return kmsStatus(ctx, AdminClient{Client: mAdmin}) -} - -func kmsStatus(ctx context.Context, minioClient MinioAdmin) (*models.KmsStatusResponse, *models.Error) { - st, err := minioClient.kmsStatus(ctx) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - return &models.KmsStatusResponse{ - DefaultKeyID: st.DefaultKeyID, - Name: st.Name, - Endpoints: parseStatusEndpoints(st.Endpoints), - }, nil -} - -func parseStatusEndpoints(endpoints map[string]madmin.ItemState) (kmsEndpoints []*models.KmsEndpoint) { - for key, value := range endpoints { - kmsEndpoints = append(kmsEndpoints, &models.KmsEndpoint{URL: key, Status: string(value)}) - } - return kmsEndpoints -} - func GetKMSCreateKeyResponse(session *models.Principal, params kmsAPI.KMSCreateKeyParams) *models.Error { ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) defer cancel() diff --git a/restapi/admin_kms_test.go b/restapi/admin_kms_test.go index 1cd50f9c2..b2df00db1 100644 --- a/restapi/admin_kms_test.go +++ b/restapi/admin_kms_test.go @@ -35,6 +35,18 @@ func (ac adminClientMock) kmsStatus(ctx context.Context) (madmin.KMSStatus, erro return madmin.KMSStatus{Name: "name", DefaultKeyID: "key", Endpoints: map[string]madmin.ItemState{"localhost": madmin.ItemState("online")}}, nil } +func (ac adminClientMock) kmsAPIs(ctx context.Context) ([]madmin.KMSAPI, error) { + return []madmin.KMSAPI{{Method: "GET", Path: "/mock"}}, nil +} + +func (ac adminClientMock) kmsMetrics(ctx context.Context) (*madmin.KMSMetrics, error) { + return &madmin.KMSMetrics{}, nil +} + +func (ac adminClientMock) kmsVersion(ctx context.Context) (*madmin.KMSVersion, error) { + return &madmin.KMSVersion{Version: "test-version"}, nil +} + func (ac adminClientMock) createKey(ctx context.Context, key string) error { return nil } @@ -147,6 +159,9 @@ func (suite *KMSTestSuite) TestRegisterKMSHandlers() { func (suite *KMSTestSuite) assertHandlersAreNil(api *operations.ConsoleAPI) { suite.assert.Nil(api.KmsKMSStatusHandler) + suite.assert.Nil(api.KmsKMSMetricsHandler) + suite.assert.Nil(api.KmsKMSAPIsHandler) + suite.assert.Nil(api.KmsKMSVersionHandler) suite.assert.Nil(api.KmsKMSCreateKeyHandler) suite.assert.Nil(api.KmsKMSImportKeyHandler) suite.assert.Nil(api.KmsKMSListKeysHandler) @@ -166,6 +181,9 @@ func (suite *KMSTestSuite) assertHandlersAreNil(api *operations.ConsoleAPI) { func (suite *KMSTestSuite) assertHandlersAreNotNil(api *operations.ConsoleAPI) { suite.assert.NotNil(api.KmsKMSStatusHandler) + suite.assert.NotNil(api.KmsKMSMetricsHandler) + suite.assert.NotNil(api.KmsKMSAPIsHandler) + suite.assert.NotNil(api.KmsKMSVersionHandler) suite.assert.NotNil(api.KmsKMSCreateKeyHandler) suite.assert.NotNil(api.KmsKMSImportKeyHandler) suite.assert.NotNil(api.KmsKMSListKeysHandler) @@ -203,6 +221,66 @@ func (suite *KMSTestSuite) TestKMSStatusWithoutError() { suite.assert.Nil(err) } +func (suite *KMSTestSuite) TestKMSMetricsHandlerWithError() { + params, api := suite.initKMSMetricsRequest() + response := api.KmsKMSMetricsHandler.Handle(params, &models.Principal{}) + _, ok := response.(*kmsAPI.KMSMetricsDefault) + suite.assert.True(ok) +} + +func (suite *KMSTestSuite) initKMSMetricsRequest() (params kmsAPI.KMSMetricsParams, api operations.ConsoleAPI) { + registerKMSHandlers(&api) + params.HTTPRequest = &http.Request{} + return params, api +} + +func (suite *KMSTestSuite) TestKMSMetricsWithoutError() { + ctx := context.Background() + res, err := kmsMetrics(ctx, suite.adminClient) + suite.assert.NotNil(res) + suite.assert.Nil(err) +} + +func (suite *KMSTestSuite) TestKMSAPIsHandlerWithError() { + params, api := suite.initKMSAPIsRequest() + response := api.KmsKMSAPIsHandler.Handle(params, &models.Principal{}) + _, ok := response.(*kmsAPI.KMSAPIsDefault) + suite.assert.True(ok) +} + +func (suite *KMSTestSuite) initKMSAPIsRequest() (params kmsAPI.KMSAPIsParams, api operations.ConsoleAPI) { + registerKMSHandlers(&api) + params.HTTPRequest = &http.Request{} + return params, api +} + +func (suite *KMSTestSuite) TestKMSAPIsWithoutError() { + ctx := context.Background() + res, err := kmsAPIs(ctx, suite.adminClient) + suite.assert.NotNil(res) + suite.assert.Nil(err) +} + +func (suite *KMSTestSuite) TestKMSVersionHandlerWithError() { + params, api := suite.initKMSVersionRequest() + response := api.KmsKMSVersionHandler.Handle(params, &models.Principal{}) + _, ok := response.(*kmsAPI.KMSVersionDefault) + suite.assert.True(ok) +} + +func (suite *KMSTestSuite) initKMSVersionRequest() (params kmsAPI.KMSVersionParams, api operations.ConsoleAPI) { + registerKMSHandlers(&api) + params.HTTPRequest = &http.Request{} + return params, api +} + +func (suite *KMSTestSuite) TestKMSVersionWithoutError() { + ctx := context.Background() + res, err := kmsVersion(ctx, suite.adminClient) + suite.assert.NotNil(res) + suite.assert.Nil(err) +} + func (suite *KMSTestSuite) TestKMSCreateKeyHandlerWithError() { params, api := suite.initKMSCreateKeyRequest() response := api.KmsKMSCreateKeyHandler.Handle(params, &models.Principal{}) diff --git a/restapi/client-admin.go b/restapi/client-admin.go index 114ee0610..c5eedd5d5 100644 --- a/restapi/client-admin.go +++ b/restapi/client-admin.go @@ -126,6 +126,9 @@ type MinioAdmin interface { // KMS kmsStatus(ctx context.Context) (madmin.KMSStatus, error) + kmsMetrics(ctx context.Context) (*madmin.KMSMetrics, error) + kmsAPIs(ctx context.Context) ([]madmin.KMSAPI, error) + kmsVersion(ctx context.Context) (*madmin.KMSVersion, error) createKey(ctx context.Context, key string) error importKey(ctx context.Context, key string, content []byte) error listKeys(ctx context.Context, pattern string) ([]madmin.KMSKeyInfo, error) @@ -575,6 +578,18 @@ func (ac AdminClient) kmsStatus(ctx context.Context) (madmin.KMSStatus, error) { return ac.Client.KMSStatus(ctx) } +func (ac AdminClient) kmsMetrics(ctx context.Context) (*madmin.KMSMetrics, error) { + return ac.Client.KMSMetrics(ctx) +} + +func (ac AdminClient) kmsAPIs(ctx context.Context) ([]madmin.KMSAPI, error) { + return ac.Client.KMSAPIs(ctx) +} + +func (ac AdminClient) kmsVersion(ctx context.Context) (*madmin.KMSVersion, error) { + return ac.Client.KMSVersion(ctx) +} + func (ac AdminClient) createKey(ctx context.Context, key string) error { return ac.Client.CreateKey(ctx, key) } diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go index 5ad5b5340..b900ce6e1 100644 --- a/restapi/embedded_spec.go +++ b/restapi/embedded_spec.go @@ -2787,6 +2787,29 @@ func init() { } } }, + "/kms/apis": { + "get": { + "tags": [ + "KMS" + ], + "summary": "KMS apis", + "operationId": "KMSAPIs", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/kmsAPIsResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/kms/describe-self/identity": { "get": { "tags": [ @@ -3057,6 +3080,29 @@ func init() { } } }, + "/kms/metrics": { + "get": { + "tags": [ + "KMS" + ], + "summary": "KMS metrics", + "operationId": "KMSMetrics", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/kmsMetricsResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/kms/policies": { "get": { "tags": [ @@ -3267,6 +3313,29 @@ func init() { } } }, + "/kms/version": { + "get": { + "tags": [ + "KMS" + ], + "summary": "KMS version", + "operationId": "KMSVersion", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/kmsVersionResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/list-external-buckets": { "post": { "tags": [ @@ -5705,6 +5774,34 @@ func init() { "kmDeleteKeyRequest": { "type": "object" }, + "kmsAPI": { + "type": "object", + "properties": { + "maxBody": { + "type": "integer" + }, + "method": { + "type": "string" + }, + "path": { + "type": "string" + }, + "timeout": { + "type": "integer" + } + } + }, + "kmsAPIsResponse": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/kmsAPI" + } + } + } + }, "kmsAssignPolicyRequest": { "type": "object", "properties": { @@ -5868,6 +5965,14 @@ func init() { } } }, + "kmsLatencyHistogram": { + "type": "object", + "properties": { + "duration": { + "type": "integer" + } + } + }, "kmsListIdentitiesResponse": { "type": "object", "properties": { @@ -5901,6 +6006,68 @@ func init() { } } }, + "kmsMetricsResponse": { + "type": "object", + "required": [ + "requestOK", + "requestErr", + "requestFail", + "requestActive", + "auditEvents", + "errorEvents", + "latencyHistogram", + "uptime", + "cpus", + "usableCPUs", + "threads", + "heapAlloc", + "stackAlloc" + ], + "properties": { + "auditEvents": { + "type": "integer" + }, + "cpus": { + "type": "integer" + }, + "errorEvents": { + "type": "integer" + }, + "heapAlloc": { + "type": "integer" + }, + "heapObjects": { + "type": "integer" + }, + "latencyHistogram": { + "$ref": "#/definitions/kmsLatencyHistogram" + }, + "requestActive": { + "type": "integer" + }, + "requestErr": { + "type": "integer" + }, + "requestFail": { + "type": "integer" + }, + "requestOK": { + "type": "integer" + }, + "stackAlloc": { + "type": "integer" + }, + "threads": { + "type": "integer" + }, + "uptime": { + "type": "integer" + }, + "usableCPUs": { + "type": "integer" + } + } + }, "kmsPolicyInfo": { "type": "object", "properties": { @@ -5955,6 +6122,14 @@ func init() { } } }, + "kmsVersionResponse": { + "type": "object", + "properties": { + "version": { + "type": "string" + } + } + }, "license": { "type": "object", "properties": { @@ -10739,6 +10914,29 @@ func init() { } } }, + "/kms/apis": { + "get": { + "tags": [ + "KMS" + ], + "summary": "KMS apis", + "operationId": "KMSAPIs", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/kmsAPIsResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/kms/describe-self/identity": { "get": { "tags": [ @@ -11009,6 +11207,29 @@ func init() { } } }, + "/kms/metrics": { + "get": { + "tags": [ + "KMS" + ], + "summary": "KMS metrics", + "operationId": "KMSMetrics", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/kmsMetricsResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/kms/policies": { "get": { "tags": [ @@ -11219,6 +11440,29 @@ func init() { } } }, + "/kms/version": { + "get": { + "tags": [ + "KMS" + ], + "summary": "KMS version", + "operationId": "KMSVersion", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/kmsVersionResponse" + } + }, + "default": { + "description": "Generic error response.", + "schema": { + "$ref": "#/definitions/error" + } + } + } + } + }, "/list-external-buckets": { "post": { "tags": [ @@ -13783,6 +14027,34 @@ func init() { "kmDeleteKeyRequest": { "type": "object" }, + "kmsAPI": { + "type": "object", + "properties": { + "maxBody": { + "type": "integer" + }, + "method": { + "type": "string" + }, + "path": { + "type": "string" + }, + "timeout": { + "type": "integer" + } + } + }, + "kmsAPIsResponse": { + "type": "object", + "properties": { + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/kmsAPI" + } + } + } + }, "kmsAssignPolicyRequest": { "type": "object", "properties": { @@ -13946,6 +14218,14 @@ func init() { } } }, + "kmsLatencyHistogram": { + "type": "object", + "properties": { + "duration": { + "type": "integer" + } + } + }, "kmsListIdentitiesResponse": { "type": "object", "properties": { @@ -13979,6 +14259,68 @@ func init() { } } }, + "kmsMetricsResponse": { + "type": "object", + "required": [ + "requestOK", + "requestErr", + "requestFail", + "requestActive", + "auditEvents", + "errorEvents", + "latencyHistogram", + "uptime", + "cpus", + "usableCPUs", + "threads", + "heapAlloc", + "stackAlloc" + ], + "properties": { + "auditEvents": { + "type": "integer" + }, + "cpus": { + "type": "integer" + }, + "errorEvents": { + "type": "integer" + }, + "heapAlloc": { + "type": "integer" + }, + "heapObjects": { + "type": "integer" + }, + "latencyHistogram": { + "$ref": "#/definitions/kmsLatencyHistogram" + }, + "requestActive": { + "type": "integer" + }, + "requestErr": { + "type": "integer" + }, + "requestFail": { + "type": "integer" + }, + "requestOK": { + "type": "integer" + }, + "stackAlloc": { + "type": "integer" + }, + "threads": { + "type": "integer" + }, + "uptime": { + "type": "integer" + }, + "usableCPUs": { + "type": "integer" + } + } + }, "kmsPolicyInfo": { "type": "object", "properties": { @@ -14033,6 +14375,14 @@ func init() { } } }, + "kmsVersionResponse": { + "type": "object", + "properties": { + "version": { + "type": "string" + } + } + }, "license": { "type": "object", "properties": { diff --git a/restapi/operations/console_api.go b/restapi/operations/console_api.go index 7f4c5cf1a..0b02b322a 100644 --- a/restapi/operations/console_api.go +++ b/restapi/operations/console_api.go @@ -265,6 +265,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI { InspectInspectHandler: inspect.InspectHandlerFunc(func(params inspect.InspectParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation inspect.Inspect has not yet been implemented") }), + KmsKMSAPIsHandler: k_m_s.KMSAPIsHandlerFunc(func(params k_m_s.KMSAPIsParams, principal *models.Principal) middleware.Responder { + return middleware.NotImplemented("operation k_m_s.KMSAPIs has not yet been implemented") + }), KmsKMSAssignPolicyHandler: k_m_s.KMSAssignPolicyHandlerFunc(func(params k_m_s.KMSAssignPolicyParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation k_m_s.KMSAssignPolicy has not yet been implemented") }), @@ -307,12 +310,18 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI { KmsKMSListPoliciesHandler: k_m_s.KMSListPoliciesHandlerFunc(func(params k_m_s.KMSListPoliciesParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation k_m_s.KMSListPolicies has not yet been implemented") }), + KmsKMSMetricsHandler: k_m_s.KMSMetricsHandlerFunc(func(params k_m_s.KMSMetricsParams, principal *models.Principal) middleware.Responder { + return middleware.NotImplemented("operation k_m_s.KMSMetrics has not yet been implemented") + }), KmsKMSSetPolicyHandler: k_m_s.KMSSetPolicyHandlerFunc(func(params k_m_s.KMSSetPolicyParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation k_m_s.KMSSetPolicy has not yet been implemented") }), KmsKMSStatusHandler: k_m_s.KMSStatusHandlerFunc(func(params k_m_s.KMSStatusParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation k_m_s.KMSStatus has not yet been implemented") }), + KmsKMSVersionHandler: k_m_s.KMSVersionHandlerFunc(func(params k_m_s.KMSVersionParams, principal *models.Principal) middleware.Responder { + return middleware.NotImplemented("operation k_m_s.KMSVersion has not yet been implemented") + }), UserListAUserServiceAccountsHandler: user.ListAUserServiceAccountsHandlerFunc(func(params user.ListAUserServiceAccountsParams, principal *models.Principal) middleware.Responder { return middleware.NotImplemented("operation user.ListAUserServiceAccounts has not yet been implemented") }), @@ -686,6 +695,8 @@ type ConsoleAPI struct { GroupGroupInfoHandler group.GroupInfoHandler // InspectInspectHandler sets the operation handler for the inspect operation InspectInspectHandler inspect.InspectHandler + // KmsKMSAPIsHandler sets the operation handler for the k m s a p is operation + KmsKMSAPIsHandler k_m_s.KMSAPIsHandler // KmsKMSAssignPolicyHandler sets the operation handler for the k m s assign policy operation KmsKMSAssignPolicyHandler k_m_s.KMSAssignPolicyHandler // KmsKMSCreateKeyHandler sets the operation handler for the k m s create key operation @@ -714,10 +725,14 @@ type ConsoleAPI struct { KmsKMSListKeysHandler k_m_s.KMSListKeysHandler // KmsKMSListPoliciesHandler sets the operation handler for the k m s list policies operation KmsKMSListPoliciesHandler k_m_s.KMSListPoliciesHandler + // KmsKMSMetricsHandler sets the operation handler for the k m s metrics operation + KmsKMSMetricsHandler k_m_s.KMSMetricsHandler // KmsKMSSetPolicyHandler sets the operation handler for the k m s set policy operation KmsKMSSetPolicyHandler k_m_s.KMSSetPolicyHandler // KmsKMSStatusHandler sets the operation handler for the k m s status operation KmsKMSStatusHandler k_m_s.KMSStatusHandler + // KmsKMSVersionHandler sets the operation handler for the k m s version operation + KmsKMSVersionHandler k_m_s.KMSVersionHandler // UserListAUserServiceAccountsHandler sets the operation handler for the list a user service accounts operation UserListAUserServiceAccountsHandler user.ListAUserServiceAccountsHandler // BucketListAccessRulesWithBucketHandler sets the operation handler for the list access rules with bucket operation @@ -1118,6 +1133,9 @@ func (o *ConsoleAPI) Validate() error { if o.InspectInspectHandler == nil { unregistered = append(unregistered, "inspect.InspectHandler") } + if o.KmsKMSAPIsHandler == nil { + unregistered = append(unregistered, "k_m_s.KMSAPIsHandler") + } if o.KmsKMSAssignPolicyHandler == nil { unregistered = append(unregistered, "k_m_s.KMSAssignPolicyHandler") } @@ -1160,12 +1178,18 @@ func (o *ConsoleAPI) Validate() error { if o.KmsKMSListPoliciesHandler == nil { unregistered = append(unregistered, "k_m_s.KMSListPoliciesHandler") } + if o.KmsKMSMetricsHandler == nil { + unregistered = append(unregistered, "k_m_s.KMSMetricsHandler") + } if o.KmsKMSSetPolicyHandler == nil { unregistered = append(unregistered, "k_m_s.KMSSetPolicyHandler") } if o.KmsKMSStatusHandler == nil { unregistered = append(unregistered, "k_m_s.KMSStatusHandler") } + if o.KmsKMSVersionHandler == nil { + unregistered = append(unregistered, "k_m_s.KMSVersionHandler") + } if o.UserListAUserServiceAccountsHandler == nil { unregistered = append(unregistered, "user.ListAUserServiceAccountsHandler") } @@ -1705,6 +1729,10 @@ func (o *ConsoleAPI) initHandlerCache() { o.handlers["GET"] = make(map[string]http.Handler) } o.handlers["GET"]["/admin/inspect"] = inspect.NewInspect(o.context, o.InspectInspectHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/kms/apis"] = k_m_s.NewKMSAPIs(o.context, o.KmsKMSAPIsHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } @@ -1761,6 +1789,10 @@ func (o *ConsoleAPI) initHandlerCache() { o.handlers["GET"] = make(map[string]http.Handler) } o.handlers["GET"]["/kms/policies"] = k_m_s.NewKMSListPolicies(o.context, o.KmsKMSListPoliciesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/kms/metrics"] = k_m_s.NewKMSMetrics(o.context, o.KmsKMSMetricsHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } @@ -1772,6 +1804,10 @@ func (o *ConsoleAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } + o.handlers["GET"]["/kms/version"] = k_m_s.NewKMSVersion(o.context, o.KmsKMSVersionHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } o.handlers["GET"]["/user/{name}/service-accounts"] = user.NewListAUserServiceAccounts(o.context, o.UserListAUserServiceAccountsHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) diff --git a/restapi/operations/k_m_s/k_m_s_a_p_is.go b/restapi/operations/k_m_s/k_m_s_a_p_is.go new file mode 100644 index 000000000..fa32803de --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_a_p_is.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// KMSAPIsHandlerFunc turns a function with the right signature into a k m s a p is handler +type KMSAPIsHandlerFunc func(KMSAPIsParams, *models.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn KMSAPIsHandlerFunc) Handle(params KMSAPIsParams, principal *models.Principal) middleware.Responder { + return fn(params, principal) +} + +// KMSAPIsHandler interface for that can handle valid k m s a p is params +type KMSAPIsHandler interface { + Handle(KMSAPIsParams, *models.Principal) middleware.Responder +} + +// NewKMSAPIs creates a new http.Handler for the k m s a p is operation +func NewKMSAPIs(ctx *middleware.Context, handler KMSAPIsHandler) *KMSAPIs { + return &KMSAPIs{Context: ctx, Handler: handler} +} + +/* + KMSAPIs swagger:route GET /kms/apis KMS kMSAPIs + +KMS apis +*/ +type KMSAPIs struct { + Context *middleware.Context + Handler KMSAPIsHandler +} + +func (o *KMSAPIs) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewKMSAPIsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal *models.Principal + if uprinc != nil { + principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/restapi/operations/k_m_s/k_m_s_a_p_is_parameters.go b/restapi/operations/k_m_s/k_m_s_a_p_is_parameters.go new file mode 100644 index 000000000..1d9f378f9 --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_a_p_is_parameters.go @@ -0,0 +1,63 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// NewKMSAPIsParams creates a new KMSAPIsParams object +// +// There are no default values defined in the spec. +func NewKMSAPIsParams() KMSAPIsParams { + + return KMSAPIsParams{} +} + +// KMSAPIsParams contains all the bound params for the k m s a p is operation +// typically these are obtained from a http.Request +// +// swagger:parameters KMSAPIs +type KMSAPIsParams 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 NewKMSAPIsParams() beforehand. +func (o *KMSAPIsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/restapi/operations/k_m_s/k_m_s_a_p_is_responses.go b/restapi/operations/k_m_s/k_m_s_a_p_is_responses.go new file mode 100644 index 000000000..af8b34d1f --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_a_p_is_responses.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// KMSAPIsOKCode is the HTTP code returned for type KMSAPIsOK +const KMSAPIsOKCode int = 200 + +/* +KMSAPIsOK A successful response. + +swagger:response kMSAPIsOK +*/ +type KMSAPIsOK struct { + + /* + In: Body + */ + Payload *models.KmsAPIsResponse `json:"body,omitempty"` +} + +// NewKMSAPIsOK creates KMSAPIsOK with default headers values +func NewKMSAPIsOK() *KMSAPIsOK { + + return &KMSAPIsOK{} +} + +// WithPayload adds the payload to the k m s a p is o k response +func (o *KMSAPIsOK) WithPayload(payload *models.KmsAPIsResponse) *KMSAPIsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the k m s a p is o k response +func (o *KMSAPIsOK) SetPayload(payload *models.KmsAPIsResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *KMSAPIsOK) 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 + } + } +} + +/* +KMSAPIsDefault Generic error response. + +swagger:response kMSAPIsDefault +*/ +type KMSAPIsDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewKMSAPIsDefault creates KMSAPIsDefault with default headers values +func NewKMSAPIsDefault(code int) *KMSAPIsDefault { + if code <= 0 { + code = 500 + } + + return &KMSAPIsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the k m s a p is default response +func (o *KMSAPIsDefault) WithStatusCode(code int) *KMSAPIsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the k m s a p is default response +func (o *KMSAPIsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the k m s a p is default response +func (o *KMSAPIsDefault) WithPayload(payload *models.Error) *KMSAPIsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the k m s a p is default response +func (o *KMSAPIsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *KMSAPIsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/restapi/operations/k_m_s/k_m_s_a_p_is_urlbuilder.go b/restapi/operations/k_m_s/k_m_s_a_p_is_urlbuilder.go new file mode 100644 index 000000000..38cd7dbab --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_a_p_is_urlbuilder.go @@ -0,0 +1,104 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// KMSAPIsURL generates an URL for the k m s a p is operation +type KMSAPIsURL 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 *KMSAPIsURL) WithBasePath(bp string) *KMSAPIsURL { + 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 *KMSAPIsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *KMSAPIsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/kms/apis" + + _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 *KMSAPIsURL) 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 *KMSAPIsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *KMSAPIsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on KMSAPIsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on KMSAPIsURL") + } + + 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 *KMSAPIsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/restapi/operations/k_m_s/k_m_s_metrics.go b/restapi/operations/k_m_s/k_m_s_metrics.go new file mode 100644 index 000000000..f4e951fb6 --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_metrics.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// KMSMetricsHandlerFunc turns a function with the right signature into a k m s metrics handler +type KMSMetricsHandlerFunc func(KMSMetricsParams, *models.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn KMSMetricsHandlerFunc) Handle(params KMSMetricsParams, principal *models.Principal) middleware.Responder { + return fn(params, principal) +} + +// KMSMetricsHandler interface for that can handle valid k m s metrics params +type KMSMetricsHandler interface { + Handle(KMSMetricsParams, *models.Principal) middleware.Responder +} + +// NewKMSMetrics creates a new http.Handler for the k m s metrics operation +func NewKMSMetrics(ctx *middleware.Context, handler KMSMetricsHandler) *KMSMetrics { + return &KMSMetrics{Context: ctx, Handler: handler} +} + +/* + KMSMetrics swagger:route GET /kms/metrics KMS kMSMetrics + +KMS metrics +*/ +type KMSMetrics struct { + Context *middleware.Context + Handler KMSMetricsHandler +} + +func (o *KMSMetrics) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewKMSMetricsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal *models.Principal + if uprinc != nil { + principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/restapi/operations/k_m_s/k_m_s_metrics_parameters.go b/restapi/operations/k_m_s/k_m_s_metrics_parameters.go new file mode 100644 index 000000000..2f8eddde3 --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_metrics_parameters.go @@ -0,0 +1,63 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// NewKMSMetricsParams creates a new KMSMetricsParams object +// +// There are no default values defined in the spec. +func NewKMSMetricsParams() KMSMetricsParams { + + return KMSMetricsParams{} +} + +// KMSMetricsParams contains all the bound params for the k m s metrics operation +// typically these are obtained from a http.Request +// +// swagger:parameters KMSMetrics +type KMSMetricsParams 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 NewKMSMetricsParams() beforehand. +func (o *KMSMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/restapi/operations/k_m_s/k_m_s_metrics_responses.go b/restapi/operations/k_m_s/k_m_s_metrics_responses.go new file mode 100644 index 000000000..d8e13858d --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_metrics_responses.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// KMSMetricsOKCode is the HTTP code returned for type KMSMetricsOK +const KMSMetricsOKCode int = 200 + +/* +KMSMetricsOK A successful response. + +swagger:response kMSMetricsOK +*/ +type KMSMetricsOK struct { + + /* + In: Body + */ + Payload *models.KmsMetricsResponse `json:"body,omitempty"` +} + +// NewKMSMetricsOK creates KMSMetricsOK with default headers values +func NewKMSMetricsOK() *KMSMetricsOK { + + return &KMSMetricsOK{} +} + +// WithPayload adds the payload to the k m s metrics o k response +func (o *KMSMetricsOK) WithPayload(payload *models.KmsMetricsResponse) *KMSMetricsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the k m s metrics o k response +func (o *KMSMetricsOK) SetPayload(payload *models.KmsMetricsResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *KMSMetricsOK) 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 + } + } +} + +/* +KMSMetricsDefault Generic error response. + +swagger:response kMSMetricsDefault +*/ +type KMSMetricsDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewKMSMetricsDefault creates KMSMetricsDefault with default headers values +func NewKMSMetricsDefault(code int) *KMSMetricsDefault { + if code <= 0 { + code = 500 + } + + return &KMSMetricsDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the k m s metrics default response +func (o *KMSMetricsDefault) WithStatusCode(code int) *KMSMetricsDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the k m s metrics default response +func (o *KMSMetricsDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the k m s metrics default response +func (o *KMSMetricsDefault) WithPayload(payload *models.Error) *KMSMetricsDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the k m s metrics default response +func (o *KMSMetricsDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *KMSMetricsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/restapi/operations/k_m_s/k_m_s_metrics_urlbuilder.go b/restapi/operations/k_m_s/k_m_s_metrics_urlbuilder.go new file mode 100644 index 000000000..94d5167dd --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_metrics_urlbuilder.go @@ -0,0 +1,104 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// KMSMetricsURL generates an URL for the k m s metrics operation +type KMSMetricsURL 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 *KMSMetricsURL) WithBasePath(bp string) *KMSMetricsURL { + 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 *KMSMetricsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *KMSMetricsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/kms/metrics" + + _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 *KMSMetricsURL) 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 *KMSMetricsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *KMSMetricsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on KMSMetricsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on KMSMetricsURL") + } + + 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 *KMSMetricsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/restapi/operations/k_m_s/k_m_s_version.go b/restapi/operations/k_m_s/k_m_s_version.go new file mode 100644 index 000000000..110255fd0 --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_version.go @@ -0,0 +1,88 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// KMSVersionHandlerFunc turns a function with the right signature into a k m s version handler +type KMSVersionHandlerFunc func(KMSVersionParams, *models.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn KMSVersionHandlerFunc) Handle(params KMSVersionParams, principal *models.Principal) middleware.Responder { + return fn(params, principal) +} + +// KMSVersionHandler interface for that can handle valid k m s version params +type KMSVersionHandler interface { + Handle(KMSVersionParams, *models.Principal) middleware.Responder +} + +// NewKMSVersion creates a new http.Handler for the k m s version operation +func NewKMSVersion(ctx *middleware.Context, handler KMSVersionHandler) *KMSVersion { + return &KMSVersion{Context: ctx, Handler: handler} +} + +/* + KMSVersion swagger:route GET /kms/version KMS kMSVersion + +KMS version +*/ +type KMSVersion struct { + Context *middleware.Context + Handler KMSVersionHandler +} + +func (o *KMSVersion) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewKMSVersionParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal *models.Principal + if uprinc != nil { + principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise + } + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/restapi/operations/k_m_s/k_m_s_version_parameters.go b/restapi/operations/k_m_s/k_m_s_version_parameters.go new file mode 100644 index 000000000..a20989b37 --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_version_parameters.go @@ -0,0 +1,63 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// NewKMSVersionParams creates a new KMSVersionParams object +// +// There are no default values defined in the spec. +func NewKMSVersionParams() KMSVersionParams { + + return KMSVersionParams{} +} + +// KMSVersionParams contains all the bound params for the k m s version operation +// typically these are obtained from a http.Request +// +// swagger:parameters KMSVersion +type KMSVersionParams 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 NewKMSVersionParams() beforehand. +func (o *KMSVersionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/restapi/operations/k_m_s/k_m_s_version_responses.go b/restapi/operations/k_m_s/k_m_s_version_responses.go new file mode 100644 index 000000000..e48ce3f7c --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_version_responses.go @@ -0,0 +1,135 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// KMSVersionOKCode is the HTTP code returned for type KMSVersionOK +const KMSVersionOKCode int = 200 + +/* +KMSVersionOK A successful response. + +swagger:response kMSVersionOK +*/ +type KMSVersionOK struct { + + /* + In: Body + */ + Payload *models.KmsVersionResponse `json:"body,omitempty"` +} + +// NewKMSVersionOK creates KMSVersionOK with default headers values +func NewKMSVersionOK() *KMSVersionOK { + + return &KMSVersionOK{} +} + +// WithPayload adds the payload to the k m s version o k response +func (o *KMSVersionOK) WithPayload(payload *models.KmsVersionResponse) *KMSVersionOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the k m s version o k response +func (o *KMSVersionOK) SetPayload(payload *models.KmsVersionResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *KMSVersionOK) 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 + } + } +} + +/* +KMSVersionDefault Generic error response. + +swagger:response kMSVersionDefault +*/ +type KMSVersionDefault struct { + _statusCode int + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewKMSVersionDefault creates KMSVersionDefault with default headers values +func NewKMSVersionDefault(code int) *KMSVersionDefault { + if code <= 0 { + code = 500 + } + + return &KMSVersionDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the k m s version default response +func (o *KMSVersionDefault) WithStatusCode(code int) *KMSVersionDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the k m s version default response +func (o *KMSVersionDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the k m s version default response +func (o *KMSVersionDefault) WithPayload(payload *models.Error) *KMSVersionDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the k m s version default response +func (o *KMSVersionDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *KMSVersionDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/restapi/operations/k_m_s/k_m_s_version_urlbuilder.go b/restapi/operations/k_m_s/k_m_s_version_urlbuilder.go new file mode 100644 index 000000000..1b1133431 --- /dev/null +++ b/restapi/operations/k_m_s/k_m_s_version_urlbuilder.go @@ -0,0 +1,104 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// This file is part of MinIO Console Server +// Copyright (c) 2022 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// + +package k_m_s + +// 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" +) + +// KMSVersionURL generates an URL for the k m s version operation +type KMSVersionURL 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 *KMSVersionURL) WithBasePath(bp string) *KMSVersionURL { + 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 *KMSVersionURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *KMSVersionURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/kms/version" + + _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 *KMSVersionURL) 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 *KMSVersionURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *KMSVersionURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on KMSVersionURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on KMSVersionURL") + } + + 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 *KMSVersionURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/swagger-console.yml b/swagger-console.yml index fce86be2e..e20599754 100644 --- a/swagger-console.yml +++ b/swagger-console.yml @@ -2884,6 +2884,51 @@ paths: $ref: "#/definitions/error" tags: - KMS + /kms/metrics: + get: + summary: KMS metrics + operationId: KMSMetrics + responses: + 200: + description: A successful response. + schema: + $ref: "#/definitions/kmsMetricsResponse" + default: + description: Generic error response. + schema: + $ref: "#/definitions/error" + tags: + - KMS + /kms/apis: + get: + summary: KMS apis + operationId: KMSAPIs + responses: + 200: + description: A successful response. + schema: + $ref: "#/definitions/kmsAPIsResponse" + default: + description: Generic error response. + schema: + $ref: "#/definitions/error" + tags: + - KMS + /kms/version: + get: + summary: KMS version + operationId: KMSVersion + responses: + 200: + description: A successful response. + schema: + $ref: "#/definitions/kmsVersionResponse" + default: + description: Generic error response. + schema: + $ref: "#/definitions/error" + tags: + - KMS /kms/keys: post: summary: KMS create key @@ -5439,6 +5484,79 @@ definitions: type: string createdBy: type: string + kmsMetricsResponse: + type: object + required: + - requestOK + - requestErr + - requestFail + - requestActive + - auditEvents + - errorEvents + - latencyHistogram + - uptime + - cpus + - usableCPUs + - threads + - heapAlloc + - stackAlloc + properties: + requestOK: + type: integer + requestErr: + type: integer + requestFail: + type: integer + requestActive: + type: integer + auditEvents: + type: integer + errorEvents: + type: integer + latencyHistogram: + $ref: "#/definitions/kmsLatencyHistogram" + uptime: + type: integer + cpus: + type: integer + usableCPUs: + type: integer + threads: + type: integer + heapAlloc: + type: integer + heapObjects: + type: integer + stackAlloc: + type: integer + kmsLatencyHistogram: + type: object + properties: + duration: + type: integer + kmsAPIsResponse: + type: object + properties: + results: + type: array + items: + $ref: "#/definitions/kmsAPI" + kmsAPI: + type: object + properties: + method: + type: string + path: + type: string + maxBody: + type: integer + timeout: + type: integer + kmsVersionResponse: + type: object + properties: + version: + type: string environmentConstants: type: object