Kernel::System::Service

NAME

Kernel::System::Service – service lib

DESCRIPTION

All service functions.

PUBLIC INTERFACE

new()

create an object

    my $ServiceObject = $Kernel::OM->Get('Kernel::System::Service');

ServiceList()

return a hash list of services

    my %ServiceList = $ServiceObject->ServiceList(
        Valid  => 0,   # (optional) default 1 (0|1)
        UserID => 1,
    );

ServiceListGet()

return a list of services with the complete list of attributes for each service

    my $ServiceList = $ServiceObject->ServiceListGet(
        Valid  => 0,   # (optional) default 1 (0|1)
        UserID => 1,
        CriticalityValue => 1, # (optional) default 1 (0/1)
    );

    returns

    $ServiceList = [
        {
            ServiceID  => 1,
            ParentID   => 0,
            Name       => 'MyService',
            NameShort  => 'MyService',
            ValidID    => 1,
            Comment    => 'Some Comment'
            CreateTime => '2011-02-08 15:08:00',
            ChangeTime => '2011-06-11 17:22:00',
            CreateBy   => 1,
            ChangeBy   => 1,
            TypeID           => 16,
            Type             => 'Backend',
            Criticality      => '3 normal',
            CriticalityValue => '3 normal',
            CurInciStateID   => 1,
            CurInciState     => 'Operational',
            CurInciStateType => 'operational',
        },
        {
            ServiceID  => 2,
            ParentID   => 1,
            Name       => 'MyService::MySubService',
            NameShort  => 'MySubService',
            ValidID    => 1,
            Comment    => 'Some Comment'
            CreateTime => '2011-02-08 15:08:00',
            ChangeTime => '2011-06-11 17:22:00',
            CreateBy   => 1,
            ChangeBy   => 1,
            TypeID           => 16,
            Type             => 'Backend',
            Criticality      => '3 normal',
            CriticalityValue => '3 normal',
            CurInciStateID   => 1,
            CurInciState     => 'Operational',
            CurInciStateType => 'operational',
        },
        # ...
    ];

ServiceGet()

return a service as hash

Return $ServiceData{ServiceID} $ServiceData{ParentID} $ServiceData{Name} $ServiceData{NameShort} $ServiceData{ValidID} $ServiceData{Comment} $ServiceData{CreateTime} $ServiceData{CreateBy} $ServiceData{ChangeTime} $ServiceData{ChangeBy} $ServiceData{TypeID} $ServiceData{Type} $ServiceData{Criticality} $ServiceData{CriticalityValue} $ServiceData{CurInciStateID} # Only if IncidentState is 1 $ServiceData{CurInciState} # Only if IncidentState is 1 $ServiceData{CurInciStateType} # Only if IncidentState is 1

    my %ServiceData = $ServiceObject->ServiceGet(
        ServiceID     => 123,
        IncidentState => 1, # Optional, returns CurInciState etc.
        CriticalityValue => 1, # (optional) default 1 (0/1)
        UserID        => 1,
    );

    my %ServiceData = $ServiceObject->ServiceGet(
        ServiceID          => 123,
        UserID             => 1,
        IncludePreferences => '0|1' # optional, default '1'
    );

    my %ServiceData = $ServiceObject->ServiceGet(
        Name    => 'Service::SubService',
        UserID  => 1,
    );

ServiceLookup()

return a service name and id

    my $ServiceName = $ServiceObject->ServiceLookup(
        ServiceID => 123,
    );

    or

    my $ServiceID = $ServiceObject->ServiceLookup(
        Name => 'Service::SubService',
    );

ServiceAdd()

add a service

    my $ServiceID = $ServiceObject->ServiceAdd(
        Name     => 'Service Name',
        ParentID => 1,           # (optional)
        ValidID  => 1,
        Comment  => 'Comment',    # (optional)
        UserID   => 1,
        TypeID      => 2,
        Criticality => '3 normal',
    );

ServiceUpdate()

