diff --git a/framework/.changeset/v0.10.10.md b/framework/.changeset/v0.10.10.md new file mode 100644 index 000000000..baa6f8bdc --- /dev/null +++ b/framework/.changeset/v0.10.10.md @@ -0,0 +1 @@ +- Extend clclient to support querying /v2/keys/workflow. diff --git a/framework/clclient/client.go b/framework/clclient/client.go index 1018afe1b..5f9b50946 100644 --- a/framework/clclient/client.go +++ b/framework/clclient/client.go @@ -945,6 +945,31 @@ func (c *ChainlinkClient) ImportVRFKey(vrfExportKey *VRFExportKey) (*VRFKey, *ht return vrfKey, resp.RawResponse, err } +// ReadWorkflowKeys reads all Workflow keys from the Chainlink node +func (c *ChainlinkClient) ReadWorkflowKeys() (*WorkflowKeys, *http.Response, error) { + workflowKeys := &WorkflowKeys{} + framework.L.Info().Str(NodeURL, c.Config.URL).Msg("Reading Workflow Keys") + resp, err := c.APIClient.R(). + SetResult(workflowKeys). + Get("/v2/keys/workflow") + if err != nil { + return nil, nil, err + } + if len(workflowKeys.Data) == 0 { + framework.L.Warn().Str(NodeURL, c.Config.URL).Msg("Found no Workflow Keys on the node") + } + return workflowKeys, resp.RawResponse, err +} + +// MustReadWorkflowKeys reads all Workflow keys from the Chainlink node +func (c *ChainlinkClient) MustReadWorkflowKeys() (*WorkflowKeys, *http.Response, error) { + workflowKeys, res, err := c.ReadWorkflowKeys() + if err != nil { + return nil, res, err + } + return workflowKeys, res, VerifyStatusCode(res.StatusCode, http.StatusOK) +} + // CreateCSAKey creates a CSA key on the Chainlink node, only 1 CSA key per node func (c *ChainlinkClient) CreateCSAKey() (*CSAKey, *http.Response, error) { csaKey := &CSAKey{} diff --git a/framework/clclient/models.go b/framework/clclient/models.go index 6980d0c67..9d9a07012 100644 --- a/framework/clclient/models.go +++ b/framework/clclient/models.go @@ -211,6 +211,22 @@ type VRFKeys struct { Data []VRFKey `json:"data"` } +// WorkflowKeyAttributes is the model that represents the created workflow key attributes when read +type WorkflowKeyAttributes struct { + PublicKey string `json:"publicKey"` +} + +// WorkflowKey is the model that represents the created workflow key when read +type WorkflowKey struct { + ID string + Attributes WorkflowKeyAttributes +} + +// WorkflowKeys is the model that represents the created workflow keys when read +type WorkflowKeys struct { + Data []WorkflowKey `json:"data"` +} + // OCRKeys is the model that represents the created OCR keys when read type OCRKeys struct { Data []OCRKeyData `json:"data"`