@Override
    public ObjectNode encode(K8sNetwork network, CodecContext context) {
        checkNotNull(network, "Kubernetes network cannot be null");

        ObjectNode result = context.mapper().createObjectNode()
                .put(NETWORK_ID, network.networkId())
                .put(NAME, network.name())
                .put(CIDR, network.cidr());

        if (network.type() != null) {
            result.put(TYPE, network.type().name());
        }

        if (network.segmentId() != null) {
            result.put(SEGMENT_ID, network.segmentId());
        }

        if (network.mtu() != null) {
            result.put(MTU, network.mtu());
        }

        return result;
    }
@Test
    public void testK8sNetworkEncode() {
        K8sNetwork network = DefaultK8sNetwork.builder()
                .networkId("network-1")
                .name("network-1")
                .segmentId("1")
                .type(K8sNetwork.Type.VXLAN)
                .cidr("10.10.0.0/24")
                .mtu(1500)
                .build();

        ObjectNode nodeJson = k8sNetworkCodec.encode(network, context);
        assertThat(nodeJson, matchesK8sNetwork(network));
    }