
################
ConfigItemUpdate
################


****
NAME
****


Kernel::System::ProcessManagement::TransitionAction::ConfigItemUpdate - A module to deploy CI state


********
SYNOPSIS
********


All ConfigItemUpdate functions.


****************
PUBLIC INTERFACE
****************


new()
=====


create an object. Do not use it directly, instead use:


.. code-block:: perl

     my $ConfigItemUpdateObject = $Kernel::OM->Get('Kernel::System::ProcessManagement::TransitionAction::ConfigItemUpdate');



Run()
=====


Runs TransitionAction ConfigItemUpdate.
This function sets, updates or deletes values (of attribute) of given ConfigItemID (ConfigItemNumber).


.. code-block:: perl

     my $Success = $ConfigItemUpdateObject->Run(
         UserID                   => 123,
 
         # Ticket contains the result of TicketGet including dynamic fields
         Ticket                   => \%Ticket,   # required
 
         ProcessEntityID          => 'P123',
         ActivityEntityID         => 'A123',
         TransitionEntityID       => 'T123',
         TransitionActionEntityID => 'TA123',
 
         # Config is the hash stored in a Process::TransitionAction's config key
         Config                   => {
             ConfigItemID    => 123,             # you can also use multiple ConfigItemIDs separated by commas (123, 234, 345)
             or
             ConfigItemNumber => 123,            # you can also use multiple ConfigItemNumbers separated by commas (123, 234, 345)
             UserID           => 123,            # optional, to override the UserID from the logged user
 
             $Key             => $Value,         # required
         }
     );


Returns:


.. code-block:: perl

     my $Success = 1;     # 0



ConfigItemAttributesSet()
=========================


Deploys new CI attributes - creates a new CI Version.


.. code-block:: perl

     my $Success = $ConfigItemUpdateObject->ConfigItemAttributesSet(
         ConfigItemID               => 1,
         or
         ConfigItemNumber           => 1,
 
         # default ConfigItem data
         DeplStateName              => 'Production',
         InciStateName              => 'Operational',
 
         # StringifiedXMLData
         'CPU::'                    => 'NEW-CPU, NEW-CPU2',
         'HardDisk::1'              => 'NEW-HardDisk1',
         'HardDisk::1::Capacity::1' => '12',
         'HardDisk::2'              => 'NEW-HardDisk2',
         'HardDisk::2::Capacity::1' => '44',
         'Ram::1'                   => 'NEW-Ram',
         'Ram::2'                   => 'NEW-Ram2',
         'Vendor::1'                => 'NEW-Vendor',
 
         UserID                     => 123,
     );


Returns:


.. code-block:: perl

     my $Success = 1;



ConfigItemAttributesGet()
=========================


Returns a valid data structure for a new ConfigItem version.


.. code-block:: perl

     my %ConfigItemParams = $ConfigItemUpdateObject->ConfigItemAttributesGet(
         ConfigItemID => 1,
         or
         ConfigItemNumber => 1,
 
         # default ConfigItem data
         DeplStateName              => 'Production',
         InciStateName              => 'Operational',
 
         # StringifiedXMLData
         'CPU::'                    => 'NEW-CPU, NEW-CPU2',
         'HardDisk::1'              => 'NEW-HardDisk1',
         'HardDisk::1::Capacity::1' => '12',
         'HardDisk::2'              => 'NEW-HardDisk2',
         'HardDisk::2::Capacity::1' => '44',
         'Ram::1'                   => 'NEW-Ram',
         'Ram::2'                   => 'NEW-Ram2',
         'Vendor'                   => 'NEW-Vendor',
         'Description::1'           => '<OTRS_TICKET_Title>',
         'SerialNumber::1'          => '<OTRS_Ticket_DynamicField_SerialNumber>',
 
         UserID                     => 123,
     );


Returns:


.. code-block:: perl

     my %ConfigItemParams = (
         ConfigItemID  => 1,
         DeplStateName => 'Production',
         InciStateName => 'Operational',
         XMLData => {
             'CPU' => [
                 {
                     'Content' => 'NEW-CPU'
                 },
                 {
                     'Content' => 'NEW-CPU2'
                 }
             ],
             'HardDisk' => [
                 {
                     'Capacity' => [
                         {
                             'Content' => '12'
                         }
                     ],
                     'Content' => 'NEW-HardDisk1'
                 },
                 {
                     'Capacity' => [
                         {
                             'Content' => '44'
                         }
                     ],
                     'Content' => 'NEW-HardDisk2'
                 }
             ],
             [...],
         }
     );



XMLData2StringifiedXMLData()
============================


