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

use strict;

package Raritan::RPC::cascading::CascadeManager::Status;

use Raritan::RPC::cascading::CascadeManager::LinkUnit;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'role'} = 1 * $in->{'role'};
    $encoded->{'master'} = "$in->{'master'}";
    $encoded->{'linkUnits'} = [];
    foreach my $key0 (keys %{$in->{'linkUnits'}}) {
        my $value0 = $in->{'linkUnits'}->{$key0};
        my $elem0 = {};
        $elem0->{'key'} = 1 * $key0;
        $elem0->{'value'} = Raritan::RPC::cascading::CascadeManager::LinkUnit::encode($value0);
        push(@{$encoded->{'linkUnits'}}, $elem0);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'role'} = $in->{'role'};
    $decoded->{'master'} = $in->{'master'};
    $decoded->{'linkUnits'} = {};
    for (my $i0 = 0; $i0 <= $#{$in->{'linkUnits'}}; $i0++) {
        my $key0 = $in->{'linkUnits'}->[$i0]->{'key'};
        my $value0 = Raritan::RPC::cascading::CascadeManager::LinkUnit::decode($agent, $in->{'linkUnits'}->[$i0]->{'value'});
        $decoded->{'linkUnits'}->{$key0} = $value0;
    }
    return $decoded;
}

1;
