From 910c07f810ce3b19325bcb2baffe4871aef873eb Mon Sep 17 00:00:00 2001 From: ii2day Date: Wed, 14 Jun 2023 18:48:56 +0800 Subject: [PATCH] add app mode testing server Signed-off-by: ii2day --- .../echo/delete_kdoctoragent_parameters.go | 131 ++++ .../echo/delete_kdoctoragent_responses.go | 153 ++++ .../client/echo/delete_parameters.go | 131 ++++ .../client/echo/delete_responses.go | 153 ++++ api/v1/agentServer/client/echo/echo_client.go | 504 +++++++++++++ .../echo/get_kdoctoragent_parameters.go | 36 + .../agentServer/client/echo/get_parameters.go | 36 + .../echo/head_kdoctoragent_parameters.go | 167 +++++ .../echo/head_kdoctoragent_responses.go | 106 +++ .../client/echo/head_parameters.go | 167 +++++ .../agentServer/client/echo/head_responses.go | 106 +++ .../echo/options_kdoctoragent_parameters.go | 167 +++++ .../echo/options_kdoctoragent_responses.go | 106 +++ .../client/echo/options_parameters.go | 167 +++++ .../client/echo/options_responses.go | 106 +++ .../echo/patch_kdoctoragent_parameters.go | 167 +++++ .../echo/patch_kdoctoragent_responses.go | 106 +++ .../client/echo/patch_parameters.go | 167 +++++ .../client/echo/patch_responses.go | 106 +++ .../echo/post_kdoctoragent_parameters.go | 188 +++++ .../echo/post_kdoctoragent_responses.go | 168 +++++ .../client/echo/post_parameters.go | 188 +++++ .../agentServer/client/echo/post_responses.go | 168 +++++ .../echo/put_kdoctoragent_parameters.go | 167 +++++ .../client/echo/put_kdoctoragent_responses.go | 106 +++ .../agentServer/client/echo/put_parameters.go | 167 +++++ .../agentServer/client/echo/put_responses.go | 106 +++ api/v1/agentServer/models/echo_body.go | 56 ++ api/v1/agentServer/models/echo_res.go | 19 +- api/v1/agentServer/openapi.yaml | 228 +++++- .../server/configure_http_server_api.go | 60 ++ api/v1/agentServer/server/embedded_spec.go | 674 +++++++++++++++++- .../agentServer/server/restapi/echo/delete.go | 61 ++ .../restapi/echo/delete_kdoctoragent.go | 61 ++ .../echo/delete_kdoctoragent_parameters.go | 49 ++ .../echo/delete_kdoctoragent_responses.go | 65 ++ .../echo/delete_kdoctoragent_urlbuilder.go | 90 +++ .../server/restapi/echo/delete_parameters.go | 49 ++ .../server/restapi/echo/delete_responses.go | 65 ++ .../server/restapi/echo/delete_urlbuilder.go | 90 +++ .../echo/get_kdoctoragent_parameters.go | 37 + .../echo/get_kdoctoragent_urlbuilder.go | 18 + .../server/restapi/echo/get_parameters.go | 37 + .../server/restapi/echo/get_urlbuilder.go | 18 + .../agentServer/server/restapi/echo/head.go | 61 ++ .../server/restapi/echo/head_kdoctoragent.go | 61 ++ .../echo/head_kdoctoragent_parameters.go | 86 +++ .../echo/head_kdoctoragent_responses.go | 62 ++ .../echo/head_kdoctoragent_urlbuilder.go | 108 +++ .../server/restapi/echo/head_parameters.go | 86 +++ .../server/restapi/echo/head_responses.go | 62 ++ .../server/restapi/echo/head_urlbuilder.go | 108 +++ .../server/restapi/echo/options.go | 61 ++ .../restapi/echo/options_kdoctoragent.go | 61 ++ .../echo/options_kdoctoragent_parameters.go | 86 +++ .../echo/options_kdoctoragent_responses.go | 62 ++ .../echo/options_kdoctoragent_urlbuilder.go | 108 +++ .../server/restapi/echo/options_parameters.go | 86 +++ .../server/restapi/echo/options_responses.go | 62 ++ .../server/restapi/echo/options_urlbuilder.go | 108 +++ .../agentServer/server/restapi/echo/patch.go | 61 ++ .../server/restapi/echo/patch_kdoctoragent.go | 61 ++ .../echo/patch_kdoctoragent_parameters.go | 86 +++ .../echo/patch_kdoctoragent_responses.go | 62 ++ .../echo/patch_kdoctoragent_urlbuilder.go | 108 +++ .../server/restapi/echo/patch_parameters.go | 86 +++ .../server/restapi/echo/patch_responses.go | 62 ++ .../server/restapi/echo/patch_urlbuilder.go | 108 +++ .../agentServer/server/restapi/echo/post.go | 61 ++ .../server/restapi/echo/post_kdoctoragent.go | 61 ++ .../echo/post_kdoctoragent_parameters.go | 123 ++++ .../echo/post_kdoctoragent_responses.go | 87 +++ .../echo/post_kdoctoragent_urlbuilder.go | 108 +++ .../server/restapi/echo/post_parameters.go | 123 ++++ .../server/restapi/echo/post_responses.go | 87 +++ .../server/restapi/echo/post_urlbuilder.go | 108 +++ api/v1/agentServer/server/restapi/echo/put.go | 61 ++ .../server/restapi/echo/put_kdoctoragent.go | 61 ++ .../echo/put_kdoctoragent_parameters.go | 86 +++ .../echo/put_kdoctoragent_responses.go | 62 ++ .../echo/put_kdoctoragent_urlbuilder.go | 108 +++ .../server/restapi/echo/put_parameters.go | 86 +++ .../server/restapi/echo/put_responses.go | 62 ++ .../server/restapi/echo/put_urlbuilder.go | 108 +++ .../server/restapi/http_server_api_api.go | 144 ++++ charts/templates/daemonset.yaml | 37 +- charts/templates/ingress.yaml | 2 +- charts/templates/service.yaml | 12 +- charts/templates/tls.yaml | 30 +- charts/values.yaml | 22 +- cmd/agent/cmd/cert.go | 104 +++ cmd/agent/cmd/config.go | 3 + cmd/agent/cmd/daemon.go | 55 +- cmd/agent/cmd/grpcServer.go | 16 +- cmd/agent/cmd/httpServer.go | 150 ---- go.mod | 5 +- go.sum | 9 +- pkg/agentHttpServer/appHttpServer.go | 451 ++++++++++++ pkg/agentHttpServer/healthHttpServer.go | 83 +++ pkg/loadRequest/loadHttp/http.go | 4 +- pkg/loadRequest/loadHttp/http_requester.go | 6 +- .../apphttphealthy/agentExecuteTask.go | 15 +- pkg/pluginManager/netdns/agentExecuteTask.go | 2 +- .../netreach/agentExecuteTask.go | 8 +- pkg/types/agent_config.go | 19 +- pkg/utils/cert.go | 113 +-- test/Makefile | 5 +- test/yaml/testpod.yaml | 49 +- vendor/modules.txt | 6 + 109 files changed, 10081 insertions(+), 280 deletions(-) create mode 100644 api/v1/agentServer/client/echo/delete_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/client/echo/delete_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/client/echo/delete_parameters.go create mode 100644 api/v1/agentServer/client/echo/delete_responses.go create mode 100644 api/v1/agentServer/client/echo/head_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/client/echo/head_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/client/echo/head_parameters.go create mode 100644 api/v1/agentServer/client/echo/head_responses.go create mode 100644 api/v1/agentServer/client/echo/options_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/client/echo/options_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/client/echo/options_parameters.go create mode 100644 api/v1/agentServer/client/echo/options_responses.go create mode 100644 api/v1/agentServer/client/echo/patch_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/client/echo/patch_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/client/echo/patch_parameters.go create mode 100644 api/v1/agentServer/client/echo/patch_responses.go create mode 100644 api/v1/agentServer/client/echo/post_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/client/echo/post_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/client/echo/post_parameters.go create mode 100644 api/v1/agentServer/client/echo/post_responses.go create mode 100644 api/v1/agentServer/client/echo/put_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/client/echo/put_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/client/echo/put_parameters.go create mode 100644 api/v1/agentServer/client/echo/put_responses.go create mode 100644 api/v1/agentServer/models/echo_body.go create mode 100644 api/v1/agentServer/server/restapi/echo/delete.go create mode 100644 api/v1/agentServer/server/restapi/echo/delete_kdoctoragent.go create mode 100644 api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/delete_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/delete_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/delete_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/head.go create mode 100644 api/v1/agentServer/server/restapi/echo/head_kdoctoragent.go create mode 100644 api/v1/agentServer/server/restapi/echo/head_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/head_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/head_kdoctoragent_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/head_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/head_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/head_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/options.go create mode 100644 api/v1/agentServer/server/restapi/echo/options_kdoctoragent.go create mode 100644 api/v1/agentServer/server/restapi/echo/options_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/options_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/options_kdoctoragent_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/options_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/options_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/options_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/patch.go create mode 100644 api/v1/agentServer/server/restapi/echo/patch_kdoctoragent.go create mode 100644 api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/patch_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/patch_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/patch_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/post.go create mode 100644 api/v1/agentServer/server/restapi/echo/post_kdoctoragent.go create mode 100644 api/v1/agentServer/server/restapi/echo/post_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/post_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/post_kdoctoragent_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/post_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/post_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/post_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/put.go create mode 100644 api/v1/agentServer/server/restapi/echo/put_kdoctoragent.go create mode 100644 api/v1/agentServer/server/restapi/echo/put_kdoctoragent_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/put_kdoctoragent_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/put_kdoctoragent_urlbuilder.go create mode 100644 api/v1/agentServer/server/restapi/echo/put_parameters.go create mode 100644 api/v1/agentServer/server/restapi/echo/put_responses.go create mode 100644 api/v1/agentServer/server/restapi/echo/put_urlbuilder.go create mode 100644 cmd/agent/cmd/cert.go delete mode 100644 cmd/agent/cmd/httpServer.go create mode 100644 pkg/agentHttpServer/appHttpServer.go create mode 100644 pkg/agentHttpServer/healthHttpServer.go diff --git a/api/v1/agentServer/client/echo/delete_kdoctoragent_parameters.go b/api/v1/agentServer/client/echo/delete_kdoctoragent_parameters.go new file mode 100644 index 00000000..6c1dd287 --- /dev/null +++ b/api/v1/agentServer/client/echo/delete_kdoctoragent_parameters.go @@ -0,0 +1,131 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewDeleteKdoctoragentParams creates a new DeleteKdoctoragentParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewDeleteKdoctoragentParams() *DeleteKdoctoragentParams { + return &DeleteKdoctoragentParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDeleteKdoctoragentParamsWithTimeout creates a new DeleteKdoctoragentParams object +// with the ability to set a timeout on a request. +func NewDeleteKdoctoragentParamsWithTimeout(timeout time.Duration) *DeleteKdoctoragentParams { + return &DeleteKdoctoragentParams{ + timeout: timeout, + } +} + +// NewDeleteKdoctoragentParamsWithContext creates a new DeleteKdoctoragentParams object +// with the ability to set a context for a request. +func NewDeleteKdoctoragentParamsWithContext(ctx context.Context) *DeleteKdoctoragentParams { + return &DeleteKdoctoragentParams{ + Context: ctx, + } +} + +// NewDeleteKdoctoragentParamsWithHTTPClient creates a new DeleteKdoctoragentParams object +// with the ability to set a custom HTTPClient for a request. +func NewDeleteKdoctoragentParamsWithHTTPClient(client *http.Client) *DeleteKdoctoragentParams { + return &DeleteKdoctoragentParams{ + HTTPClient: client, + } +} + +/* +DeleteKdoctoragentParams contains all the parameters to send to the API endpoint + + for the delete kdoctoragent operation. + + Typically these are written to a http.Request. +*/ +type DeleteKdoctoragentParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the delete kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteKdoctoragentParams) WithDefaults() *DeleteKdoctoragentParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteKdoctoragentParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the delete kdoctoragent params +func (o *DeleteKdoctoragentParams) WithTimeout(timeout time.Duration) *DeleteKdoctoragentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete kdoctoragent params +func (o *DeleteKdoctoragentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete kdoctoragent params +func (o *DeleteKdoctoragentParams) WithContext(ctx context.Context) *DeleteKdoctoragentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete kdoctoragent params +func (o *DeleteKdoctoragentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete kdoctoragent params +func (o *DeleteKdoctoragentParams) WithHTTPClient(client *http.Client) *DeleteKdoctoragentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete kdoctoragent params +func (o *DeleteKdoctoragentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *DeleteKdoctoragentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/delete_kdoctoragent_responses.go b/api/v1/agentServer/client/echo/delete_kdoctoragent_responses.go new file mode 100644 index 00000000..b97f1dde --- /dev/null +++ b/api/v1/agentServer/client/echo/delete_kdoctoragent_responses.go @@ -0,0 +1,153 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// DeleteKdoctoragentReader is a Reader for the DeleteKdoctoragent structure. +type DeleteKdoctoragentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeleteKdoctoragentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewDeleteKdoctoragentOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewDeleteKdoctoragentInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewDeleteKdoctoragentOK creates a DeleteKdoctoragentOK with default headers values +func NewDeleteKdoctoragentOK() *DeleteKdoctoragentOK { + return &DeleteKdoctoragentOK{} +} + +/* +DeleteKdoctoragentOK describes a response with status code 200, with default header values. + +Success +*/ +type DeleteKdoctoragentOK struct { +} + +// IsSuccess returns true when this delete kdoctoragent o k response has a 2xx status code +func (o *DeleteKdoctoragentOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete kdoctoragent o k response has a 3xx status code +func (o *DeleteKdoctoragentOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete kdoctoragent o k response has a 4xx status code +func (o *DeleteKdoctoragentOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete kdoctoragent o k response has a 5xx status code +func (o *DeleteKdoctoragentOK) IsServerError() bool { + return false +} + +// IsCode returns true when this delete kdoctoragent o k response a status code equal to that given +func (o *DeleteKdoctoragentOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the delete kdoctoragent o k response +func (o *DeleteKdoctoragentOK) Code() int { + return 200 +} + +func (o *DeleteKdoctoragentOK) Error() string { + return fmt.Sprintf("[DELETE /kdoctoragent][%d] deleteKdoctoragentOK ", 200) +} + +func (o *DeleteKdoctoragentOK) String() string { + return fmt.Sprintf("[DELETE /kdoctoragent][%d] deleteKdoctoragentOK ", 200) +} + +func (o *DeleteKdoctoragentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewDeleteKdoctoragentInternalServerError creates a DeleteKdoctoragentInternalServerError with default headers values +func NewDeleteKdoctoragentInternalServerError() *DeleteKdoctoragentInternalServerError { + return &DeleteKdoctoragentInternalServerError{} +} + +/* +DeleteKdoctoragentInternalServerError describes a response with status code 500, with default header values. + +Failed +*/ +type DeleteKdoctoragentInternalServerError struct { +} + +// IsSuccess returns true when this delete kdoctoragent internal server error response has a 2xx status code +func (o *DeleteKdoctoragentInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete kdoctoragent internal server error response has a 3xx status code +func (o *DeleteKdoctoragentInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete kdoctoragent internal server error response has a 4xx status code +func (o *DeleteKdoctoragentInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete kdoctoragent internal server error response has a 5xx status code +func (o *DeleteKdoctoragentInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this delete kdoctoragent internal server error response a status code equal to that given +func (o *DeleteKdoctoragentInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the delete kdoctoragent internal server error response +func (o *DeleteKdoctoragentInternalServerError) Code() int { + return 500 +} + +func (o *DeleteKdoctoragentInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /kdoctoragent][%d] deleteKdoctoragentInternalServerError ", 500) +} + +func (o *DeleteKdoctoragentInternalServerError) String() string { + return fmt.Sprintf("[DELETE /kdoctoragent][%d] deleteKdoctoragentInternalServerError ", 500) +} + +func (o *DeleteKdoctoragentInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/api/v1/agentServer/client/echo/delete_parameters.go b/api/v1/agentServer/client/echo/delete_parameters.go new file mode 100644 index 00000000..01d90d0f --- /dev/null +++ b/api/v1/agentServer/client/echo/delete_parameters.go @@ -0,0 +1,131 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewDeleteParams creates a new DeleteParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewDeleteParams() *DeleteParams { + return &DeleteParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDeleteParamsWithTimeout creates a new DeleteParams object +// with the ability to set a timeout on a request. +func NewDeleteParamsWithTimeout(timeout time.Duration) *DeleteParams { + return &DeleteParams{ + timeout: timeout, + } +} + +// NewDeleteParamsWithContext creates a new DeleteParams object +// with the ability to set a context for a request. +func NewDeleteParamsWithContext(ctx context.Context) *DeleteParams { + return &DeleteParams{ + Context: ctx, + } +} + +// NewDeleteParamsWithHTTPClient creates a new DeleteParams object +// with the ability to set a custom HTTPClient for a request. +func NewDeleteParamsWithHTTPClient(client *http.Client) *DeleteParams { + return &DeleteParams{ + HTTPClient: client, + } +} + +/* +DeleteParams contains all the parameters to send to the API endpoint + + for the delete operation. + + Typically these are written to a http.Request. +*/ +type DeleteParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteParams) WithDefaults() *DeleteParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the delete params +func (o *DeleteParams) WithTimeout(timeout time.Duration) *DeleteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete params +func (o *DeleteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete params +func (o *DeleteParams) WithContext(ctx context.Context) *DeleteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete params +func (o *DeleteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete params +func (o *DeleteParams) WithHTTPClient(client *http.Client) *DeleteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete params +func (o *DeleteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *DeleteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/delete_responses.go b/api/v1/agentServer/client/echo/delete_responses.go new file mode 100644 index 00000000..5aee4a09 --- /dev/null +++ b/api/v1/agentServer/client/echo/delete_responses.go @@ -0,0 +1,153 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// DeleteReader is a Reader for the Delete structure. +type DeleteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeleteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewDeleteOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewDeleteInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewDeleteOK creates a DeleteOK with default headers values +func NewDeleteOK() *DeleteOK { + return &DeleteOK{} +} + +/* +DeleteOK describes a response with status code 200, with default header values. + +Success +*/ +type DeleteOK struct { +} + +// IsSuccess returns true when this delete o k response has a 2xx status code +func (o *DeleteOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete o k response has a 3xx status code +func (o *DeleteOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete o k response has a 4xx status code +func (o *DeleteOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete o k response has a 5xx status code +func (o *DeleteOK) IsServerError() bool { + return false +} + +// IsCode returns true when this delete o k response a status code equal to that given +func (o *DeleteOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the delete o k response +func (o *DeleteOK) Code() int { + return 200 +} + +func (o *DeleteOK) Error() string { + return fmt.Sprintf("[DELETE /][%d] deleteOK ", 200) +} + +func (o *DeleteOK) String() string { + return fmt.Sprintf("[DELETE /][%d] deleteOK ", 200) +} + +func (o *DeleteOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewDeleteInternalServerError creates a DeleteInternalServerError with default headers values +func NewDeleteInternalServerError() *DeleteInternalServerError { + return &DeleteInternalServerError{} +} + +/* +DeleteInternalServerError describes a response with status code 500, with default header values. + +Failed +*/ +type DeleteInternalServerError struct { +} + +// IsSuccess returns true when this delete internal server error response has a 2xx status code +func (o *DeleteInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete internal server error response has a 3xx status code +func (o *DeleteInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete internal server error response has a 4xx status code +func (o *DeleteInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete internal server error response has a 5xx status code +func (o *DeleteInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this delete internal server error response a status code equal to that given +func (o *DeleteInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the delete internal server error response +func (o *DeleteInternalServerError) Code() int { + return 500 +} + +func (o *DeleteInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /][%d] deleteInternalServerError ", 500) +} + +func (o *DeleteInternalServerError) String() string { + return fmt.Sprintf("[DELETE /][%d] deleteInternalServerError ", 500) +} + +func (o *DeleteInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/api/v1/agentServer/client/echo/echo_client.go b/api/v1/agentServer/client/echo/echo_client.go index 0caceff9..694da6ba 100644 --- a/api/v1/agentServer/client/echo/echo_client.go +++ b/api/v1/agentServer/client/echo/echo_client.go @@ -33,13 +33,117 @@ type ClientOption func(*runtime.ClientOperation) // ClientService is the interface for Client methods type ClientService interface { + Delete(params *DeleteParams, opts ...ClientOption) (*DeleteOK, error) + + DeleteKdoctoragent(params *DeleteKdoctoragentParams, opts ...ClientOption) (*DeleteKdoctoragentOK, error) + Get(params *GetParams, opts ...ClientOption) (*GetOK, error) GetKdoctoragent(params *GetKdoctoragentParams, opts ...ClientOption) (*GetKdoctoragentOK, error) + Head(params *HeadParams, opts ...ClientOption) (*HeadOK, error) + + HeadKdoctoragent(params *HeadKdoctoragentParams, opts ...ClientOption) (*HeadKdoctoragentOK, error) + + Options(params *OptionsParams, opts ...ClientOption) (*OptionsOK, error) + + OptionsKdoctoragent(params *OptionsKdoctoragentParams, opts ...ClientOption) (*OptionsKdoctoragentOK, error) + + Patch(params *PatchParams, opts ...ClientOption) (*PatchOK, error) + + PatchKdoctoragent(params *PatchKdoctoragentParams, opts ...ClientOption) (*PatchKdoctoragentOK, error) + + Post(params *PostParams, opts ...ClientOption) (*PostOK, error) + + PostKdoctoragent(params *PostKdoctoragentParams, opts ...ClientOption) (*PostKdoctoragentOK, error) + + Put(params *PutParams, opts ...ClientOption) (*PutOK, error) + + PutKdoctoragent(params *PutKdoctoragentParams, opts ...ClientOption) (*PutKdoctoragentOK, error) + SetTransport(transport runtime.ClientTransport) } +/* +Delete cleans http request counts + +clean http request counts +*/ +func (a *Client) Delete(params *DeleteParams, opts ...ClientOption) (*DeleteOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteParams() + } + op := &runtime.ClientOperation{ + ID: "Delete", + Method: "DELETE", + PathPattern: "/", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &DeleteReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*DeleteOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for Delete: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +DeleteKdoctoragent cleans http request counts + +clean http request counts +*/ +func (a *Client) DeleteKdoctoragent(params *DeleteKdoctoragentParams, opts ...ClientOption) (*DeleteKdoctoragentOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteKdoctoragentParams() + } + op := &runtime.ClientOperation{ + ID: "DeleteKdoctoragent", + Method: "DELETE", + PathPattern: "/kdoctoragent", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &DeleteKdoctoragentReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*DeleteKdoctoragentOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for DeleteKdoctoragent: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* Get echos http request @@ -120,6 +224,406 @@ func (a *Client) GetKdoctoragent(params *GetKdoctoragentParams, opts ...ClientOp panic(msg) } +/* +Head echos http request + +echo http request +*/ +func (a *Client) Head(params *HeadParams, opts ...ClientOption) (*HeadOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewHeadParams() + } + op := &runtime.ClientOperation{ + ID: "Head", + Method: "HEAD", + PathPattern: "/", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &HeadReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*HeadOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for Head: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +HeadKdoctoragent echos http request + +echo http request +*/ +func (a *Client) HeadKdoctoragent(params *HeadKdoctoragentParams, opts ...ClientOption) (*HeadKdoctoragentOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewHeadKdoctoragentParams() + } + op := &runtime.ClientOperation{ + ID: "HeadKdoctoragent", + Method: "HEAD", + PathPattern: "/kdoctoragent", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &HeadKdoctoragentReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*HeadKdoctoragentOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for HeadKdoctoragent: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +Options echos http request + +echo http request +*/ +func (a *Client) Options(params *OptionsParams, opts ...ClientOption) (*OptionsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewOptionsParams() + } + op := &runtime.ClientOperation{ + ID: "Options", + Method: "OPTIONS", + PathPattern: "/", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &OptionsReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*OptionsOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for Options: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +OptionsKdoctoragent echos http request + +echo http request +*/ +func (a *Client) OptionsKdoctoragent(params *OptionsKdoctoragentParams, opts ...ClientOption) (*OptionsKdoctoragentOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewOptionsKdoctoragentParams() + } + op := &runtime.ClientOperation{ + ID: "OptionsKdoctoragent", + Method: "OPTIONS", + PathPattern: "/kdoctoragent", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &OptionsKdoctoragentReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*OptionsKdoctoragentOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for OptionsKdoctoragent: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +Patch echos http request + +echo http request +*/ +func (a *Client) Patch(params *PatchParams, opts ...ClientOption) (*PatchOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPatchParams() + } + op := &runtime.ClientOperation{ + ID: "Patch", + Method: "PATCH", + PathPattern: "/", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PatchReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PatchOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for Patch: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +PatchKdoctoragent echos http request + +echo http request +*/ +func (a *Client) PatchKdoctoragent(params *PatchKdoctoragentParams, opts ...ClientOption) (*PatchKdoctoragentOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPatchKdoctoragentParams() + } + op := &runtime.ClientOperation{ + ID: "PatchKdoctoragent", + Method: "PATCH", + PathPattern: "/kdoctoragent", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PatchKdoctoragentReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PatchKdoctoragentOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for PatchKdoctoragent: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +Post echos http request counts + +echo http request counts +*/ +func (a *Client) Post(params *PostParams, opts ...ClientOption) (*PostOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPostParams() + } + op := &runtime.ClientOperation{ + ID: "Post", + Method: "POST", + PathPattern: "/", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PostReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PostOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for Post: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +PostKdoctoragent echos http request counts + +echo http request counts +*/ +func (a *Client) PostKdoctoragent(params *PostKdoctoragentParams, opts ...ClientOption) (*PostKdoctoragentOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPostKdoctoragentParams() + } + op := &runtime.ClientOperation{ + ID: "PostKdoctoragent", + Method: "POST", + PathPattern: "/kdoctoragent", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PostKdoctoragentReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PostKdoctoragentOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for PostKdoctoragent: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +Put echos http request + +echo http request +*/ +func (a *Client) Put(params *PutParams, opts ...ClientOption) (*PutOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPutParams() + } + op := &runtime.ClientOperation{ + ID: "Put", + Method: "PUT", + PathPattern: "/", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PutReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PutOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for Put: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +PutKdoctoragent echos http request + +echo http request +*/ +func (a *Client) PutKdoctoragent(params *PutKdoctoragentParams, opts ...ClientOption) (*PutKdoctoragentOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPutKdoctoragentParams() + } + op := &runtime.ClientOperation{ + ID: "PutKdoctoragent", + Method: "PUT", + PathPattern: "/kdoctoragent", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &PutKdoctoragentReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PutKdoctoragentOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for PutKdoctoragent: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + // SetTransport changes the transport on the client func (a *Client) SetTransport(transport runtime.ClientTransport) { a.transport = transport diff --git a/api/v1/agentServer/client/echo/get_kdoctoragent_parameters.go b/api/v1/agentServer/client/echo/get_kdoctoragent_parameters.go index 66bc0440..a2d5cb81 100644 --- a/api/v1/agentServer/client/echo/get_kdoctoragent_parameters.go +++ b/api/v1/agentServer/client/echo/get_kdoctoragent_parameters.go @@ -17,6 +17,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetKdoctoragentParams creates a new GetKdoctoragentParams object, @@ -63,6 +64,13 @@ GetKdoctoragentParams contains all the parameters to send to the API endpoint Typically these are written to a http.Request. */ type GetKdoctoragentParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + timeout time.Duration Context context.Context HTTPClient *http.Client @@ -116,6 +124,17 @@ func (o *GetKdoctoragentParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithDelay adds the delay to the get kdoctoragent params +func (o *GetKdoctoragentParams) WithDelay(delay *int64) *GetKdoctoragentParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the get kdoctoragent params +func (o *GetKdoctoragentParams) SetDelay(delay *int64) { + o.Delay = delay +} + // WriteToRequest writes these params to a swagger request func (o *GetKdoctoragentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -124,6 +143,23 @@ func (o *GetKdoctoragentParams) WriteToRequest(r runtime.ClientRequest, reg strf } var res []error + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } diff --git a/api/v1/agentServer/client/echo/get_parameters.go b/api/v1/agentServer/client/echo/get_parameters.go index 0968af9e..7695d9df 100644 --- a/api/v1/agentServer/client/echo/get_parameters.go +++ b/api/v1/agentServer/client/echo/get_parameters.go @@ -17,6 +17,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetParams creates a new GetParams object, @@ -63,6 +64,13 @@ GetParams contains all the parameters to send to the API endpoint Typically these are written to a http.Request. */ type GetParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + timeout time.Duration Context context.Context HTTPClient *http.Client @@ -116,6 +124,17 @@ func (o *GetParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithDelay adds the delay to the get params +func (o *GetParams) WithDelay(delay *int64) *GetParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the get params +func (o *GetParams) SetDelay(delay *int64) { + o.Delay = delay +} + // WriteToRequest writes these params to a swagger request func (o *GetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -124,6 +143,23 @@ func (o *GetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) } var res []error + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } diff --git a/api/v1/agentServer/client/echo/head_kdoctoragent_parameters.go b/api/v1/agentServer/client/echo/head_kdoctoragent_parameters.go new file mode 100644 index 00000000..a05e29e3 --- /dev/null +++ b/api/v1/agentServer/client/echo/head_kdoctoragent_parameters.go @@ -0,0 +1,167 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewHeadKdoctoragentParams creates a new HeadKdoctoragentParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewHeadKdoctoragentParams() *HeadKdoctoragentParams { + return &HeadKdoctoragentParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewHeadKdoctoragentParamsWithTimeout creates a new HeadKdoctoragentParams object +// with the ability to set a timeout on a request. +func NewHeadKdoctoragentParamsWithTimeout(timeout time.Duration) *HeadKdoctoragentParams { + return &HeadKdoctoragentParams{ + timeout: timeout, + } +} + +// NewHeadKdoctoragentParamsWithContext creates a new HeadKdoctoragentParams object +// with the ability to set a context for a request. +func NewHeadKdoctoragentParamsWithContext(ctx context.Context) *HeadKdoctoragentParams { + return &HeadKdoctoragentParams{ + Context: ctx, + } +} + +// NewHeadKdoctoragentParamsWithHTTPClient creates a new HeadKdoctoragentParams object +// with the ability to set a custom HTTPClient for a request. +func NewHeadKdoctoragentParamsWithHTTPClient(client *http.Client) *HeadKdoctoragentParams { + return &HeadKdoctoragentParams{ + HTTPClient: client, + } +} + +/* +HeadKdoctoragentParams contains all the parameters to send to the API endpoint + + for the head kdoctoragent operation. + + Typically these are written to a http.Request. +*/ +type HeadKdoctoragentParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the head kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *HeadKdoctoragentParams) WithDefaults() *HeadKdoctoragentParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the head kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *HeadKdoctoragentParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the head kdoctoragent params +func (o *HeadKdoctoragentParams) WithTimeout(timeout time.Duration) *HeadKdoctoragentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the head kdoctoragent params +func (o *HeadKdoctoragentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the head kdoctoragent params +func (o *HeadKdoctoragentParams) WithContext(ctx context.Context) *HeadKdoctoragentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the head kdoctoragent params +func (o *HeadKdoctoragentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the head kdoctoragent params +func (o *HeadKdoctoragentParams) WithHTTPClient(client *http.Client) *HeadKdoctoragentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the head kdoctoragent params +func (o *HeadKdoctoragentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the head kdoctoragent params +func (o *HeadKdoctoragentParams) WithDelay(delay *int64) *HeadKdoctoragentParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the head kdoctoragent params +func (o *HeadKdoctoragentParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WriteToRequest writes these params to a swagger request +func (o *HeadKdoctoragentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/head_kdoctoragent_responses.go b/api/v1/agentServer/client/echo/head_kdoctoragent_responses.go new file mode 100644 index 00000000..bce3898b --- /dev/null +++ b/api/v1/agentServer/client/echo/head_kdoctoragent_responses.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// HeadKdoctoragentReader is a Reader for the HeadKdoctoragent structure. +type HeadKdoctoragentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *HeadKdoctoragentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewHeadKdoctoragentOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewHeadKdoctoragentOK creates a HeadKdoctoragentOK with default headers values +func NewHeadKdoctoragentOK() *HeadKdoctoragentOK { + return &HeadKdoctoragentOK{} +} + +/* +HeadKdoctoragentOK describes a response with status code 200, with default header values. + +Success +*/ +type HeadKdoctoragentOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this head kdoctoragent o k response has a 2xx status code +func (o *HeadKdoctoragentOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this head kdoctoragent o k response has a 3xx status code +func (o *HeadKdoctoragentOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this head kdoctoragent o k response has a 4xx status code +func (o *HeadKdoctoragentOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this head kdoctoragent o k response has a 5xx status code +func (o *HeadKdoctoragentOK) IsServerError() bool { + return false +} + +// IsCode returns true when this head kdoctoragent o k response a status code equal to that given +func (o *HeadKdoctoragentOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the head kdoctoragent o k response +func (o *HeadKdoctoragentOK) Code() int { + return 200 +} + +func (o *HeadKdoctoragentOK) Error() string { + return fmt.Sprintf("[HEAD /kdoctoragent][%d] headKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *HeadKdoctoragentOK) String() string { + return fmt.Sprintf("[HEAD /kdoctoragent][%d] headKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *HeadKdoctoragentOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *HeadKdoctoragentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/api/v1/agentServer/client/echo/head_parameters.go b/api/v1/agentServer/client/echo/head_parameters.go new file mode 100644 index 00000000..5089bd46 --- /dev/null +++ b/api/v1/agentServer/client/echo/head_parameters.go @@ -0,0 +1,167 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewHeadParams creates a new HeadParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewHeadParams() *HeadParams { + return &HeadParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewHeadParamsWithTimeout creates a new HeadParams object +// with the ability to set a timeout on a request. +func NewHeadParamsWithTimeout(timeout time.Duration) *HeadParams { + return &HeadParams{ + timeout: timeout, + } +} + +// NewHeadParamsWithContext creates a new HeadParams object +// with the ability to set a context for a request. +func NewHeadParamsWithContext(ctx context.Context) *HeadParams { + return &HeadParams{ + Context: ctx, + } +} + +// NewHeadParamsWithHTTPClient creates a new HeadParams object +// with the ability to set a custom HTTPClient for a request. +func NewHeadParamsWithHTTPClient(client *http.Client) *HeadParams { + return &HeadParams{ + HTTPClient: client, + } +} + +/* +HeadParams contains all the parameters to send to the API endpoint + + for the head operation. + + Typically these are written to a http.Request. +*/ +type HeadParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the head params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *HeadParams) WithDefaults() *HeadParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the head params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *HeadParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the head params +func (o *HeadParams) WithTimeout(timeout time.Duration) *HeadParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the head params +func (o *HeadParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the head params +func (o *HeadParams) WithContext(ctx context.Context) *HeadParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the head params +func (o *HeadParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the head params +func (o *HeadParams) WithHTTPClient(client *http.Client) *HeadParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the head params +func (o *HeadParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the head params +func (o *HeadParams) WithDelay(delay *int64) *HeadParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the head params +func (o *HeadParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WriteToRequest writes these params to a swagger request +func (o *HeadParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/head_responses.go b/api/v1/agentServer/client/echo/head_responses.go new file mode 100644 index 00000000..d9b15a9d --- /dev/null +++ b/api/v1/agentServer/client/echo/head_responses.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// HeadReader is a Reader for the Head structure. +type HeadReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *HeadReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewHeadOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewHeadOK creates a HeadOK with default headers values +func NewHeadOK() *HeadOK { + return &HeadOK{} +} + +/* +HeadOK describes a response with status code 200, with default header values. + +Success +*/ +type HeadOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this head o k response has a 2xx status code +func (o *HeadOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this head o k response has a 3xx status code +func (o *HeadOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this head o k response has a 4xx status code +func (o *HeadOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this head o k response has a 5xx status code +func (o *HeadOK) IsServerError() bool { + return false +} + +// IsCode returns true when this head o k response a status code equal to that given +func (o *HeadOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the head o k response +func (o *HeadOK) Code() int { + return 200 +} + +func (o *HeadOK) Error() string { + return fmt.Sprintf("[HEAD /][%d] headOK %+v", 200, o.Payload) +} + +func (o *HeadOK) String() string { + return fmt.Sprintf("[HEAD /][%d] headOK %+v", 200, o.Payload) +} + +func (o *HeadOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *HeadOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/api/v1/agentServer/client/echo/options_kdoctoragent_parameters.go b/api/v1/agentServer/client/echo/options_kdoctoragent_parameters.go new file mode 100644 index 00000000..81db0646 --- /dev/null +++ b/api/v1/agentServer/client/echo/options_kdoctoragent_parameters.go @@ -0,0 +1,167 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewOptionsKdoctoragentParams creates a new OptionsKdoctoragentParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewOptionsKdoctoragentParams() *OptionsKdoctoragentParams { + return &OptionsKdoctoragentParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewOptionsKdoctoragentParamsWithTimeout creates a new OptionsKdoctoragentParams object +// with the ability to set a timeout on a request. +func NewOptionsKdoctoragentParamsWithTimeout(timeout time.Duration) *OptionsKdoctoragentParams { + return &OptionsKdoctoragentParams{ + timeout: timeout, + } +} + +// NewOptionsKdoctoragentParamsWithContext creates a new OptionsKdoctoragentParams object +// with the ability to set a context for a request. +func NewOptionsKdoctoragentParamsWithContext(ctx context.Context) *OptionsKdoctoragentParams { + return &OptionsKdoctoragentParams{ + Context: ctx, + } +} + +// NewOptionsKdoctoragentParamsWithHTTPClient creates a new OptionsKdoctoragentParams object +// with the ability to set a custom HTTPClient for a request. +func NewOptionsKdoctoragentParamsWithHTTPClient(client *http.Client) *OptionsKdoctoragentParams { + return &OptionsKdoctoragentParams{ + HTTPClient: client, + } +} + +/* +OptionsKdoctoragentParams contains all the parameters to send to the API endpoint + + for the options kdoctoragent operation. + + Typically these are written to a http.Request. +*/ +type OptionsKdoctoragentParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the options kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *OptionsKdoctoragentParams) WithDefaults() *OptionsKdoctoragentParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the options kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *OptionsKdoctoragentParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the options kdoctoragent params +func (o *OptionsKdoctoragentParams) WithTimeout(timeout time.Duration) *OptionsKdoctoragentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the options kdoctoragent params +func (o *OptionsKdoctoragentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the options kdoctoragent params +func (o *OptionsKdoctoragentParams) WithContext(ctx context.Context) *OptionsKdoctoragentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the options kdoctoragent params +func (o *OptionsKdoctoragentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the options kdoctoragent params +func (o *OptionsKdoctoragentParams) WithHTTPClient(client *http.Client) *OptionsKdoctoragentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the options kdoctoragent params +func (o *OptionsKdoctoragentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the options kdoctoragent params +func (o *OptionsKdoctoragentParams) WithDelay(delay *int64) *OptionsKdoctoragentParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the options kdoctoragent params +func (o *OptionsKdoctoragentParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WriteToRequest writes these params to a swagger request +func (o *OptionsKdoctoragentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/options_kdoctoragent_responses.go b/api/v1/agentServer/client/echo/options_kdoctoragent_responses.go new file mode 100644 index 00000000..66fc9e7f --- /dev/null +++ b/api/v1/agentServer/client/echo/options_kdoctoragent_responses.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// OptionsKdoctoragentReader is a Reader for the OptionsKdoctoragent structure. +type OptionsKdoctoragentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *OptionsKdoctoragentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewOptionsKdoctoragentOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewOptionsKdoctoragentOK creates a OptionsKdoctoragentOK with default headers values +func NewOptionsKdoctoragentOK() *OptionsKdoctoragentOK { + return &OptionsKdoctoragentOK{} +} + +/* +OptionsKdoctoragentOK describes a response with status code 200, with default header values. + +Success +*/ +type OptionsKdoctoragentOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this options kdoctoragent o k response has a 2xx status code +func (o *OptionsKdoctoragentOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this options kdoctoragent o k response has a 3xx status code +func (o *OptionsKdoctoragentOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this options kdoctoragent o k response has a 4xx status code +func (o *OptionsKdoctoragentOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this options kdoctoragent o k response has a 5xx status code +func (o *OptionsKdoctoragentOK) IsServerError() bool { + return false +} + +// IsCode returns true when this options kdoctoragent o k response a status code equal to that given +func (o *OptionsKdoctoragentOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the options kdoctoragent o k response +func (o *OptionsKdoctoragentOK) Code() int { + return 200 +} + +func (o *OptionsKdoctoragentOK) Error() string { + return fmt.Sprintf("[OPTIONS /kdoctoragent][%d] optionsKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *OptionsKdoctoragentOK) String() string { + return fmt.Sprintf("[OPTIONS /kdoctoragent][%d] optionsKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *OptionsKdoctoragentOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *OptionsKdoctoragentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/api/v1/agentServer/client/echo/options_parameters.go b/api/v1/agentServer/client/echo/options_parameters.go new file mode 100644 index 00000000..303629ef --- /dev/null +++ b/api/v1/agentServer/client/echo/options_parameters.go @@ -0,0 +1,167 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewOptionsParams creates a new OptionsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewOptionsParams() *OptionsParams { + return &OptionsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewOptionsParamsWithTimeout creates a new OptionsParams object +// with the ability to set a timeout on a request. +func NewOptionsParamsWithTimeout(timeout time.Duration) *OptionsParams { + return &OptionsParams{ + timeout: timeout, + } +} + +// NewOptionsParamsWithContext creates a new OptionsParams object +// with the ability to set a context for a request. +func NewOptionsParamsWithContext(ctx context.Context) *OptionsParams { + return &OptionsParams{ + Context: ctx, + } +} + +// NewOptionsParamsWithHTTPClient creates a new OptionsParams object +// with the ability to set a custom HTTPClient for a request. +func NewOptionsParamsWithHTTPClient(client *http.Client) *OptionsParams { + return &OptionsParams{ + HTTPClient: client, + } +} + +/* +OptionsParams contains all the parameters to send to the API endpoint + + for the options operation. + + Typically these are written to a http.Request. +*/ +type OptionsParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the options params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *OptionsParams) WithDefaults() *OptionsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the options params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *OptionsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the options params +func (o *OptionsParams) WithTimeout(timeout time.Duration) *OptionsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the options params +func (o *OptionsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the options params +func (o *OptionsParams) WithContext(ctx context.Context) *OptionsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the options params +func (o *OptionsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the options params +func (o *OptionsParams) WithHTTPClient(client *http.Client) *OptionsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the options params +func (o *OptionsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the options params +func (o *OptionsParams) WithDelay(delay *int64) *OptionsParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the options params +func (o *OptionsParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WriteToRequest writes these params to a swagger request +func (o *OptionsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/options_responses.go b/api/v1/agentServer/client/echo/options_responses.go new file mode 100644 index 00000000..91b51b8f --- /dev/null +++ b/api/v1/agentServer/client/echo/options_responses.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// OptionsReader is a Reader for the Options structure. +type OptionsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *OptionsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewOptionsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewOptionsOK creates a OptionsOK with default headers values +func NewOptionsOK() *OptionsOK { + return &OptionsOK{} +} + +/* +OptionsOK describes a response with status code 200, with default header values. + +Success +*/ +type OptionsOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this options o k response has a 2xx status code +func (o *OptionsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this options o k response has a 3xx status code +func (o *OptionsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this options o k response has a 4xx status code +func (o *OptionsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this options o k response has a 5xx status code +func (o *OptionsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this options o k response a status code equal to that given +func (o *OptionsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the options o k response +func (o *OptionsOK) Code() int { + return 200 +} + +func (o *OptionsOK) Error() string { + return fmt.Sprintf("[OPTIONS /][%d] optionsOK %+v", 200, o.Payload) +} + +func (o *OptionsOK) String() string { + return fmt.Sprintf("[OPTIONS /][%d] optionsOK %+v", 200, o.Payload) +} + +func (o *OptionsOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *OptionsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/api/v1/agentServer/client/echo/patch_kdoctoragent_parameters.go b/api/v1/agentServer/client/echo/patch_kdoctoragent_parameters.go new file mode 100644 index 00000000..b51a78b0 --- /dev/null +++ b/api/v1/agentServer/client/echo/patch_kdoctoragent_parameters.go @@ -0,0 +1,167 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPatchKdoctoragentParams creates a new PatchKdoctoragentParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPatchKdoctoragentParams() *PatchKdoctoragentParams { + return &PatchKdoctoragentParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPatchKdoctoragentParamsWithTimeout creates a new PatchKdoctoragentParams object +// with the ability to set a timeout on a request. +func NewPatchKdoctoragentParamsWithTimeout(timeout time.Duration) *PatchKdoctoragentParams { + return &PatchKdoctoragentParams{ + timeout: timeout, + } +} + +// NewPatchKdoctoragentParamsWithContext creates a new PatchKdoctoragentParams object +// with the ability to set a context for a request. +func NewPatchKdoctoragentParamsWithContext(ctx context.Context) *PatchKdoctoragentParams { + return &PatchKdoctoragentParams{ + Context: ctx, + } +} + +// NewPatchKdoctoragentParamsWithHTTPClient creates a new PatchKdoctoragentParams object +// with the ability to set a custom HTTPClient for a request. +func NewPatchKdoctoragentParamsWithHTTPClient(client *http.Client) *PatchKdoctoragentParams { + return &PatchKdoctoragentParams{ + HTTPClient: client, + } +} + +/* +PatchKdoctoragentParams contains all the parameters to send to the API endpoint + + for the patch kdoctoragent operation. + + Typically these are written to a http.Request. +*/ +type PatchKdoctoragentParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the patch kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchKdoctoragentParams) WithDefaults() *PatchKdoctoragentParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchKdoctoragentParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the patch kdoctoragent params +func (o *PatchKdoctoragentParams) WithTimeout(timeout time.Duration) *PatchKdoctoragentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the patch kdoctoragent params +func (o *PatchKdoctoragentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the patch kdoctoragent params +func (o *PatchKdoctoragentParams) WithContext(ctx context.Context) *PatchKdoctoragentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the patch kdoctoragent params +func (o *PatchKdoctoragentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the patch kdoctoragent params +func (o *PatchKdoctoragentParams) WithHTTPClient(client *http.Client) *PatchKdoctoragentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the patch kdoctoragent params +func (o *PatchKdoctoragentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the patch kdoctoragent params +func (o *PatchKdoctoragentParams) WithDelay(delay *int64) *PatchKdoctoragentParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the patch kdoctoragent params +func (o *PatchKdoctoragentParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WriteToRequest writes these params to a swagger request +func (o *PatchKdoctoragentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/patch_kdoctoragent_responses.go b/api/v1/agentServer/client/echo/patch_kdoctoragent_responses.go new file mode 100644 index 00000000..310bd8d4 --- /dev/null +++ b/api/v1/agentServer/client/echo/patch_kdoctoragent_responses.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PatchKdoctoragentReader is a Reader for the PatchKdoctoragent structure. +type PatchKdoctoragentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PatchKdoctoragentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPatchKdoctoragentOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPatchKdoctoragentOK creates a PatchKdoctoragentOK with default headers values +func NewPatchKdoctoragentOK() *PatchKdoctoragentOK { + return &PatchKdoctoragentOK{} +} + +/* +PatchKdoctoragentOK describes a response with status code 200, with default header values. + +Success +*/ +type PatchKdoctoragentOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this patch kdoctoragent o k response has a 2xx status code +func (o *PatchKdoctoragentOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this patch kdoctoragent o k response has a 3xx status code +func (o *PatchKdoctoragentOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch kdoctoragent o k response has a 4xx status code +func (o *PatchKdoctoragentOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this patch kdoctoragent o k response has a 5xx status code +func (o *PatchKdoctoragentOK) IsServerError() bool { + return false +} + +// IsCode returns true when this patch kdoctoragent o k response a status code equal to that given +func (o *PatchKdoctoragentOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the patch kdoctoragent o k response +func (o *PatchKdoctoragentOK) Code() int { + return 200 +} + +func (o *PatchKdoctoragentOK) Error() string { + return fmt.Sprintf("[PATCH /kdoctoragent][%d] patchKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *PatchKdoctoragentOK) String() string { + return fmt.Sprintf("[PATCH /kdoctoragent][%d] patchKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *PatchKdoctoragentOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *PatchKdoctoragentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/api/v1/agentServer/client/echo/patch_parameters.go b/api/v1/agentServer/client/echo/patch_parameters.go new file mode 100644 index 00000000..ac79b593 --- /dev/null +++ b/api/v1/agentServer/client/echo/patch_parameters.go @@ -0,0 +1,167 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPatchParams creates a new PatchParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPatchParams() *PatchParams { + return &PatchParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPatchParamsWithTimeout creates a new PatchParams object +// with the ability to set a timeout on a request. +func NewPatchParamsWithTimeout(timeout time.Duration) *PatchParams { + return &PatchParams{ + timeout: timeout, + } +} + +// NewPatchParamsWithContext creates a new PatchParams object +// with the ability to set a context for a request. +func NewPatchParamsWithContext(ctx context.Context) *PatchParams { + return &PatchParams{ + Context: ctx, + } +} + +// NewPatchParamsWithHTTPClient creates a new PatchParams object +// with the ability to set a custom HTTPClient for a request. +func NewPatchParamsWithHTTPClient(client *http.Client) *PatchParams { + return &PatchParams{ + HTTPClient: client, + } +} + +/* +PatchParams contains all the parameters to send to the API endpoint + + for the patch operation. + + Typically these are written to a http.Request. +*/ +type PatchParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the patch params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchParams) WithDefaults() *PatchParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the patch params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PatchParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the patch params +func (o *PatchParams) WithTimeout(timeout time.Duration) *PatchParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the patch params +func (o *PatchParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the patch params +func (o *PatchParams) WithContext(ctx context.Context) *PatchParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the patch params +func (o *PatchParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the patch params +func (o *PatchParams) WithHTTPClient(client *http.Client) *PatchParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the patch params +func (o *PatchParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the patch params +func (o *PatchParams) WithDelay(delay *int64) *PatchParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the patch params +func (o *PatchParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WriteToRequest writes these params to a swagger request +func (o *PatchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/patch_responses.go b/api/v1/agentServer/client/echo/patch_responses.go new file mode 100644 index 00000000..666ffed7 --- /dev/null +++ b/api/v1/agentServer/client/echo/patch_responses.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PatchReader is a Reader for the Patch structure. +type PatchReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PatchReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPatchOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPatchOK creates a PatchOK with default headers values +func NewPatchOK() *PatchOK { + return &PatchOK{} +} + +/* +PatchOK describes a response with status code 200, with default header values. + +Success +*/ +type PatchOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this patch o k response has a 2xx status code +func (o *PatchOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this patch o k response has a 3xx status code +func (o *PatchOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this patch o k response has a 4xx status code +func (o *PatchOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this patch o k response has a 5xx status code +func (o *PatchOK) IsServerError() bool { + return false +} + +// IsCode returns true when this patch o k response a status code equal to that given +func (o *PatchOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the patch o k response +func (o *PatchOK) Code() int { + return 200 +} + +func (o *PatchOK) Error() string { + return fmt.Sprintf("[PATCH /][%d] patchOK %+v", 200, o.Payload) +} + +func (o *PatchOK) String() string { + return fmt.Sprintf("[PATCH /][%d] patchOK %+v", 200, o.Payload) +} + +func (o *PatchOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *PatchOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/api/v1/agentServer/client/echo/post_kdoctoragent_parameters.go b/api/v1/agentServer/client/echo/post_kdoctoragent_parameters.go new file mode 100644 index 00000000..b9eb9369 --- /dev/null +++ b/api/v1/agentServer/client/echo/post_kdoctoragent_parameters.go @@ -0,0 +1,188 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// NewPostKdoctoragentParams creates a new PostKdoctoragentParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPostKdoctoragentParams() *PostKdoctoragentParams { + return &PostKdoctoragentParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPostKdoctoragentParamsWithTimeout creates a new PostKdoctoragentParams object +// with the ability to set a timeout on a request. +func NewPostKdoctoragentParamsWithTimeout(timeout time.Duration) *PostKdoctoragentParams { + return &PostKdoctoragentParams{ + timeout: timeout, + } +} + +// NewPostKdoctoragentParamsWithContext creates a new PostKdoctoragentParams object +// with the ability to set a context for a request. +func NewPostKdoctoragentParamsWithContext(ctx context.Context) *PostKdoctoragentParams { + return &PostKdoctoragentParams{ + Context: ctx, + } +} + +// NewPostKdoctoragentParamsWithHTTPClient creates a new PostKdoctoragentParams object +// with the ability to set a custom HTTPClient for a request. +func NewPostKdoctoragentParamsWithHTTPClient(client *http.Client) *PostKdoctoragentParams { + return &PostKdoctoragentParams{ + HTTPClient: client, + } +} + +/* +PostKdoctoragentParams contains all the parameters to send to the API endpoint + + for the post kdoctoragent operation. + + Typically these are written to a http.Request. +*/ +type PostKdoctoragentParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + // TestArgs. + TestArgs *models.EchoBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the post kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PostKdoctoragentParams) WithDefaults() *PostKdoctoragentParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the post kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PostKdoctoragentParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the post kdoctoragent params +func (o *PostKdoctoragentParams) WithTimeout(timeout time.Duration) *PostKdoctoragentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the post kdoctoragent params +func (o *PostKdoctoragentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the post kdoctoragent params +func (o *PostKdoctoragentParams) WithContext(ctx context.Context) *PostKdoctoragentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the post kdoctoragent params +func (o *PostKdoctoragentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the post kdoctoragent params +func (o *PostKdoctoragentParams) WithHTTPClient(client *http.Client) *PostKdoctoragentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the post kdoctoragent params +func (o *PostKdoctoragentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the post kdoctoragent params +func (o *PostKdoctoragentParams) WithDelay(delay *int64) *PostKdoctoragentParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the post kdoctoragent params +func (o *PostKdoctoragentParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WithTestArgs adds the testArgs to the post kdoctoragent params +func (o *PostKdoctoragentParams) WithTestArgs(testArgs *models.EchoBody) *PostKdoctoragentParams { + o.SetTestArgs(testArgs) + return o +} + +// SetTestArgs adds the testArgs to the post kdoctoragent params +func (o *PostKdoctoragentParams) SetTestArgs(testArgs *models.EchoBody) { + o.TestArgs = testArgs +} + +// WriteToRequest writes these params to a swagger request +func (o *PostKdoctoragentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + if o.TestArgs != nil { + if err := r.SetBodyParam(o.TestArgs); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/post_kdoctoragent_responses.go b/api/v1/agentServer/client/echo/post_kdoctoragent_responses.go new file mode 100644 index 00000000..417aabe6 --- /dev/null +++ b/api/v1/agentServer/client/echo/post_kdoctoragent_responses.go @@ -0,0 +1,168 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PostKdoctoragentReader is a Reader for the PostKdoctoragent structure. +type PostKdoctoragentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PostKdoctoragentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPostKdoctoragentOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewPostKdoctoragentInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPostKdoctoragentOK creates a PostKdoctoragentOK with default headers values +func NewPostKdoctoragentOK() *PostKdoctoragentOK { + return &PostKdoctoragentOK{} +} + +/* +PostKdoctoragentOK describes a response with status code 200, with default header values. + +Success +*/ +type PostKdoctoragentOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this post kdoctoragent o k response has a 2xx status code +func (o *PostKdoctoragentOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this post kdoctoragent o k response has a 3xx status code +func (o *PostKdoctoragentOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post kdoctoragent o k response has a 4xx status code +func (o *PostKdoctoragentOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this post kdoctoragent o k response has a 5xx status code +func (o *PostKdoctoragentOK) IsServerError() bool { + return false +} + +// IsCode returns true when this post kdoctoragent o k response a status code equal to that given +func (o *PostKdoctoragentOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the post kdoctoragent o k response +func (o *PostKdoctoragentOK) Code() int { + return 200 +} + +func (o *PostKdoctoragentOK) Error() string { + return fmt.Sprintf("[POST /kdoctoragent][%d] postKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *PostKdoctoragentOK) String() string { + return fmt.Sprintf("[POST /kdoctoragent][%d] postKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *PostKdoctoragentOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *PostKdoctoragentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostKdoctoragentInternalServerError creates a PostKdoctoragentInternalServerError with default headers values +func NewPostKdoctoragentInternalServerError() *PostKdoctoragentInternalServerError { + return &PostKdoctoragentInternalServerError{} +} + +/* +PostKdoctoragentInternalServerError describes a response with status code 500, with default header values. + +Failed +*/ +type PostKdoctoragentInternalServerError struct { +} + +// IsSuccess returns true when this post kdoctoragent internal server error response has a 2xx status code +func (o *PostKdoctoragentInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post kdoctoragent internal server error response has a 3xx status code +func (o *PostKdoctoragentInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post kdoctoragent internal server error response has a 4xx status code +func (o *PostKdoctoragentInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this post kdoctoragent internal server error response has a 5xx status code +func (o *PostKdoctoragentInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this post kdoctoragent internal server error response a status code equal to that given +func (o *PostKdoctoragentInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the post kdoctoragent internal server error response +func (o *PostKdoctoragentInternalServerError) Code() int { + return 500 +} + +func (o *PostKdoctoragentInternalServerError) Error() string { + return fmt.Sprintf("[POST /kdoctoragent][%d] postKdoctoragentInternalServerError ", 500) +} + +func (o *PostKdoctoragentInternalServerError) String() string { + return fmt.Sprintf("[POST /kdoctoragent][%d] postKdoctoragentInternalServerError ", 500) +} + +func (o *PostKdoctoragentInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/api/v1/agentServer/client/echo/post_parameters.go b/api/v1/agentServer/client/echo/post_parameters.go new file mode 100644 index 00000000..c096e7bb --- /dev/null +++ b/api/v1/agentServer/client/echo/post_parameters.go @@ -0,0 +1,188 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// NewPostParams creates a new PostParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPostParams() *PostParams { + return &PostParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPostParamsWithTimeout creates a new PostParams object +// with the ability to set a timeout on a request. +func NewPostParamsWithTimeout(timeout time.Duration) *PostParams { + return &PostParams{ + timeout: timeout, + } +} + +// NewPostParamsWithContext creates a new PostParams object +// with the ability to set a context for a request. +func NewPostParamsWithContext(ctx context.Context) *PostParams { + return &PostParams{ + Context: ctx, + } +} + +// NewPostParamsWithHTTPClient creates a new PostParams object +// with the ability to set a custom HTTPClient for a request. +func NewPostParamsWithHTTPClient(client *http.Client) *PostParams { + return &PostParams{ + HTTPClient: client, + } +} + +/* +PostParams contains all the parameters to send to the API endpoint + + for the post operation. + + Typically these are written to a http.Request. +*/ +type PostParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + // TestArgs. + TestArgs *models.EchoBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PostParams) WithDefaults() *PostParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the post params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PostParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the post params +func (o *PostParams) WithTimeout(timeout time.Duration) *PostParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the post params +func (o *PostParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the post params +func (o *PostParams) WithContext(ctx context.Context) *PostParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the post params +func (o *PostParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the post params +func (o *PostParams) WithHTTPClient(client *http.Client) *PostParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the post params +func (o *PostParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the post params +func (o *PostParams) WithDelay(delay *int64) *PostParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the post params +func (o *PostParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WithTestArgs adds the testArgs to the post params +func (o *PostParams) WithTestArgs(testArgs *models.EchoBody) *PostParams { + o.SetTestArgs(testArgs) + return o +} + +// SetTestArgs adds the testArgs to the post params +func (o *PostParams) SetTestArgs(testArgs *models.EchoBody) { + o.TestArgs = testArgs +} + +// WriteToRequest writes these params to a swagger request +func (o *PostParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + if o.TestArgs != nil { + if err := r.SetBodyParam(o.TestArgs); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/post_responses.go b/api/v1/agentServer/client/echo/post_responses.go new file mode 100644 index 00000000..326a54eb --- /dev/null +++ b/api/v1/agentServer/client/echo/post_responses.go @@ -0,0 +1,168 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PostReader is a Reader for the Post structure. +type PostReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PostReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPostOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 500: + result := NewPostInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPostOK creates a PostOK with default headers values +func NewPostOK() *PostOK { + return &PostOK{} +} + +/* +PostOK describes a response with status code 200, with default header values. + +Success +*/ +type PostOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this post o k response has a 2xx status code +func (o *PostOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this post o k response has a 3xx status code +func (o *PostOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post o k response has a 4xx status code +func (o *PostOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this post o k response has a 5xx status code +func (o *PostOK) IsServerError() bool { + return false +} + +// IsCode returns true when this post o k response a status code equal to that given +func (o *PostOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the post o k response +func (o *PostOK) Code() int { + return 200 +} + +func (o *PostOK) Error() string { + return fmt.Sprintf("[POST /][%d] postOK %+v", 200, o.Payload) +} + +func (o *PostOK) String() string { + return fmt.Sprintf("[POST /][%d] postOK %+v", 200, o.Payload) +} + +func (o *PostOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *PostOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostInternalServerError creates a PostInternalServerError with default headers values +func NewPostInternalServerError() *PostInternalServerError { + return &PostInternalServerError{} +} + +/* +PostInternalServerError describes a response with status code 500, with default header values. + +Failed +*/ +type PostInternalServerError struct { +} + +// IsSuccess returns true when this post internal server error response has a 2xx status code +func (o *PostInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post internal server error response has a 3xx status code +func (o *PostInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post internal server error response has a 4xx status code +func (o *PostInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this post internal server error response has a 5xx status code +func (o *PostInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this post internal server error response a status code equal to that given +func (o *PostInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the post internal server error response +func (o *PostInternalServerError) Code() int { + return 500 +} + +func (o *PostInternalServerError) Error() string { + return fmt.Sprintf("[POST /][%d] postInternalServerError ", 500) +} + +func (o *PostInternalServerError) String() string { + return fmt.Sprintf("[POST /][%d] postInternalServerError ", 500) +} + +func (o *PostInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/api/v1/agentServer/client/echo/put_kdoctoragent_parameters.go b/api/v1/agentServer/client/echo/put_kdoctoragent_parameters.go new file mode 100644 index 00000000..9caf5d8b --- /dev/null +++ b/api/v1/agentServer/client/echo/put_kdoctoragent_parameters.go @@ -0,0 +1,167 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPutKdoctoragentParams creates a new PutKdoctoragentParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPutKdoctoragentParams() *PutKdoctoragentParams { + return &PutKdoctoragentParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPutKdoctoragentParamsWithTimeout creates a new PutKdoctoragentParams object +// with the ability to set a timeout on a request. +func NewPutKdoctoragentParamsWithTimeout(timeout time.Duration) *PutKdoctoragentParams { + return &PutKdoctoragentParams{ + timeout: timeout, + } +} + +// NewPutKdoctoragentParamsWithContext creates a new PutKdoctoragentParams object +// with the ability to set a context for a request. +func NewPutKdoctoragentParamsWithContext(ctx context.Context) *PutKdoctoragentParams { + return &PutKdoctoragentParams{ + Context: ctx, + } +} + +// NewPutKdoctoragentParamsWithHTTPClient creates a new PutKdoctoragentParams object +// with the ability to set a custom HTTPClient for a request. +func NewPutKdoctoragentParamsWithHTTPClient(client *http.Client) *PutKdoctoragentParams { + return &PutKdoctoragentParams{ + HTTPClient: client, + } +} + +/* +PutKdoctoragentParams contains all the parameters to send to the API endpoint + + for the put kdoctoragent operation. + + Typically these are written to a http.Request. +*/ +type PutKdoctoragentParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the put kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutKdoctoragentParams) WithDefaults() *PutKdoctoragentParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put kdoctoragent params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutKdoctoragentParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the put kdoctoragent params +func (o *PutKdoctoragentParams) WithTimeout(timeout time.Duration) *PutKdoctoragentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the put kdoctoragent params +func (o *PutKdoctoragentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the put kdoctoragent params +func (o *PutKdoctoragentParams) WithContext(ctx context.Context) *PutKdoctoragentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the put kdoctoragent params +func (o *PutKdoctoragentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the put kdoctoragent params +func (o *PutKdoctoragentParams) WithHTTPClient(client *http.Client) *PutKdoctoragentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the put kdoctoragent params +func (o *PutKdoctoragentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the put kdoctoragent params +func (o *PutKdoctoragentParams) WithDelay(delay *int64) *PutKdoctoragentParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the put kdoctoragent params +func (o *PutKdoctoragentParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WriteToRequest writes these params to a swagger request +func (o *PutKdoctoragentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/put_kdoctoragent_responses.go b/api/v1/agentServer/client/echo/put_kdoctoragent_responses.go new file mode 100644 index 00000000..552e708d --- /dev/null +++ b/api/v1/agentServer/client/echo/put_kdoctoragent_responses.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PutKdoctoragentReader is a Reader for the PutKdoctoragent structure. +type PutKdoctoragentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PutKdoctoragentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPutKdoctoragentOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPutKdoctoragentOK creates a PutKdoctoragentOK with default headers values +func NewPutKdoctoragentOK() *PutKdoctoragentOK { + return &PutKdoctoragentOK{} +} + +/* +PutKdoctoragentOK describes a response with status code 200, with default header values. + +Success +*/ +type PutKdoctoragentOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this put kdoctoragent o k response has a 2xx status code +func (o *PutKdoctoragentOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put kdoctoragent o k response has a 3xx status code +func (o *PutKdoctoragentOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put kdoctoragent o k response has a 4xx status code +func (o *PutKdoctoragentOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this put kdoctoragent o k response has a 5xx status code +func (o *PutKdoctoragentOK) IsServerError() bool { + return false +} + +// IsCode returns true when this put kdoctoragent o k response a status code equal to that given +func (o *PutKdoctoragentOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the put kdoctoragent o k response +func (o *PutKdoctoragentOK) Code() int { + return 200 +} + +func (o *PutKdoctoragentOK) Error() string { + return fmt.Sprintf("[PUT /kdoctoragent][%d] putKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *PutKdoctoragentOK) String() string { + return fmt.Sprintf("[PUT /kdoctoragent][%d] putKdoctoragentOK %+v", 200, o.Payload) +} + +func (o *PutKdoctoragentOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *PutKdoctoragentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/api/v1/agentServer/client/echo/put_parameters.go b/api/v1/agentServer/client/echo/put_parameters.go new file mode 100644 index 00000000..425fd03d --- /dev/null +++ b/api/v1/agentServer/client/echo/put_parameters.go @@ -0,0 +1,167 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPutParams creates a new PutParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPutParams() *PutParams { + return &PutParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPutParamsWithTimeout creates a new PutParams object +// with the ability to set a timeout on a request. +func NewPutParamsWithTimeout(timeout time.Duration) *PutParams { + return &PutParams{ + timeout: timeout, + } +} + +// NewPutParamsWithContext creates a new PutParams object +// with the ability to set a context for a request. +func NewPutParamsWithContext(ctx context.Context) *PutParams { + return &PutParams{ + Context: ctx, + } +} + +// NewPutParamsWithHTTPClient creates a new PutParams object +// with the ability to set a custom HTTPClient for a request. +func NewPutParamsWithHTTPClient(client *http.Client) *PutParams { + return &PutParams{ + HTTPClient: client, + } +} + +/* +PutParams contains all the parameters to send to the API endpoint + + for the put operation. + + Typically these are written to a http.Request. +*/ +type PutParams struct { + + /* Delay. + + delay some second return response + */ + Delay *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutParams) WithDefaults() *PutParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the put params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PutParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the put params +func (o *PutParams) WithTimeout(timeout time.Duration) *PutParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the put params +func (o *PutParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the put params +func (o *PutParams) WithContext(ctx context.Context) *PutParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the put params +func (o *PutParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the put params +func (o *PutParams) WithHTTPClient(client *http.Client) *PutParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the put params +func (o *PutParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithDelay adds the delay to the put params +func (o *PutParams) WithDelay(delay *int64) *PutParams { + o.SetDelay(delay) + return o +} + +// SetDelay adds the delay to the put params +func (o *PutParams) SetDelay(delay *int64) { + o.Delay = delay +} + +// WriteToRequest writes these params to a swagger request +func (o *PutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Delay != nil { + + // query param delay + var qrDelay int64 + + if o.Delay != nil { + qrDelay = *o.Delay + } + qDelay := swag.FormatInt64(qrDelay) + if qDelay != "" { + + if err := r.SetQueryParam("delay", qDelay); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/client/echo/put_responses.go b/api/v1/agentServer/client/echo/put_responses.go new file mode 100644 index 00000000..9a0a99f0 --- /dev/null +++ b/api/v1/agentServer/client/echo/put_responses.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PutReader is a Reader for the Put structure. +type PutReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PutReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPutOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPutOK creates a PutOK with default headers values +func NewPutOK() *PutOK { + return &PutOK{} +} + +/* +PutOK describes a response with status code 200, with default header values. + +Success +*/ +type PutOK struct { + Payload *models.EchoRes +} + +// IsSuccess returns true when this put o k response has a 2xx status code +func (o *PutOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this put o k response has a 3xx status code +func (o *PutOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this put o k response has a 4xx status code +func (o *PutOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this put o k response has a 5xx status code +func (o *PutOK) IsServerError() bool { + return false +} + +// IsCode returns true when this put o k response a status code equal to that given +func (o *PutOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the put o k response +func (o *PutOK) Code() int { + return 200 +} + +func (o *PutOK) Error() string { + return fmt.Sprintf("[PUT /][%d] putOK %+v", 200, o.Payload) +} + +func (o *PutOK) String() string { + return fmt.Sprintf("[PUT /][%d] putOK %+v", 200, o.Payload) +} + +func (o *PutOK) GetPayload() *models.EchoRes { + return o.Payload +} + +func (o *PutOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EchoRes) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/api/v1/agentServer/models/echo_body.go b/api/v1/agentServer/models/echo_body.go new file mode 100644 index 00000000..70a05b4f --- /dev/null +++ b/api/v1/agentServer/models/echo_body.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +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" +) + +// EchoBody echo request body args +// +// swagger:model EchoBody +type EchoBody struct { + + // test1 + Test1 string `json:"test1,omitempty"` + + // test2 + Test2 string `json:"test2,omitempty"` +} + +// Validate validates this echo body +func (m *EchoBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this echo body based on context it is used +func (m *EchoBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *EchoBody) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EchoBody) UnmarshalBinary(b []byte) error { + var res EchoBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/v1/agentServer/models/echo_res.go b/api/v1/agentServer/models/echo_res.go index 9fb30289..d9507af5 100644 --- a/api/v1/agentServer/models/echo_res.go +++ b/api/v1/agentServer/models/echo_res.go @@ -23,17 +23,32 @@ type EchoRes struct { // client source ip ClientIP string `json:"clientIp,omitempty"` - // other information - OtherDetail map[string]string `json:"otherDetail,omitempty"` + // param detail + ParamDetail map[string]string `json:"paramDetail,omitempty"` + + // request body + RequestBody string `json:"requestBody,omitempty"` + + // request count + RequestCount int64 `json:"requestCount,omitempty"` // request header RequestHeader map[string]string `json:"requestHeader,omitempty"` + // request method + RequestMethod string `json:"requestMethod,omitempty"` + + // request param + RequestParam string `json:"requestParam,omitempty"` + // request url RequestURL string `json:"requestUrl,omitempty"` // server host name ServerName string `json:"serverName,omitempty"` + + // request body + SupportedMethod []string `json:"supportedMethod"` } // Validate validates this echo res diff --git a/api/v1/agentServer/openapi.yaml b/api/v1/agentServer/openapi.yaml index 8c1e0c51..686183cd 100644 --- a/api/v1/agentServer/openapi.yaml +++ b/api/v1/agentServer/openapi.yaml @@ -45,29 +45,222 @@ paths: description: Success "500": description: Failed - "/kdoctoragent": + "/": get: summary: echo http request description: echo http request tags: - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response responses: "200": description: Success schema: "$ref": "#/definitions/EchoRes" - "/": + post: + summary: echo http request counts + description: echo http request counts + tags: + - echo + parameters: + - name: test-args + in: body + required: true + schema: + $ref: "#/definitions/EchoBody" + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + "500": + description: Failed + delete: + summary: clean http request counts + description: clean http request counts + tags: + - echo + responses: + "200": + description: Success + "500": + description: Failed + put: + summary: echo http request + description: echo http request + tags: + - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + head: + summary: echo http request + description: echo http request + tags: + - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + patch: + summary: echo http request + description: echo http request + tags: + - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + options: + summary: echo http request + description: echo http request + tags: + - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + "/kdoctoragent": get: summary: echo http request description: echo http request tags: - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + post: + summary: echo http request counts + description: echo http request counts + tags: + - echo + parameters: + - name: test-args + in: body + required: true + schema: + $ref: "#/definitions/EchoBody" + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + "500": + description: Failed + delete: + summary: clean http request counts + description: clean http request counts + tags: + - echo + responses: + "200": + description: Success + "500": + description: Failed + put: + summary: echo http request + description: echo http request + tags: + - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + head: + summary: echo http request + description: echo http request + tags: + - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + patch: + summary: echo http request + description: echo http request + tags: + - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response + responses: + "200": + description: Success + schema: + "$ref": "#/definitions/EchoRes" + options: + summary: echo http request + description: echo http request + tags: + - echo + parameters: + - in: query + name: delay + type: integer + description: delay some second return response responses: "200": description: Success schema: "$ref": "#/definitions/EchoRes" - definitions: EchoRes: description: echo request @@ -82,13 +275,38 @@ definitions: requestUrl: description: request url type: string + requestMethod: + description: request method + type: string requestHeader: description: request header type: object additionalProperties: type: string - otherDetail: - description: other information + requestCount: + description: request count + type: integer + requestParam: + description: request param + type: string + requestBody: + description: request body + type: string + supportedMethod: + description: request body + type: array + items: + type: string + paramDetail: + description: param detail type: object additionalProperties: type: string + EchoBody: + description: echo request body args + type: object + properties: + test1: + type: string + test2: + type: string diff --git a/api/v1/agentServer/server/configure_http_server_api.go b/api/v1/agentServer/server/configure_http_server_api.go index c941e684..8ee22579 100644 --- a/api/v1/agentServer/server/configure_http_server_api.go +++ b/api/v1/agentServer/server/configure_http_server_api.go @@ -42,6 +42,16 @@ func configureAPI(api *restapi.HTTPServerAPIAPI) http.Handler { api.JSONProducer = runtime.JSONProducer() + if api.EchoDeleteHandler == nil { + api.EchoDeleteHandler = echo.DeleteHandlerFunc(func(params echo.DeleteParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Delete has not yet been implemented") + }) + } + if api.EchoDeleteKdoctoragentHandler == nil { + api.EchoDeleteKdoctoragentHandler = echo.DeleteKdoctoragentHandlerFunc(func(params echo.DeleteKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.DeleteKdoctoragent has not yet been implemented") + }) + } if api.EchoGetHandler == nil { api.EchoGetHandler = echo.GetHandlerFunc(func(params echo.GetParams) middleware.Responder { return middleware.NotImplemented("operation echo.Get has not yet been implemented") @@ -67,6 +77,56 @@ func configureAPI(api *restapi.HTTPServerAPIAPI) http.Handler { return middleware.NotImplemented("operation echo.GetKdoctoragent has not yet been implemented") }) } + if api.EchoHeadHandler == nil { + api.EchoHeadHandler = echo.HeadHandlerFunc(func(params echo.HeadParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Head has not yet been implemented") + }) + } + if api.EchoHeadKdoctoragentHandler == nil { + api.EchoHeadKdoctoragentHandler = echo.HeadKdoctoragentHandlerFunc(func(params echo.HeadKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.HeadKdoctoragent has not yet been implemented") + }) + } + if api.EchoOptionsHandler == nil { + api.EchoOptionsHandler = echo.OptionsHandlerFunc(func(params echo.OptionsParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Options has not yet been implemented") + }) + } + if api.EchoOptionsKdoctoragentHandler == nil { + api.EchoOptionsKdoctoragentHandler = echo.OptionsKdoctoragentHandlerFunc(func(params echo.OptionsKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.OptionsKdoctoragent has not yet been implemented") + }) + } + if api.EchoPatchHandler == nil { + api.EchoPatchHandler = echo.PatchHandlerFunc(func(params echo.PatchParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Patch has not yet been implemented") + }) + } + if api.EchoPatchKdoctoragentHandler == nil { + api.EchoPatchKdoctoragentHandler = echo.PatchKdoctoragentHandlerFunc(func(params echo.PatchKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.PatchKdoctoragent has not yet been implemented") + }) + } + if api.EchoPostHandler == nil { + api.EchoPostHandler = echo.PostHandlerFunc(func(params echo.PostParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Post has not yet been implemented") + }) + } + if api.EchoPostKdoctoragentHandler == nil { + api.EchoPostKdoctoragentHandler = echo.PostKdoctoragentHandlerFunc(func(params echo.PostKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.PostKdoctoragent has not yet been implemented") + }) + } + if api.EchoPutHandler == nil { + api.EchoPutHandler = echo.PutHandlerFunc(func(params echo.PutParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Put has not yet been implemented") + }) + } + if api.EchoPutKdoctoragentHandler == nil { + api.EchoPutKdoctoragentHandler = echo.PutKdoctoragentHandlerFunc(func(params echo.PutKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.PutKdoctoragent has not yet been implemented") + }) + } api.PreServerShutdown = func() {} diff --git a/api/v1/agentServer/server/embedded_spec.go b/api/v1/agentServer/server/embedded_spec.go index 3a824f87..153f333c 100644 --- a/api/v1/agentServer/server/embedded_spec.go +++ b/api/v1/agentServer/server/embedded_spec.go @@ -42,6 +42,155 @@ func init() { "echo" ], "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "put": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "post": { + "description": "echo http request counts", + "tags": [ + "echo" + ], + "summary": "echo http request counts", + "parameters": [ + { + "name": "test-args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/EchoBody" + } + }, + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + }, + "500": { + "description": "Failed" + } + } + }, + "delete": { + "description": "clean http request counts", + "tags": [ + "echo" + ], + "summary": "clean http request counts", + "responses": { + "200": { + "description": "Success" + }, + "500": { + "description": "Failed" + } + } + }, + "options": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "head": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "patch": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], "responses": { "200": { "description": "Success", @@ -110,6 +259,155 @@ func init() { "echo" ], "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "put": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "post": { + "description": "echo http request counts", + "tags": [ + "echo" + ], + "summary": "echo http request counts", + "parameters": [ + { + "name": "test-args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/EchoBody" + } + }, + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + }, + "500": { + "description": "Failed" + } + } + }, + "delete": { + "description": "clean http request counts", + "tags": [ + "echo" + ], + "summary": "clean http request counts", + "responses": { + "200": { + "description": "Success" + }, + "500": { + "description": "Failed" + } + } + }, + "options": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "head": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "patch": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], "responses": { "200": { "description": "Success", @@ -122,6 +420,18 @@ func init() { } }, "definitions": { + "EchoBody": { + "description": "echo request body args", + "type": "object", + "properties": { + "test1": { + "type": "string" + }, + "test2": { + "type": "string" + } + } + }, "EchoRes": { "description": "echo request", "type": "object", @@ -130,13 +440,21 @@ func init() { "description": "client source ip", "type": "string" }, - "otherDetail": { - "description": "other information", + "paramDetail": { + "description": "param detail", "type": "object", "additionalProperties": { "type": "string" } }, + "requestBody": { + "description": "request body", + "type": "string" + }, + "requestCount": { + "description": "request count", + "type": "integer" + }, "requestHeader": { "description": "request header", "type": "object", @@ -144,6 +462,14 @@ func init() { "type": "string" } }, + "requestMethod": { + "description": "request method", + "type": "string" + }, + "requestParam": { + "description": "request param", + "type": "string" + }, "requestUrl": { "description": "request url", "type": "string" @@ -151,6 +477,13 @@ func init() { "serverName": { "description": "server host name", "type": "string" + }, + "supportedMethod": { + "description": "request body", + "type": "array", + "items": { + "type": "string" + } } } } @@ -181,6 +514,155 @@ func init() { "echo" ], "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "put": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "post": { + "description": "echo http request counts", + "tags": [ + "echo" + ], + "summary": "echo http request counts", + "parameters": [ + { + "name": "test-args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/EchoBody" + } + }, + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + }, + "500": { + "description": "Failed" + } + } + }, + "delete": { + "description": "clean http request counts", + "tags": [ + "echo" + ], + "summary": "clean http request counts", + "responses": { + "200": { + "description": "Success" + }, + "500": { + "description": "Failed" + } + } + }, + "options": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "head": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "patch": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], "responses": { "200": { "description": "Success", @@ -249,6 +731,155 @@ func init() { "echo" ], "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "put": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "post": { + "description": "echo http request counts", + "tags": [ + "echo" + ], + "summary": "echo http request counts", + "parameters": [ + { + "name": "test-args", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/EchoBody" + } + }, + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + }, + "500": { + "description": "Failed" + } + } + }, + "delete": { + "description": "clean http request counts", + "tags": [ + "echo" + ], + "summary": "clean http request counts", + "responses": { + "200": { + "description": "Success" + }, + "500": { + "description": "Failed" + } + } + }, + "options": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "head": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/EchoRes" + } + } + } + }, + "patch": { + "description": "echo http request", + "tags": [ + "echo" + ], + "summary": "echo http request", + "parameters": [ + { + "type": "integer", + "description": "delay some second return response", + "name": "delay", + "in": "query" + } + ], "responses": { "200": { "description": "Success", @@ -261,6 +892,18 @@ func init() { } }, "definitions": { + "EchoBody": { + "description": "echo request body args", + "type": "object", + "properties": { + "test1": { + "type": "string" + }, + "test2": { + "type": "string" + } + } + }, "EchoRes": { "description": "echo request", "type": "object", @@ -269,13 +912,21 @@ func init() { "description": "client source ip", "type": "string" }, - "otherDetail": { - "description": "other information", + "paramDetail": { + "description": "param detail", "type": "object", "additionalProperties": { "type": "string" } }, + "requestBody": { + "description": "request body", + "type": "string" + }, + "requestCount": { + "description": "request count", + "type": "integer" + }, "requestHeader": { "description": "request header", "type": "object", @@ -283,6 +934,14 @@ func init() { "type": "string" } }, + "requestMethod": { + "description": "request method", + "type": "string" + }, + "requestParam": { + "description": "request param", + "type": "string" + }, "requestUrl": { "description": "request url", "type": "string" @@ -290,6 +949,13 @@ func init() { "serverName": { "description": "server host name", "type": "string" + }, + "supportedMethod": { + "description": "request body", + "type": "array", + "items": { + "type": "string" + } } } } diff --git a/api/v1/agentServer/server/restapi/echo/delete.go b/api/v1/agentServer/server/restapi/echo/delete.go new file mode 100644 index 00000000..14327d32 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/delete.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// DeleteHandlerFunc turns a function with the right signature into a delete handler +type DeleteHandlerFunc func(DeleteParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteHandlerFunc) Handle(params DeleteParams) middleware.Responder { + return fn(params) +} + +// DeleteHandler interface for that can handle valid delete params +type DeleteHandler interface { + Handle(DeleteParams) middleware.Responder +} + +// NewDelete creates a new http.Handler for the delete operation +func NewDelete(ctx *middleware.Context, handler DeleteHandler) *Delete { + return &Delete{Context: ctx, Handler: handler} +} + +/* + Delete swagger:route DELETE / echo delete + +clean http request counts + +clean http request counts +*/ +type Delete struct { + Context *middleware.Context + Handler DeleteHandler +} + +func (o *Delete) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent.go b/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent.go new file mode 100644 index 00000000..adc30fe4 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// DeleteKdoctoragentHandlerFunc turns a function with the right signature into a delete kdoctoragent handler +type DeleteKdoctoragentHandlerFunc func(DeleteKdoctoragentParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteKdoctoragentHandlerFunc) Handle(params DeleteKdoctoragentParams) middleware.Responder { + return fn(params) +} + +// DeleteKdoctoragentHandler interface for that can handle valid delete kdoctoragent params +type DeleteKdoctoragentHandler interface { + Handle(DeleteKdoctoragentParams) middleware.Responder +} + +// NewDeleteKdoctoragent creates a new http.Handler for the delete kdoctoragent operation +func NewDeleteKdoctoragent(ctx *middleware.Context, handler DeleteKdoctoragentHandler) *DeleteKdoctoragent { + return &DeleteKdoctoragent{Context: ctx, Handler: handler} +} + +/* + DeleteKdoctoragent swagger:route DELETE /kdoctoragent echo deleteKdoctoragent + +clean http request counts + +clean http request counts +*/ +type DeleteKdoctoragent struct { + Context *middleware.Context + Handler DeleteKdoctoragentHandler +} + +func (o *DeleteKdoctoragent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteKdoctoragentParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_parameters.go b/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_parameters.go new file mode 100644 index 00000000..6df5f8f5 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_parameters.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// NewDeleteKdoctoragentParams creates a new DeleteKdoctoragentParams object +// +// There are no default values defined in the spec. +func NewDeleteKdoctoragentParams() DeleteKdoctoragentParams { + + return DeleteKdoctoragentParams{} +} + +// DeleteKdoctoragentParams contains all the bound params for the delete kdoctoragent operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteKdoctoragent +type DeleteKdoctoragentParams 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 NewDeleteKdoctoragentParams() beforehand. +func (o *DeleteKdoctoragentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_responses.go b/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_responses.go new file mode 100644 index 00000000..7819e646 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_responses.go @@ -0,0 +1,65 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// DeleteKdoctoragentOKCode is the HTTP code returned for type DeleteKdoctoragentOK +const DeleteKdoctoragentOKCode int = 200 + +/* +DeleteKdoctoragentOK Success + +swagger:response deleteKdoctoragentOK +*/ +type DeleteKdoctoragentOK struct { +} + +// NewDeleteKdoctoragentOK creates DeleteKdoctoragentOK with default headers values +func NewDeleteKdoctoragentOK() *DeleteKdoctoragentOK { + + return &DeleteKdoctoragentOK{} +} + +// WriteResponse to the client +func (o *DeleteKdoctoragentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteKdoctoragentInternalServerErrorCode is the HTTP code returned for type DeleteKdoctoragentInternalServerError +const DeleteKdoctoragentInternalServerErrorCode int = 500 + +/* +DeleteKdoctoragentInternalServerError Failed + +swagger:response deleteKdoctoragentInternalServerError +*/ +type DeleteKdoctoragentInternalServerError struct { +} + +// NewDeleteKdoctoragentInternalServerError creates DeleteKdoctoragentInternalServerError with default headers values +func NewDeleteKdoctoragentInternalServerError() *DeleteKdoctoragentInternalServerError { + + return &DeleteKdoctoragentInternalServerError{} +} + +// WriteResponse to the client +func (o *DeleteKdoctoragentInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_urlbuilder.go new file mode 100644 index 00000000..f51ca186 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/delete_kdoctoragent_urlbuilder.go @@ -0,0 +1,90 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// DeleteKdoctoragentURL generates an URL for the delete kdoctoragent operation +type DeleteKdoctoragentURL 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 *DeleteKdoctoragentURL) WithBasePath(bp string) *DeleteKdoctoragentURL { + 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 *DeleteKdoctoragentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteKdoctoragentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/kdoctoragent" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _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 *DeleteKdoctoragentURL) 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 *DeleteKdoctoragentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteKdoctoragentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteKdoctoragentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteKdoctoragentURL") + } + + 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 *DeleteKdoctoragentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/delete_parameters.go b/api/v1/agentServer/server/restapi/echo/delete_parameters.go new file mode 100644 index 00000000..5cf03262 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/delete_parameters.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// NewDeleteParams creates a new DeleteParams object +// +// There are no default values defined in the spec. +func NewDeleteParams() DeleteParams { + + return DeleteParams{} +} + +// DeleteParams contains all the bound params for the delete operation +// typically these are obtained from a http.Request +// +// swagger:parameters Delete +type DeleteParams 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 NewDeleteParams() beforehand. +func (o *DeleteParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/delete_responses.go b/api/v1/agentServer/server/restapi/echo/delete_responses.go new file mode 100644 index 00000000..129695cc --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/delete_responses.go @@ -0,0 +1,65 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// DeleteOKCode is the HTTP code returned for type DeleteOK +const DeleteOKCode int = 200 + +/* +DeleteOK Success + +swagger:response deleteOK +*/ +type DeleteOK struct { +} + +// NewDeleteOK creates DeleteOK with default headers values +func NewDeleteOK() *DeleteOK { + + return &DeleteOK{} +} + +// WriteResponse to the client +func (o *DeleteOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// DeleteInternalServerErrorCode is the HTTP code returned for type DeleteInternalServerError +const DeleteInternalServerErrorCode int = 500 + +/* +DeleteInternalServerError Failed + +swagger:response deleteInternalServerError +*/ +type DeleteInternalServerError struct { +} + +// NewDeleteInternalServerError creates DeleteInternalServerError with default headers values +func NewDeleteInternalServerError() *DeleteInternalServerError { + + return &DeleteInternalServerError{} +} + +// WriteResponse to the client +func (o *DeleteInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/api/v1/agentServer/server/restapi/echo/delete_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/delete_urlbuilder.go new file mode 100644 index 00000000..0d04c551 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/delete_urlbuilder.go @@ -0,0 +1,90 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// DeleteURL generates an URL for the delete operation +type DeleteURL 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 *DeleteURL) WithBasePath(bp string) *DeleteURL { + 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 *DeleteURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _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 *DeleteURL) 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 *DeleteURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteURL") + } + + 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 *DeleteURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/get_kdoctoragent_parameters.go b/api/v1/agentServer/server/restapi/echo/get_kdoctoragent_parameters.go index 7242117a..06bb5aef 100644 --- a/api/v1/agentServer/server/restapi/echo/get_kdoctoragent_parameters.go +++ b/api/v1/agentServer/server/restapi/echo/get_kdoctoragent_parameters.go @@ -12,7 +12,10 @@ import ( "net/http" "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetKdoctoragentParams creates a new GetKdoctoragentParams object @@ -31,6 +34,11 @@ type GetKdoctoragentParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface @@ -42,8 +50,37 @@ func (o *GetKdoctoragentParams) BindRequest(r *http.Request, route *middleware.M o.HTTPRequest = r + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } + +// bindDelay binds and validates parameter Delay from query. +func (o *GetKdoctoragentParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/get_kdoctoragent_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/get_kdoctoragent_urlbuilder.go index be174741..c2a41ae7 100644 --- a/api/v1/agentServer/server/restapi/echo/get_kdoctoragent_urlbuilder.go +++ b/api/v1/agentServer/server/restapi/echo/get_kdoctoragent_urlbuilder.go @@ -12,11 +12,17 @@ import ( "errors" "net/url" golangswaggerpaths "path" + + "github.com/go-openapi/swag" ) // GetKdoctoragentURL generates an URL for the get kdoctoragent operation type GetKdoctoragentURL struct { + Delay *int64 + _basePath string + // avoid unkeyed usage + _ struct{} } // WithBasePath sets the base path for this url builder, only required when it's different from the @@ -46,6 +52,18 @@ func (o *GetKdoctoragentURL) Build() (*url.URL, error) { } _result.Path = golangswaggerpaths.Join(_basePath, _path) + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + return &_result, nil } diff --git a/api/v1/agentServer/server/restapi/echo/get_parameters.go b/api/v1/agentServer/server/restapi/echo/get_parameters.go index eca71a0f..f3040288 100644 --- a/api/v1/agentServer/server/restapi/echo/get_parameters.go +++ b/api/v1/agentServer/server/restapi/echo/get_parameters.go @@ -12,7 +12,10 @@ import ( "net/http" "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetParams creates a new GetParams object @@ -31,6 +34,11 @@ type GetParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface @@ -42,8 +50,37 @@ func (o *GetParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) o.HTTPRequest = r + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } + +// bindDelay binds and validates parameter Delay from query. +func (o *GetParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/get_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/get_urlbuilder.go index 0fda50fd..0e62250d 100644 --- a/api/v1/agentServer/server/restapi/echo/get_urlbuilder.go +++ b/api/v1/agentServer/server/restapi/echo/get_urlbuilder.go @@ -12,11 +12,17 @@ import ( "errors" "net/url" golangswaggerpaths "path" + + "github.com/go-openapi/swag" ) // GetURL generates an URL for the get operation type GetURL struct { + Delay *int64 + _basePath string + // avoid unkeyed usage + _ struct{} } // WithBasePath sets the base path for this url builder, only required when it's different from the @@ -46,6 +52,18 @@ func (o *GetURL) Build() (*url.URL, error) { } _result.Path = golangswaggerpaths.Join(_basePath, _path) + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + return &_result, nil } diff --git a/api/v1/agentServer/server/restapi/echo/head.go b/api/v1/agentServer/server/restapi/echo/head.go new file mode 100644 index 00000000..52d9c58f --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/head.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// HeadHandlerFunc turns a function with the right signature into a head handler +type HeadHandlerFunc func(HeadParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn HeadHandlerFunc) Handle(params HeadParams) middleware.Responder { + return fn(params) +} + +// HeadHandler interface for that can handle valid head params +type HeadHandler interface { + Handle(HeadParams) middleware.Responder +} + +// NewHead creates a new http.Handler for the head operation +func NewHead(ctx *middleware.Context, handler HeadHandler) *Head { + return &Head{Context: ctx, Handler: handler} +} + +/* + Head swagger:route HEAD / echo head + +echo http request + +echo http request +*/ +type Head struct { + Context *middleware.Context + Handler HeadHandler +} + +func (o *Head) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewHeadParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/head_kdoctoragent.go b/api/v1/agentServer/server/restapi/echo/head_kdoctoragent.go new file mode 100644 index 00000000..a82a92a5 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/head_kdoctoragent.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// HeadKdoctoragentHandlerFunc turns a function with the right signature into a head kdoctoragent handler +type HeadKdoctoragentHandlerFunc func(HeadKdoctoragentParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn HeadKdoctoragentHandlerFunc) Handle(params HeadKdoctoragentParams) middleware.Responder { + return fn(params) +} + +// HeadKdoctoragentHandler interface for that can handle valid head kdoctoragent params +type HeadKdoctoragentHandler interface { + Handle(HeadKdoctoragentParams) middleware.Responder +} + +// NewHeadKdoctoragent creates a new http.Handler for the head kdoctoragent operation +func NewHeadKdoctoragent(ctx *middleware.Context, handler HeadKdoctoragentHandler) *HeadKdoctoragent { + return &HeadKdoctoragent{Context: ctx, Handler: handler} +} + +/* + HeadKdoctoragent swagger:route HEAD /kdoctoragent echo headKdoctoragent + +echo http request + +echo http request +*/ +type HeadKdoctoragent struct { + Context *middleware.Context + Handler HeadKdoctoragentHandler +} + +func (o *HeadKdoctoragent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewHeadKdoctoragentParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/head_kdoctoragent_parameters.go b/api/v1/agentServer/server/restapi/echo/head_kdoctoragent_parameters.go new file mode 100644 index 00000000..ec63ad18 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/head_kdoctoragent_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewHeadKdoctoragentParams creates a new HeadKdoctoragentParams object +// +// There are no default values defined in the spec. +func NewHeadKdoctoragentParams() HeadKdoctoragentParams { + + return HeadKdoctoragentParams{} +} + +// HeadKdoctoragentParams contains all the bound params for the head kdoctoragent operation +// typically these are obtained from a http.Request +// +// swagger:parameters HeadKdoctoragent +type HeadKdoctoragentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 +} + +// 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 NewHeadKdoctoragentParams() beforehand. +func (o *HeadKdoctoragentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *HeadKdoctoragentParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/head_kdoctoragent_responses.go b/api/v1/agentServer/server/restapi/echo/head_kdoctoragent_responses.go new file mode 100644 index 00000000..1f73493c --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/head_kdoctoragent_responses.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// HeadKdoctoragentOKCode is the HTTP code returned for type HeadKdoctoragentOK +const HeadKdoctoragentOKCode int = 200 + +/* +HeadKdoctoragentOK Success + +swagger:response headKdoctoragentOK +*/ +type HeadKdoctoragentOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewHeadKdoctoragentOK creates HeadKdoctoragentOK with default headers values +func NewHeadKdoctoragentOK() *HeadKdoctoragentOK { + + return &HeadKdoctoragentOK{} +} + +// WithPayload adds the payload to the head kdoctoragent o k response +func (o *HeadKdoctoragentOK) WithPayload(payload *models.EchoRes) *HeadKdoctoragentOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the head kdoctoragent o k response +func (o *HeadKdoctoragentOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *HeadKdoctoragentOK) 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 + } + } +} diff --git a/api/v1/agentServer/server/restapi/echo/head_kdoctoragent_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/head_kdoctoragent_urlbuilder.go new file mode 100644 index 00000000..d3edd5b2 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/head_kdoctoragent_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// HeadKdoctoragentURL generates an URL for the head kdoctoragent operation +type HeadKdoctoragentURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *HeadKdoctoragentURL) WithBasePath(bp string) *HeadKdoctoragentURL { + 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 *HeadKdoctoragentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *HeadKdoctoragentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/kdoctoragent" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *HeadKdoctoragentURL) 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 *HeadKdoctoragentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *HeadKdoctoragentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on HeadKdoctoragentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on HeadKdoctoragentURL") + } + + 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 *HeadKdoctoragentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/head_parameters.go b/api/v1/agentServer/server/restapi/echo/head_parameters.go new file mode 100644 index 00000000..72f9f002 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/head_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewHeadParams creates a new HeadParams object +// +// There are no default values defined in the spec. +func NewHeadParams() HeadParams { + + return HeadParams{} +} + +// HeadParams contains all the bound params for the head operation +// typically these are obtained from a http.Request +// +// swagger:parameters Head +type HeadParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 +} + +// 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 NewHeadParams() beforehand. +func (o *HeadParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *HeadParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/head_responses.go b/api/v1/agentServer/server/restapi/echo/head_responses.go new file mode 100644 index 00000000..8b94d13e --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/head_responses.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// HeadOKCode is the HTTP code returned for type HeadOK +const HeadOKCode int = 200 + +/* +HeadOK Success + +swagger:response headOK +*/ +type HeadOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewHeadOK creates HeadOK with default headers values +func NewHeadOK() *HeadOK { + + return &HeadOK{} +} + +// WithPayload adds the payload to the head o k response +func (o *HeadOK) WithPayload(payload *models.EchoRes) *HeadOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the head o k response +func (o *HeadOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *HeadOK) 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 + } + } +} diff --git a/api/v1/agentServer/server/restapi/echo/head_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/head_urlbuilder.go new file mode 100644 index 00000000..7a8048a5 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/head_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// HeadURL generates an URL for the head operation +type HeadURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *HeadURL) WithBasePath(bp string) *HeadURL { + 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 *HeadURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *HeadURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *HeadURL) 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 *HeadURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *HeadURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on HeadURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on HeadURL") + } + + 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 *HeadURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/options.go b/api/v1/agentServer/server/restapi/echo/options.go new file mode 100644 index 00000000..3bebd36c --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/options.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// OptionsHandlerFunc turns a function with the right signature into a options handler +type OptionsHandlerFunc func(OptionsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn OptionsHandlerFunc) Handle(params OptionsParams) middleware.Responder { + return fn(params) +} + +// OptionsHandler interface for that can handle valid options params +type OptionsHandler interface { + Handle(OptionsParams) middleware.Responder +} + +// NewOptions creates a new http.Handler for the options operation +func NewOptions(ctx *middleware.Context, handler OptionsHandler) *Options { + return &Options{Context: ctx, Handler: handler} +} + +/* + Options swagger:route OPTIONS / echo options + +echo http request + +echo http request +*/ +type Options struct { + Context *middleware.Context + Handler OptionsHandler +} + +func (o *Options) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewOptionsParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/options_kdoctoragent.go b/api/v1/agentServer/server/restapi/echo/options_kdoctoragent.go new file mode 100644 index 00000000..2353e962 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/options_kdoctoragent.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// OptionsKdoctoragentHandlerFunc turns a function with the right signature into a options kdoctoragent handler +type OptionsKdoctoragentHandlerFunc func(OptionsKdoctoragentParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn OptionsKdoctoragentHandlerFunc) Handle(params OptionsKdoctoragentParams) middleware.Responder { + return fn(params) +} + +// OptionsKdoctoragentHandler interface for that can handle valid options kdoctoragent params +type OptionsKdoctoragentHandler interface { + Handle(OptionsKdoctoragentParams) middleware.Responder +} + +// NewOptionsKdoctoragent creates a new http.Handler for the options kdoctoragent operation +func NewOptionsKdoctoragent(ctx *middleware.Context, handler OptionsKdoctoragentHandler) *OptionsKdoctoragent { + return &OptionsKdoctoragent{Context: ctx, Handler: handler} +} + +/* + OptionsKdoctoragent swagger:route OPTIONS /kdoctoragent echo optionsKdoctoragent + +echo http request + +echo http request +*/ +type OptionsKdoctoragent struct { + Context *middleware.Context + Handler OptionsKdoctoragentHandler +} + +func (o *OptionsKdoctoragent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewOptionsKdoctoragentParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/options_kdoctoragent_parameters.go b/api/v1/agentServer/server/restapi/echo/options_kdoctoragent_parameters.go new file mode 100644 index 00000000..ad79a757 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/options_kdoctoragent_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewOptionsKdoctoragentParams creates a new OptionsKdoctoragentParams object +// +// There are no default values defined in the spec. +func NewOptionsKdoctoragentParams() OptionsKdoctoragentParams { + + return OptionsKdoctoragentParams{} +} + +// OptionsKdoctoragentParams contains all the bound params for the options kdoctoragent operation +// typically these are obtained from a http.Request +// +// swagger:parameters OptionsKdoctoragent +type OptionsKdoctoragentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 +} + +// 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 NewOptionsKdoctoragentParams() beforehand. +func (o *OptionsKdoctoragentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *OptionsKdoctoragentParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/options_kdoctoragent_responses.go b/api/v1/agentServer/server/restapi/echo/options_kdoctoragent_responses.go new file mode 100644 index 00000000..8631905b --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/options_kdoctoragent_responses.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// OptionsKdoctoragentOKCode is the HTTP code returned for type OptionsKdoctoragentOK +const OptionsKdoctoragentOKCode int = 200 + +/* +OptionsKdoctoragentOK Success + +swagger:response optionsKdoctoragentOK +*/ +type OptionsKdoctoragentOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewOptionsKdoctoragentOK creates OptionsKdoctoragentOK with default headers values +func NewOptionsKdoctoragentOK() *OptionsKdoctoragentOK { + + return &OptionsKdoctoragentOK{} +} + +// WithPayload adds the payload to the options kdoctoragent o k response +func (o *OptionsKdoctoragentOK) WithPayload(payload *models.EchoRes) *OptionsKdoctoragentOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the options kdoctoragent o k response +func (o *OptionsKdoctoragentOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OptionsKdoctoragentOK) 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 + } + } +} diff --git a/api/v1/agentServer/server/restapi/echo/options_kdoctoragent_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/options_kdoctoragent_urlbuilder.go new file mode 100644 index 00000000..65f32ade --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/options_kdoctoragent_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// OptionsKdoctoragentURL generates an URL for the options kdoctoragent operation +type OptionsKdoctoragentURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *OptionsKdoctoragentURL) WithBasePath(bp string) *OptionsKdoctoragentURL { + 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 *OptionsKdoctoragentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *OptionsKdoctoragentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/kdoctoragent" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *OptionsKdoctoragentURL) 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 *OptionsKdoctoragentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *OptionsKdoctoragentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on OptionsKdoctoragentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on OptionsKdoctoragentURL") + } + + 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 *OptionsKdoctoragentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/options_parameters.go b/api/v1/agentServer/server/restapi/echo/options_parameters.go new file mode 100644 index 00000000..18d1df23 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/options_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewOptionsParams creates a new OptionsParams object +// +// There are no default values defined in the spec. +func NewOptionsParams() OptionsParams { + + return OptionsParams{} +} + +// OptionsParams contains all the bound params for the options operation +// typically these are obtained from a http.Request +// +// swagger:parameters Options +type OptionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 +} + +// 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 NewOptionsParams() beforehand. +func (o *OptionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *OptionsParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/options_responses.go b/api/v1/agentServer/server/restapi/echo/options_responses.go new file mode 100644 index 00000000..a453b901 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/options_responses.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// OptionsOKCode is the HTTP code returned for type OptionsOK +const OptionsOKCode int = 200 + +/* +OptionsOK Success + +swagger:response optionsOK +*/ +type OptionsOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewOptionsOK creates OptionsOK with default headers values +func NewOptionsOK() *OptionsOK { + + return &OptionsOK{} +} + +// WithPayload adds the payload to the options o k response +func (o *OptionsOK) WithPayload(payload *models.EchoRes) *OptionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the options o k response +func (o *OptionsOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *OptionsOK) 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 + } + } +} diff --git a/api/v1/agentServer/server/restapi/echo/options_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/options_urlbuilder.go new file mode 100644 index 00000000..c3f5b04e --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/options_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// OptionsURL generates an URL for the options operation +type OptionsURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *OptionsURL) WithBasePath(bp string) *OptionsURL { + 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 *OptionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *OptionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *OptionsURL) 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 *OptionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *OptionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on OptionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on OptionsURL") + } + + 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 *OptionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/patch.go b/api/v1/agentServer/server/restapi/echo/patch.go new file mode 100644 index 00000000..1020198f --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/patch.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// PatchHandlerFunc turns a function with the right signature into a patch handler +type PatchHandlerFunc func(PatchParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PatchHandlerFunc) Handle(params PatchParams) middleware.Responder { + return fn(params) +} + +// PatchHandler interface for that can handle valid patch params +type PatchHandler interface { + Handle(PatchParams) middleware.Responder +} + +// NewPatch creates a new http.Handler for the patch operation +func NewPatch(ctx *middleware.Context, handler PatchHandler) *Patch { + return &Patch{Context: ctx, Handler: handler} +} + +/* + Patch swagger:route PATCH / echo patch + +echo http request + +echo http request +*/ +type Patch struct { + Context *middleware.Context + Handler PatchHandler +} + +func (o *Patch) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPatchParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent.go b/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent.go new file mode 100644 index 00000000..a73a9f6c --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// PatchKdoctoragentHandlerFunc turns a function with the right signature into a patch kdoctoragent handler +type PatchKdoctoragentHandlerFunc func(PatchKdoctoragentParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PatchKdoctoragentHandlerFunc) Handle(params PatchKdoctoragentParams) middleware.Responder { + return fn(params) +} + +// PatchKdoctoragentHandler interface for that can handle valid patch kdoctoragent params +type PatchKdoctoragentHandler interface { + Handle(PatchKdoctoragentParams) middleware.Responder +} + +// NewPatchKdoctoragent creates a new http.Handler for the patch kdoctoragent operation +func NewPatchKdoctoragent(ctx *middleware.Context, handler PatchKdoctoragentHandler) *PatchKdoctoragent { + return &PatchKdoctoragent{Context: ctx, Handler: handler} +} + +/* + PatchKdoctoragent swagger:route PATCH /kdoctoragent echo patchKdoctoragent + +echo http request + +echo http request +*/ +type PatchKdoctoragent struct { + Context *middleware.Context + Handler PatchKdoctoragentHandler +} + +func (o *PatchKdoctoragent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPatchKdoctoragentParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_parameters.go b/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_parameters.go new file mode 100644 index 00000000..fa54f1c6 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPatchKdoctoragentParams creates a new PatchKdoctoragentParams object +// +// There are no default values defined in the spec. +func NewPatchKdoctoragentParams() PatchKdoctoragentParams { + + return PatchKdoctoragentParams{} +} + +// PatchKdoctoragentParams contains all the bound params for the patch kdoctoragent operation +// typically these are obtained from a http.Request +// +// swagger:parameters PatchKdoctoragent +type PatchKdoctoragentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 +} + +// 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 NewPatchKdoctoragentParams() beforehand. +func (o *PatchKdoctoragentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *PatchKdoctoragentParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_responses.go b/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_responses.go new file mode 100644 index 00000000..8114ae11 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_responses.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PatchKdoctoragentOKCode is the HTTP code returned for type PatchKdoctoragentOK +const PatchKdoctoragentOKCode int = 200 + +/* +PatchKdoctoragentOK Success + +swagger:response patchKdoctoragentOK +*/ +type PatchKdoctoragentOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewPatchKdoctoragentOK creates PatchKdoctoragentOK with default headers values +func NewPatchKdoctoragentOK() *PatchKdoctoragentOK { + + return &PatchKdoctoragentOK{} +} + +// WithPayload adds the payload to the patch kdoctoragent o k response +func (o *PatchKdoctoragentOK) WithPayload(payload *models.EchoRes) *PatchKdoctoragentOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch kdoctoragent o k response +func (o *PatchKdoctoragentOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchKdoctoragentOK) 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 + } + } +} diff --git a/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_urlbuilder.go new file mode 100644 index 00000000..ff13a339 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/patch_kdoctoragent_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// PatchKdoctoragentURL generates an URL for the patch kdoctoragent operation +type PatchKdoctoragentURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchKdoctoragentURL) WithBasePath(bp string) *PatchKdoctoragentURL { + 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 *PatchKdoctoragentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PatchKdoctoragentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/kdoctoragent" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PatchKdoctoragentURL) 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 *PatchKdoctoragentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PatchKdoctoragentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PatchKdoctoragentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PatchKdoctoragentURL") + } + + 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 *PatchKdoctoragentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/patch_parameters.go b/api/v1/agentServer/server/restapi/echo/patch_parameters.go new file mode 100644 index 00000000..cf76f4e3 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/patch_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPatchParams creates a new PatchParams object +// +// There are no default values defined in the spec. +func NewPatchParams() PatchParams { + + return PatchParams{} +} + +// PatchParams contains all the bound params for the patch operation +// typically these are obtained from a http.Request +// +// swagger:parameters Patch +type PatchParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 +} + +// 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 NewPatchParams() beforehand. +func (o *PatchParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *PatchParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/patch_responses.go b/api/v1/agentServer/server/restapi/echo/patch_responses.go new file mode 100644 index 00000000..b841c16d --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/patch_responses.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PatchOKCode is the HTTP code returned for type PatchOK +const PatchOKCode int = 200 + +/* +PatchOK Success + +swagger:response patchOK +*/ +type PatchOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewPatchOK creates PatchOK with default headers values +func NewPatchOK() *PatchOK { + + return &PatchOK{} +} + +// WithPayload adds the payload to the patch o k response +func (o *PatchOK) WithPayload(payload *models.EchoRes) *PatchOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the patch o k response +func (o *PatchOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PatchOK) 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 + } + } +} diff --git a/api/v1/agentServer/server/restapi/echo/patch_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/patch_urlbuilder.go new file mode 100644 index 00000000..132ca64b --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/patch_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// PatchURL generates an URL for the patch operation +type PatchURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PatchURL) WithBasePath(bp string) *PatchURL { + 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 *PatchURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PatchURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PatchURL) 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 *PatchURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PatchURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PatchURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PatchURL") + } + + 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 *PatchURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/post.go b/api/v1/agentServer/server/restapi/echo/post.go new file mode 100644 index 00000000..24e13c3b --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/post.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// PostHandlerFunc turns a function with the right signature into a post handler +type PostHandlerFunc func(PostParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostHandlerFunc) Handle(params PostParams) middleware.Responder { + return fn(params) +} + +// PostHandler interface for that can handle valid post params +type PostHandler interface { + Handle(PostParams) middleware.Responder +} + +// NewPost creates a new http.Handler for the post operation +func NewPost(ctx *middleware.Context, handler PostHandler) *Post { + return &Post{Context: ctx, Handler: handler} +} + +/* + Post swagger:route POST / echo post + +echo http request counts + +echo http request counts +*/ +type Post struct { + Context *middleware.Context + Handler PostHandler +} + +func (o *Post) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPostParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/post_kdoctoragent.go b/api/v1/agentServer/server/restapi/echo/post_kdoctoragent.go new file mode 100644 index 00000000..f2ed60f5 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/post_kdoctoragent.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// PostKdoctoragentHandlerFunc turns a function with the right signature into a post kdoctoragent handler +type PostKdoctoragentHandlerFunc func(PostKdoctoragentParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostKdoctoragentHandlerFunc) Handle(params PostKdoctoragentParams) middleware.Responder { + return fn(params) +} + +// PostKdoctoragentHandler interface for that can handle valid post kdoctoragent params +type PostKdoctoragentHandler interface { + Handle(PostKdoctoragentParams) middleware.Responder +} + +// NewPostKdoctoragent creates a new http.Handler for the post kdoctoragent operation +func NewPostKdoctoragent(ctx *middleware.Context, handler PostKdoctoragentHandler) *PostKdoctoragent { + return &PostKdoctoragent{Context: ctx, Handler: handler} +} + +/* + PostKdoctoragent swagger:route POST /kdoctoragent echo postKdoctoragent + +echo http request counts + +echo http request counts +*/ +type PostKdoctoragent struct { + Context *middleware.Context + Handler PostKdoctoragentHandler +} + +func (o *PostKdoctoragent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPostKdoctoragentParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/post_kdoctoragent_parameters.go b/api/v1/agentServer/server/restapi/echo/post_kdoctoragent_parameters.go new file mode 100644 index 00000000..2c33893d --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/post_kdoctoragent_parameters.go @@ -0,0 +1,123 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// NewPostKdoctoragentParams creates a new PostKdoctoragentParams object +// +// There are no default values defined in the spec. +func NewPostKdoctoragentParams() PostKdoctoragentParams { + + return PostKdoctoragentParams{} +} + +// PostKdoctoragentParams contains all the bound params for the post kdoctoragent operation +// typically these are obtained from a http.Request +// +// swagger:parameters PostKdoctoragent +type PostKdoctoragentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 + /* + Required: true + In: body + */ + TestArgs *models.EchoBody +} + +// 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 NewPostKdoctoragentParams() beforehand. +func (o *PostKdoctoragentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.EchoBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("testArgs", "body", "")) + } else { + res = append(res, errors.NewParseError("testArgs", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(r.Context()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.TestArgs = &body + } + } + } else { + res = append(res, errors.Required("testArgs", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *PostKdoctoragentParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/post_kdoctoragent_responses.go b/api/v1/agentServer/server/restapi/echo/post_kdoctoragent_responses.go new file mode 100644 index 00000000..ea921a2e --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/post_kdoctoragent_responses.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PostKdoctoragentOKCode is the HTTP code returned for type PostKdoctoragentOK +const PostKdoctoragentOKCode int = 200 + +/* +PostKdoctoragentOK Success + +swagger:response postKdoctoragentOK +*/ +type PostKdoctoragentOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewPostKdoctoragentOK creates PostKdoctoragentOK with default headers values +func NewPostKdoctoragentOK() *PostKdoctoragentOK { + + return &PostKdoctoragentOK{} +} + +// WithPayload adds the payload to the post kdoctoragent o k response +func (o *PostKdoctoragentOK) WithPayload(payload *models.EchoRes) *PostKdoctoragentOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post kdoctoragent o k response +func (o *PostKdoctoragentOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostKdoctoragentOK) 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 + } + } +} + +// PostKdoctoragentInternalServerErrorCode is the HTTP code returned for type PostKdoctoragentInternalServerError +const PostKdoctoragentInternalServerErrorCode int = 500 + +/* +PostKdoctoragentInternalServerError Failed + +swagger:response postKdoctoragentInternalServerError +*/ +type PostKdoctoragentInternalServerError struct { +} + +// NewPostKdoctoragentInternalServerError creates PostKdoctoragentInternalServerError with default headers values +func NewPostKdoctoragentInternalServerError() *PostKdoctoragentInternalServerError { + + return &PostKdoctoragentInternalServerError{} +} + +// WriteResponse to the client +func (o *PostKdoctoragentInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/api/v1/agentServer/server/restapi/echo/post_kdoctoragent_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/post_kdoctoragent_urlbuilder.go new file mode 100644 index 00000000..fa78102f --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/post_kdoctoragent_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// PostKdoctoragentURL generates an URL for the post kdoctoragent operation +type PostKdoctoragentURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostKdoctoragentURL) WithBasePath(bp string) *PostKdoctoragentURL { + 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 *PostKdoctoragentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostKdoctoragentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/kdoctoragent" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostKdoctoragentURL) 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 *PostKdoctoragentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostKdoctoragentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostKdoctoragentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostKdoctoragentURL") + } + + 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 *PostKdoctoragentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/post_parameters.go b/api/v1/agentServer/server/restapi/echo/post_parameters.go new file mode 100644 index 00000000..dc2bcd9d --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/post_parameters.go @@ -0,0 +1,123 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" + + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// NewPostParams creates a new PostParams object +// +// There are no default values defined in the spec. +func NewPostParams() PostParams { + + return PostParams{} +} + +// PostParams contains all the bound params for the post operation +// typically these are obtained from a http.Request +// +// swagger:parameters Post +type PostParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 + /* + Required: true + In: body + */ + TestArgs *models.EchoBody +} + +// 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 NewPostParams() beforehand. +func (o *PostParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.EchoBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("testArgs", "body", "")) + } else { + res = append(res, errors.NewParseError("testArgs", "body", "", err)) + } + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + ctx := validate.WithOperationRequest(r.Context()) + if err := body.ContextValidate(ctx, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.TestArgs = &body + } + } + } else { + res = append(res, errors.Required("testArgs", "body", "")) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *PostParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/post_responses.go b/api/v1/agentServer/server/restapi/echo/post_responses.go new file mode 100644 index 00000000..82ca4bd1 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/post_responses.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PostOKCode is the HTTP code returned for type PostOK +const PostOKCode int = 200 + +/* +PostOK Success + +swagger:response postOK +*/ +type PostOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewPostOK creates PostOK with default headers values +func NewPostOK() *PostOK { + + return &PostOK{} +} + +// WithPayload adds the payload to the post o k response +func (o *PostOK) WithPayload(payload *models.EchoRes) *PostOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post o k response +func (o *PostOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostOK) 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 + } + } +} + +// PostInternalServerErrorCode is the HTTP code returned for type PostInternalServerError +const PostInternalServerErrorCode int = 500 + +/* +PostInternalServerError Failed + +swagger:response postInternalServerError +*/ +type PostInternalServerError struct { +} + +// NewPostInternalServerError creates PostInternalServerError with default headers values +func NewPostInternalServerError() *PostInternalServerError { + + return &PostInternalServerError{} +} + +// WriteResponse to the client +func (o *PostInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(500) +} diff --git a/api/v1/agentServer/server/restapi/echo/post_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/post_urlbuilder.go new file mode 100644 index 00000000..594515e8 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/post_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// PostURL generates an URL for the post operation +type PostURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostURL) WithBasePath(bp string) *PostURL { + 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 *PostURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostURL) 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 *PostURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostURL") + } + + 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 *PostURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/put.go b/api/v1/agentServer/server/restapi/echo/put.go new file mode 100644 index 00000000..23085cad --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/put.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// PutHandlerFunc turns a function with the right signature into a put handler +type PutHandlerFunc func(PutParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PutHandlerFunc) Handle(params PutParams) middleware.Responder { + return fn(params) +} + +// PutHandler interface for that can handle valid put params +type PutHandler interface { + Handle(PutParams) middleware.Responder +} + +// NewPut creates a new http.Handler for the put operation +func NewPut(ctx *middleware.Context, handler PutHandler) *Put { + return &Put{Context: ctx, Handler: handler} +} + +/* + Put swagger:route PUT / echo put + +echo http request + +echo http request +*/ +type Put struct { + Context *middleware.Context + Handler PutHandler +} + +func (o *Put) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPutParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/put_kdoctoragent.go b/api/v1/agentServer/server/restapi/echo/put_kdoctoragent.go new file mode 100644 index 00000000..4d14610a --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/put_kdoctoragent.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" +) + +// PutKdoctoragentHandlerFunc turns a function with the right signature into a put kdoctoragent handler +type PutKdoctoragentHandlerFunc func(PutKdoctoragentParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PutKdoctoragentHandlerFunc) Handle(params PutKdoctoragentParams) middleware.Responder { + return fn(params) +} + +// PutKdoctoragentHandler interface for that can handle valid put kdoctoragent params +type PutKdoctoragentHandler interface { + Handle(PutKdoctoragentParams) middleware.Responder +} + +// NewPutKdoctoragent creates a new http.Handler for the put kdoctoragent operation +func NewPutKdoctoragent(ctx *middleware.Context, handler PutKdoctoragentHandler) *PutKdoctoragent { + return &PutKdoctoragent{Context: ctx, Handler: handler} +} + +/* + PutKdoctoragent swagger:route PUT /kdoctoragent echo putKdoctoragent + +echo http request + +echo http request +*/ +type PutKdoctoragent struct { + Context *middleware.Context + Handler PutKdoctoragentHandler +} + +func (o *PutKdoctoragent) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPutKdoctoragentParams() + 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) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/v1/agentServer/server/restapi/echo/put_kdoctoragent_parameters.go b/api/v1/agentServer/server/restapi/echo/put_kdoctoragent_parameters.go new file mode 100644 index 00000000..d9cc5578 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/put_kdoctoragent_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPutKdoctoragentParams creates a new PutKdoctoragentParams object +// +// There are no default values defined in the spec. +func NewPutKdoctoragentParams() PutKdoctoragentParams { + + return PutKdoctoragentParams{} +} + +// PutKdoctoragentParams contains all the bound params for the put kdoctoragent operation +// typically these are obtained from a http.Request +// +// swagger:parameters PutKdoctoragent +type PutKdoctoragentParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 +} + +// 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 NewPutKdoctoragentParams() beforehand. +func (o *PutKdoctoragentParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *PutKdoctoragentParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/put_kdoctoragent_responses.go b/api/v1/agentServer/server/restapi/echo/put_kdoctoragent_responses.go new file mode 100644 index 00000000..7acfa8c4 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/put_kdoctoragent_responses.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PutKdoctoragentOKCode is the HTTP code returned for type PutKdoctoragentOK +const PutKdoctoragentOKCode int = 200 + +/* +PutKdoctoragentOK Success + +swagger:response putKdoctoragentOK +*/ +type PutKdoctoragentOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewPutKdoctoragentOK creates PutKdoctoragentOK with default headers values +func NewPutKdoctoragentOK() *PutKdoctoragentOK { + + return &PutKdoctoragentOK{} +} + +// WithPayload adds the payload to the put kdoctoragent o k response +func (o *PutKdoctoragentOK) WithPayload(payload *models.EchoRes) *PutKdoctoragentOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the put kdoctoragent o k response +func (o *PutKdoctoragentOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PutKdoctoragentOK) 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 + } + } +} diff --git a/api/v1/agentServer/server/restapi/echo/put_kdoctoragent_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/put_kdoctoragent_urlbuilder.go new file mode 100644 index 00000000..99b6e365 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/put_kdoctoragent_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// PutKdoctoragentURL generates an URL for the put kdoctoragent operation +type PutKdoctoragentURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PutKdoctoragentURL) WithBasePath(bp string) *PutKdoctoragentURL { + 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 *PutKdoctoragentURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PutKdoctoragentURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/kdoctoragent" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PutKdoctoragentURL) 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 *PutKdoctoragentURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PutKdoctoragentURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PutKdoctoragentURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PutKdoctoragentURL") + } + + 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 *PutKdoctoragentURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/echo/put_parameters.go b/api/v1/agentServer/server/restapi/echo/put_parameters.go new file mode 100644 index 00000000..04a48860 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/put_parameters.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewPutParams creates a new PutParams object +// +// There are no default values defined in the spec. +func NewPutParams() PutParams { + + return PutParams{} +} + +// PutParams contains all the bound params for the put operation +// typically these are obtained from a http.Request +// +// swagger:parameters Put +type PutParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*delay some second return response + In: query + */ + Delay *int64 +} + +// 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 NewPutParams() beforehand. +func (o *PutParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + qDelay, qhkDelay, _ := qs.GetOK("delay") + if err := o.bindDelay(qDelay, qhkDelay, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDelay binds and validates parameter Delay from query. +func (o *PutParams) bindDelay(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertInt64(raw) + if err != nil { + return errors.InvalidType("delay", "query", "int64", raw) + } + o.Delay = &value + + return nil +} diff --git a/api/v1/agentServer/server/restapi/echo/put_responses.go b/api/v1/agentServer/server/restapi/echo/put_responses.go new file mode 100644 index 00000000..fc02a603 --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/put_responses.go @@ -0,0 +1,62 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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/kdoctor-io/kdoctor/api/v1/agentServer/models" +) + +// PutOKCode is the HTTP code returned for type PutOK +const PutOKCode int = 200 + +/* +PutOK Success + +swagger:response putOK +*/ +type PutOK struct { + + /* + In: Body + */ + Payload *models.EchoRes `json:"body,omitempty"` +} + +// NewPutOK creates PutOK with default headers values +func NewPutOK() *PutOK { + + return &PutOK{} +} + +// WithPayload adds the payload to the put o k response +func (o *PutOK) WithPayload(payload *models.EchoRes) *PutOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the put o k response +func (o *PutOK) SetPayload(payload *models.EchoRes) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PutOK) 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 + } + } +} diff --git a/api/v1/agentServer/server/restapi/echo/put_urlbuilder.go b/api/v1/agentServer/server/restapi/echo/put_urlbuilder.go new file mode 100644 index 00000000..0985986e --- /dev/null +++ b/api/v1/agentServer/server/restapi/echo/put_urlbuilder.go @@ -0,0 +1,108 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package echo + +// 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" + + "github.com/go-openapi/swag" +) + +// PutURL generates an URL for the put operation +type PutURL struct { + Delay *int64 + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PutURL) WithBasePath(bp string) *PutURL { + 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 *PutURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PutURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var delayQ string + if o.Delay != nil { + delayQ = swag.FormatInt64(*o.Delay) + } + if delayQ != "" { + qs.Set("delay", delayQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PutURL) 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 *PutURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PutURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PutURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PutURL") + } + + 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 *PutURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/v1/agentServer/server/restapi/http_server_api_api.go b/api/v1/agentServer/server/restapi/http_server_api_api.go index 20abe95d..489d2a34 100644 --- a/api/v1/agentServer/server/restapi/http_server_api_api.go +++ b/api/v1/agentServer/server/restapi/http_server_api_api.go @@ -48,6 +48,12 @@ func NewHTTPServerAPIAPI(spec *loads.Document) *HTTPServerAPIAPI { JSONProducer: runtime.JSONProducer(), + EchoDeleteHandler: echo.DeleteHandlerFunc(func(params echo.DeleteParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Delete has not yet been implemented") + }), + EchoDeleteKdoctoragentHandler: echo.DeleteKdoctoragentHandlerFunc(func(params echo.DeleteKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.DeleteKdoctoragent has not yet been implemented") + }), EchoGetHandler: echo.GetHandlerFunc(func(params echo.GetParams) middleware.Responder { return middleware.NotImplemented("operation echo.Get has not yet been implemented") }), @@ -63,6 +69,36 @@ func NewHTTPServerAPIAPI(spec *loads.Document) *HTTPServerAPIAPI { EchoGetKdoctoragentHandler: echo.GetKdoctoragentHandlerFunc(func(params echo.GetKdoctoragentParams) middleware.Responder { return middleware.NotImplemented("operation echo.GetKdoctoragent has not yet been implemented") }), + EchoHeadHandler: echo.HeadHandlerFunc(func(params echo.HeadParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Head has not yet been implemented") + }), + EchoHeadKdoctoragentHandler: echo.HeadKdoctoragentHandlerFunc(func(params echo.HeadKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.HeadKdoctoragent has not yet been implemented") + }), + EchoOptionsHandler: echo.OptionsHandlerFunc(func(params echo.OptionsParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Options has not yet been implemented") + }), + EchoOptionsKdoctoragentHandler: echo.OptionsKdoctoragentHandlerFunc(func(params echo.OptionsKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.OptionsKdoctoragent has not yet been implemented") + }), + EchoPatchHandler: echo.PatchHandlerFunc(func(params echo.PatchParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Patch has not yet been implemented") + }), + EchoPatchKdoctoragentHandler: echo.PatchKdoctoragentHandlerFunc(func(params echo.PatchKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.PatchKdoctoragent has not yet been implemented") + }), + EchoPostHandler: echo.PostHandlerFunc(func(params echo.PostParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Post has not yet been implemented") + }), + EchoPostKdoctoragentHandler: echo.PostKdoctoragentHandlerFunc(func(params echo.PostKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.PostKdoctoragent has not yet been implemented") + }), + EchoPutHandler: echo.PutHandlerFunc(func(params echo.PutParams) middleware.Responder { + return middleware.NotImplemented("operation echo.Put has not yet been implemented") + }), + EchoPutKdoctoragentHandler: echo.PutKdoctoragentHandlerFunc(func(params echo.PutKdoctoragentParams) middleware.Responder { + return middleware.NotImplemented("operation echo.PutKdoctoragent has not yet been implemented") + }), } } @@ -99,6 +135,10 @@ type HTTPServerAPIAPI struct { // - application/json JSONProducer runtime.Producer + // EchoDeleteHandler sets the operation handler for the delete operation + EchoDeleteHandler echo.DeleteHandler + // EchoDeleteKdoctoragentHandler sets the operation handler for the delete kdoctoragent operation + EchoDeleteKdoctoragentHandler echo.DeleteKdoctoragentHandler // EchoGetHandler sets the operation handler for the get operation EchoGetHandler echo.GetHandler // HealthyGetHealthyLivenessHandler sets the operation handler for the get healthy liveness operation @@ -109,6 +149,26 @@ type HTTPServerAPIAPI struct { HealthyGetHealthyStartupHandler healthy.GetHealthyStartupHandler // EchoGetKdoctoragentHandler sets the operation handler for the get kdoctoragent operation EchoGetKdoctoragentHandler echo.GetKdoctoragentHandler + // EchoHeadHandler sets the operation handler for the head operation + EchoHeadHandler echo.HeadHandler + // EchoHeadKdoctoragentHandler sets the operation handler for the head kdoctoragent operation + EchoHeadKdoctoragentHandler echo.HeadKdoctoragentHandler + // EchoOptionsHandler sets the operation handler for the options operation + EchoOptionsHandler echo.OptionsHandler + // EchoOptionsKdoctoragentHandler sets the operation handler for the options kdoctoragent operation + EchoOptionsKdoctoragentHandler echo.OptionsKdoctoragentHandler + // EchoPatchHandler sets the operation handler for the patch operation + EchoPatchHandler echo.PatchHandler + // EchoPatchKdoctoragentHandler sets the operation handler for the patch kdoctoragent operation + EchoPatchKdoctoragentHandler echo.PatchKdoctoragentHandler + // EchoPostHandler sets the operation handler for the post operation + EchoPostHandler echo.PostHandler + // EchoPostKdoctoragentHandler sets the operation handler for the post kdoctoragent operation + EchoPostKdoctoragentHandler echo.PostKdoctoragentHandler + // EchoPutHandler sets the operation handler for the put operation + EchoPutHandler echo.PutHandler + // EchoPutKdoctoragentHandler sets the operation handler for the put kdoctoragent operation + EchoPutKdoctoragentHandler echo.PutKdoctoragentHandler // ServeError is called when an error is received, there is a default handler // but you can set your own with this @@ -186,6 +246,12 @@ func (o *HTTPServerAPIAPI) Validate() error { unregistered = append(unregistered, "JSONProducer") } + if o.EchoDeleteHandler == nil { + unregistered = append(unregistered, "echo.DeleteHandler") + } + if o.EchoDeleteKdoctoragentHandler == nil { + unregistered = append(unregistered, "echo.DeleteKdoctoragentHandler") + } if o.EchoGetHandler == nil { unregistered = append(unregistered, "echo.GetHandler") } @@ -201,6 +267,36 @@ func (o *HTTPServerAPIAPI) Validate() error { if o.EchoGetKdoctoragentHandler == nil { unregistered = append(unregistered, "echo.GetKdoctoragentHandler") } + if o.EchoHeadHandler == nil { + unregistered = append(unregistered, "echo.HeadHandler") + } + if o.EchoHeadKdoctoragentHandler == nil { + unregistered = append(unregistered, "echo.HeadKdoctoragentHandler") + } + if o.EchoOptionsHandler == nil { + unregistered = append(unregistered, "echo.OptionsHandler") + } + if o.EchoOptionsKdoctoragentHandler == nil { + unregistered = append(unregistered, "echo.OptionsKdoctoragentHandler") + } + if o.EchoPatchHandler == nil { + unregistered = append(unregistered, "echo.PatchHandler") + } + if o.EchoPatchKdoctoragentHandler == nil { + unregistered = append(unregistered, "echo.PatchKdoctoragentHandler") + } + if o.EchoPostHandler == nil { + unregistered = append(unregistered, "echo.PostHandler") + } + if o.EchoPostKdoctoragentHandler == nil { + unregistered = append(unregistered, "echo.PostKdoctoragentHandler") + } + if o.EchoPutHandler == nil { + unregistered = append(unregistered, "echo.PutHandler") + } + if o.EchoPutKdoctoragentHandler == nil { + unregistered = append(unregistered, "echo.PutKdoctoragentHandler") + } if len(unregistered) > 0 { return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) @@ -289,6 +385,14 @@ func (o *HTTPServerAPIAPI) initHandlerCache() { o.handlers = make(map[string]map[string]http.Handler) } + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"][""] = echo.NewDelete(o.context, o.EchoDeleteHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/kdoctoragent"] = echo.NewDeleteKdoctoragent(o.context, o.EchoDeleteKdoctoragentHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } @@ -309,6 +413,46 @@ func (o *HTTPServerAPIAPI) initHandlerCache() { o.handlers["GET"] = make(map[string]http.Handler) } o.handlers["GET"]["/kdoctoragent"] = echo.NewGetKdoctoragent(o.context, o.EchoGetKdoctoragentHandler) + if o.handlers["HEAD"] == nil { + o.handlers["HEAD"] = make(map[string]http.Handler) + } + o.handlers["HEAD"][""] = echo.NewHead(o.context, o.EchoHeadHandler) + if o.handlers["HEAD"] == nil { + o.handlers["HEAD"] = make(map[string]http.Handler) + } + o.handlers["HEAD"]["/kdoctoragent"] = echo.NewHeadKdoctoragent(o.context, o.EchoHeadKdoctoragentHandler) + if o.handlers["OPTIONS"] == nil { + o.handlers["OPTIONS"] = make(map[string]http.Handler) + } + o.handlers["OPTIONS"][""] = echo.NewOptions(o.context, o.EchoOptionsHandler) + if o.handlers["OPTIONS"] == nil { + o.handlers["OPTIONS"] = make(map[string]http.Handler) + } + o.handlers["OPTIONS"]["/kdoctoragent"] = echo.NewOptionsKdoctoragent(o.context, o.EchoOptionsKdoctoragentHandler) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } + o.handlers["PATCH"][""] = echo.NewPatch(o.context, o.EchoPatchHandler) + if o.handlers["PATCH"] == nil { + o.handlers["PATCH"] = make(map[string]http.Handler) + } + o.handlers["PATCH"]["/kdoctoragent"] = echo.NewPatchKdoctoragent(o.context, o.EchoPatchKdoctoragentHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"][""] = echo.NewPost(o.context, o.EchoPostHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/kdoctoragent"] = echo.NewPostKdoctoragent(o.context, o.EchoPostKdoctoragentHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"][""] = echo.NewPut(o.context, o.EchoPutHandler) + if o.handlers["PUT"] == nil { + o.handlers["PUT"] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/kdoctoragent"] = echo.NewPutKdoctoragent(o.context, o.EchoPutKdoctoragentHandler) } // Serve creates a http handler to serve the API over HTTP diff --git a/charts/templates/daemonset.yaml b/charts/templates/daemonset.yaml index 035e56c9..0cc714d8 100644 --- a/charts/templates/daemonset.yaml +++ b/charts/templates/daemonset.yaml @@ -92,6 +92,8 @@ spec: - {{ .Values.kdoctorAgent.cmdBinName }} args: - --config-path=/tmp/config-map/conf.yml + - --tls-ca-cert=/etc/tls/ca.crt + - --tls-ca-key=/etc/tls/ca.key {{- with .Values.kdoctorAgent.extraArgs }} {{- toYaml . | trim | nindent 8 }} {{- end }} @@ -102,15 +104,21 @@ spec: protocol: TCP {{- end }} {{- if or .Values.feature.enableIPv4 .Values.feature.enableIPv6 }} + - name: health + containerPort: {{ .Values.kdoctorAgent.httpServer.healthPort }} + protocol: TCP - name: http - containerPort: {{ .Values.kdoctorAgent.httpServer.port }} + containerPort: {{ .Values.kdoctorAgent.httpServer.appHttpPort }} + protocol: TCP + - name: https + containerPort: {{ .Values.kdoctorAgent.httpServer.appHttpsPort }} protocol: TCP {{- end }} {{- if semverCompare ">=1.20-0" .Capabilities.KubeVersion.Version }} startupProbe: httpGet: path: /healthy/startup - port: {{ .Values.kdoctorAgent.httpServer.port }} + port: {{ .Values.kdoctorAgent.httpServer.healthPort }} scheme: HTTP failureThreshold: {{ .Values.kdoctorAgent.httpServer.startupProbe.failureThreshold }} periodSeconds: {{ .Values.kdoctorAgent.httpServer.startupProbe.periodSeconds }} @@ -119,7 +127,7 @@ spec: livenessProbe: httpGet: path: /healthy/liveness - port: {{ .Values.kdoctorAgent.httpServer.port }} + port: {{ .Values.kdoctorAgent.httpServer.healthPort }} scheme: HTTP initialDelaySeconds: 60 periodSeconds: {{ .Values.kdoctorAgent.httpServer.livenessProbe.periodSeconds }} @@ -129,7 +137,7 @@ spec: readinessProbe: httpGet: path: /healthy/readiness - port: {{ .Values.kdoctorAgent.httpServer.port }} + port: {{ .Values.kdoctorAgent.httpServer.healthPort }} scheme: HTTP initialDelaySeconds: 5 periodSeconds: {{ .Values.kdoctorAgent.httpServer.readinessProbe.periodSeconds }} @@ -147,8 +155,12 @@ spec: value: {{ .Values.kdoctorAgent.prometheus.enabled | quote }} - name: ENV_METRIC_HTTP_PORT value: {{ .Values.kdoctorAgent.prometheus.port | quote }} - - name: ENV_HTTP_PORT - value: {{ .Values.kdoctorAgent.httpServer.port | quote }} + - name: ENV_AGENT_HEALTH_HTTP_PORT + value: {{ .Values.kdoctorAgent.httpServer.healthPort | quote }} + - name: ENV_AGENT_APP_HTTP_PORT + value: {{ .Values.kdoctorAgent.httpServer.appHttpPort | quote }} + - name: ENV_AGENT_APP_HTTPS_PORT + value: {{ .Values.kdoctorAgent.httpServer.appHttpsPort | quote }} - name: ENV_GOPS_LISTEN_PORT value: {{ .Values.kdoctorAgent.debug.gopsPort | quote }} - name: ENV_AGENT_GRPC_LISTEN_PORT @@ -192,6 +204,8 @@ spec: readOnly: true - name: report-data mountPath: /report + - name: tls + mountPath: /etc/tls {{- if .Values.kdoctorAgent.extraVolumes }} {{- include "tplvalues.render" ( dict "value" .Values.kdoctorAgent.extraVolumeMounts "context" $ ) | nindent 12 }} {{- end }} @@ -205,6 +219,17 @@ spec: hostPath: path: {{ .Values.kdoctorAgent.reportHostPath }} type: DirectoryOrCreate + - name: tls + projected: + defaultMode: 0400 + sources: + - secret: + items: + - key: tls.key + path: ca.key + - key: tls.crt + path: ca.crt + name: {{ .Values.tls.ca.secretName }} {{- if .Values.kdoctorAgent.extraVolumeMounts }} {{- include "tplvalues.render" ( dict "value" .Values.kdoctorAgent.extraVolumeMounts "context" $ ) | nindent 6 }} {{- end }} diff --git a/charts/templates/ingress.yaml b/charts/templates/ingress.yaml index c5072645..2029ae0d 100644 --- a/charts/templates/ingress.yaml +++ b/charts/templates/ingress.yaml @@ -21,5 +21,5 @@ spec: name: {{ include "project.kdoctorAgent.serviceIpv6Name" . }} {{- end }} port: - number: {{ .Values.kdoctorAgent.httpServer.port }} + number: {{ .Values.kdoctorAgent.httpServer.appHttpPort }} {{- end }} \ No newline at end of file diff --git a/charts/templates/service.yaml b/charts/templates/service.yaml index 07e0a7a8..c26610e1 100644 --- a/charts/templates/service.yaml +++ b/charts/templates/service.yaml @@ -29,9 +29,13 @@ spec: {{- end }} {{- if .Values.feature.enableIPv4 }} - name: http - port: {{ .Values.kdoctorAgent.httpServer.port }} + port: {{ .Values.kdoctorAgent.httpServer.appHttpPort }} targetPort: http protocol: TCP + - name: https + port: {{ .Values.kdoctorAgent.httpServer.appHttpsPort }} + targetPort: https + protocol: TCP {{- end }} ipFamilyPolicy: SingleStack ipFamilies: @@ -71,9 +75,13 @@ spec: {{- end }} {{- if .Values.feature.enableIPv6 }} - name: http - port: {{ .Values.kdoctorAgent.httpServer.port }} + port: {{ .Values.kdoctorAgent.httpServer.appHttpPort }} targetPort: http protocol: TCP + - name: https + port: {{ .Values.kdoctorAgent.httpServer.appHttpsPort }} + targetPort: https + protocol: TCP {{- end }} ipFamilyPolicy: SingleStack ipFamilies: diff --git a/charts/templates/tls.yaml b/charts/templates/tls.yaml index fa547925..418e6a51 100644 --- a/charts/templates/tls.yaml +++ b/charts/templates/tls.yaml @@ -1,7 +1,4 @@ -{{- if (eq .Values.kdoctorController.tls.method "auto") }} {{- $_ := include "generate-ca-certs" . }} -{{- end }} - apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: @@ -247,4 +244,29 @@ data: ca.crt: {{ .ca.Cert | b64enc }} tls.crt: {{ $cert.Cert | b64enc }} tls.key: {{ $cert.Key | b64enc }} -{{- end }} \ No newline at end of file +{{- end }} + +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.tls.ca.secretName | trunc 63 | trimSuffix "-" }} + namespace: {{ .Release.Namespace }} +type: kubernetes.io/tls +data: + tls.crt: {{ .ca.Cert | b64enc }} + tls.key: {{ .ca.Key | b64enc }} + +--- +{{- $cn := printf "kdoctor.io" }} +{{- $cert := genSignedCert $cn (list) (list) 73000 .ca }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.tls.client.secretName | trunc 63 | trimSuffix "-" }} + namespace: {{ .Release.Namespace }} +type: kubernetes.io/tls +data: + ca.crt: {{ .ca.Cert | b64enc }} + tls.crt: {{ $cert.Cert | b64enc }} + tls.key: {{ $cert.Key | b64enc }} diff --git a/charts/values.yaml b/charts/values.yaml index 87058806..cf1427c7 100644 --- a/charts/values.yaml +++ b/charts/values.yaml @@ -26,6 +26,7 @@ global: ## @param global.configName the configmap name configName: "kdoctor" + ## @section feature parameters feature: ## @param feature.enableIPv4 enable ipv4 @@ -250,8 +251,12 @@ kdoctorAgent: port: 3000 httpServer: - ## @param kdoctorAgent.httpServer.port the http Port for kdoctorAgent, for health checking - port: 80 + ## @param kdoctorAgent.httpServer.healthPort the http Port for kdoctorAgent, for health checking + healthPort: 5710 + ## @param kdoctorAgent.httpServer.appPort the http Port for kdoctorAgent, testing connect + appHttpPort: 80 + ## @param kdoctorAgent.httpServer.appPort the https Port for kdoctorAgent, testing connect + appHttpsPort: 443 startupProbe: ## @param kdoctorAgent.httpServer.startupProbe.failureThreshold the failure threshold of startup probe for kdoctorAgent health checking @@ -323,8 +328,6 @@ kdoctorAgent: ## @param kdoctorAgent.debug.gopsPort the gops port of template agent gopsPort: 5712 -## @section kdoctorController parameters -## kdoctorController: ## @param kdoctorController.name the kdoctorController name name: "kdoctor-controller" @@ -592,3 +595,14 @@ kdoctorController: apiserver: ## @param kdoctorApiserver.name the kdoctorApiserver name name: "kdoctor-apiserver" + +## TLS configuration for kdoctor +tls: + ca: + ## @param tls.ca.secretName the secret name for storing TLS certificates + secretName: "kdoctor-ca" + + ## TLS configuration for kdoctor client + client: + ## @param tls.ca.client.secretName the secret name for storing TLS certificates + secretName: "kdoctor-client-cert" diff --git a/cmd/agent/cmd/cert.go b/cmd/agent/cmd/cert.go new file mode 100644 index 00000000..6df19fc2 --- /dev/null +++ b/cmd/agent/cmd/cert.go @@ -0,0 +1,104 @@ +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package cmd + +import ( + "context" + "fmt" + k8sObjManager "github.com/kdoctor-io/kdoctor/pkg/k8ObjManager" + "github.com/kdoctor-io/kdoctor/pkg/types" + "github.com/kdoctor-io/kdoctor/pkg/utils" + "go.uber.org/zap" + "net" + "strings" +) + +var ( + TlsCertPath = "/tmp/cert.crt" + TlsKeyPath = "/tmp/key.crt" + CaCertPath = "/tmp/ca.crt" +) + +func GenServerCert(logger *zap.Logger) { + + // get svc domain and ip + alternateIP := []net.IP{} + alternateDNS := []string{} + servicePortName := "http" + + if types.AgentConfig.Configmap.EnableIPv4 { + serviceIPv4, err := k8sObjManager.GetK8sObjManager().GetServiceAccessUrl(context.Background(), types.AgentConfig.Configmap.AgentSerivceIpv4Name, types.AgentConfig.PodNamespace, servicePortName) + if err != nil { + logger.Sugar().Fatalf("failed to get kdoctor ipv4 service %s/%s, reason=%v ", types.AgentConfig.PodNamespace, types.AgentConfig.Configmap.AgentSerivceIpv4Name, err) + } + logger.Sugar().Debugf("get ipv4 serviceAccessurl %v", serviceIPv4) + // ipv4 ip + for _, v := range serviceIPv4.ClusterIPUrl { + host, _, err := net.SplitHostPort(v) + if err != nil { + logger.Sugar().Errorf("ip addr %s split host port err,reason: %v ", v, err) + continue + } + alternateIP = append(alternateIP, net.ParseIP(host)) + } + + for _, v := range serviceIPv4.LoadBalancerUrl { + host, _, err := net.SplitHostPort(v) + if err != nil { + logger.Sugar().Errorf("ip addr %s split host port err,reason: %v ", v, err) + continue + } + alternateIP = append(alternateIP, net.ParseIP(host)) + } + + // ipv4 dns + alternateDNS = append(alternateDNS, types.AgentConfig.Configmap.AgentSerivceIpv4Name) + domain := fmt.Sprintf("%s.%s", types.AgentConfig.Configmap.AgentSerivceIpv4Name, types.AgentConfig.PodNamespace) + alternateDNS = append(alternateDNS, domain) + alternateDNS = append(alternateDNS, fmt.Sprintf("%s.svc", domain)) + alternateDNS = append(alternateDNS, fmt.Sprintf("%s.svc.cluster.local", domain)) + } + + if types.AgentConfig.Configmap.EnableIPv6 { + serviceIPv6, err := k8sObjManager.GetK8sObjManager().GetServiceAccessUrl(context.Background(), types.AgentConfig.Configmap.AgentSerivceIpv6Name, types.AgentConfig.PodNamespace, servicePortName) + if err != nil { + logger.Sugar().Fatalf("failed to get kdoctor ipv4 service %s/%s, reason=%v ", types.AgentConfig.PodNamespace, types.AgentConfig.Configmap.AgentSerivceIpv6Name, err) + } + // ipv6 ip + logger.Sugar().Debugf("get ipv6 serviceAccessurl %v", serviceIPv6) + for _, v := range serviceIPv6.ClusterIPUrl { + p := strings.LastIndex(v, ":") + host := net.ParseIP(v[:p]) + if len(host) == 0 { + logger.Sugar().Errorf("parse ip %s err", v[:p]) + continue + } + alternateIP = append(alternateIP, host) + } + for _, v := range serviceIPv6.LoadBalancerUrl { + p := strings.LastIndex(v, ":") + host := net.ParseIP(v[:p]) + if len(host) == 0 { + logger.Sugar().Errorf("parse ip %s err", v[:p]) + continue + } + alternateIP = append(alternateIP, host) + } + + // ipv6 dns + alternateDNS = append(alternateDNS, types.AgentConfig.Configmap.AgentSerivceIpv6Name) + domain := fmt.Sprintf("%s.%s", types.AgentConfig.Configmap.AgentSerivceIpv6Name, types.AgentConfig.PodNamespace) + alternateDNS = append(alternateDNS, domain) + alternateDNS = append(alternateDNS, fmt.Sprintf("%s.svc", domain)) + alternateDNS = append(alternateDNS, fmt.Sprintf("%s.svc.cluster.local", domain)) + } + + alternateDNS = append(alternateDNS, types.AgentConfig.PodName) + logger.Sugar().Debugf("alternate ip for tls cert: %v", alternateIP) + logger.Sugar().Debugf("alternate dns for tls cert: %v", alternateDNS) + // generate self-signed certificates + if e := utils.NewServerCertKeyForLocalNode(alternateDNS, alternateIP, types.AgentConfig.TlsCaCertPath, types.AgentConfig.TlsCaKeyPath, TlsCertPath, TlsKeyPath, CaCertPath); e != nil { + logger.Sugar().Fatalf("failed to generate certiface, error=%v", e) + } +} diff --git a/cmd/agent/cmd/config.go b/cmd/agent/cmd/config.go index 50b50696..ab56b9da 100644 --- a/cmd/agent/cmd/config.go +++ b/cmd/agent/cmd/config.go @@ -71,6 +71,9 @@ func init() { globalFlag := rootCmd.PersistentFlags() globalFlag.StringVarP(&types.AgentConfig.ConfigMapPath, "config-path", "C", "", "configmap file path") globalFlag.BoolVarP(&types.AgentConfig.AppMode, "app-mode", "A", false, "app mode") + globalFlag.BoolVarP(&types.AgentConfig.TlsInsecure, "tls-insecure", "K", true, "skip verify tls") + globalFlag.StringVarP(&types.AgentConfig.TlsCaCertPath, "tls-ca-cert", "R", "/etc/tls/ca.crt", "ca file path") + globalFlag.StringVarP(&types.AgentConfig.TlsCaKeyPath, "tls-ca-key", "Y", "/etc/tls/ca.key", "ca key file path") if e := viper.BindPFlags(globalFlag); e != nil { logger.Sugar().Fatalf("failed to BindPFlags, reason=%v", e) } diff --git a/cmd/agent/cmd/daemon.go b/cmd/agent/cmd/daemon.go index 902b9a20..948a7292 100644 --- a/cmd/agent/cmd/daemon.go +++ b/cmd/agent/cmd/daemon.go @@ -4,9 +4,17 @@ package cmd import ( + agenthttpserver "github.com/kdoctor-io/kdoctor/pkg/agentHttpServer" "github.com/kdoctor-io/kdoctor/pkg/debug" + k8sObjManager "github.com/kdoctor-io/kdoctor/pkg/k8ObjManager" "github.com/kdoctor-io/kdoctor/pkg/pluginManager" "github.com/kdoctor-io/kdoctor/pkg/types" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" ) func SetupUtility() { @@ -24,15 +32,41 @@ func SetupUtility() { func DaemonMain() { rootLogger.Sugar().Infof("config: %+v", types.AgentConfig) - SetupHttpServer() - initGrpcServer() // TODO: udp server, tcp server, websocket server - if types.AgentConfig.AppMode { // app mode, just used to debug rootLogger.Info("run in app mode") - // sleep forever - select {} + scheme := runtime.NewScheme() + if err := clientgoscheme.AddToScheme(scheme); err != nil { + rootLogger.Sugar().Fatalf("failed to add to scheme, reason=%v", err) + } + + n := ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: "0", + HealthProbeBindAddress: "0", + LeaderElection: false, + // for this not watched obj, get directly from api-server + ClientDisableCacheFor: []client.Object{ + &corev1.Node{}, + &corev1.Namespace{}, + &corev1.Pod{}, + &corev1.Service{}, + &appsv1.Deployment{}, + &appsv1.StatefulSet{}, + &appsv1.ReplicaSet{}, + &appsv1.DaemonSet{}, + }, + } + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), n) + if err != nil { + rootLogger.Sugar().Fatalf("failed to NewManager, reason=%v", err) + } + + if e := k8sObjManager.Initk8sObjManager(mgr.GetClient()); e != nil { + rootLogger.Sugar().Fatalf("failed to Initk8sObjManager, error=%v", e) + } + } else { rootLogger.Info("run in agent mode") @@ -43,9 +77,14 @@ func DaemonMain() { s := pluginManager.InitPluginManager(rootLogger.Named("agentContorller")) s.RunAgentController() - rootLogger.Info("finish initialization") - // sleep forever - select {} } + rootLogger.Sugar().Info("generate server cert and key") + GenServerCert(rootLogger) + agenthttpserver.SetupHealthHttpServer(rootLogger) + agenthttpserver.SetupAppHttpServer(rootLogger, TlsCertPath, TlsKeyPath) + initGrpcServer() + rootLogger.Info("finish initialization") + // sleep forever + select {} } diff --git a/cmd/agent/cmd/grpcServer.go b/cmd/agent/cmd/grpcServer.go index a0927030..1f8f5598 100644 --- a/cmd/agent/cmd/grpcServer.go +++ b/cmd/agent/cmd/grpcServer.go @@ -7,27 +7,13 @@ import ( "fmt" "github.com/kdoctor-io/kdoctor/pkg/grpcManager" "github.com/kdoctor-io/kdoctor/pkg/types" - "github.com/kdoctor-io/kdoctor/pkg/utils" -) - -const ( - tlsCertPath = "/tmp/cert.crt" - tlsKeyPath = "/tmp/key.crt" - tlsCaPath = "/tmp/ca.crt" ) func initGrpcServer() { // ---- grpc server rootLogger.Info("start grpc server") - alternateDNS := []string{} - alternateDNS = append(alternateDNS, types.AgentConfig.PodName) - // generate self-signed certificates - if e := utils.NewServerCertKeyForLocalNode(alternateDNS, tlsCertPath, tlsKeyPath, tlsCaPath); e != nil { - rootLogger.Sugar().Fatalf("failed to generate certiface, error=%v", e) - } - - t := grpcManager.NewGrpcServer(rootLogger, tlsCertPath, tlsKeyPath) + t := grpcManager.NewGrpcServer(rootLogger, TlsCertPath, TlsKeyPath) listenAddr := fmt.Sprintf(":%d", types.AgentConfig.AgentGrpcListenPort) t.Run(listenAddr) } diff --git a/cmd/agent/cmd/httpServer.go b/cmd/agent/cmd/httpServer.go deleted file mode 100644 index 6f009f48..00000000 --- a/cmd/agent/cmd/httpServer.go +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2023 Authors of kdoctor-io -// SPDX-License-Identifier: Apache-2.0 - -package cmd - -import ( - "fmt" - "github.com/go-openapi/loads" - "github.com/go-openapi/runtime/middleware" - "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" - "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server" - "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server/restapi" - "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server/restapi/echo" - "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server/restapi/healthy" - "github.com/kdoctor-io/kdoctor/pkg/types" - "go.uber.org/zap" - "os" -) - -// ---------- test request Handler - -var ( - DefaultInformation = map[string]string{ - "/kdoctoragent": "route to print request", - } -) - -// ---------- "/" route -type echoHandler struct { - logger *zap.Logger -} - -func (s *echoHandler) Handle(r echo.GetParams) middleware.Responder { - s.logger.Debug("HTTP request from " + r.HTTPRequest.RemoteAddr) - - hostname := types.AgentConfig.PodName - if len(hostname) == 0 { - hostname, _ = os.Hostname() - } - head := map[string]string{} - for k, v := range r.HTTPRequest.Header { - t := "" - for _, m := range v { - t += " " + m + " " - } - head[k] = t - } - - t := echo.NewGetOK() - t.Payload = &models.EchoRes{ - ClientIP: r.HTTPRequest.RemoteAddr, - RequestHeader: head, - RequestURL: r.HTTPRequest.RequestURI, - ServerName: hostname, - OtherDetail: DefaultInformation, - } - return t -} - -// ---------- route "/kdoctoragent" - -type echoAgentHandler struct { - logger *zap.Logger -} - -func (s *echoAgentHandler) Handle(r echo.GetParams) middleware.Responder { - m := r.HTTPRequest - return (&echoHandler{logger: s.logger}).Handle(echo.GetParams{ - HTTPRequest: m, - }) -} - -// ---------- readiness Healthy Handler -type readinessHealthyHandler struct { - logger *zap.Logger -} - -func (s *readinessHealthyHandler) Handle(r healthy.GetHealthyReadinessParams) middleware.Responder { - // return healthy.NewGetHealthyReadinessInternalServerError() - return healthy.NewGetHealthyReadinessOK() -} - -// ---------- liveness Healthy Handler -type livenessHealthyHandler struct { - logger *zap.Logger -} - -func (s *livenessHealthyHandler) Handle(r healthy.GetHealthyLivenessParams) middleware.Responder { - return healthy.NewGetHealthyLivenessOK() -} - -// ---------- startup Healthy Handler -type startupHealthyHandler struct { - logger *zap.Logger -} - -func (s *startupHealthyHandler) Handle(r healthy.GetHealthyStartupParams) middleware.Responder { - - return healthy.NewGetHealthyStartupOK() -} - -// ==================== - -func SetupHttpServer() { - logger := rootLogger.Named("http") - - if types.AgentConfig.HttpPort == 0 { - logger.Sugar().Warn("http server is disabled") - return - } - logger.Sugar().Infof("setup http server at port %v", types.AgentConfig.HttpPort) - - spec, err := loads.Embedded(server.SwaggerJSON, server.FlatSwaggerJSON) - if err != nil { - logger.Sugar().Fatalf("failed to load Swagger spec, reason=%v ", err) - } - - api := restapi.NewHTTPServerAPIAPI(spec) - api.Logger = func(s string, i ...interface{}) { - logger.Sugar().Infof(s, i) - } - - // setup route - api.HealthyGetHealthyReadinessHandler = &readinessHealthyHandler{logger: logger.Named("route: readiness health")} - api.HealthyGetHealthyLivenessHandler = &livenessHealthyHandler{logger: logger.Named("route: liveness health")} - api.HealthyGetHealthyStartupHandler = &startupHealthyHandler{logger: logger.Named("route: startup health")} - api.EchoGetHandler = &echoHandler{logger: logger.Named("route: request")} - api.EchoGetHandler = &echoAgentHandler{logger: logger.Named("route: request")} - - // - srv := server.NewServer(api) - srv.EnabledListeners = []string{"http"} - // srv.EnabledListeners = []string{"unix"} - // srv.SocketPath = "/var/run/http-server-api.sock" - - // default to listen on "0.0.0.0" and "::1" - // srv.Host = "0.0.0.0" - srv.Port = int(types.AgentConfig.HttpPort) - srv.ConfigureAPI() - - go func() { - e := srv.Serve() - s := "http server break" - if e != nil { - s += fmt.Sprintf(" reason=%v", e) - } - logger.Fatal(s) - }() - -} diff --git a/go.mod b/go.mod index 845e2d75..e4022029 100644 --- a/go.mod +++ b/go.mod @@ -55,7 +55,7 @@ require ( github.com/go-openapi/spec v0.20.9 github.com/go-openapi/strfmt v0.21.7 github.com/go-openapi/swag v0.22.3 - github.com/go-openapi/validate v0.22.1 // indirect + github.com/go-openapi/validate v0.22.1 github.com/go-swagger/go-swagger v0.30.4 k8s.io/kube-openapi v0.0.0-20221110221610-a28e98eb7c70 // indirect ) @@ -82,6 +82,7 @@ require ( github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/fatih/color v1.13.0 // indirect github.com/felixge/httpsnoop v1.0.3 // indirect + github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -90,6 +91,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect + github.com/google/btree v1.1.2 // indirect github.com/google/cel-go v0.12.6 // indirect github.com/google/gnostic v0.6.9 // indirect github.com/google/go-cmp v0.5.9 // indirect @@ -103,6 +105,7 @@ require ( github.com/huandu/xstrings v1.3.3 // indirect github.com/imdario/mergo v0.3.13 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jonboulle/clockwork v0.3.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0 // indirect diff --git a/go.sum b/go.sum index 886b7150..f0ea07d6 100644 --- a/go.sum +++ b/go.sum @@ -126,7 +126,8 @@ github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c= +github.com/form3tech-oss/jwt-go v3.2.5+incompatible h1:/l4kBbb4/vGSsdtB5nUe8L7B9mImVMaBPw9L/0TBHU8= +github.com/form3tech-oss/jwt-go v3.2.5+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= @@ -258,7 +259,8 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/cel-go v0.12.6 h1:kjeKudqV0OygrAqA9fX6J55S8gj+Jre2tckIm5RoG4M= github.com/google/cel-go v0.12.6/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= @@ -334,7 +336,8 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= +github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= +github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= diff --git a/pkg/agentHttpServer/appHttpServer.go b/pkg/agentHttpServer/appHttpServer.go new file mode 100644 index 00000000..9726db23 --- /dev/null +++ b/pkg/agentHttpServer/appHttpServer.go @@ -0,0 +1,451 @@ +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package agenthttpserver + +import ( + "fmt" + "github.com/go-openapi/loads" + "github.com/go-openapi/runtime/middleware" + "github.com/jessevdk/go-flags" + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/models" + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server" + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server/restapi" + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server/restapi/echo" + "github.com/kdoctor-io/kdoctor/pkg/types" + "go.uber.org/zap" + "os" + "sync/atomic" + "time" +) + +var ( + ParamInformation = map[string]string{ + "delay": "in query, delay some second return response", + } + SupportedMethod = []string{"GET", "PUT", "POST", "DELETE", "HEAD", "PATCH", "OPTIONS"} + requestCounts int64 = 0 + + HttpsCertPath = "/etc/app-tls/tls.crt" + HttpsKeyPath = "/etc/app-tls/tls.key" +) + +// route / +// ---------- get +type echoGetHandler struct { + logger *zap.Logger +} + +func (s *echoGetHandler) Handle(r echo.GetParams) middleware.Responder { + if r.Delay != nil { + s.logger.Sugar().Debugf("%s method %s delay %d request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, *r.Delay, r.HTTPRequest.RemoteAddr) + } else { + s.logger.Sugar().Debugf("%s method %s delay 0 request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, r.HTTPRequest.RemoteAddr) + } + + hostname := types.AgentConfig.PodName + if len(hostname) == 0 { + hostname, _ = os.Hostname() + } + head := map[string]string{} + for k, v := range r.HTTPRequest.Header { + t := "" + for _, m := range v { + t += " " + m + " " + } + head[k] = t + } + atomic.AddInt64(&requestCounts, 1) + t := echo.NewGetOK() + t.Payload = &models.EchoRes{ + ClientIP: r.HTTPRequest.RemoteAddr, + RequestHeader: head, + RequestURL: r.HTTPRequest.RequestURI, + RequestMethod: r.HTTPRequest.Method, + ServerName: hostname, + RequestCount: atomic.LoadInt64(&requestCounts), + ParamDetail: ParamInformation, + SupportedMethod: SupportedMethod, + } + if r.Delay != nil { + time.Sleep(time.Duration(*r.Delay) * time.Second) + t.Payload.RequestParam = fmt.Sprintf("delay=%d", *r.Delay) + } + return t +} + +// -----------delete +type echoDeleteHandler struct { + logger *zap.Logger +} + +func (s *echoDeleteHandler) Handle(r echo.DeleteParams) middleware.Responder { + atomic.StoreInt64(&requestCounts, 0) + return echo.NewDeleteOK() +} + +// ----------- put +type echoPutHandler struct { + logger *zap.Logger +} + +func (s *echoPutHandler) Handle(r echo.PutParams) middleware.Responder { + if r.Delay != nil { + s.logger.Sugar().Debugf("%s method %s delay %d request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, *r.Delay, r.HTTPRequest.RemoteAddr) + } else { + s.logger.Sugar().Debugf("%s method %s delay 0 request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, r.HTTPRequest.RemoteAddr) + } + hostname := types.AgentConfig.PodName + if len(hostname) == 0 { + hostname, _ = os.Hostname() + } + head := map[string]string{} + for k, v := range r.HTTPRequest.Header { + t := "" + for _, m := range v { + t += " " + m + " " + } + head[k] = t + } + t := echo.NewPutOK() + t.Payload = &models.EchoRes{ + ClientIP: r.HTTPRequest.RemoteAddr, + RequestHeader: head, + RequestURL: r.HTTPRequest.RequestURI, + RequestMethod: r.HTTPRequest.Method, + ServerName: hostname, + RequestCount: atomic.LoadInt64(&requestCounts), + ParamDetail: ParamInformation, + SupportedMethod: SupportedMethod, + } + if r.Delay != nil { + time.Sleep(time.Duration(*r.Delay) * time.Second) + t.Payload.RequestParam = fmt.Sprintf("delay=%d", *r.Delay) + } + + return t +} + +// ----------- post +type echoPostHandler struct { + logger *zap.Logger +} + +func (s *echoPostHandler) Handle(r echo.PostParams) middleware.Responder { + if r.Delay != nil { + s.logger.Sugar().Debugf("%s method %s delay %d request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, *r.Delay, r.HTTPRequest.RemoteAddr) + } else { + s.logger.Sugar().Debugf("%s method %s delay 0 request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, r.HTTPRequest.RemoteAddr) + } + hostname := types.AgentConfig.PodName + if len(hostname) == 0 { + hostname, _ = os.Hostname() + } + head := map[string]string{} + for k, v := range r.HTTPRequest.Header { + t := "" + for _, m := range v { + t += " " + m + " " + } + head[k] = t + } + t := echo.NewPostOK() + t.Payload = &models.EchoRes{ + ClientIP: r.HTTPRequest.RemoteAddr, + RequestHeader: head, + RequestURL: r.HTTPRequest.RequestURI, + RequestMethod: r.HTTPRequest.Method, + ServerName: hostname, + RequestCount: atomic.LoadInt64(&requestCounts), + ParamDetail: ParamInformation, + SupportedMethod: SupportedMethod, + } + + body, _ := r.TestArgs.MarshalBinary() + t.Payload.RequestBody = string(body) + + if r.Delay != nil { + time.Sleep(time.Duration(*r.Delay) * time.Second) + t.Payload.RequestParam = fmt.Sprintf("delay=%d", *r.Delay) + } else { + t.Payload.RequestParam = "delay=0" + } + return t +} + +// ----------- head +type echoHeadHandler struct { + logger *zap.Logger +} + +func (s *echoHeadHandler) Handle(r echo.HeadParams) middleware.Responder { + + return echo.NewHeadOK() +} + +// ----------- options +type echoOptionsHandler struct { + logger *zap.Logger +} + +func (s *echoOptionsHandler) Handle(r echo.OptionsParams) middleware.Responder { + p := echo.NewPutParams() + p.HTTPRequest = r.HTTPRequest + p.Delay = r.Delay + return (&echoPutHandler{logger: s.logger}).Handle(p) +} + +// ----------- patch +type echoPatchHandler struct { + logger *zap.Logger +} + +func (s *echoPatchHandler) Handle(r echo.PatchParams) middleware.Responder { + p := echo.NewPutParams() + p.HTTPRequest = r.HTTPRequest + p.Delay = r.Delay + return (&echoPutHandler{logger: s.logger}).Handle(p) +} + +// route /kdoctoragent +// ---------- get +type echoKdoctorGetHandler struct { + logger *zap.Logger +} + +func (s *echoKdoctorGetHandler) Handle(r echo.GetKdoctoragentParams) middleware.Responder { + if r.Delay != nil { + s.logger.Sugar().Debugf("%s method %s delay %d request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, *r.Delay, r.HTTPRequest.RemoteAddr) + } else { + s.logger.Sugar().Debugf("%s method %s delay 0 request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, r.HTTPRequest.RemoteAddr) + } + + hostname := types.AgentConfig.PodName + if len(hostname) == 0 { + hostname, _ = os.Hostname() + } + head := map[string]string{} + for k, v := range r.HTTPRequest.Header { + t := "" + for _, m := range v { + t += " " + m + " " + } + head[k] = t + } + atomic.AddInt64(&requestCounts, 1) + t := echo.NewGetKdoctoragentOK() + t.Payload = &models.EchoRes{ + ClientIP: r.HTTPRequest.RemoteAddr, + RequestHeader: head, + RequestURL: r.HTTPRequest.RequestURI, + RequestMethod: r.HTTPRequest.Method, + ServerName: hostname, + RequestCount: atomic.LoadInt64(&requestCounts), + ParamDetail: ParamInformation, + SupportedMethod: SupportedMethod, + } + if r.Delay != nil { + time.Sleep(time.Duration(*r.Delay) * time.Second) + t.Payload.RequestParam = fmt.Sprintf("delay=%d", *r.Delay) + } + return t +} + +// -----------delete +type echoKdoctorDeleteHandler struct { + logger *zap.Logger +} + +func (s *echoKdoctorDeleteHandler) Handle(r echo.DeleteKdoctoragentParams) middleware.Responder { + atomic.StoreInt64(&requestCounts, 0) + return echo.NewDeleteKdoctoragentOK() +} + +// ----------- put +type echoKdoctorPutHandler struct { + logger *zap.Logger +} + +func (s *echoKdoctorPutHandler) Handle(r echo.PutKdoctoragentParams) middleware.Responder { + if r.Delay != nil { + s.logger.Sugar().Debugf("%s method %s delay %d request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, *r.Delay, r.HTTPRequest.RemoteAddr) + } else { + s.logger.Sugar().Debugf("%s method %s delay 0 request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, r.HTTPRequest.RemoteAddr) + } + hostname := types.AgentConfig.PodName + if len(hostname) == 0 { + hostname, _ = os.Hostname() + } + head := map[string]string{} + for k, v := range r.HTTPRequest.Header { + t := "" + for _, m := range v { + t += " " + m + " " + } + head[k] = t + } + t := echo.NewPutKdoctoragentOK() + t.Payload = &models.EchoRes{ + ClientIP: r.HTTPRequest.RemoteAddr, + RequestHeader: head, + RequestURL: r.HTTPRequest.RequestURI, + RequestMethod: r.HTTPRequest.Method, + ServerName: hostname, + RequestCount: atomic.LoadInt64(&requestCounts), + ParamDetail: ParamInformation, + SupportedMethod: SupportedMethod, + } + if r.Delay != nil { + time.Sleep(time.Duration(*r.Delay) * time.Second) + t.Payload.RequestParam = fmt.Sprintf("delay=%d", *r.Delay) + } + + return t +} + +// ----------- post +type echoKdoctorPostHandler struct { + logger *zap.Logger +} + +func (s *echoKdoctorPostHandler) Handle(r echo.PostKdoctoragentParams) middleware.Responder { + if r.Delay != nil { + s.logger.Sugar().Debugf("%s method %s delay %d request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, *r.Delay, r.HTTPRequest.RemoteAddr) + } else { + s.logger.Sugar().Debugf("%s method %s delay 0 request from %s", r.HTTPRequest.Proto, r.HTTPRequest.Method, r.HTTPRequest.RemoteAddr) + } + hostname := types.AgentConfig.PodName + if len(hostname) == 0 { + hostname, _ = os.Hostname() + } + head := map[string]string{} + for k, v := range r.HTTPRequest.Header { + t := "" + for _, m := range v { + t += " " + m + " " + } + head[k] = t + } + t := echo.NewPostKdoctoragentOK() + t.Payload = &models.EchoRes{ + ClientIP: r.HTTPRequest.RemoteAddr, + RequestHeader: head, + RequestURL: r.HTTPRequest.RequestURI, + RequestMethod: r.HTTPRequest.Method, + ServerName: hostname, + RequestCount: atomic.LoadInt64(&requestCounts), + ParamDetail: ParamInformation, + SupportedMethod: SupportedMethod, + } + + body, _ := r.TestArgs.MarshalBinary() + t.Payload.RequestBody = string(body) + + if r.Delay != nil { + time.Sleep(time.Duration(*r.Delay) * time.Second) + t.Payload.RequestParam = fmt.Sprintf("delay=%d", *r.Delay) + } else { + t.Payload.RequestParam = "delay=0" + } + return t +} + +// ----------- head +type echoKdoctorHeadHandler struct { + logger *zap.Logger +} + +func (s *echoKdoctorHeadHandler) Handle(r echo.HeadKdoctoragentParams) middleware.Responder { + + return echo.NewHeadKdoctoragentOK() +} + +// ----------- options +type echoKdoctorOptionsHandler struct { + logger *zap.Logger +} + +func (s *echoKdoctorOptionsHandler) Handle(r echo.OptionsKdoctoragentParams) middleware.Responder { + p := echo.NewPutKdoctoragentParams() + p.HTTPRequest = r.HTTPRequest + p.Delay = r.Delay + return (&echoKdoctorPutHandler{logger: s.logger}).Handle(p) +} + +// ----------- patch +type echoKdoctorPatchHandler struct { + logger *zap.Logger +} + +func (s *echoKdoctorPatchHandler) Handle(r echo.PatchKdoctoragentParams) middleware.Responder { + p := echo.NewPutKdoctoragentParams() + p.HTTPRequest = r.HTTPRequest + p.Delay = r.Delay + return (&echoKdoctorPutHandler{logger: s.logger}).Handle(p) +} + +func SetupAppHttpServer(rootLogger *zap.Logger, tlsCert, tlsKey string) { + logger := rootLogger.Named("app http") + + if types.AgentConfig.AppHttpPort == 0 { + logger.Sugar().Warn("app http server is disabled") + return + } + + spec, err := loads.Embedded(server.SwaggerJSON, server.FlatSwaggerJSON) + if err != nil { + logger.Sugar().Fatalf("failed to load Swagger spec, reason=%v ", err) + } + + api := restapi.NewHTTPServerAPIAPI(spec) + api.Logger = func(s string, i ...interface{}) { + logger.Sugar().Infof(s, i) + } + + // setup route "/" + api.EchoGetHandler = &echoGetHandler{logger: logger.Named("route: request")} + api.EchoDeleteHandler = &echoDeleteHandler{logger: logger.Named("route: summary counts")} + api.EchoPostHandler = &echoPostHandler{logger: logger.Named("route: summary counts")} + api.EchoPutHandler = &echoPutHandler{logger: logger.Named("route: summary counts")} + api.EchoHeadHandler = &echoHeadHandler{logger: logger.Named("route: summary counts")} + api.EchoOptionsHandler = &echoOptionsHandler{logger: logger.Named("route: summary counts")} + api.EchoPatchHandler = &echoPatchHandler{logger: logger.Named("route: summary counts")} + + // setup route "/kdoctoragent" + api.EchoGetKdoctoragentHandler = &echoKdoctorGetHandler{logger: logger.Named("route: request")} + api.EchoDeleteKdoctoragentHandler = &echoKdoctorDeleteHandler{logger: logger.Named("route: summary counts")} + api.EchoPostKdoctoragentHandler = &echoKdoctorPostHandler{logger: logger.Named("route: summary counts")} + api.EchoPutKdoctoragentHandler = &echoKdoctorPutHandler{logger: logger.Named("route: summary counts")} + api.EchoHeadKdoctoragentHandler = &echoKdoctorHeadHandler{logger: logger.Named("route: summary counts")} + api.EchoOptionsKdoctoragentHandler = &echoKdoctorOptionsHandler{logger: logger.Named("route: summary counts")} + api.EchoPatchKdoctoragentHandler = &echoKdoctorPatchHandler{logger: logger.Named("route: summary counts")} + + srvApp := server.NewServer(api) + srvApp.EnabledListeners = []string{"https", "http"} + // http + srvApp.Port = int(types.AgentConfig.AppHttpPort) + // https + srvApp.TLSPort = int(types.AgentConfig.AppHttpsPort) + // verify ca + if !types.AgentConfig.TlsInsecure { + srvApp.TLSCACertificate = flags.Filename(types.AgentConfig.TlsCaCertPath) + logger.Sugar().Infof("agent enabled verify tls") + } else { + logger.Sugar().Infof("agent disabled verify tls") + } + srvApp.TLSCertificate = flags.Filename(tlsCert) + srvApp.TLSCertificateKey = flags.Filename(tlsKey) + + logger.Sugar().Infof("setup agent app http server at port %v", types.AgentConfig.AppHttpPort) + logger.Sugar().Infof("setup agent app https server at port %v", types.AgentConfig.AppHttpsPort) + + srvApp.ConfigureAPI() + go func() { + e := srvApp.Serve() + s := "app http server break" + if e != nil { + s += fmt.Sprintf(" reason=%v", e) + } + logger.Fatal(s) + }() +} diff --git a/pkg/agentHttpServer/healthHttpServer.go b/pkg/agentHttpServer/healthHttpServer.go new file mode 100644 index 00000000..7582ee5d --- /dev/null +++ b/pkg/agentHttpServer/healthHttpServer.go @@ -0,0 +1,83 @@ +// Copyright 2023 Authors of kdoctor-io +// SPDX-License-Identifier: Apache-2.0 + +package agenthttpserver + +import ( + "fmt" + "github.com/go-openapi/loads" + "github.com/go-openapi/runtime/middleware" + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server" + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server/restapi" + "github.com/kdoctor-io/kdoctor/api/v1/agentServer/server/restapi/healthy" + "github.com/kdoctor-io/kdoctor/pkg/types" + "go.uber.org/zap" +) + +// ---------- readiness Healthy Handler +type readinessHealthyHandler struct { + logger *zap.Logger +} + +func (s *readinessHealthyHandler) Handle(r healthy.GetHealthyReadinessParams) middleware.Responder { + // return healthy.NewGetHealthyReadinessInternalServerError() + return healthy.NewGetHealthyReadinessOK() +} + +// ---------- liveness Healthy Handler +type livenessHealthyHandler struct { + logger *zap.Logger +} + +func (s *livenessHealthyHandler) Handle(r healthy.GetHealthyLivenessParams) middleware.Responder { + return healthy.NewGetHealthyLivenessOK() +} + +// ---------- startup Healthy Handler +type startupHealthyHandler struct { + logger *zap.Logger +} + +func (s *startupHealthyHandler) Handle(r healthy.GetHealthyStartupParams) middleware.Responder { + + return healthy.NewGetHealthyStartupOK() +} + +func SetupHealthHttpServer(rootLogger *zap.Logger) { + logger := rootLogger.Named("health http") + + if types.AgentConfig.AgentHealthPort == 0 { + logger.Sugar().Warn("health http server is disabled") + return + } + logger.Sugar().Infof("setup agent health http server at port %v", types.AgentConfig.AgentHealthPort) + + spec, err := loads.Embedded(server.SwaggerJSON, server.FlatSwaggerJSON) + if err != nil { + logger.Sugar().Fatalf("failed to load Swagger spec, reason=%v ", err) + } + + api := restapi.NewHTTPServerAPIAPI(spec) + api.Logger = func(s string, i ...interface{}) { + logger.Sugar().Infof(s, i) + } + + // setup route + api.HealthyGetHealthyReadinessHandler = &readinessHealthyHandler{logger: logger.Named("route: readiness health")} + api.HealthyGetHealthyLivenessHandler = &livenessHealthyHandler{logger: logger.Named("route: liveness health")} + api.HealthyGetHealthyStartupHandler = &startupHealthyHandler{logger: logger.Named("route: startup health")} + + srvHealth := server.NewServer(api) + srvHealth.EnabledListeners = []string{"http"} + srvHealth.Port = int(types.AgentConfig.AgentHealthPort) + srvHealth.ConfigureAPI() + + go func() { + e := srvHealth.Serve() + s := "health http server break" + if e != nil { + s += fmt.Sprintf(" reason=%v", e) + } + logger.Fatal(s) + }() +} diff --git a/pkg/loadRequest/loadHttp/http.go b/pkg/loadRequest/loadHttp/http.go index 21480019..3610e41d 100644 --- a/pkg/loadRequest/loadHttp/http.go +++ b/pkg/loadRequest/loadHttp/http.go @@ -35,7 +35,7 @@ type HttpRequestData struct { PerRequestTimeoutMS int RequestTimeSecond int Header map[string]string - Body string + Body []byte ClientCert tls.Certificate CaCertPool *x509.CertPool Http2 bool @@ -65,8 +65,8 @@ func HttpRequest(logger *zap.Logger, reqData *HttpRequestData) *v1beta1.HttpMetr Http2: reqData.Http2, Cert: reqData.ClientCert, CertPool: reqData.CaCertPool, - RequestBody: []byte(reqData.Body), ExpectStatusCode: reqData.ExpectStatusCode, + RequestBody: reqData.Body, } logger.Sugar().Infof("do http requests work=%v", w) w.Init() diff --git a/pkg/loadRequest/loadHttp/http_requester.go b/pkg/loadRequest/loadHttp/http_requester.go index 887d9054..0394e499 100644 --- a/pkg/loadRequest/loadHttp/http_requester.go +++ b/pkg/loadRequest/loadHttp/http_requester.go @@ -25,6 +25,8 @@ import ( "crypto/x509" "fmt" "github.com/kdoctor-io/kdoctor/pkg/k8s/apis/system/v1beta1" + config "github.com/kdoctor-io/kdoctor/pkg/types" + "github.com/kdoctor-io/kdoctor/pkg/utils/stats" "golang.org/x/net/http2" "io" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -35,9 +37,6 @@ import ( "strconv" "sync" "time" - - config "github.com/kdoctor-io/kdoctor/pkg/types" - "github.com/kdoctor-io/kdoctor/pkg/utils/stats" ) // Max size of the buffer of result channel. @@ -375,7 +374,6 @@ func cloneRequest(r *http.Request, body []byte) *http.Request { } if len(body) > 0 { r2.Body = io.NopCloser(bytes.NewReader(body)) - } return r2 } diff --git a/pkg/pluginManager/apphttphealthy/agentExecuteTask.go b/pkg/pluginManager/apphttphealthy/agentExecuteTask.go index cf6a7802..7e153996 100644 --- a/pkg/pluginManager/apphttphealthy/agentExecuteTask.go +++ b/pkg/pluginManager/apphttphealthy/agentExecuteTask.go @@ -7,6 +7,7 @@ import ( "context" "crypto/tls" "crypto/x509" + "encoding/json" "fmt" k8sObjManager "github.com/kdoctor-io/kdoctor/pkg/k8ObjManager" crd "github.com/kdoctor-io/kdoctor/pkg/k8s/apis/kdoctor.io/v1beta1" @@ -16,6 +17,7 @@ import ( "go.uber.org/zap" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/pointer" + "strings" ) func ParseSuccessCondition(successCondition *crd.NetSuccessCondition, metricResult *v1beta1.HttpMetrics) (failureReason string, err error) { @@ -141,8 +143,8 @@ func (s *PluginAppHttpHealthy) AgentExecuteTask(logger *zap.Logger, ctx context. err = fmt.Errorf(msg) return finalfailureReason, task, err } - body, ok := bodyCM.Data["body"] - if !ok { + body, err := json.Marshal(bodyCM.Data) + if err != nil { msg := fmt.Sprintf("failed get body from [%s/%s] configmap err : %v", *target.BodyConfigNamespace, *target.BodyConfigName, err) logger.Sugar().Errorf(msg) err = fmt.Errorf(msg) @@ -151,6 +153,15 @@ func (s *PluginAppHttpHealthy) AgentExecuteTask(logger *zap.Logger, ctx context. d.Body = body } + if len(target.Header) != 0 { + header := make(map[string]string, len(target.Header)) + for _, v := range target.Header { + h := strings.Split(v, ":") + header[h[0]] = h[1] + } + d.Header = header + } + failureReason, itemReport := SendRequestAndReport(logger, "HttpAppHealthy target", d, successCondition) if len(failureReason) > 0 { finalfailureReason = fmt.Sprintf("test HttpAppHealthy target: %v", failureReason) diff --git a/pkg/pluginManager/netdns/agentExecuteTask.go b/pkg/pluginManager/netdns/agentExecuteTask.go index 5f659e77..44d0601e 100644 --- a/pkg/pluginManager/netdns/agentExecuteTask.go +++ b/pkg/pluginManager/netdns/agentExecuteTask.go @@ -198,10 +198,10 @@ func (s *PluginNetDns) AgentExecuteTask(logger *zap.Logger, ctx context.Context, go func(wg *sync.WaitGroup, l *lock.Mutex, t testTarget) { logger.Sugar().Debugf("implement test %v, request %v ", t.Name, *t.Request) failureReason, itemReport := SendRequestAndReport(logger, t.Name, t.Request, instance.Spec.SuccessCondition) + l.Lock() if failureReason != "" { finalfailureReason = fmt.Sprintf("test %v: %v", t.Name, failureReason) } - l.Lock() reportList = append(reportList, itemReport) l.Unlock() wg.Done() diff --git a/pkg/pluginManager/netreach/agentExecuteTask.go b/pkg/pluginManager/netreach/agentExecuteTask.go index bb85d03d..32ce47de 100644 --- a/pkg/pluginManager/netreach/agentExecuteTask.go +++ b/pkg/pluginManager/netreach/agentExecuteTask.go @@ -125,14 +125,14 @@ func (s *PluginNetReach) AgentExecuteTask(logger *zap.Logger, ctx context.Contex if len(podips.IPv4) > 0 && (target.IPv4 == nil || (target.IPv4 != nil && *target.IPv4)) { testTargetList = append(testTargetList, &TestTarget{ Name: "AgentPodV4IP_" + podname + "_" + podips.IPv4, - Url: fmt.Sprintf("http://%s:%d", podips.IPv4, config.AgentConfig.HttpPort), + Url: fmt.Sprintf("http://%s:%d", podips.IPv4, config.AgentConfig.AppHttpPort), Method: loadHttp.HttpMethodGet, }) } if len(podips.IPv6) > 0 && (target.IPv6 == nil || (target.IPv6 != nil && *target.IPv6)) { testTargetList = append(testTargetList, &TestTarget{ Name: "AgentPodV6IP_" + podname + "_" + podips.IPv6, - Url: fmt.Sprintf("http://%s:%d", podips.IPv6, config.AgentConfig.HttpPort), + Url: fmt.Sprintf("http://%s:%d", podips.IPv6, config.AgentConfig.AppHttpPort), Method: loadHttp.HttpMethodGet, }) } @@ -269,7 +269,7 @@ func (s *PluginNetReach) AgentExecuteTask(logger *zap.Logger, ctx context.Contex if len(agentIngress.Spec.TLS) > 0 { http = "https" } - url := fmt.Sprintf("%s://%s/%s", http, agentIngress.Status.LoadBalancer.Ingress[0].IP, agentIngress.Spec.Rules[0].HTTP.Paths[0].Path) + url := fmt.Sprintf("%s://%s%s", http, agentIngress.Status.LoadBalancer.Ingress[0].IP, agentIngress.Spec.Rules[0].HTTP.Paths[0].Path) testTargetList = append(testTargetList, &TestTarget{ Name: "AgentIngress_" + url, Url: url, @@ -301,10 +301,10 @@ func (s *PluginNetReach) AgentExecuteTask(logger *zap.Logger, ctx context.Contex } logger.Sugar().Debugf("implement test %v, request %v ", t.Name, *d) failureReason, itemReport := SendRequestAndReport(logger, t.Name, d, successCondition) + l.Lock() if len(failureReason) > 0 { finalfailureReason = fmt.Sprintf("test %v: %v", t.Name, failureReason) } - l.Lock() reportList = append(reportList, itemReport) l.Unlock() wg.Done() diff --git a/pkg/types/agent_config.go b/pkg/types/agent_config.go index 24afdce0..ef4d9d56 100644 --- a/pkg/types/agent_config.go +++ b/pkg/types/agent_config.go @@ -6,7 +6,7 @@ package types var AgentEnvMapping = []EnvMapping{ {"ENV_ENABLED_METRIC", "false", &AgentConfig.EnableMetric}, {"ENV_METRIC_HTTP_PORT", "", &AgentConfig.MetricPort}, - {"ENV_HTTP_PORT", "80", &AgentConfig.HttpPort}, + {"ENV_AGENT_HEALTH_HTTP_PORT", "5710", &AgentConfig.AgentHealthPort}, {"ENV_GOPS_LISTEN_PORT", "", &AgentConfig.GopsPort}, {"ENV_WEBHOOK_PORT", "", &AgentConfig.WebhookPort}, {"ENV_PYROSCOPE_PUSH_SERVER_ADDRESS", "", &AgentConfig.PyroscopeServerAddress}, @@ -14,6 +14,8 @@ var AgentEnvMapping = []EnvMapping{ {"ENV_POD_NAMESPACE", "", &AgentConfig.PodNamespace}, {"ENV_GOLANG_MAXPROCS", "8", &AgentConfig.GolangMaxProcs}, {"ENV_AGENT_GRPC_LISTEN_PORT", "3000", &AgentConfig.AgentGrpcListenPort}, + {"ENV_AGENT_APP_HTTP_PORT", "80", &AgentConfig.AppHttpPort}, + {"ENV_AGENT_APP_HTTPS_PORT", "443", &AgentConfig.AppHttpsPort}, {"ENV_ENABLE_AGGREGATE_AGENT_REPORT", "false", &AgentConfig.EnableAggregateAgentReport}, {"ENV_AGENT_REPORT_STORAGE_PATH", "", &AgentConfig.DirPathAgentReport}, {"ENV_CLEAN_AGED_REPORT_INTERVAL_IN_MINUTE", "10", &AgentConfig.CleanAgedReportInMinute}, @@ -26,10 +28,12 @@ type AgentConfigStruct struct { // ------- from env EnableMetric bool MetricPort int32 - HttpPort int32 GopsPort int32 WebhookPort int32 AgentGrpcListenPort int32 + AppHttpPort int32 + AppHttpsPort int32 + AgentHealthPort int32 PyroscopeServerAddress string GolangMaxProcs int32 @@ -44,12 +48,11 @@ type AgentConfigStruct struct { CleanAgedReportInMinute int32 // ------- from flags - ConfigMapPath string - TlsCaCertPath string - TlsServerCertPath string - TlsServerKeyPath string - - AppMode bool + ConfigMapPath string + TlsCaCertPath string + TlsCaKeyPath string + TlsInsecure bool + AppMode bool // from configmap Configmap ConfigmapConfig diff --git a/pkg/utils/cert.go b/pkg/utils/cert.go index 6da613a7..00da5714 100644 --- a/pkg/utils/cert.go +++ b/pkg/utils/cert.go @@ -23,46 +23,74 @@ import ( ) const ( - // 100 years - DefaultCAduration = time.Hour * 24 * 365 * 100 + // 200 years + DefaultCAduration = time.Hour * 24 * 365 * 200 ) // host could be ip or dns -func NewServerCertKey(host string, alternateIPs []net.IP, alternateDNS []string) (serverCert, serverKey, caCert []byte, err error) { - - // ----------- generate self-signed ca +func NewServerCertKey(host string, alternateIPs []net.IP, alternateDNS []string, caCertPath, caKeyPath string) (serverCert, serverKey, caCert []byte, err error) { validFrom := time.Now().Add(-time.Hour) // valid an hour earlier to avoid flakes due to clock skew + var caCertificate *x509.Certificate + var caKey *rsa.PrivateKey + var caDERBytes []byte + // ----------- generate self-signed ca + if caCertPath == "" || caKeyPath == "" { + + caKey, err := rsa.GenerateKey(cryptorand.Reader, 2048) + + if err != nil { + return nil, nil, nil, err + } + + CommonName := types.TlsCaCommonName + Organization := []string{types.TlsCaCommonName} + + tmpl := x509.Certificate{ + SerialNumber: new(big.Int).SetInt64(0), + Subject: pkix.Name{ + CommonName: CommonName, + Organization: Organization, + }, + DNSNames: []string{CommonName}, + NotBefore: validFrom.UTC(), + NotAfter: validFrom.Add(DefaultCAduration).UTC(), + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, + BasicConstraintsValid: true, + IsCA: true, + } + + caDERBytes, err := x509.CreateCertificate(cryptorand.Reader, &tmpl, &tmpl, caKey.Public(), caKey) + if err != nil { + return nil, nil, nil, err + } + + caCertificate, err = x509.ParseCertificate(caDERBytes) + if err != nil { + return nil, nil, nil, err + } + } else { + //read ca cert + caDERBytes, err = os.ReadFile(caCertPath) + if err != nil { + return nil, nil, nil, err + } + blockCert, _ := pem.Decode(caDERBytes) + caCertificate, err = x509.ParseCertificate(blockCert.Bytes) + if err != nil { + return nil, nil, nil, err + } + + //read ca key + cakeyByte, err := os.ReadFile(caKeyPath) + if err != nil { + return nil, nil, nil, err + } + blockKey, _ := pem.Decode(cakeyByte) + caKey, err = x509.ParsePKCS1PrivateKey(blockKey.Bytes) + if err != nil { + return nil, nil, nil, err + } - caKey, err := rsa.GenerateKey(cryptorand.Reader, 2048) - if err != nil { - return nil, nil, nil, err - } - - CommonName := types.TlsCaCommonName - Organization := []string{types.TlsCaCommonName} - - tmpl := x509.Certificate{ - SerialNumber: new(big.Int).SetInt64(0), - Subject: pkix.Name{ - CommonName: CommonName, - Organization: Organization, - }, - DNSNames: []string{CommonName}, - NotBefore: validFrom.UTC(), - NotAfter: validFrom.Add(DefaultCAduration).UTC(), - KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, - BasicConstraintsValid: true, - IsCA: true, - } - - caDERBytes, err := x509.CreateCertificate(cryptorand.Reader, &tmpl, &tmpl, caKey.Public(), caKey) - if err != nil { - return nil, nil, nil, err - } - - caCertificate, err := x509.ParseCertificate(caDERBytes) - if err != nil { - return nil, nil, nil, err } // --------------- server cert @@ -120,9 +148,8 @@ func NewServerCertKey(host string, alternateIPs []net.IP, alternateDNS []string) // generate cert for local host name and local ip, and write to files // alternateDNS could be pod dns name -func NewServerCertKeyForLocalNode(alternateDNS []string, destCertFilePath, destKeyFilePath, destCaFilePath string) error { +func NewServerCertKeyForLocalNode(alternateDNS []string, alternateIPs []net.IP, caCertPath, caKeyPath, destCertFilePath, destKeyFilePath, destCaCertPath string) error { host, _ := os.Hostname() - alternateIPs := []net.IP{} ipv4List, ipv6List, err := GetAllInterfaceUnicastAddrWithoutMask() if err != nil { @@ -131,7 +158,7 @@ func NewServerCertKeyForLocalNode(alternateDNS []string, destCertFilePath, destK alternateIPs = append(alternateIPs, ipv4List...) alternateIPs = append(alternateIPs, ipv6List...) - serverCert, serverKey, caCert, err := NewServerCertKey(host, alternateIPs, alternateDNS) + serverCert, serverKey, caCert, err := NewServerCertKey(host, alternateIPs, alternateDNS, caCertPath, caKeyPath) if err != nil { return err } @@ -139,17 +166,13 @@ func NewServerCertKeyForLocalNode(alternateDNS []string, destCertFilePath, destK if err := cert.WriteCert(destCertFilePath, serverCert); err != nil { return err } - if err := cert.WriteCert(destCaFilePath, caCert); err != nil { + + if err := cert.WriteCert(destCaCertPath, caCert); err != nil { return err } + if err := keyutil.WriteKey(destKeyFilePath, serverKey); err != nil { return err } return nil } - -// CanReadCertAndKey returns true if the certificate and key files already exists, -// otherwise returns false. If lost one of cert and key, returns error. -func CanReadCertAndKey(certPath, keyPath string) (bool, error) { - return cert.CanReadCertAndKey(certPath, keyPath) -} diff --git a/test/Makefile b/test/Makefile index c7ecf62c..705d65cb 100644 --- a/test/Makefile +++ b/test/Makefile @@ -510,10 +510,11 @@ install_nginx: .PHONY: install_example_app install_example_app: KIND_KUBECONFIG ?= $(E2E_KIND_KUBECONFIG_PATH) install_example_app: KIND_CLUSTER_NAME ?= $(E2E_KIND_CLUSTER_NAME) +install_example_app: IMAGE_TAG ?= $(GIT_COMMIT_VERSION) install_example_app: @echo "---------- install example app" - sed 's?<>?ghcr.io/kdoctor-io/kdoctor-agent:'$(PROJECT_IMAGE_VERSION)'?' yaml/testpod.yaml | kubectl --kubeconfig=$(KIND_KUBECONFIG) apply -f - - @ if ! kubectl rollout status daemonset/test --kubeconfig $(KIND_KUBECONFIG) -w --timeout=120s ; then \ + sed 's?<>?ghcr.io/kdoctor-io/kdoctor-agent:'$(IMAGE_TAG)'?' yaml/testpod.yaml | kubectl --kubeconfig=$(KIND_KUBECONFIG) apply -f - + @ if ! kubectl rollout status daemonset/kdoctor-test -n kube-system --kubeconfig $(KIND_KUBECONFIG) -w --timeout=120s ; then \ kubectl get pod -A ; \ echo "error, failed to create a test pod" ; \ exit 1 ; \ diff --git a/test/yaml/testpod.yaml b/test/yaml/testpod.yaml index 3b5a6fe5..9a0e988f 100644 --- a/test/yaml/testpod.yaml +++ b/test/yaml/testpod.yaml @@ -1,24 +1,59 @@ apiVersion: apps/v1 kind: DaemonSet metadata: - name: test - namespace: default + name: kdoctor-test + namespace: kube-system labels: - app: test + app: kdoctor-test spec: selector: matchLabels: - app: test + app: kdoctor-test template: metadata: - name: test + name: kdoctor-test labels: - app: test + app: kdoctor-test spec: containers: - - name: test + - name: kdoctor-test image: <> imagePullPolicy: IfNotPresent command: ["/usr/bin/agent"] args: - "--app-mode=true" + - "--tls-ca-cert=/etc/tls/ca.crt" + - "--tls-ca-key=/etc/tls/ca.key" + volumeMounts: + - mountPath: /etc/tls + name: tls + volumes: + - name: tls + projected: + defaultMode: 0400 + sources: + - secret: + items: + - key: tls.key + path: ca.key + - key: tls.crt + path: ca.crt + name: kdoctor-ca + +--- +apiVersion: v1 +kind: Service +metadata: + name: kdoctor-test + namespace: kube-system +spec: + selector: + app: kdoctor-test + ports: + - name: http + port: 80 + targetPort: 80 + - name: https + port: 443 + targetPort: 443 + type: ClusterIP \ No newline at end of file diff --git a/vendor/modules.txt b/vendor/modules.txt index feece840..9f04e739 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -57,6 +57,8 @@ github.com/fatih/color # github.com/felixge/httpsnoop v1.0.3 ## explicit; go 1.13 github.com/felixge/httpsnoop +# github.com/form3tech-oss/jwt-go v3.2.5+incompatible +## explicit # github.com/fsnotify/fsnotify v1.6.0 ## explicit; go 1.16 github.com/fsnotify/fsnotify @@ -150,6 +152,8 @@ github.com/golang/protobuf/ptypes github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/timestamp +# github.com/google/btree v1.1.2 +## explicit; go 1.18 # github.com/google/cel-go v0.12.6 ## explicit; go 1.17 github.com/google/cel-go/cel @@ -234,6 +238,8 @@ github.com/inconshreveable/mousetrap # github.com/jessevdk/go-flags v1.5.0 ## explicit; go 1.15 github.com/jessevdk/go-flags +# github.com/jonboulle/clockwork v0.3.0 +## explicit; go 1.13 # github.com/josharian/intern v1.0.0 ## explicit; go 1.5 github.com/josharian/intern