NAME

Kernel::System::ITSMConfigItem - config item lib

DESCRIPTION

All config item functions.

PUBLIC INTERFACE

new()

create an object

   use Kernel::System::ObjectManager;
   local $Kernel::OM = Kernel::System::ObjectManager->new();
   my $ConfigItemObject = $Kernel::OM->Get('Kernel::System::ITSMConfigItem');

ConfigItemCount()

count all records of a config item class

   my $Count = $ConfigItemObject->ConfigItemCount(
       ClassID => 123,
   );

ConfigItemResultList()

return a config item list as array hash reference

   my $ConfigItemListRef = $ConfigItemObject->ConfigItemResultList(
       ClassID => 123,
       Start   => 100,
       Limit   => 50,
   );

ConfigItemGet()

return a config item as hash reference

   my $ConfigItem = $ConfigItemObject->ConfigItemGet(
       ConfigItemID => 123,
       Cache        => 0,    # (optional) default 1 (0|1)
   );

A hashref with the following keys is returned:

   $ConfigItem{ConfigItemID}
   $ConfigItem{Number}
   $ConfigItem{ClassID}
   $ConfigItem{Class}
   $ConfigItem{LastVersionID}
   $ConfigItem{CurDeplStateID}
   $ConfigItem{CurDeplState}
   $ConfigItem{CurDeplStateType}
   $ConfigItem{CurInciStateID}
   $ConfigItem{CurInciState}
   $ConfigItem{CurInciStateType}
   $ConfigItem{CreateTime}
   $ConfigItem{CreateBy}
   $ConfigItem{ChangeTime}
   $ConfigItem{ChangeBy}

ConfigItemAdd()

add a new config item

   my $ConfigItemID = $ConfigItemObject->ConfigItemAdd(
       Number  => '111',  # (optional)
       ClassID => 123,
       UserID  => 1,
   );

ConfigItemDelete()

delete an existing config item

   my $True = $ConfigItemObject->ConfigItemDelete(
       ConfigItemID => 123,
       UserID       => 1,
   );

ConfigItemAttachmentAdd()

adds an attachment to a config item

   my $Success = $ConfigItemObject->ConfigItemAttachmentAdd(
       ConfigItemID    => 1,
       Filename        => 'filename',
       Content         => 'content',
       ContentType     => 'text/plain',
       UserID          => 1,
   );

ConfigItemAttachmentDelete()

Delete the given file from the virtual filesystem.

   my $Success = $ConfigItemObject->ConfigItemAttachmentDelete(
       ConfigItemID => 123,               # used in event handling, e.g. for logging the history
       Filename     => 'Projectplan.pdf', # identifies the attachment (together with the ConfigItemID)
       UserID       => 1,
   );

ConfigItemAttachmentGet()

This method returns information about one specific attachment.

   my $Attachment = $ConfigItemObject->ConfigItemAttachmentGet(
       ConfigItemID => 4,
       Filename     => 'test.txt',
   );

returns

   {
       Preferences => {
           AllPreferences => 'test',
       },
       Filename    => 'test.txt',
       Content     => 'content',
       ContentType => 'text/plain',
       Filesize    => 12348409,
       Type        => 'attachment',
   }

ConfigItemAttachmentList()

Returns an array with all attachments of the given config item.

   my @Attachments = $ConfigItemObject->ConfigItemAttachmentList(
       ConfigItemID => 123,
   );

returns

   @Attachments = (
       'filename.txt',
       'other_file.pdf',
   );

ConfigItemAttachmentExists()

Checks if a file with a given filename exists.

   my $Exists = $ConfigItemObject->ConfigItemAttachmentExists(
       Filename => 'test.txt',
       ConfigItemID => 123,
       UserID   => 1,
   );

ConfigItemSearchExtended()

return a config item list as an array reference

   my $ConfigItemIDs = $ConfigItemObject->ConfigItemSearchExtended(
       Number       => 'The ConfigItem Number',  # (optional)
       Name         => 'The Name',               # (optional)
       ClassIDs     => [9, 8, 7, 6],             # (optional)
       DeplStateIDs => [1, 2, 3, 4],             # (optional)
       InciStateIDs => [1, 2, 3, 4],             # (optional)

       # config items with created time after ...
       ConfigItemCreateTimeNewerDate => '2006-01-09 00:00:01',  # (optional)
       # config items with created time before then ....
       ConfigItemCreateTimeOlderDate => '2006-01-19 23:59:59',  # (optional)

       # config items with changed time after ...
       ConfigItemChangeTimeNewerDate => '2006-01-09 00:00:01',  # (optional)
       # config items with changed time before then ....
       ConfigItemChangeTimeOlderDate => '2006-01-19 23:59:59',  # (optional)

       What => [                                                # (optional)
           # each array element is a and condition
           {
               # or condition in hash
               "[%]{'ElementA'}[%]{'ElementB'}[%]{'Content'}" => '%contentA%',
               "[%]{'ElementA'}[%]{'ElementC'}[%]{'Content'}" => '%contentA%',
           },
           {
               "[%]{'ElementA'}[%]{'ElementB'}[%]{'Content'}" => '%contentB%',
               "[%]{'ElementA'}[%]{'ElementC'}[%]{'Content'}" => '%contentB%',
           },
           {
               # use array reference if different content with same key was searched
               "[%]{'ElementA'}[%]{'ElementB'}[%]{'Content'}" => ['%contentC%', '%contentD%', '%contentE%'],
               "[%]{'ElementA'}[%]{'ElementC'}[%]{'Content'}" => ['%contentC%', '%contentD%', '%contentE%'],
           },
       ],

       PreviousVersionSearch => 1,  # (optional) default 0 (0|1)

       OrderBy => [ 'ConfigItemID', 'Number' ],                  # (optional)
       # default: [ 'ConfigItemID' ]
       # (ConfigItemID, Number, Name, ClassID, DeplStateID, InciStateID,
       # CreateTime, CreateBy, ChangeTime, ChangeBy)

       # Additional information for OrderBy:
       # The OrderByDirection can be specified for each OrderBy attribute.
       # The pairing is made by the array indices.

       OrderByDirection => [ 'Down', 'Up' ],                    # (optional)
       # default: [ 'Down' ]
       # (Down | Up)

       Limit          => 122,  # (optional)
       UsingWildcards => 0,    # (optional) default 1
   );

