NodeStatus.fromJson constructor

NodeStatus.fromJson(
  1. Map<String, dynamic> json
)

Creates a NodeStatus from JSON data.

Implementation

factory NodeStatus.fromJson(Map<String, dynamic> json) {
  final tempAddressesJson = json['addresses'];
  final tempAllocatableJson = json['allocatable'];
  final tempCapacityJson = json['capacity'];
  final tempConditionsJson = json['conditions'];
  final tempConfigJson = json['config'];
  final tempDaemonEndpointsJson = json['daemonEndpoints'];
  final tempImagesJson = json['images'];
  final tempNodeInfoJson = json['nodeInfo'];
  final tempPhaseJson = json['phase'];
  final tempVolumesAttachedJson = json['volumesAttached'];
  final tempVolumesInUseJson = json['volumesInUse'];

  final List<NodeAddress>? tempAddresses = tempAddressesJson != null
      ? List<dynamic>.from(tempAddressesJson)
          .map(
            (e) => NodeAddress.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final Map<String, String>? tempAllocatable = tempAllocatableJson != null
      ? Map<String, String>.from(tempAllocatableJson)
      : null;

  final Map<String, String>? tempCapacity = tempCapacityJson != null
      ? Map<String, String>.from(tempCapacityJson)
      : null;

  final List<NodeCondition>? tempConditions = tempConditionsJson != null
      ? List<dynamic>.from(tempConditionsJson)
          .map(
            (e) => NodeCondition.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final NodeConfigStatus? tempConfig = tempConfigJson != null
      ? NodeConfigStatus.fromJson(tempConfigJson)
      : null;
  final NodeDaemonEndpoints? tempDaemonEndpoints =
      tempDaemonEndpointsJson != null
          ? NodeDaemonEndpoints.fromJson(tempDaemonEndpointsJson)
          : null;

  final List<ContainerImage>? tempImages = tempImagesJson != null
      ? List<dynamic>.from(tempImagesJson)
          .map(
            (e) => ContainerImage.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final NodeSystemInfo? tempNodeInfo = tempNodeInfoJson != null
      ? NodeSystemInfo.fromJson(tempNodeInfoJson)
      : null;
  final String? tempPhase = tempPhaseJson;

  final List<AttachedVolume>? tempVolumesAttached =
      tempVolumesAttachedJson != null
          ? List<dynamic>.from(tempVolumesAttachedJson)
              .map(
                (e) => AttachedVolume.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final List<String>? tempVolumesInUse = tempVolumesInUseJson != null
      ? List<String>.from(tempVolumesInUseJson)
      : null;

  return NodeStatus(
    addresses: tempAddresses,
    allocatable: tempAllocatable,
    capacity: tempCapacity,
    conditions: tempConditions,
    config: tempConfig,
    daemonEndpoints: tempDaemonEndpoints,
    images: tempImages,
    nodeInfo: tempNodeInfo,
    phase: tempPhase,
    volumesAttached: tempVolumesAttached,
    volumesInUse: tempVolumesInUse,
  );
}