mirror of
https://github.com/openziti/zrok.git
synced 2024-11-24 17:13:51 +01:00
add backend for 'admin delete frontend' (#129)
This commit is contained in:
parent
f0228e8fe0
commit
309f4e7d87
@ -26,3 +26,5 @@ swagger generate client -P rest_model_zrok.Principal -f "$zrokSpec" -c rest_clie
|
||||
|
||||
echo "...generating js client"
|
||||
openapi -s specs/zrok.yml -o ui/src/api -l js
|
||||
|
||||
git co rest_server_zrok/configure_zrok.go
|
||||
|
@ -32,6 +32,7 @@ func Run(inCfg *Config) error {
|
||||
api.AccountRegisterHandler = newRegisterHandler()
|
||||
api.AccountVerifyHandler = newVerifyHandler()
|
||||
api.AdminCreateFrontendHandler = newCreateFrontendHandler()
|
||||
api.AdminDeleteFrontendHandler = newDeleteFrontendHandler()
|
||||
api.EnvironmentEnableHandler = newEnableHandler()
|
||||
api.EnvironmentDisableHandler = newDisableHandler()
|
||||
api.MetadataOverviewHandler = metadata.OverviewHandlerFunc(overviewHandler)
|
||||
|
49
controller/delete_frontend.go
Normal file
49
controller/delete_frontend.go
Normal file
@ -0,0 +1,49 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/admin"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type deleteFrontendHandler struct{}
|
||||
|
||||
func newDeleteFrontendHandler() *deleteFrontendHandler {
|
||||
return &deleteFrontendHandler{}
|
||||
}
|
||||
|
||||
func (h *deleteFrontendHandler) Handle(params admin.DeleteFrontendParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
feToken := params.Body.FrontendToken
|
||||
|
||||
if !principal.Admin {
|
||||
logrus.Errorf("invalid admin principal")
|
||||
return admin.NewDeleteFrontendUnauthorized()
|
||||
}
|
||||
|
||||
tx, err := str.Begin()
|
||||
if err != nil {
|
||||
logrus.Errorf("error starting transaction: %v", err)
|
||||
return admin.NewDeleteFrontendInternalServerError()
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
fe, err := str.FindFrontendWithToken(feToken, tx)
|
||||
if err != nil {
|
||||
logrus.Errorf("error finding frontend with token '%v': %v", feToken, err)
|
||||
return admin.NewDeleteFrontendNotFound()
|
||||
}
|
||||
|
||||
if err := str.DeleteFrontend(fe.Id, tx); err != nil {
|
||||
logrus.Errorf("error deleting frontend '%v': %v", feToken, err)
|
||||
return admin.NewDeleteFrontendInternalServerError()
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
logrus.Errorf("error commiting frontend '%v' deletion: %v", feToken, err)
|
||||
return admin.NewDeleteFrontendInternalServerError()
|
||||
}
|
||||
|
||||
return admin.NewDeleteFrontendOK()
|
||||
|
||||
}
|
@ -32,6 +32,8 @@ type ClientOption func(*runtime.ClientOperation)
|
||||
type ClientService interface {
|
||||
CreateFrontend(params *CreateFrontendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*CreateFrontendCreated, error)
|
||||
|
||||
DeleteFrontend(params *DeleteFrontendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteFrontendOK, error)
|
||||
|
||||
SetTransport(transport runtime.ClientTransport)
|
||||
}
|
||||
|
||||
@ -74,6 +76,45 @@ func (a *Client) CreateFrontend(params *CreateFrontendParams, authInfo runtime.C
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteFrontend delete frontend API
|
||||
*/
|
||||
func (a *Client) DeleteFrontend(params *DeleteFrontendParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*DeleteFrontendOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewDeleteFrontendParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "deleteFrontend",
|
||||
Method: "DELETE",
|
||||
PathPattern: "/frontend",
|
||||
ProducesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &DeleteFrontendReader{formats: a.formats},
|
||||
AuthInfo: authInfo,
|
||||
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.(*DeleteFrontendOK)
|
||||
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 deleteFrontend: 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
|
||||
|
150
rest_client_zrok/admin/delete_frontend_parameters.go
Normal file
150
rest_client_zrok/admin/delete_frontend_parameters.go
Normal file
@ -0,0 +1,150 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewDeleteFrontendParams creates a new DeleteFrontendParams 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 NewDeleteFrontendParams() *DeleteFrontendParams {
|
||||
return &DeleteFrontendParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteFrontendParamsWithTimeout creates a new DeleteFrontendParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewDeleteFrontendParamsWithTimeout(timeout time.Duration) *DeleteFrontendParams {
|
||||
return &DeleteFrontendParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteFrontendParamsWithContext creates a new DeleteFrontendParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewDeleteFrontendParamsWithContext(ctx context.Context) *DeleteFrontendParams {
|
||||
return &DeleteFrontendParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteFrontendParamsWithHTTPClient creates a new DeleteFrontendParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewDeleteFrontendParamsWithHTTPClient(client *http.Client) *DeleteFrontendParams {
|
||||
return &DeleteFrontendParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteFrontendParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the delete frontend operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type DeleteFrontendParams struct {
|
||||
|
||||
// Body.
|
||||
Body *rest_model_zrok.DeleteFrontendRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the delete frontend params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DeleteFrontendParams) WithDefaults() *DeleteFrontendParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the delete frontend params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *DeleteFrontendParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the delete frontend params
|
||||
func (o *DeleteFrontendParams) WithTimeout(timeout time.Duration) *DeleteFrontendParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the delete frontend params
|
||||
func (o *DeleteFrontendParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the delete frontend params
|
||||
func (o *DeleteFrontendParams) WithContext(ctx context.Context) *DeleteFrontendParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the delete frontend params
|
||||
func (o *DeleteFrontendParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the delete frontend params
|
||||
func (o *DeleteFrontendParams) WithHTTPClient(client *http.Client) *DeleteFrontendParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the delete frontend params
|
||||
func (o *DeleteFrontendParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the delete frontend params
|
||||
func (o *DeleteFrontendParams) WithBody(body *rest_model_zrok.DeleteFrontendRequest) *DeleteFrontendParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the delete frontend params
|
||||
func (o *DeleteFrontendParams) SetBody(body *rest_model_zrok.DeleteFrontendRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *DeleteFrontendParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
if o.Body != nil {
|
||||
if err := r.SetBodyParam(o.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
254
rest_client_zrok/admin/delete_frontend_responses.go
Normal file
254
rest_client_zrok/admin/delete_frontend_responses.go
Normal file
@ -0,0 +1,254 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// DeleteFrontendReader is a Reader for the DeleteFrontend structure.
|
||||
type DeleteFrontendReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *DeleteFrontendReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewDeleteFrontendOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 401:
|
||||
result := NewDeleteFrontendUnauthorized()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 404:
|
||||
result := NewDeleteFrontendNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 500:
|
||||
result := NewDeleteFrontendInternalServerError()
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteFrontendOK creates a DeleteFrontendOK with default headers values
|
||||
func NewDeleteFrontendOK() *DeleteFrontendOK {
|
||||
return &DeleteFrontendOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteFrontendOK describes a response with status code 200, with default header values.
|
||||
|
||||
frontend deleted
|
||||
*/
|
||||
type DeleteFrontendOK struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this delete frontend o k response has a 2xx status code
|
||||
func (o *DeleteFrontendOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this delete frontend o k response has a 3xx status code
|
||||
func (o *DeleteFrontendOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this delete frontend o k response has a 4xx status code
|
||||
func (o *DeleteFrontendOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this delete frontend o k response has a 5xx status code
|
||||
func (o *DeleteFrontendOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this delete frontend o k response a status code equal to that given
|
||||
func (o *DeleteFrontendOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendOK) Error() string {
|
||||
return fmt.Sprintf("[DELETE /frontend][%d] deleteFrontendOK ", 200)
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendOK) String() string {
|
||||
return fmt.Sprintf("[DELETE /frontend][%d] deleteFrontendOK ", 200)
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteFrontendUnauthorized creates a DeleteFrontendUnauthorized with default headers values
|
||||
func NewDeleteFrontendUnauthorized() *DeleteFrontendUnauthorized {
|
||||
return &DeleteFrontendUnauthorized{}
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteFrontendUnauthorized describes a response with status code 401, with default header values.
|
||||
|
||||
unauthorized
|
||||
*/
|
||||
type DeleteFrontendUnauthorized struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this delete frontend unauthorized response has a 2xx status code
|
||||
func (o *DeleteFrontendUnauthorized) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this delete frontend unauthorized response has a 3xx status code
|
||||
func (o *DeleteFrontendUnauthorized) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this delete frontend unauthorized response has a 4xx status code
|
||||
func (o *DeleteFrontendUnauthorized) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this delete frontend unauthorized response has a 5xx status code
|
||||
func (o *DeleteFrontendUnauthorized) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this delete frontend unauthorized response a status code equal to that given
|
||||
func (o *DeleteFrontendUnauthorized) IsCode(code int) bool {
|
||||
return code == 401
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendUnauthorized) Error() string {
|
||||
return fmt.Sprintf("[DELETE /frontend][%d] deleteFrontendUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendUnauthorized) String() string {
|
||||
return fmt.Sprintf("[DELETE /frontend][%d] deleteFrontendUnauthorized ", 401)
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteFrontendNotFound creates a DeleteFrontendNotFound with default headers values
|
||||
func NewDeleteFrontendNotFound() *DeleteFrontendNotFound {
|
||||
return &DeleteFrontendNotFound{}
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteFrontendNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
not found
|
||||
*/
|
||||
type DeleteFrontendNotFound struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this delete frontend not found response has a 2xx status code
|
||||
func (o *DeleteFrontendNotFound) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this delete frontend not found response has a 3xx status code
|
||||
func (o *DeleteFrontendNotFound) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this delete frontend not found response has a 4xx status code
|
||||
func (o *DeleteFrontendNotFound) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this delete frontend not found response has a 5xx status code
|
||||
func (o *DeleteFrontendNotFound) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this delete frontend not found response a status code equal to that given
|
||||
func (o *DeleteFrontendNotFound) IsCode(code int) bool {
|
||||
return code == 404
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendNotFound) Error() string {
|
||||
return fmt.Sprintf("[DELETE /frontend][%d] deleteFrontendNotFound ", 404)
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendNotFound) String() string {
|
||||
return fmt.Sprintf("[DELETE /frontend][%d] deleteFrontendNotFound ", 404)
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDeleteFrontendInternalServerError creates a DeleteFrontendInternalServerError with default headers values
|
||||
func NewDeleteFrontendInternalServerError() *DeleteFrontendInternalServerError {
|
||||
return &DeleteFrontendInternalServerError{}
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteFrontendInternalServerError describes a response with status code 500, with default header values.
|
||||
|
||||
internal server error
|
||||
*/
|
||||
type DeleteFrontendInternalServerError struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this delete frontend internal server error response has a 2xx status code
|
||||
func (o *DeleteFrontendInternalServerError) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this delete frontend internal server error response has a 3xx status code
|
||||
func (o *DeleteFrontendInternalServerError) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this delete frontend internal server error response has a 4xx status code
|
||||
func (o *DeleteFrontendInternalServerError) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this delete frontend internal server error response has a 5xx status code
|
||||
func (o *DeleteFrontendInternalServerError) IsServerError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsCode returns true when this delete frontend internal server error response a status code equal to that given
|
||||
func (o *DeleteFrontendInternalServerError) IsCode(code int) bool {
|
||||
return code == 500
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendInternalServerError) Error() string {
|
||||
return fmt.Sprintf("[DELETE /frontend][%d] deleteFrontendInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendInternalServerError) String() string {
|
||||
return fmt.Sprintf("[DELETE /frontend][%d] deleteFrontendInternalServerError ", 500)
|
||||
}
|
||||
|
||||
func (o *DeleteFrontendInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
50
rest_model_zrok/delete_frontend_request.go
Normal file
50
rest_model_zrok/delete_frontend_request.go
Normal file
@ -0,0 +1,50 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_model_zrok
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// DeleteFrontendRequest delete frontend request
|
||||
//
|
||||
// swagger:model deleteFrontendRequest
|
||||
type DeleteFrontendRequest struct {
|
||||
|
||||
// frontend token
|
||||
FrontendToken string `json:"frontendToken,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this delete frontend request
|
||||
func (m *DeleteFrontendRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this delete frontend request based on context it is used
|
||||
func (m *DeleteFrontendRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *DeleteFrontendRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *DeleteFrontendRequest) UnmarshalBinary(b []byte) error {
|
||||
var res DeleteFrontendRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
@ -183,6 +183,40 @@ func init() {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"operationId": "deleteFrontend",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/deleteFrontendRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "frontend deleted"
|
||||
},
|
||||
"401": {
|
||||
"description": "unauthorized"
|
||||
},
|
||||
"404": {
|
||||
"description": "not found"
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/invite": {
|
||||
@ -553,6 +587,14 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"deleteFrontendRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"frontendToken": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -1031,6 +1073,40 @@ func init() {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"security": [
|
||||
{
|
||||
"key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"admin"
|
||||
],
|
||||
"operationId": "deleteFrontend",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/deleteFrontendRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "frontend deleted"
|
||||
},
|
||||
"401": {
|
||||
"description": "unauthorized"
|
||||
},
|
||||
"404": {
|
||||
"description": "not found"
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/invite": {
|
||||
@ -1401,6 +1477,14 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"deleteFrontendRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"frontendToken": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"disableRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
71
rest_server_zrok/operations/admin/delete_frontend.go
Normal file
71
rest_server_zrok/operations/admin/delete_frontend.go
Normal file
@ -0,0 +1,71 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// DeleteFrontendHandlerFunc turns a function with the right signature into a delete frontend handler
|
||||
type DeleteFrontendHandlerFunc func(DeleteFrontendParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn DeleteFrontendHandlerFunc) Handle(params DeleteFrontendParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// DeleteFrontendHandler interface for that can handle valid delete frontend params
|
||||
type DeleteFrontendHandler interface {
|
||||
Handle(DeleteFrontendParams, *rest_model_zrok.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewDeleteFrontend creates a new http.Handler for the delete frontend operation
|
||||
func NewDeleteFrontend(ctx *middleware.Context, handler DeleteFrontendHandler) *DeleteFrontend {
|
||||
return &DeleteFrontend{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
DeleteFrontend swagger:route DELETE /frontend admin deleteFrontend
|
||||
|
||||
DeleteFrontend delete frontend API
|
||||
*/
|
||||
type DeleteFrontend struct {
|
||||
Context *middleware.Context
|
||||
Handler DeleteFrontendHandler
|
||||
}
|
||||
|
||||
func (o *DeleteFrontend) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewDeleteFrontendParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *rest_model_zrok.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*rest_model_zrok.Principal) // this is really a rest_model_zrok.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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/validate"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewDeleteFrontendParams creates a new DeleteFrontendParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewDeleteFrontendParams() DeleteFrontendParams {
|
||||
|
||||
return DeleteFrontendParams{}
|
||||
}
|
||||
|
||||
// DeleteFrontendParams contains all the bound params for the delete frontend operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters deleteFrontend
|
||||
type DeleteFrontendParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
In: body
|
||||
*/
|
||||
Body *rest_model_zrok.DeleteFrontendRequest
|
||||
}
|
||||
|
||||
// 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 NewDeleteFrontendParams() beforehand.
|
||||
func (o *DeleteFrontendParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body rest_model_zrok.DeleteFrontendRequest
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(r.Context())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
112
rest_server_zrok/operations/admin/delete_frontend_responses.go
Normal file
112
rest_server_zrok/operations/admin/delete_frontend_responses.go
Normal file
@ -0,0 +1,112 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// DeleteFrontendOKCode is the HTTP code returned for type DeleteFrontendOK
|
||||
const DeleteFrontendOKCode int = 200
|
||||
|
||||
/*
|
||||
DeleteFrontendOK frontend deleted
|
||||
|
||||
swagger:response deleteFrontendOK
|
||||
*/
|
||||
type DeleteFrontendOK struct {
|
||||
}
|
||||
|
||||
// NewDeleteFrontendOK creates DeleteFrontendOK with default headers values
|
||||
func NewDeleteFrontendOK() *DeleteFrontendOK {
|
||||
|
||||
return &DeleteFrontendOK{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteFrontendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(200)
|
||||
}
|
||||
|
||||
// DeleteFrontendUnauthorizedCode is the HTTP code returned for type DeleteFrontendUnauthorized
|
||||
const DeleteFrontendUnauthorizedCode int = 401
|
||||
|
||||
/*
|
||||
DeleteFrontendUnauthorized unauthorized
|
||||
|
||||
swagger:response deleteFrontendUnauthorized
|
||||
*/
|
||||
type DeleteFrontendUnauthorized struct {
|
||||
}
|
||||
|
||||
// NewDeleteFrontendUnauthorized creates DeleteFrontendUnauthorized with default headers values
|
||||
func NewDeleteFrontendUnauthorized() *DeleteFrontendUnauthorized {
|
||||
|
||||
return &DeleteFrontendUnauthorized{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteFrontendUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(401)
|
||||
}
|
||||
|
||||
// DeleteFrontendNotFoundCode is the HTTP code returned for type DeleteFrontendNotFound
|
||||
const DeleteFrontendNotFoundCode int = 404
|
||||
|
||||
/*
|
||||
DeleteFrontendNotFound not found
|
||||
|
||||
swagger:response deleteFrontendNotFound
|
||||
*/
|
||||
type DeleteFrontendNotFound struct {
|
||||
}
|
||||
|
||||
// NewDeleteFrontendNotFound creates DeleteFrontendNotFound with default headers values
|
||||
func NewDeleteFrontendNotFound() *DeleteFrontendNotFound {
|
||||
|
||||
return &DeleteFrontendNotFound{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteFrontendNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(404)
|
||||
}
|
||||
|
||||
// DeleteFrontendInternalServerErrorCode is the HTTP code returned for type DeleteFrontendInternalServerError
|
||||
const DeleteFrontendInternalServerErrorCode int = 500
|
||||
|
||||
/*
|
||||
DeleteFrontendInternalServerError internal server error
|
||||
|
||||
swagger:response deleteFrontendInternalServerError
|
||||
*/
|
||||
type DeleteFrontendInternalServerError struct {
|
||||
}
|
||||
|
||||
// NewDeleteFrontendInternalServerError creates DeleteFrontendInternalServerError with default headers values
|
||||
func NewDeleteFrontendInternalServerError() *DeleteFrontendInternalServerError {
|
||||
|
||||
return &DeleteFrontendInternalServerError{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *DeleteFrontendInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(500)
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package admin
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// DeleteFrontendURL generates an URL for the delete frontend operation
|
||||
type DeleteFrontendURL 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 *DeleteFrontendURL) WithBasePath(bp string) *DeleteFrontendURL {
|
||||
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 *DeleteFrontendURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *DeleteFrontendURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/frontend"
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *DeleteFrontendURL) 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 *DeleteFrontendURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *DeleteFrontendURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on DeleteFrontendURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on DeleteFrontendURL")
|
||||
}
|
||||
|
||||
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 *DeleteFrontendURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
@ -55,6 +55,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
|
||||
AdminCreateFrontendHandler: admin.CreateFrontendHandlerFunc(func(params admin.CreateFrontendParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin.CreateFrontend has not yet been implemented")
|
||||
}),
|
||||
AdminDeleteFrontendHandler: admin.DeleteFrontendHandlerFunc(func(params admin.DeleteFrontendParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin.DeleteFrontend has not yet been implemented")
|
||||
}),
|
||||
EnvironmentDisableHandler: environment.DisableHandlerFunc(func(params environment.DisableParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation environment.Disable has not yet been implemented")
|
||||
}),
|
||||
@ -145,6 +148,8 @@ type ZrokAPI struct {
|
||||
ServiceAccessHandler service.AccessHandler
|
||||
// AdminCreateFrontendHandler sets the operation handler for the create frontend operation
|
||||
AdminCreateFrontendHandler admin.CreateFrontendHandler
|
||||
// AdminDeleteFrontendHandler sets the operation handler for the delete frontend operation
|
||||
AdminDeleteFrontendHandler admin.DeleteFrontendHandler
|
||||
// EnvironmentDisableHandler sets the operation handler for the disable operation
|
||||
EnvironmentDisableHandler environment.DisableHandler
|
||||
// EnvironmentEnableHandler sets the operation handler for the enable operation
|
||||
@ -256,6 +261,9 @@ func (o *ZrokAPI) Validate() error {
|
||||
if o.AdminCreateFrontendHandler == nil {
|
||||
unregistered = append(unregistered, "admin.CreateFrontendHandler")
|
||||
}
|
||||
if o.AdminDeleteFrontendHandler == nil {
|
||||
unregistered = append(unregistered, "admin.DeleteFrontendHandler")
|
||||
}
|
||||
if o.EnvironmentDisableHandler == nil {
|
||||
unregistered = append(unregistered, "environment.DisableHandler")
|
||||
}
|
||||
@ -399,6 +407,10 @@ func (o *ZrokAPI) initHandlerCache() {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/frontend"] = admin.NewCreateFrontend(o.context, o.AdminCreateFrontendHandler)
|
||||
if o.handlers["DELETE"] == nil {
|
||||
o.handlers["DELETE"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["DELETE"]["/frontend"] = admin.NewDeleteFrontend(o.context, o.AdminDeleteFrontendHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
@ -117,6 +117,26 @@ paths:
|
||||
description: not found
|
||||
500:
|
||||
description: internal server error
|
||||
delete:
|
||||
tags:
|
||||
- admin
|
||||
security:
|
||||
- key: []
|
||||
operationId: deleteFrontend
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
schema:
|
||||
$ref: "#/definitions/deleteFrontendRequest"
|
||||
responses:
|
||||
200:
|
||||
description: frontend deleted
|
||||
401:
|
||||
description: unauthorized
|
||||
404:
|
||||
description: not found
|
||||
500:
|
||||
description: internal server error
|
||||
|
||||
#
|
||||
# environment
|
||||
@ -355,6 +375,12 @@ definitions:
|
||||
token:
|
||||
type: string
|
||||
|
||||
deleteFrontendRequest:
|
||||
type: object
|
||||
properties:
|
||||
frontendToken:
|
||||
type: string
|
||||
|
||||
disableRequest:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -17,6 +17,21 @@ export function createFrontend(options) {
|
||||
return gateway.request(createFrontendOperation, parameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} options Optional options
|
||||
* @param {module:types.deleteFrontendRequest} [options.body]
|
||||
* @return {Promise<object>} frontend deleted
|
||||
*/
|
||||
export function deleteFrontend(options) {
|
||||
if (!options) options = {}
|
||||
const parameters = {
|
||||
body: {
|
||||
body: options.body
|
||||
}
|
||||
}
|
||||
return gateway.request(deleteFrontendOperation, parameters)
|
||||
}
|
||||
|
||||
const createFrontendOperation = {
|
||||
path: '/frontend',
|
||||
contentTypes: ['application/zrok.v1+json'],
|
||||
@ -27,3 +42,14 @@ const createFrontendOperation = {
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const deleteFrontendOperation = {
|
||||
path: '/frontend',
|
||||
contentTypes: ['application/zrok.v1+json'],
|
||||
method: 'delete',
|
||||
security: [
|
||||
{
|
||||
id: 'key'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -40,6 +40,13 @@
|
||||
* @property {string} token
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef deleteFrontendRequest
|
||||
* @memberof module:types
|
||||
*
|
||||
* @property {string} frontendToken
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef disableRequest
|
||||
* @memberof module:types
|
||||
|
Loading…
Reference in New Issue
Block a user