#compdef isi avscan

# Copyright C 2008-2009 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_avscan] )) ||
_isi_avscan() {
  if (( CURRENT == 2 )); then
    _tags values && { compadd $@ manual scan policy get status quarantine unquarantine release config settings report}
  else
    local cmd=${words[2]}
    (( CURRENT-- ))
    shift words
    if [[ $cmd == manual ]] || [[ $cmd == scan ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-manual:"
      _isi_avscan_manual
    elif [[ $cmd == policy ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-policy:"
      _isi_avscan_policy
    elif [[ $cmd == get ]] || [[ $cmd == status ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-get:"
      _isi_avscan_get
    elif [[ $cmd == quarantine ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-quarantine:"
      _isi_avscan_quarantine
    elif [[ $cmd == unquarantine ]] || [[ $cmd == release ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-unquarantine:"
      _isi_avscan_unquarantine
    elif [[ $cmd == config ]] || [[ $cmd == settings ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-config:"
      _isi_avscan_config
    elif [[ $cmd == report ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-report:"
      _isi_avscan_report
    else
      _message "unknown isi avscan command: $words[1]"
    fi
  fi
}

(( $+functions[_isi_avscan_manual] )) ||
_isi_avscan_manual() {
  _isi_path
  _arguments -s : \
    '-n[file name to scan]:name:_isi_path' \
    '--policy=[optional Policy ID, default is MANUAL]' \
    '--report=[optional Report ID, default is generated dynamically]' \
    '--force=[optional force scan flag, default is true]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_avscan_policy] )) ||
_isi_avscan_policy() {
  if (( CURRENT == 2 ))
  then
    _tags values && { compadd $@ run add edit delete }
  else
    local cmd=${words[2]}
    (( CURRENT-- ))
    shift words
    if [[ $cmd == run ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-policy-run:"
      _isi_avscan_policy_run
    elif [[ $cmd == add ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-policy-add:"
      _isi_avscan_policy_add
    elif [[ $cmd == edit ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-policy-edit:"
      _isi_avscan_policy_edit
    elif [[ $cmd == delete ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-policy-delete:"
      _isi_avscan_policy_delete
    fi
  fi
}

(( $+functions[_isi_avscan_policy_run] )) ||
_isi_avscan_policy_run() {
  _arguments \
    '--id=[policy id]' \
    '--report=[optional Report ID]' \
    '--force=[force policy run]' \
    '--update=[update last run time in policy file]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_avscan_policy_add] )) ||
_isi_avscan_policy_add() {
  _arguments \
    '--id=[policy id]' \
    '--enable=[Enable this policy]' \
    '--name=[Name of this policy]' \
    '--description=[Detailed description of this policy]' \
    '--path=[Paths to include in scan]' \
    '--recurse=[Depth to recurse in traversal]' \
    '--force=[Force scan despite policy or cache]' \
    '--schedule=[operation execution schedule in isi date format]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_avscan_policy_edit] )) ||
_isi_avscan_policy_edit() {
  _arguments \
    '--id=[policy id]' \
    '--enable=[Enable this policy]' \
    '--name=[Name of this policy]' \
    '--description=[Detailed description of this policy]' \
    '--path=[Paths to include in scan]' \
    '--recurse=[Depth to recurse in traversal]' \
    '--force=[Force scan despite policy or cache]' \
    '--schedule=[operation execution schedule in isi date format]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_avscan_policy_delete] )) ||
_isi_avscan_policy_delete() {
  _arguments \
    '--id=[policy id to delete]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_avscan_get] )) ||
_isi_avscan_get() {
  _arguments \
    '-n[file name to view scan attributes]' \
    '--help[Print usage help and exit]' \
    '*::name:_isi_path'
}

(( $+functions[_isi_avscan_quarantine] )) ||
_isi_avscan_quarantine() {
  _arguments \
    '-n[file name to quarantine]' \
    '--help[Print usage help and exit]' \
    '*::name:_isi_path'
}

(( $+functions[_isi_avscan_unquarantine] )) ||
_isi_avscan_unquarantine() {
  _arguments \
    '-n[file name to unquarantine]' \
    '--help[Print usage help and exit]' \
    '*::name:_isi_path'
}

(( $+functions[_isi_avscan_config] )) ||
_isi_avscan_config() {
  _arguments \
    '--scan-on-open=[scan files on access]' \
    '--fail-open=[allow access when scanning fails]' \
    '--scan-on-close=[scan files when apps close them]' \
    '--max-scan-size=[skip scanning files bigger than this; 0=unlimited]' \
    '--repair=[try to repair files when threats found]' \
    '--quarantine=[try to quarantine files when threats found]' \
    '--truncate=[try to truncate files when threats found]' \
    '--report-expiry=[seconds until old reporting data is purged]' \
    '--glob-enable=[enable glob filters]' \
    '--glob-include=[Scan, not skip, files specified glob filters]' \
    '--glob-filter=[Glob pattern of leaf filename; may specify multiples, overwrites any existing filters]' \
    '--path-prefix=[Paths to include in realtime scans; may specify multiples, overwrites any existing prefixes]' \
    '--add-server=[URL of new ICAP server to add]' \
    '--del-server=[Delete the specified server from the config]' \
    '--enable-server=[Enable the specified server from the config]' \
    '--disable-server=[Disable the specified server from the config]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_avscan_report] )) ||
_isi_avscan_report() {
  if (( CURRENT == 2 ))
  then
    _tags values && { compadd $@ scan threat purge }
  else
    local cmd=${words[2]}
    (( CURRENT-- ))
    shift words
    if [[ $cmd == scan ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-report-scan:"
      _isi_avscan_report_scan
    elif [[ $cmd == threat ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-report-threat:"
      _isi_avscan_report_threat
    elif [[ $cmd == purge ]]; then
      curcontext="${curcontext%:*:*}:isi-avscan-report-purge:"
      _isi_avscan_report_purge
    fi
  fi
}

(( $+functions[_isi_avscan_report_scan] )) ||
_isi_avscan_report_scan() {
  _arguments \
    '--detail=[display details]' \
    '--wide=[display in wide table]' \
    '--export=[export to a file]' \
    '--max-results=[maximum number of results to show]' \
    '--all=[display all results]' \
    '--report-id=[optional report id]' \
    '--policy-id=[optional policy id]' \
    '--running=[scans in progress only]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_avscan_report_threat] )) ||
_isi_avscan_report_threat() {
  _arguments \
    '--detail=[display details]' \
    '--wide=[display in wide table]' \
    '--export=[export to a file]' \
    '--max-results=[maximum number of results to show]' \
    '--all=[display all results]' \
    '--report-id=[optional report id]' \
    '--file=[file name to search for]' \
    '--remediation=[use infected, truncated, repaired, or quarantined]' \
    '--help[Print usage help and exit]'
}

(( $+functions[_isi_avscan_report_purge] )) ||
_isi_avscan_report_purge() {
  _arguments \
    '--expire=[optional duration of time to indicate the minimum age of records to be deleted]' \
    '--help[Print usage help and exit]'
}


