# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2020 Raritan Inc. All rights reserved.
#
# This file was generated by IdlC from Role.idl.

use strict;

package Raritan::RPC::usermgmt::Role::Info;

use Raritan::RPC::usermgmt::Role::Privilege;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'description'} = "$in->{'description'}";
    $encoded->{'locked'} = ($in->{'locked'}) ? JSON::true : JSON::false;
    $encoded->{'privileges'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'privileges'}}; $i0++) {
        $encoded->{'privileges'}->[$i0] = Raritan::RPC::usermgmt::Role::Privilege::encode($in->{'privileges'}->[$i0]);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'description'} = $in->{'description'};
    $decoded->{'locked'} = ($in->{'locked'}) ? 1 : 0;
    $decoded->{'privileges'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'privileges'}}; $i0++) {
        $decoded->{'privileges'}->[$i0] = Raritan::RPC::usermgmt::Role::Privilege::decode($agent, $in->{'privileges'}->[$i0]);
    }
    return $decoded;
}

1;