ConfigItemSearch()

return a config item list as an array reference

   my $ConfigItemIDs = $ConfigItemObject->ConfigItemSearch(
       Number       => 'The ConfigItem Number',  # (optional)
       ClassIDs     => [9, 8, 7, 6],             # (optional)
       DeplStateIDs => [1, 2, 3, 4],             # (optional)
       InciStateIDs => [1, 2, 3, 4],             # (optional)
       CreateBy     => [1, 2, 3],                # (optional)
       ChangeBy     => [3, 2, 1],                # (optional)

       # config items with created time after ...
       ConfigItemCreateTimeNewerDate => '2006-01-09 00:00:01',  # (optional)
       # config items with created time before then ....
       ConfigItemCreateTimeOlderDate => '2006-01-19 23:59:59',  # (optional)

       # config items with changed time after ...
       ConfigItemChangeTimeNewerDate => '2006-01-09 00:00:01',  # (optional)
       # config items with changed time before then ....
       ConfigItemChangeTimeOlderDate => '2006-01-19 23:59:59',  # (optional)

       OrderBy => [ 'ConfigItemID', 'Number' ],                  # (optional)
       # default: [ 'ConfigItemID' ]
       # (ConfigItemID, Number, ClassID, DeplStateID, InciStateID,
       # CreateTime, CreateBy, ChangeTime, ChangeBy)

       # Additional information for OrderBy:
       # The OrderByDirection can be specified for each OrderBy attribute.
       # The pairing is made by the array indices.

       OrderByDirection => [ 'Down', 'Up' ],                    # (optional)
       # default: [ 'Down' ]
       # (Down | Up)

       Limit          => 122,  # (optional)
       UsingWildcards => 0,    # (optional) default 1
   );

ConfigItemLookup()

This method does a lookup for a config-item. If a config-item id is given, it returns the number of the config-item. If a config-item number is given, the appropriate id is returned.

   my $Number = $ConfigItemObject->ConfigItemLookup(
       ConfigItemID => 1234,
   );

   my $ID = $ConfigItemObject->ConfigItemLookup(
       ConfigItemNumber => 1000001,
   );

UniqueNameCheck()

This method checks all already existing config items, whether the given name does already exist within the same config item class or among all classes, depending on the SysConfig value of UniqueCIName::UniquenessCheckScope (Class or Global).

This method requires 3 parameters: ConfigItemID, Name and Class "ConfigItemID" is the ID of the ConfigItem, which is to be checked for uniqueness "Name" is the config item name to be checked for uniqueness "ClassID" is the ID of the config item's class

All parameters are mandatory.

my $DuplicateNames = $ConfigItemObject->UniqueNameCheck( ConfigItemID => '73' Name => 'PC#005', ClassID => '32', );

The given name is not unique my $NameDuplicates = [ 5, 35, 48, ]; # IDs of ConfigItems with the same name

The given name is unique my $NameDuplicates = [];

CurInciStateRecalc()

recalculates the current incident state of this config item and all linked config items

   my $Success = $ConfigItemObject->CurInciStateRecalc(
       ConfigItemID               => 123,
       NewConfigItemIncidentState => $NewConfigItemIncidentState,  # optional, incident states of already checked CIs
       ScannedConfigItemIDs       => $ScannedConfigItemIDs,        # optional, IDs of already checked CIs
   );

INTERNAL INTERFACE

_FindInciConfigItems()

find all config items with an incident state

   $ConfigItemObject->_FindInciConfigItems(
       ConfigItemID              => $ConfigItemID,
       IncidentLinkTypeDirection => $IncidentLinkTypeDirection,
       ScannedConfigItemIDs     => \%ScannedConfigItemIDs,
   );

_FindWarnConfigItems()

find all config items with a warning

   $ConfigItemObject->_FindWarnConfigItems(
       ConfigItemID         => $ConfigItemID,
       LinkType             => $LinkType,
       Direction            => $LinkDirection,
       NumberOfLinkTypes    => 2,
       ScannedConfigItemIDs => $ScannedConfigItemIDs,
   );

_PrepareLikeString()

internal function to prepare like strings

   $ConfigItemObject->_PrepareLikeString( $StringRef );

ITSM Config Item events:

ConfigItemCreate, VersionCreate, DeploymentStateUpdate, IncidentStateUpdate, ConfigItemDelete, LinkAdd, LinkDelete, DefinitionUpdate, NameUpdate, ValueUpdate DefinitionCreate, VersionDelete

TERMS AND CONDITIONS

This software is part of the OTRS project (http://otrs.org/).

This software comes with ABSOLUTELY NO WARRANTY. For details, see the enclosed file COPYING for license information (AGPL). If you did not receive this file, see http://www.gnu.org/licenses/agpl.txt.