# $Id//depot/prod/test/nacldev/lib/NACL/CS/DFM/Rbac.pm$ # # Copyright (c) 2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Rbac ComponentState Module (auto-generated by CGT) ## @author dl-mpo-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::DFM::Rbac =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP Rbac. A related class is L, which represents access to an ONTAP Rbac. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Rbac element are the attributes of the Rbac ComponentState. =over =item C<< inherited_roles >> Array =item C<< role_name_and_id >> =item C<< capabilities>> Array =item C<< description >> =back =cut package NACL::CS::DFM::Rbac; use base 'NACL::CS::ComponentState::DFM'; use strict; use warnings; use Params::Validate qw(validate validate_with SCALAR ARRAYREF HASHREF); use NACL::ComponentUtils qw(Dumper); 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 [ new => [ '-hash', 'new' ], array => 'role_name_and_id', scalar => 'role_name_or_id', scalar => 'description', array => 'capabilities', array => 'inherited_roles', scalar => 'role_name', scalar => 'role_id', ]; =head1 METHODS =head2 fetch my $Rbac_state = NACL::CS::DFM::Rbac->fetch(command_interface => $ci, ...); my @Rbac_states = NACL::CS::DFM::Rbac->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. =cut sub fetch { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => '_fetch_zapi', interface => 'ZAPI', set => 'DFM', }, ], exception_text => 'No matching Role found.', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_zapi { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $command_interface = delete $opts{command_interface}; my $apiset = delete $opts{apiset}; my $allowed_options = [ qw( follow-role-inheritance ) ]; my %args; $pkg->_hash_copy( source => $opts{filter}, copy => $allowed_options, target => \%args, ); my $response = $apiset->rbac_role_info_list(%args); my $parsed_output = $response->get_parsed_output(); my @state_objs; # Go one level down to 'role-attributes' which will have all the fields my $output = $parsed_output->[0]->{'role-attributes'}->[0] ->{'role-attributes-identifier'}; foreach my $row ( @{$output} ) { my $obj = $pkg->new( command_interface => $command_interface ); $row->{'role-name-or-id'} = $row->{'role-name-and-id'}->[0]->{'rbac-role'}->[0] ->{'rbac-role-id'}; $row->{'role-id'} = $row->{'role-name-and-id'}->[0]->{'rbac-role'}->[0] ->{'rbac-role-id'}; $row->{'role-name'} = $row->{'role-name-and-id'}->[0]->{'rbac-role'}->[0] ->{'rbac-role-name'}; $row->{'capabilities'} = $row->{'capabilities'}->[0]->{'rbac-resource-operation'}; $obj->_set_fields( row => $row ); push @state_objs, $obj; } ## end foreach my $row ... return @state_objs; } # Overriding the implementation of the super class sub _extra_filter_fields { $Log->enter() if $may_enter; $Log->exit() if $may_exit; return [ qw(follow-role-inheritance) ]; } ## Overriding the implementation of the super class sub _apply_filter { $Log->enter() if $may_enter; my $pkg = shift; $pkg->SUPER::_apply_filter( @_, main_field => 'role-name-or-id', alternate_field => 'role-name' ); $Log->exit() if $may_exit; } 1;