# # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary AntivirusOnDemandCommand Component Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::C::AntivirusOnDemandCommand =head1 DESCRIPTION C is a derived class of L. It represents access to an ONTAP AntivirusOnDemandCommand. A related class is L, which represents the past state of an ONTAP AntivirusOnDemandCommand. Note that from SN.0, the antivirus commands were vserverized and in the process, the commands here were split into separate directories. See the components L, L, L, L. =head1 ATTRIBUTES =head2 command_interface See L =head2 name =cut package NACL::C::AntivirusOnDemandCommand; use strict; use warnings; use NACL::CS::AntivirusOnDemandCommand; use NACL::ComponentUtils qw (_optional_scalars Dumper); use base 'NACL::C::Component::ONTAP'; use Params::Validate qw(validate validate_with SCALAR); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::C::AntivirusOnDemandCommandScanVserver; use NACL::C::AntivirusOnDemandCommandScanFile; use NACL::C::AntivirusOnDemandCommandScanDir; use NACL::C::AntivirusOnDemandCommandScanCluster; use NACL::APISet::Exceptions::ResponseException qw(:try); use NACL::C::Exceptions::AntivirusOnDemandCommand::AlreadyExists (); use NACL::C::Exceptions::AntivirusOnDemandCommand::DoesNotExist (); use NACL::C::Exceptions::AntivirusOnDemandCommand::InUse (); use NACL::C::_Mixins::AntivirusOnDemandCommand qw(:all); =head1 METHODS =head2 new my $AntivirusOnDemandCommand = NACL::C::AntivirusOnDemandCommand->new(command_interface=>$ci, name =>$name, ); Return a new AntivirusOnDemandCommand component object with the given attributes. =cut use Class::MethodMaker [scalar => 'name',]; =head2 find my $AntivirusOnDemandCommand = NACL::C::AntivirusOnDemandCommand->find(command_interface => $ci, ...); my @AntivirusOnDemandCommands = NACL::C::AntivirusOnDemandCommand->find(command_interface => $ci, ...); (Class method) A constructor of sorts, which discovers which elements are present (by interacting with the given command interface). In an array context it creates a component object for each present element and returns them. In a scalar context it creates a component object for just one element. This method is generally not implemented in individual components. The base class (L provides an implementation. See for a more detailed description along with explanation of all the options accepted. =head2 state my $AntivirusOnDemandCommand_state = $NACL::C::AntivirusOnDemandCommand->state(); (Instance method) Fetch the current state of the element associated with this component, and return a Component State object corresponding to this component (calling this on NACL::C::AntivirusOnDemandCommand would return a NACL::CS::AntivirusOnDemandCommand object) This method is generally not implemented in individual components. The base class (L provides an implementation. See for a more detailed description along with explanation of all the options accepted. =cut =head2 delete NACL::C::AntivirusOnDemandCommand->delete( command_interface => $ci, name => $name, ...); or $AntivirusOnDemandCommand_object->delete(...); (Class or instance method) This method is used to deletes an on-demand scan command. Uses a CMode CLI APIset. =over =item Options =over =item C<< command_interface => $command_interface >> (Required for class method, Not Applicable for instance method) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< "name" => $name >> (Required for class method, Not Applicable for instance method) Applicable for CMode CLI. =item C<< "extended_query" => $string >> (Optional) Applicable for CMode CLI =item C<< '*' >> This method takes all other options supported by "antivirus on-demand command delete" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C This type of exception gets thrown if an attempt is made to delete an on-demand command that does not exist. =item C This type of exceptions gets thrown if an attempt is made to delete an on-demand command when the command is in use. =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub delete { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; $pkg_or_obj->_frontend_log_debug_opts(@args); my %opts = $pkg_or_obj->_common_validate_with( params => \@args, api => 'antivirus_on_demand_command_delete', ); my $ret; if ($opts{command_interface} ->has_uichange(uichange => 'antivirus-vserverization')) { # Command no longer exists, need to redirect to the relevant # component. This is determined by the "scan-type" field. my $name = delete $opts{name}; my $cs = NACL::CS::AntivirusOnDemandCommand->fetch( %opts, filter => {name => $name}, requested_fields => ['scan-type'] ); my $scan_type = $cs->scan_type(); if ($scan_type ne 'cluster') { $opts{vserver} = $cs->vserver(); } $scan_type = ucfirst $scan_type; my $pkg = 'NACL::C::AntivirusOnDemandCommandScan' . $scan_type; $ret = $pkg->delete(%opts, name => $name); } else { try { $ret = $pkg_or_obj->call_on_apiset( %opts, choices => [ { method => '_delete_cmode_cli', interface => 'CLI', set => 'CMode', }, ], frontend => 'NACL::C::AntivirusOnDemandCommand::delete', ); } catch NACL::APISet::Exceptions::ResponseException with { __PACKAGE__->_convert_exception(exception => $_[0]); }; } $Log->exit() if $may_exit; return $ret; } ## end sub delete sub _delete_cmode_cli { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; my %opts = validate_with( params => \@args, spec => $pkg_or_obj->_backend_validate_spec(), allow_extra => 1 ); my $command_interface = $opts{command_interface}; my $apiset = delete $opts{apiset}; my $prompts_answers = ['do you really want to delete it' => "yes",]; my %cmode_args = $pkg_or_obj->get_api_options( apiset => $apiset, api => 'antivirus_on_demand_command_delete', options => \%opts, ); $apiset->antivirus_on_demand_command_delete(%cmode_args, 'connectrec-match_table' => $prompts_answers); $Log->exit() if $may_exit; } ## end sub _delete_cmode_cli =head2 create my $AntivirusOnDemandCommand_object = NACL::C::AntivirusOnDemandCommand->create( command_interface => $ci, name => $name, ...); (Class method) This method is used to adds a new on-demand scan command. Uses a CMode CLI APIset. =over =item Options =over =item C<< command_interface => $command_interface >> (Required) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< "name" => $name >> (Required) Applicable for CMode CLI. =item C<< "command-line" => $string >> Applicable for CMode CLI. =item C<< "extended_query" => $string >> (Optional) Applicable for CMode CLI =item C<< '*' >> This method takes all other options supported by "antivirus on-demand command create" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C This type of exception gets thrown if an attempt is made to create an on-demand command that already exists. =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub create { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->_frontend_log_debug_opts(@args); my %opts = $pkg->_common_validate_with( params => \@args, additional_spec => {_optional_scalars(qw( command-line ))}, api => 'antivirus_on_demand_command_create', ); my $ret; if ($opts{command_interface} ->has_uichange(uichange => 'antivirus-vserverization')) { $pkg->_handle_full_cmd_line( method => 'create', opts => \%opts ); $ret = $pkg->new( command_interface => $opts{command_interface}, name => $opts{name} ); } else { try { $ret = $pkg->call_on_apiset( %opts, choices => [ { method => '_create_cmode_cli', interface => 'CLI', set => 'CMode', }, ], frontend => 'NACL::C::AntivirusOnDemandCommand::create', ); } catch NACL::APISet::Exceptions::ResponseException with { __PACKAGE__->_convert_exception(exception => $_[0]); }; } $Log->exit() if $may_exit; return $ret; } ## end sub create sub _create_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my %opts = validate_with( params => \@args, spec => $pkg->_backend_validate_spec(), allow_extra => 1 ); my $command_interface = $opts{command_interface}; my $apiset = delete $opts{apiset}; my %cmode_args = $pkg->get_api_options( apiset => $apiset, api => 'antivirus_on_demand_command_create', options => \%opts, ); $apiset->antivirus_on_demand_command_create(%cmode_args); $Log->exit() if $may_exit; return $pkg->new( command_interface => $command_interface, name => $cmode_args{'name'}, ); } ## end sub _create_cmode_cli =head2 modify NACL::C::AntivirusOnDemandCommand->modify( command_interface => $ci, name => $name, ...); or $AntivirusOnDemandCommand_object->modify(...); (Class or instance method) This method is used to modifies an on-demand scan command. Uses a CMode CLI APIset. =over =item Options =over =item C<< command_interface => $command_interface >> (Required for class method, Not Applicable for instance method) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< "name" => $name >> (Required for class method, Not Applicable for instance method) Applicable for CMode CLI. =item C<< "command-line" => $string >> Applicable for CMode CLI. =item C<< "extended_query" => $string >> (Optional) Applicable for CMode CLI =item C<< '*' >> This method takes all other options supported by "antivirus on-demand command modify" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub modify { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; $pkg_or_obj->_frontend_log_debug_opts(@args); my %opts = $pkg_or_obj->_common_validate_with( params => \@args, additional_spec => {_optional_scalars(qw( command-line ))}, api => 'antivirus_on_demand_command_modify', ); my $ret; if ($opts{command_interface} ->has_uichange(uichange => 'antivirus-vserverization')) { $ret = $pkg_or_obj->_handle_full_cmd_line( method => 'modify', opts => \%opts ); } else { $ret = $pkg_or_obj->call_on_apiset( %opts, choices => [ { method => "_modify_cmode_cli", interface => "CLI", set => "CMode", }, ], frontend => 'NACL::C::AntivirusOnDemandCommand::modify', ); } $Log->exit() if $may_exit; return $ret; } ## end sub modify sub _modify_cmode_cli { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; my %opts = validate_with( params => \@args, spec => $pkg_or_obj->_backend_validate_spec(), allow_extra => 1 ); my $command_interface = $opts{command_interface}; my $apiset = delete $opts{apiset}; my %cmode_args = $pkg_or_obj->get_api_options( apiset => $apiset, api => 'antivirus_on_demand_command_modify', options => \%opts, ); $apiset->antivirus_on_demand_command_modify(%cmode_args); $Log->exit() if $may_exit; } ## end sub _modify_cmode_cli __PACKAGE__->_load_event_class(); sub _primary_keys_validate_spec { return ('name' => {type => SCALAR},); } 1;