From 41228a3d63dff4c263e85a846d7c45bddcdace01 Mon Sep 17 00:00:00 2001 From: mikameyer Date: Mon, 17 May 2021 17:42:24 +0200 Subject: [PATCH 1/2] fixed swagger doc --- api/request_handler.go | 10 +- core/request/check_identify_request.go | 4 + core/request/check_snmp_request.go | 4 + doc/api_doc.json | 177 ++++++++++++++++++++++++- 4 files changed, 187 insertions(+), 8 deletions(-) diff --git a/api/request_handler.go b/api/request_handler.go index 8a5cabe..b3c2493 100644 --- a/api/request_handler.go +++ b/api/request_handler.go @@ -116,7 +116,7 @@ func StartAPI() { // 200: // description: Returns the response. // schema: - // $ref: '#/definitions/CheckResponse' + // $ref: '#/definitions/CheckIdentifyResponse' // 400: // description: Returns an error with more details in the body. // schema: @@ -143,7 +143,7 @@ func StartAPI() { // 200: // description: Returns the response. // schema: - // $ref: '#/definitions/CheckResponse' + // $ref: '#/definitions/CheckSNMPResponse' // 400: // description: Returns an error with more details in the body. // schema: @@ -258,7 +258,7 @@ func StartAPI() { // $ref: '#/definitions/OutputError' e.POST("/check/memory-usage", checkMemoryUsage) - // swagger:operation POST /check/cpu-load check checkCpuLoad + // swagger:operation POST /check/cpu-load check checkCPULoad // --- // summary: Check the cpu load of a device. // consumes: @@ -283,7 +283,7 @@ func StartAPI() { // description: Returns an error with more details in the body. // schema: // $ref: '#/definitions/OutputError' - e.POST("/check/cpu-load", checkCpuLoad) + e.POST("/check/cpu-load", checkCPULoad) // swagger:operation POST /check/sbc check checkSBC // --- @@ -783,7 +783,7 @@ func checkMemoryUsage(ctx echo.Context) error { return returnInFormat(ctx, http.StatusOK, resp) } -func checkCpuLoad(ctx echo.Context) error { +func checkCPULoad(ctx echo.Context) error { r := request.CheckCPULoadRequest{} if err := ctx.Bind(&r); err != nil { return err diff --git a/core/request/check_identify_request.go b/core/request/check_identify_request.go index cb13261..04a598c 100644 --- a/core/request/check_identify_request.go +++ b/core/request/check_identify_request.go @@ -21,7 +21,11 @@ type CheckIdentifyRequest struct { SerialNumberDiffWarning bool `yaml:"serial_number_diff_warning" json:"serial_number_diff_warning" xml:"serial_number_diff_warning"` } +// CheckIdentifyResponse +// // CheckIdentifyResponse is a response struct for the check identify request. +// +// swagger:model type CheckIdentifyResponse struct { CheckResponse IdentifyResult *device.Device `yaml:"identify_result" json:"identify_result" xml:"identify_result"` diff --git a/core/request/check_snmp_request.go b/core/request/check_snmp_request.go index ed1a93a..b7c7a0d 100644 --- a/core/request/check_snmp_request.go +++ b/core/request/check_snmp_request.go @@ -20,7 +20,11 @@ func (r *CheckSNMPRequest) setupConnection(_ context.Context) (*network.RequestD return &network.RequestDeviceConnection{}, nil } +// CheckSNMPResponse +// // CheckSNMPResponse is a response struct for the check snmp request. +// +// swagger:model type CheckSNMPResponse struct { CheckResponse SuccessfulSnmpCredentials *network.SNMPCredentials `yaml:"successful_snmp_credentials" json:"successful_snmp_credentials" xml:"successful_snmp_credentials"` diff --git a/doc/api_doc.json b/doc/api_doc.json index c9e3c19..880b3d6 100644 --- a/doc/api_doc.json +++ b/doc/api_doc.json @@ -37,7 +37,7 @@ "check" ], "summary": "Check the cpu load of a device.", - "operationId": "checkCpuLoad", + "operationId": "checkCPULoad", "parameters": [ { "description": "Request to process.", @@ -179,7 +179,7 @@ "200": { "description": "Returns the response.", "schema": { - "$ref": "#/definitions/CheckResponse" + "$ref": "#/definitions/CheckIdentifyResponse" } }, "400": { @@ -389,7 +389,7 @@ "200": { "description": "Returns the response.", "schema": { - "$ref": "#/definitions/CheckResponse" + "$ref": "#/definitions/CheckSNMPResponse" } }, "400": { @@ -1153,6 +1153,47 @@ }, "x-go-package": "github.com/inexio/thola/core/request" }, + "CheckIdentifyResponse": { + "description": "CheckIdentifyResponse is a response struct for the check identify request.", + "type": "object", + "title": "CheckIdentifyResponse", + "properties": { + "failed_expectations": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/IdentifyExpectationResult" + }, + "x-go-name": "FailedExpectations" + }, + "identify_result": { + "$ref": "#/definitions/Device" + }, + "messages": { + "type": "array", + "items": { + "$ref": "#/definitions/OutputMessage" + }, + "x-go-name": "Messages" + }, + "performance_data": { + "type": "array", + "items": { + "$ref": "#/definitions/PerformanceDataPoint" + }, + "x-go-name": "PerformanceData" + }, + "raw_output": { + "type": "string", + "x-go-name": "RawOutput" + }, + "status_code": { + "type": "integer", + "format": "int64", + "x-go-name": "StatusCode" + } + }, + "x-go-package": "github.com/inexio/thola/core/request" + }, "CheckInterfaceMetricsRequest": { "description": "CheckInterfaceRequest is a the request struct for the check interface metrics request.", "type": "object", @@ -1324,6 +1365,40 @@ }, "x-go-package": "github.com/inexio/thola/core/request" }, + "CheckSNMPResponse": { + "description": "CheckSNMPResponse is a response struct for the check snmp request.", + "type": "object", + "title": "CheckSNMPResponse", + "properties": { + "messages": { + "type": "array", + "items": { + "$ref": "#/definitions/OutputMessage" + }, + "x-go-name": "Messages" + }, + "performance_data": { + "type": "array", + "items": { + "$ref": "#/definitions/PerformanceDataPoint" + }, + "x-go-name": "PerformanceData" + }, + "raw_output": { + "type": "string", + "x-go-name": "RawOutput" + }, + "status_code": { + "type": "integer", + "format": "int64", + "x-go-name": "StatusCode" + }, + "successful_snmp_credentials": { + "$ref": "#/definitions/SNMPCredentials" + } + }, + "x-go-package": "github.com/inexio/thola/core/request" + }, "CheckServerRequest": { "description": "CheckServerRequest is a the request struct for the check server request.", "type": "object", @@ -1727,6 +1802,21 @@ }, "x-go-package": "github.com/inexio/thola/core/device" }, + "IdentifyExpectationResult": { + "type": "object", + "title": "IdentifyExpectationResult is a response struct for the check identify request.", + "properties": { + "expected": { + "type": "string", + "x-go-name": "Expected" + }, + "got": { + "type": "string", + "x-go-name": "Got" + } + }, + "x-go-package": "github.com/inexio/thola/core/request" + }, "IdentifyRequest": { "description": "IdentifyRequest is a the request struct for the identify request.", "type": "object", @@ -2806,6 +2896,9 @@ 161 ] }, + "v3_data": { + "$ref": "#/definitions/SNMPv3ConnectionData" + }, "versions": { "description": "The snmp version(s) of the device.", "type": "array", @@ -2820,6 +2913,84 @@ }, "x-go-package": "github.com/inexio/thola/core/network" }, + "SNMPCredentials": { + "type": "object", + "title": "SNMPCredentials includes all credential information of the snmp connection.", + "properties": { + "community": { + "type": "string", + "x-go-name": "Community" + }, + "port": { + "type": "integer", + "format": "int64", + "x-go-name": "Port" + }, + "v3ContextName": { + "type": "string", + "x-go-name": "V3ContextName" + }, + "v3Level": { + "type": "string", + "x-go-name": "V3Level" + }, + "version": { + "type": "string", + "x-go-name": "Version" + } + }, + "x-go-package": "github.com/inexio/thola/core/network" + }, + "SNMPv3ConnectionData": { + "description": "SNMPv3ConnectionData includes all snmp v3 specific connection data.", + "type": "object", + "title": "SNMPv3ConnectionData", + "properties": { + "auth_key": { + "description": "The authentication protocol passphrase of the SNMP connection.", + "type": "string", + "x-go-name": "AuthKey", + "example": "passphrase" + }, + "auth_protocol": { + "description": "The authentication protocol of the SNMP connection.", + "type": "string", + "x-go-name": "AuthProtocol", + "example": "MD5" + }, + "context_name": { + "description": "The context name of the SNMP connection.", + "type": "string", + "x-go-name": "ContextName", + "example": "bridge1" + }, + "level": { + "description": "The security level of the SNMP connection.", + "type": "string", + "x-go-name": "Level", + "example": "authPriv" + }, + "priv_key": { + "description": "The privacy protocol passphrase of the SNMP connection.", + "type": "string", + "x-go-name": "PrivKey", + "example": "passphrase" + }, + "priv_protocol": { + "description": "The privacy protocol of the SNMP connection.", + "type": "string", + "x-go-name": "PrivProtocol", + "example": "DES" + }, + "user": { + "description": "The user of the SNMP connection.", + "type": "string", + "x-go-name": "User", + "example": "user" + } + }, + "x-go-package": "github.com/inexio/thola/core/network" + }, "ServerComponent": { "description": "ServerComponent represents a server component.", "type": "object", From 4b9c7570ce5a7e2fdb84401da5891a8fa55c6473 Mon Sep 17 00:00:00 2001 From: mikameyer Date: Wed, 26 May 2021 10:25:42 +0200 Subject: [PATCH 2/2] bump version --- doc/doc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/doc.go b/doc/doc.go index 9bebe9b..2269d5a 100644 --- a/doc/doc.go +++ b/doc/doc.go @@ -27,4 +27,4 @@ // swagger:meta package doc -const Version = "v0.2.3" +const Version = "v0.2.4"