Skip to content

Commit 54006e1

Browse files
authored
Extend clclient to support querying /v2/keys/workflow (#2031)
1 parent e394db3 commit 54006e1

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

framework/clclient/client.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,31 @@ func (c *ChainlinkClient) ImportVRFKey(vrfExportKey *VRFExportKey) (*VRFKey, *ht
945945
return vrfKey, resp.RawResponse, err
946946
}
947947

948+
// ReadWorkflowKeys reads all Workflow keys from the Chainlink node
949+
func (c *ChainlinkClient) ReadWorkflowKeys() (*WorkflowKeys, *http.Response, error) {
950+
workflowKeys := &WorkflowKeys{}
951+
framework.L.Info().Str(NodeURL, c.Config.URL).Msg("Reading Workflow Keys")
952+
resp, err := c.APIClient.R().
953+
SetResult(workflowKeys).
954+
Get("/v2/keys/workflow")
955+
if err != nil {
956+
return nil, nil, err
957+
}
958+
if len(workflowKeys.Data) == 0 {
959+
framework.L.Warn().Str(NodeURL, c.Config.URL).Msg("Found no Workflow Keys on the node")
960+
}
961+
return workflowKeys, resp.RawResponse, err
962+
}
963+
964+
// MustReadWorkflowKeys reads all Workflow keys from the Chainlink node
965+
func (c *ChainlinkClient) MustReadWorkflowKeys() (*WorkflowKeys, *http.Response, error) {
966+
workflowKeys, res, err := c.ReadWorkflowKeys()
967+
if err != nil {
968+
return nil, res, err
969+
}
970+
return workflowKeys, res, VerifyStatusCode(res.StatusCode, http.StatusOK)
971+
}
972+
948973
// CreateCSAKey creates a CSA key on the Chainlink node, only 1 CSA key per node
949974
func (c *ChainlinkClient) CreateCSAKey() (*CSAKey, *http.Response, error) {
950975
csaKey := &CSAKey{}

framework/clclient/models.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,22 @@ type VRFKeys struct {
211211
Data []VRFKey `json:"data"`
212212
}
213213

214+
// WorkflowKeyAttributes is the model that represents the created workflow key attributes when read
215+
type WorkflowKeyAttributes struct {
216+
PublicKey string `json:"publicKey"`
217+
}
218+
219+
// WorkflowKey is the model that represents the created workflow key when read
220+
type WorkflowKey struct {
221+
ID string
222+
Attributes WorkflowKeyAttributes
223+
}
224+
225+
// WorkflowKeys is the model that represents the created workflow keys when read
226+
type WorkflowKeys struct {
227+
Data []WorkflowKey `json:"data"`
228+
}
229+
214230
// OCRKeys is the model that represents the created OCR keys when read
215231
type OCRKeys struct {
216232
Data []OCRKeyData `json:"data"`

0 commit comments

Comments
 (0)