zend-patterns / ZendServerSDK

Pure ZF2 CLI for zpk creation and webapi client.
BSD 3-Clause "New" or "Revised" License
22 stars 17 forks source link

add Import / Export support to Targets #91

Open zvikazend opened 8 years ago

zvikazend commented 8 years ago

Seems I'm setting up the same targets in multiple work machines, so I figured we might help admins to use a resource file, especially with automations. Let's over-architect this tiny feature into a monster! :)

Special usage

Mass-Update: export all targets, modify the exported resource, then import with override. Flush and Load: first do a removeAllTargets to wipe the list, and then importTargets so we only have fresh target metadata

New Commands

importTargets

read resource file (according to output, csv, json, xml) into the ~/.zsapi.ini

Flags (Mandatory)

--targetsFile=/path/to/targets/file

Extra Flags

2 options to resolve conflicts with target names: --prefer=old|new: where "old" will new target data and keep local, and "new" will override from import resource ...or... --duplicates=keep|override: same as old|new --format=json|xml|kv|auto (not sure what fits here, yet) --hash=passkey: protect sensitive data with a hash - wrong hash will break format and fail operation --backupFile=/path/to/targetsFileBackup: allow to backup before messing up the local targets

Return data

Imported targets list, reflecting which target was flushed/overwritten

exportTargets

drop targets to resource file, format is the normal output format

Flags (Mandatory)

--targetsFile=/path/to/targets/file

Extra Flags

--targetMatch='pattern*'|'target1,target55': If used, will only export selected targets. If not used, will export all targets --hash=passkey: protect sensitive data with a hash - wrong hash will break format and fail operation --output-format=json|xml|kv|auto

Return data

Exported targets list