Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #42 from srinandan/clean
Browse files Browse the repository at this point in the history
clean execution output #41
  • Loading branch information
srinandan authored Nov 4, 2022
2 parents 08989a6 + 9755c5d commit aa8bfb0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
35 changes: 35 additions & 0 deletions client/integrations/executions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ package integrations

import (
"encoding/json"
"fmt"
"net/url"
"path"
"regexp"
"strconv"

"github.com/srinandan/integrationcli/apiclient"
Expand Down Expand Up @@ -58,6 +60,12 @@ type booleanarray struct {
BooleanValues []bool
}

type executionResponse struct {
ExecutionId string `json:"executionId,omitempty"`
EventParameters *parametersInternal `json:"eventParameters,omitempty"`
OutputParameters interface{} `json:"outputParameters,omitempty"`
}

// ListExecutions lists all executions
func ListExecutions(name string, pageSize int, pageToken string, filter string, orderBy string) (respBody []byte, err error) {
u, _ := url.Parse(apiclient.GetBaseIntegrationURL())
Expand Down Expand Up @@ -88,8 +96,35 @@ func Execute(name string, content []byte) (respBody []byte, err error) {
return nil, err
}

regExTrigger := regexp.MustCompile(`api_trigger\/\w+`)
if !regExTrigger.MatchString(e.TriggerId) {
return nil, fmt.Errorf("triggerId must match the format api_trigger/*")
}

apiclient.SetPrintOutput(false)
u, _ := url.Parse(apiclient.GetBaseIntegrationURL())
u.Path = path.Join(u.Path, "integrations", name+":execute")
respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String(), string(content))
if err != nil {
return nil, err
}
apiclient.SetPrintOutput(false)

eresp := executionResponse{}
err = json.Unmarshal(respBody, &eresp)
if err != nil {
return nil, err
}

//remove from response
eresp.EventParameters = nil

respBody, err = json.Marshal(eresp)
if err != nil {
return nil, err
}

apiclient.PrettyPrint(respBody)

return respBody, err
}
8 changes: 8 additions & 0 deletions test/exec2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"triggerId": "api_trigger/fdic_API_1",
"inputParameters": {
"fdic_certificate_number": {
"stringValue": ""
}
}
}

0 comments on commit aa8bfb0

Please sign in to comment.