#compdef isi migrate

# Copyright C 2002-2007 by Isilon Systems, Inc. All rights not expressly
# granted herein are reserved.
# Created in the United States of America.
# 
# This digital media is protected by U.S. and international copyright and
# intellectual property laws. Unless otherwise specified, all information
# and screens appearing as part of this digital medium, including
# software, services, documents, text, images, icons, and logos design;
# the selection, assembly, arrangement, and design thereof; and the code
# that enables its presentation, are the sole property of Isilon Systems,
# Inc.
# 
# Except as otherwise required by applicable law, no part of any
# copyrighted material may be reproduced, modified, translated,
# distributed, published, or transmitted by any means, electronic or
# mechanical, for any purpose, without the prior written consent of Isilon
# Systems. 
#  
# Isilon and Isilon Systems are registered trademarks of Isilon Systems,
# Inc.  Legion is a trademark of Isilon Systems, Inc.  All other
# trademarks and registered trademarks are the property of their
# respective holders.

(( $+functions[__isi_migrate_throttle] )) ||
_isi_migrate_throttle () {
  if (( CURRENT == 2 )); then
    _tags values && { compadd $@ delete list create modify enable disable }
  fi
}

(( $+functions[__isi_migrate_bandwidth] )) ||
_isi_migrate_bandwidth () {
  if (( CURRENT == 2 )); then
    _tags values && { compadd $@ delete list create modify enable disable }
  fi
}

(( $+functions[__isi_migrate_jobs] )) ||
_isi_migrate_jobs () {
  if (( CURRENT == 2 )); then
    _tags values && { compadd $@ list resume stop pause report }
  fi
}

(( $+functions[__isi_migrate_policy] )) ||
_isi_migrate_policy () {
  if (( CURRENT == 2 )); then
    _tags values && { compadd $@ run delete list create assess modify disable enable report pause resume stop resolve reset }
  fi
}

(( $+functions[__isi_migrate_reports] )) ||
_isi_migrate_reports () {
  if (( CURRENT == 2 )); then
    _tags values && { compadd $@ policyconf config rotate rebuild }
  fi
}

(( $+functions[__isi_migrate_target] )) ||
_isi_migrate_target () {
  if (( CURRENT == 2 )); then
    _tags values && { compadd $@ list cancel break report allow_write }
  fi
}

(( $+functions[__isi_migrate_resync] )) ||
_isi_migrate_resync () {
  if (( CURRENT == 2 )); then
     _tags values && { compadd $@ prep }
  fi
}

(( $+functions[__isi_migrate] )) ||
_isi_migrate () {
  if (( CURRENT == 2 )); then
    _tags values && { compadd $@ config status start stop pause resume policy jobs bandwidth throttle reports target resync }
  else
    local cmd=${words[2]}
    (( CURRENT-- ))
    shift words
    if [[ $cmd == throttle ]]; then
      curcontext="${curcontext%:*:*}:isi-migrate-throttle:"
      _isi_migrate_throttle
    elif [[ $cmd == bandwidth ]]; then
      curcontext="${curcontext%:*:*}:isi-migrate-bandwidth:"
      _isi_migrate_bandwidth
    elif [[ $cmd == jobs ]]; then
      curcontext="${curcontext%:*:*}:isi-migrate-jobs:"
      _isi_migrate_jobs
    elif [[ $cmd == policy ]]; then
      curcontext="${curcontext%:*:*}:isi-migrate-policy:"
      _isi_migrate_policy
    elif [[ $cmd == reports ]]; then
      curcontext="${curcontext%:*:*}:isi-migrate-reports:"
      _isi_migrate_reports
    elif [[ $cmd == target ]]; then
      curcontext="${curcontext%:*:*}:isi-migrate-target:"
      _isi_migrate_target
    elif [[ $cmd == resync ]]; then
      curcontext="${curcontext%:*:*}:isi-migrate-resync:"
      _isi_migrate_resync
    fi
  fi
}