Converts XMLdata structure (used by $ZnunyHelperObject => _ITSMConfigItemVersionAdd()) to stringified XMLData 'CPU::1'.
This function should be integrated into Znuny::ITSM.


.. code-block:: perl

     my $StringifiedXMLData = $ConfigItemUpdateObject->XMLData2StringifiedXMLData(
         Prefix  => $Prefix,
         XMLData => {
             'NIC' => [
                 {
                     'Content'    => 'NicName1',
                     'IPoverDHCP' => [
                         {
                             'Content' => 'Yes',
                         }
                     ],
                     'IPAddress' => [
                         {
                             'Content' => '123',
                         },
                     ],
                 },
                 {
                     'Content'   => 'NicName2',
                     'IPoverDHCP' => [
                         {
                             'Content' => 'No',
                         }
                     ],
                     'IPAddress' => [
                         {
                             'Content' => '456',
                         }
                     ],
                 }
             ],
         }
     );


Returns:


.. code-block:: perl

     my $StringifiedXMLData = {
         NIC::1                => 'NicName1',
         NIC::1::IPAddress::1  => '123',
         NIC::1::IPoverDHCP::1 => 'Yes',
         NIC::2                => 'NicName2',
         NIC::2::IPAddress::1  => '456',
         NIC::2::IPoverDHCP::1 => 'No',
     };



StringifiedXMLData2XMLData()
============================


Converts stringified XMLData 'CPU::1' for config-item into XMLdata structure (used by $ZnunyHelperObject => _ITSMConfigItemVersionAdd()).
This function should be integrated into Znuny::ITSM.


.. code-block:: perl

     my $XMLData = $ConfigItemUpdateObject->StringifiedXMLData2XMLData(
 
         # new stringified XMLData for this ConfigItem
         StringifiedXMLData => {
             'CPU::1'                   => 'NEW-CPU',
             'CPU::2'                   => 'NEW-CPU2',
             'HardDisk::1'              => 'NEW-HardDisk1',
             'HardDisk::1::Capacity::1' => '12',
             'HardDisk::2'              => 'NEW-HardDisk2',
             'HardDisk::2::Capacity::1' => '44',
             'Ram::1'                   => 'NEW-Ram',
             'Ram::2'                   => 'NEW-Ram2',
             'Vendor::1'                => 'NEW-Vendor',
         }
 
         # this is the definition  of this Class $Definition->{DefinitionRef},
         XMLDefinition => [
             {
                 'Key' => 'NIC',
                 'Input' => {
                        'MaxLength' => 100,
                        'Size'      => 50,
                        'Type'      => 'Text',
                        'Required'  => 1
                 },
                 'CountDefault' => 1,
                 'CountMin'     => 0,
                 'CountMax'     => 10,
                 'Sub'          => [
                     {
                         'CountMin' => 1,
                         'CountDefault' => 1,
                         'Name' => 'IP over DHCP',
                         'CountMax' => 1,
                         'Input' => {
                             'Type'        => 'GeneralCatalog',
                             'Class'       => 'ITSM::ConfigItem::YesNo',
                             'Required'    => 1,
                             'Translation' => 1
                         },
                         'Key' => 'IPoverDHCP'
                     },
                     {
                         'Searchable'   => 1,
                         'CountMin'     => 0,
                         'CountDefault' => 0,
                         'CountMax'     => 20,
                         'Name'         => 'IP Address',
                         'Key'          => 'IPAddress',
                         'Input'        => {
                             'Type'         => 'Text',
                             'Required'     => 1,
                             'Size'         => 40,
                             'MaxLength'    => 40,
                         }
                     }
                 ],
                 'Name' => 'Network Adapter'
             },
         ],
 
         # original stringified XMLData from the latest version of this ConfigItem
         OriginalStringifiedXMLData => {
             'CPU::1'                   => 'CPU',
             'CPU::2'                   => 'CPU2',
             'HardDisk::1'              => 'HardDisk1',
             'HardDisk::1::Capacity::1' => '12',
             'HardDisk::2'              => 'HardDisk2',
             'HardDisk::2::Capacity::1' => '44',
             'Ram::1'                   => 'Ram',
             'Ram::2'                   => 'Ram2',
             'Vendor::1'                => 'Vendor',
         },
         Prefix       => $Prefix,
     );


Returns:


.. code-block:: perl

     $XMLData = {
         'CPU' => [
             {
                 'Content' => 'CPU'
             },
             {
                 'Content' => 'CPU2'
             }
         ],
         'Ram' => [
             {
                 'Content' => 'Ram'
             },
             {
                 'Content' => 'Ram2'
             }
         ],
         [...]
     };




