# Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary ComponentState Module for the method NACL::C::Snapmirror->show_history() (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SnapmirrorShowHistory =head1 DESCRIPTION C is a derived class of L. Object(s) of this type are returned when NACL::C::Snapmirror->show_history() is invoked. ((This module does not represent the state of any element, but is an object repesentation of the output obtained when NACL::C::Snapmirror->show_history() is invoked.) =head1 ATTRIBUTES The fields of the output are fields of the ComponentState object. =over =item C<< destination_volume >> Destination Volume Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< destination_vserver >> Destination Vserver Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< source_volume >> Source Volume Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< operation_id >> Operation ID Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< start_time_int >> Start Time Internal Filled in for CMode CLI. =item C<< end_time >> End Time Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< source_vserver >> Source Vserver Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< additional_info >> Additional Information Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< group_type >> Group Type possible value(s) are, Volume,Vserver,InfiniteVol Filled in for CMode CLI. =item C<< relationship_id >> Relationship ID Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< node >> Node Name possible value(s) are, ,local Filled in for CMode CLI. =item C<< transfer_size >> Transfer Size Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< start_time >> Start Time Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< destination_path >> Destination Path Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< operation_type >> Operation Type possible value(s) are, create,modify,quiesce,resume,delete,initialize,manual-update,scheduled-update,break,resync,abort,restore Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< end_time_int >> End Time Internal Filled in for CMode CLI. =item C<< source_path >> Source Path Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =item C<< result >> Result of the Operation possible value(s) are, success,failure Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: =back =cut package NACL::CS::SnapmirrorShowHistory; use strict; use warnings; use Params::Validate qw(validate); use NATE::Log qw(log_global); use NACL::Exceptions::NoElementsFound qw(:try); use NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use base 'NACL::CS::ComponentState::ONTAP'; use NACL::Exceptions::InvalidChoice; use NACL::CS::_Mixins::Snapmirror qw(:all); # _zapi_fields_underscored_value should not be used from the mix-in use NACL::C::_Mixins::Snapmirror qw(:all !_zapi_fields_underscored_value); use Class::MethodMaker [ scalar => 'destination_volume', scalar => 'destination_vserver', scalar => 'source_volume', scalar => 'operation_id', scalar => 'start_time_int', scalar => 'end_time', scalar => 'source_vserver', scalar => 'additional_info', scalar => 'group_type', scalar => 'relationship_id', scalar => 'node', scalar => 'transfer_size', scalar => 'start_time', scalar => 'destination_path', scalar => 'operation_type', scalar => 'end_time_int', scalar => 'source_path', scalar => 'result', ]; my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); =head1 METHODS =head2 fetch my $SnapmirrorShowHistory_state = NACL::CS::SnapmirrorShowHistory->fetch(command_interface => $ci, ...); my @SnapmirrorShowHistory_states = NACL::CS::SnapmirrorShowHistory->fetch(command_interface => $ci, ...); (Class method) Discovers which elements are present and returns their state in ComponentState objects. Called in scalar context it returns only one state object, in list context it returns all state objects. See L for a more detailed description along with a complete explanation of the options it accepts. Supports CMode CLI/ZAPI (both iter and non-iter). Invokes 'snapmirror-history-get-iter' API for iter CMode ZAPI; invokes 'snapmirror-history-get' for non-iter CMode ZAPI. =over =item Exceptions =over =item C When there are no elements matching the query specified or elements of that type doesn't exist, then this exception will be thrown. =back =back =cut sub fetch { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::fetch( @args, choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', zapi_type => 'none', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', zapi_type => 'iter', }, { method => '_fetch_cmode_zapi_non_iter', interface => 'ZAPI', set => 'CMode', zapi_type => 'non-iter', check => '_local_non_iter_check', }, ], show_cmd => 'snapmirror show-history', exception_text => 'No matching snapmirror(s) found', frontend => 'NACL::CS::SnapmirrorShowHistory::fetch', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@args, api => 'snapmirror_show_history',); $Log->exit() if $may_exit; return @state_objs; } sub _local_common_zapi_copy { my @copy = ( qw(destination-volume operation-id source-volume destination-vserver end-time additional-info source-vserver relationship-id transfer-size start-time operation-type result) ); return wantarray ? @copy : [@copy]; } sub _local_common_zapi_map { my %map = ( 'destination-path' => 'destination-location', 'source-path' => 'source-location', 'group-type' => 'relationship-group-type', ); return wantarray ? %map : {%map}; } sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my $copy = $pkg->_local_common_zapi_copy(); my $map = $pkg->_local_common_zapi_map(); my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, copy => $copy, map => $map, api => 'snapmirror-history-get-iter', ); $Log->exit() if $may_exit; return @state_objs; } sub _fetch_cmode_zapi_non_iter { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my $copy = $pkg->_local_common_zapi_copy(); my $map = $pkg->_local_common_zapi_map(); my @state_objs = $pkg->SUPER::_fetch_cmode_zapi_non_iter( %opts, api => 'snapmirror-history-get', copy => $copy, map => $map, primary_keys => [ qw(operation-id destination-volume destination-vserver destination-path) ], ); $Log->exit() if $may_exit; return @state_objs; } sub _update_state_objs_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; $pkg->SUPER::_update_state_objs_cmode_zapi( %opts, zapi_field_translations => { hyphenate_value => [$pkg->_zapi_fields_underscored_value()], }, hash_map_translations => { $pkg->_hash_map_translations_group_type(), }, ); $Log->exit() if $may_exit; } sub _zapi_fields_underscored_value { return (qw(operation-type)); } # In addition to the destination-path, the "operation-id" is mandatory sub _local_non_iter_check { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my $filter = $opts{filter}; # Checks that destination-path can be constructed $pkg->_non_iter_check_cs(%opts); if (!defined $filter->{'operation-id'}) { $Log->exit() if $may_exit; NACL::Exceptions::InvalidChoice->throw("'operation-id' " . 'is mandatory for the snapmirror-history-get ZAPI ' . 'but was not provided in the filter, hence the ' . 'non-iter back-end cannot be used'); } $Log->exit() if $may_exit; } sub _super_apply_filter { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; $pkg->SUPER::_apply_filter(%opts); $Log->exit() if $may_exit; } sub _extra_filter_fields { $Log->enter() if $may_enter; $Log->exit() if $may_exit; return [qw(expand max-rows-per-relationship)]; } 1;