bbende / nifi

Mirror of Apache NiFi
Apache License 2.0
1 stars 1 forks source link

`nifi-reg export-flow-version` should not require a bucket id #21

Closed aperepel closed 6 years ago

aperepel commented 6 years ago

The command wants the flow uuid and bucket uuid, which doesn't make sense, as we have a global pointer into the flow version already.

2 ways to address it:

  1. drop the bucket requirement for the command
  2. support (or switch to) using unique names for buckets & flows and building URIs with those.
bbende commented 6 years ago

For now I'd like to make the CLI tool work against the already released 0.1.0 version of NiFi Registry, and of course submit improvements to the registry side of things and then update the CLI later to use those improvements.

Given that, there currently is no REST end-point in NiFi Registry to retrieve a flow just by id or name, it is always scoped under a bucket. So there would be two ways to currently implement this...

1) CLI retrieves all buckets, loop over each bucket and retrieve all flows, check each flow til we find the matching id/name.

2) CLI calls the "/items" end-point which NiFi Registry UI uses for the main display, this currently returns every "item" in the registry, so we can then loop over each item, check for the type == FLOW and see if the id/name matches.

Either of the above approaches works, as long as we realize we are going from making a single direct REST call, to potentially multiple calls with larger responses. I would opt for option 2 since its just one big response to process.

bbende commented 6 years ago

I've gone ahead and implemented option 2, so now export and import no longer require the bucket id, and behind the scenes it determines the bucket automatically.

Example steps to move the latest version of a flow to a new bucket/flow:

#> nifi-reg export-flow-version -f 06acb207-d2f1-447f-85ed-9b8672fe6d30 -o my-flow.json
#> nifi-reg create-bucket -bn "New Bucket"
d5669000-3b16-4c87-9b30-4e7ffc9923d5
#> nifi-reg create-flow -b d5669000-3b16-4c87-9b30-4e7ffc9923d5 -fn "Copied My Flow"
3e46bb91-c930-47c1-89d7-5b762c425ce7
#> nifi-reg import-flow-version -f 3e46bb91-c930-47c1-89d7-5b762c425ce7 -i my-flow.json
1

Will push the commit and close this.