diff --git a/api/restapi/configure_loxilb_rest_api.go b/api/restapi/configure_loxilb_rest_api.go index ef93aa4e6..1f1450cf0 100644 --- a/api/restapi/configure_loxilb_rest_api.go +++ b/api/restapi/configure_loxilb_rest_api.go @@ -61,6 +61,7 @@ func configureAPI(api *operations.LoxilbRestAPIAPI) http.Handler { // Load balancer add and delete and get api.PostConfigLoadbalancerHandler = operations.PostConfigLoadbalancerHandlerFunc(handler.ConfigPostLoadbalancer) api.DeleteConfigLoadbalancerUrlpathUrlpathExternalipaddressIPAddressPortPortProtocolProtoHandler = operations.DeleteConfigLoadbalancerUrlpathUrlpathExternalipaddressIPAddressPortPortProtocolProtoHandlerFunc(handler.ConfigDeleteLoadbalancer) + api.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler = operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandlerFunc(handler.ConfigDeleteLoadbalancerWithoutPath) api.GetConfigLoadbalancerAllHandler = operations.GetConfigLoadbalancerAllHandlerFunc(handler.ConfigGetLoadbalancer) api.DeleteConfigLoadbalancerAllHandler = operations.DeleteConfigLoadbalancerAllHandlerFunc(handler.ConfigDeleteAllLoadbalancer) api.DeleteConfigLoadbalancerNameLbNameHandler = operations.DeleteConfigLoadbalancerNameLbNameHandlerFunc(handler.ConfigDeleteLoadbalancerByName) diff --git a/api/restapi/embedded_spec.go b/api/restapi/embedded_spec.go index 9893bf687..248fe3775 100644 --- a/api/restapi/embedded_spec.go +++ b/api/restapi/embedded_spec.go @@ -2036,6 +2036,94 @@ func init() { } } }, + "/config/loadbalancer/externalipaddress/{ip_address}/port/{port}/protocol/{proto}": { + "delete": { + "description": "Delete an existing load balancer service with .", + "summary": "Delete an existing Load balancer service", + "parameters": [ + { + "type": "string", + "description": "Attributes for load balance service", + "name": "ip_address", + "in": "path", + "required": true + }, + { + "type": "number", + "description": "Attributes for load balance service", + "name": "port", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attributes for load balance service", + "name": "proto", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "option for BGP enable", + "name": "bgp", + "in": "query" + }, + { + "type": "number", + "description": "block value if any", + "name": "block", + "in": "query" + } + ], + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, "/config/loadbalancer/name/{lb_name}": { "delete": { "description": "Delete an existing load balancer service with name.", @@ -7655,6 +7743,94 @@ func init() { } } }, + "/config/loadbalancer/externalipaddress/{ip_address}/port/{port}/protocol/{proto}": { + "delete": { + "description": "Delete an existing load balancer service with .", + "summary": "Delete an existing Load balancer service", + "parameters": [ + { + "type": "string", + "description": "Attributes for load balance service", + "name": "ip_address", + "in": "path", + "required": true + }, + { + "type": "number", + "description": "Attributes for load balance service", + "name": "port", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Attributes for load balance service", + "name": "proto", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "option for BGP enable", + "name": "bgp", + "in": "query" + }, + { + "type": "number", + "description": "block value if any", + "name": "block", + "in": "query" + } + ], + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "403": { + "description": "Capacity insufficient", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "Resource not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Resource Conflict. VLAN already exists OR dependency VRF/VNET not found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintanence mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, "/config/loadbalancer/name/{lb_name}": { "delete": { "description": "Delete an existing load balancer service with name.", diff --git a/api/restapi/handler/loadbalancer.go b/api/restapi/handler/loadbalancer.go index 3abb1f5a5..f40daca8d 100644 --- a/api/restapi/handler/loadbalancer.go +++ b/api/restapi/handler/loadbalancer.go @@ -86,7 +86,11 @@ func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerUrlpathU lbServ.ServIP = params.IPAddress lbServ.ServPort = uint16(params.Port) lbServ.Proto = params.Proto - lbServ.Path = params.Urlpath + if params.Urlpath == "any" { + lbServ.Path = "" + } else { + lbServ.Path = params.Urlpath + } if params.Block != nil { lbServ.BlockNum = uint16(*params.Block) } @@ -104,6 +108,32 @@ func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerUrlpathU return &ResultResponse{Result: "Success"} } +func ConfigDeleteLoadbalancerWithoutPath(params operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + + var lbServ cmn.LbServiceArg + var lbRules cmn.LbRuleMod + lbServ.ServIP = params.IPAddress + lbServ.ServPort = uint16(params.Port) + lbServ.Proto = params.Proto + lbServ.Path = "" + if params.Block != nil { + lbServ.BlockNum = uint16(*params.Block) + } + if params.Bgp != nil { + lbServ.Bgp = *params.Bgp + } + + lbRules.Serv = lbServ + tk.LogIt(tk.LogDebug, "[API] lbRules (w/o Path): %v\n", lbRules) + _, err := ApiHooks.NetLbRuleDel(&lbRules) + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + return &ResultResponse{Result: "Success"} +} + func ConfigGetLoadbalancer(params operations.GetConfigLoadbalancerAllParams) middleware.Responder { // Get LB rules tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) diff --git a/api/restapi/operations/loxilb_rest_api_api.go b/api/restapi/operations/loxilb_rest_api_api.go index 0f79cd5bb..9d571cd3b 100644 --- a/api/restapi/operations/loxilb_rest_api_api.go +++ b/api/restapi/operations/loxilb_rest_api_api.go @@ -72,6 +72,9 @@ func NewLoxilbRestAPIAPI(spec *loads.Document) *LoxilbRestAPIAPI { DeleteConfigLoadbalancerAllHandler: DeleteConfigLoadbalancerAllHandlerFunc(func(params DeleteConfigLoadbalancerAllParams) middleware.Responder { return middleware.NotImplemented("operation DeleteConfigLoadbalancerAll has not yet been implemented") }), + DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler: DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandlerFunc(func(params DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder { + return middleware.NotImplemented("operation DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProto has not yet been implemented") + }), DeleteConfigLoadbalancerNameLbNameHandler: DeleteConfigLoadbalancerNameLbNameHandlerFunc(func(params DeleteConfigLoadbalancerNameLbNameParams) middleware.Responder { return middleware.NotImplemented("operation DeleteConfigLoadbalancerNameLbName has not yet been implemented") }), @@ -308,6 +311,8 @@ type LoxilbRestAPIAPI struct { DeleteConfigIpv4addressIPAddressMaskDevIfNameHandler DeleteConfigIpv4addressIPAddressMaskDevIfNameHandler // DeleteConfigLoadbalancerAllHandler sets the operation handler for the delete config loadbalancer all operation DeleteConfigLoadbalancerAllHandler DeleteConfigLoadbalancerAllHandler + // DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler sets the operation handler for the delete config loadbalancer externalipaddress IP address port port protocol proto operation + DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler // DeleteConfigLoadbalancerNameLbNameHandler sets the operation handler for the delete config loadbalancer name lb name operation DeleteConfigLoadbalancerNameLbNameHandler DeleteConfigLoadbalancerNameLbNameHandler // DeleteConfigLoadbalancerUrlpathUrlpathExternalipaddressIPAddressPortPortProtocolProtoHandler sets the operation handler for the delete config loadbalancer urlpath urlpath externalipaddress IP address port port protocol proto operation @@ -535,6 +540,9 @@ func (o *LoxilbRestAPIAPI) Validate() error { if o.DeleteConfigLoadbalancerAllHandler == nil { unregistered = append(unregistered, "DeleteConfigLoadbalancerAllHandler") } + if o.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler == nil { + unregistered = append(unregistered, "DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler") + } if o.DeleteConfigLoadbalancerNameLbNameHandler == nil { unregistered = append(unregistered, "DeleteConfigLoadbalancerNameLbNameHandler") } @@ -846,6 +854,10 @@ func (o *LoxilbRestAPIAPI) initHandlerCache() { if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) } + o.handlers["DELETE"]["/config/loadbalancer/externalipaddress/{ip_address}/port/{port}/protocol/{proto}"] = NewDeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProto(o.context, o.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } o.handlers["DELETE"]["/config/loadbalancer/name/{lb_name}"] = NewDeleteConfigLoadbalancerNameLbName(o.context, o.DeleteConfigLoadbalancerNameLbNameHandler) if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) diff --git a/api/swagger.yml b/api/swagger.yml index 0586f3957..6d98815dd 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -174,6 +174,66 @@ paths: description: Maintanence mode schema: $ref: '#/definitions/Error' + '/config/loadbalancer/externalipaddress/{ip_address}/port/{port}/protocol/{proto}': + delete: + summary: Delete an existing Load balancer service + description: Delete an existing load balancer service with . + parameters: + - name: ip_address + in: path + type: string + required: true + description: Attributes for load balance service + - name: port + in: path + type: number + required: true + description: Attributes for load balance service + - name: proto + in: path + type: string + required: true + description: Attributes for load balance service + - name: bgp + in: query + type: boolean + description: option for BGP enable + - name: block + in: query + type: number + required: false + description: block value if any + responses: + '204': + description: OK + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '403': + description: Capacity insufficient + schema: + $ref: '#/definitions/Error' + '404': + description: Resource not found + schema: + $ref: '#/definitions/Error' + '409': + description: Resource Conflict. VLAN already exists OR dependency VRF/VNET not found + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintanence mode + schema: + $ref: '#/definitions/Error' '/config/loadbalancer/urlpath/{urlpath}/externalipaddress/{ip_address}/port/{port}/protocol/{proto}': delete: summary: Delete an existing Load balancer service