added a new parameter to the /admiralty/targets route to specify the peerId of the peer targeted, allowing to name differently peers targeted in a namespace

This commit is contained in:
pb
2025-05-05 16:13:49 +02:00
parent 03f81c66f9
commit 8e8d0d3e01
3 changed files with 12 additions and 4 deletions

View File

@@ -168,13 +168,21 @@ func (c *AdmiraltyController) CreateAdmiraltySource() {
// @Title CreateAdmiraltyTarget
// @Description Create an Admiralty Target in the namespace associated to the executionID
// @Param execution path string true "execution id of the workflow"
// @Param peer path string true "peerId of the peer the target points to"
// @Success 201
// @router /target/:execution [post]
func (c *AdmiraltyController) CreateAdmiraltyTarget(){
var data map[string]interface{}
execution := c.Ctx.Input.Param(":execution")
peerId := c.Ctx.Input.Param(":peer")
if execution == "" || peerId == "" {
c.Ctx.Output.SetStatus(400)
c.Data["json"] = map[string]string{"error" : "parameters can be empty"}
c.ServeJSON()
return
}
serv, err := infrastructure.NewService()
if err != nil {
@@ -185,7 +193,7 @@ func (c *AdmiraltyController) CreateAdmiraltyTarget(){
return
}
resp, err := serv.CreateAdmiraltyTarget(c.Ctx.Request.Context(),execution)
resp, err := serv.CreateAdmiraltyTarget(c.Ctx.Request.Context(),execution, peerId)
if err != nil {
// change code to 500
c.Ctx.Output.SetStatus(500)