# # Copyright (c) 2017 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # # ## @summary Mediator ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here ################################################################################ =head1 NAME NACL::CS::Client::ONTAPSelectDeploy::Mediator =head1 DESCRIPTION C is a derived class of L. It represents the state of Interface. A related class is L, which represents access to an interface. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Mediator element are the attributes of the Mediator ComponentState. =over =item C<< mediator_ip >> Filled in for ONTAPSelectDeploy CLI. Maps to: For 'filter': Applicable, Filtering will be done by Components. For 'requested_fields', Not applicable, but the field will be populated in the CS object. =back =head2 command_interface See L =cut ################### # Package package NACL::CS::Client::ONTAPSelectDeploy::Mediator; ################### use strict; use warnings; ################### # Module includes use NACL::ComponentUtils qw (_optional_scalars Dumper); use base 'NACL::CS::ComponentState::Client'; use Params::Validate qw(validate validate_with SCALAR BOOLEAN); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Class::MethodMaker [ scalar => 'mediator_ip', ]; =head1 METHODS =head2 fetch my $interface_state = NACL::CS::Client::ONTAPSelectDeploy::Mediator->fetch(command_interface=>$ci,...); my @interface_states = NACL::CS::Client::ONTAPSelectDeploy::Mediator->fetch(command_interface=>$ci,...); see L Supports ONTAPSelectDeploy CLI. Invokes "Mediator" command. =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 = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => "_fetch", interface => "CLI", set => "ONTAPSelectDeploy" }, ], exception_text => '' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $filter = $opts{filter}; my ( @state_objs, $output, $response ); my %api_args; if ( defined $filter->{'mediator_ip'} ) { $api_args{'mediator_ip'} = $filter->{'mediator_ip'}; $response = $apiset->mediator_show(%api_args); } else { $response = $apiset->mediator_show_all(); } $output = $response->get_parsed_output(); foreach my $row (@$output) { my $obj = $pkg->new( command_interface => $opts{command_interface} ); $obj->_set_fields( row => $row, add_unknown_fields => 1 ); push @state_objs, $obj; } ## end foreach my $row (@$output) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch 1;