# 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_2_0_1::Status;

use Raritan::RPC::cascading::CascadeManager_2_0_1::LinkUnit;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'role'} = 1 * $in->{'role'};
    $encoded->{'primaryUnit'} = "$in->{'primaryUnit'}";
    $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_2_0_1::LinkUnit::encode($value0);
        push(@{$encoded->{'linkUnits'}}, $elem0);
    }
    return $encoded;
}

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

1;
