JobStatus.fromJson constructor

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

Creates a JobStatus from JSON data.

Implementation

factory JobStatus.fromJson(Map<String, dynamic> json) {
  final tempActiveJson = json['active'];
  final tempCompletedIndexesJson = json['completedIndexes'];
  final tempCompletionTimeJson = json['completionTime'];
  final tempConditionsJson = json['conditions'];
  final tempFailedJson = json['failed'];
  final tempReadyJson = json['ready'];
  final tempStartTimeJson = json['startTime'];
  final tempSucceededJson = json['succeeded'];
  final tempUncountedTerminatedPodsJson = json['uncountedTerminatedPods'];

  final int? tempActive = tempActiveJson;
  final String? tempCompletedIndexes = tempCompletedIndexesJson;
  final DateTime? tempCompletionTime = tempCompletionTimeJson != null
      ? DateTime.tryParse(tempCompletionTimeJson)
      : null;

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

  final int? tempFailed = tempFailedJson;
  final int? tempReady = tempReadyJson;
  final DateTime? tempStartTime =
      tempStartTimeJson != null ? DateTime.tryParse(tempStartTimeJson) : null;
  final int? tempSucceeded = tempSucceededJson;
  final UncountedTerminatedPods? tempUncountedTerminatedPods =
      tempUncountedTerminatedPodsJson != null
          ? UncountedTerminatedPods.fromJson(tempUncountedTerminatedPodsJson)
          : null;

  return JobStatus(
    active: tempActive,
    completedIndexes: tempCompletedIndexes,
    completionTime: tempCompletionTime,
    conditions: tempConditions,
    failed: tempFailed,
    ready: tempReady,
    startTime: tempStartTime,
    succeeded: tempSucceeded,
    uncountedTerminatedPods: tempUncountedTerminatedPods,
  );
}