update an existing service

    my $True = $ServiceObject->ServiceUpdate(
        ServiceID => 123,
        ParentID  => 1,           # (optional)
        Name      => 'Service Name',
        ValidID   => 1,
        Comment   => 'Comment',    # (optional)
        UserID    => 1,
        TypeID      => 2,
        Criticality => '3 normal',
    );

ServiceSearch()

return service ids as an array

    my @ServiceList = $ServiceObject->ServiceSearch(
        Name   => 'Service Name', # (optional)
        Limit  => 122,            # (optional) default 1000
        UserID => 1,
        ServiceID        => [ 2, 3 ] || 2,
        ExcludeServiceID        => [ 2, 3 ] || 2,
        NameShort        => 'Name*',
        Comment          => 'Example*',
        Valid            => 1,                                     # (optional) default 1 (0|1)
        TypeIDs          => [ 2, 3 ] || 2,
        Types            => [ 'Test', 'Example' ] || 'Test',
        Criticalities    => [ '2 low', '3 normal' ] || '2 low',
        CurInciStateID   => [ 2, 3 ] || 2,
        CurInciState     => [ 'problem', 'warning' ] || 'warning',
        CurInciStateType => [ 'Test' ] || 'Test',
        CreatedBy        => [ 1, 2 ] || 2,
        ChangedBy        => [ 1, 2 ] || 2,
        OrderBy          => 'Name',
        OrderDirection   => 'Up' (Up|Down),
    );

CustomerUserServiceMemberList()

returns a list of customeruser/service members

    ServiceID: service id
    CustomerUserLogin: customer user login
    DefaultServices: activate or deactivate default services

    Result: HASH -> returns a hash of key => service id, value => service name
            Name -> returns an array of user names
            ID   -> returns an array of user ids

    Example (get services of customer user):

    $ServiceObject->CustomerUserServiceMemberList(
        CustomerUserLogin => 'Test',
        Result            => 'HASH',
        DefaultServices   => 0,
    );

    Example (get customer user of service):

    $ServiceObject->CustomerUserServiceMemberList(
        ServiceID => $ID,
        Result    => 'HASH',
    );

CustomerUserServiceMemberAdd()

to add a member to a service

if 'Active' is 0, the customer is removed from the service

    $ServiceObject->CustomerUserServiceMemberAdd(
        CustomerUserLogin => 'Test1',
        ServiceID         => 6,
        Active            => 1,
        UserID            => 123,
    );

ServicePreferencesSet()

set service preferences

    $ServiceObject->ServicePreferencesSet(
        ServiceID => 123,
        Key       => 'UserComment',
        Value     => 'some comment',
        UserID    => 123,
    );

ServicePreferencesGet()

get service preferences

    my %Preferences = $ServiceObject->ServicePreferencesGet(
        ServiceID => 123,
        UserID    => 123,
    );

ServicePreferencesDelete()

Delete service preferences

    my $Success = $ServiceObject->ServicePreferencesDelete(
        ServiceID => 123,
    );

ServiceDelete()

Delete a Service

    my $Success = $ServiceObject->ServiceDelete(
        ServiceID    => 123,
        UserID       => 123,
    );

ServiceParentsGet()

return an ordered list all parent service IDs for the given service from the root parent to the current service parent

    my $ServiceParentsList = $ServiceObject->ServiceParentsGet(
        ServiceID => 123,
        UserID    => 1,
    );

    returns

    $ServiceParentsList = [ 1, 2, ...];

GetAllCustomServices()

get all custom services of one user

    my @Services = $ServiceObject->GetAllCustomServices( UserID => 123 );

_ServiceGetCurrentIncidentState()

Returns a hash with the original service data, enhanced with additional service data about the current incident state, based on configuration items and other services.

    %ServiceData = $ServiceObject->_ServiceGetCurrentIncidentState(
        ServiceData => \%ServiceData,
        Preferences => \%Preferences,
        UserID      => 1,
    );

CustomerUserServiceMemberDelete()

Deletes all relations between the service id given and its customer users and vice versa.

    $ServiceObject->CustomerUserServiceMemberDelete(
        CustomerUserLogin  => 789,
    );

    $ServiceObject->CustomerUserServiceMemberDelete(
        ServiceID  => 123,
    );
Scroll to Top