# # Copyright (c) 2014 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # # ## @summary UserGroup ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here ################################################################################ =head1 NAME NACL::CS::Client::UserGroup =head1 DESCRIPTION C is a derived class of L. It represents the state of Interface. A related class is L, which represents user group. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the user group element are the attributes of the UserGroup ComponentState. =over =item C<< group >> Filled in for Linux CLI The user group name. =item C<< gid >> Filled in for Linux CLI. The Group ID of the UserGroup. =item C<< passwd >> Filled in for Linux CLI The user group passwd. =item C<< users >> Filled in for Linux CLI The users present in the user group. =back =head2 command_interface See L =cut ################### # Package package NACL::CS::Client::UserGroup; ################### use strict; use warnings; ################### # Module includes use NACL::ComponentUtils qw (_optional_scalars Dumper); use base 'NACL::CS::ComponentState::Client'; use Params::Validate qw(validate SCALAR BOOLEAN); use NACL::APISet::Exceptions::ResponseException qw/:try/; 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 => 'group', scalar => 'password', scalar => 'group_id', array => 'users' ]; =head1 METHODS =head2 fetch my $interface_state = NACL::CS::Client::UserGroup->fetch(command_interface=>$ci,...); my @interface_states = NACL::CS::Client::UserGroup->fetch(command_interface=>$ci,...); see L Supports Linux/Solaris CLI. Invokes "UserGroup" command for Linux/Solaris CLI. =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_linux_cli", interface => "CLI", set => 'Linux' } ], exception_text => 'No matching user group found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_linux_cli { $Log->enter() if $may_enter; my @state_objs; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $filter = $opts{filter}; my $command_interface = $opts{command_interface}; my %api_args; if ( defined $filter->{group} ) { $api_args{group} = $filter->{group}; } my $response = $command_interface->apiset->getent_group(%api_args); my $parsed_output = $response->get_parsed_output() ; foreach my $row (@$parsed_output) { my $obj = $pkg->new( command_interface => $opts{command_interface}, ); $obj->_set_fields( row => $row ); push @state_objs, $obj; } return @state_objs; } ## end sub _fetch_linux_cli 1;