toJson method

Map<String, Object> toJson()

Converts a JobSpec instance to JSON data.

Implementation

Map<String, Object> toJson() {
  final jsonData = <String, Object>{};

  final tempActiveDeadlineSeconds = activeDeadlineSeconds;
  final tempBackoffLimit = backoffLimit;
  final tempCompletionMode = completionMode;
  final tempCompletions = completions;
  final tempManualSelector = manualSelector;
  final tempParallelism = parallelism;
  final tempPodFailurePolicy = podFailurePolicy;
  final tempSelector = selector;
  final tempSuspend = suspend;
  final tempTemplate = template;
  final tempTtlSecondsAfterFinished = ttlSecondsAfterFinished;

  if (tempActiveDeadlineSeconds != null) {
    jsonData['activeDeadlineSeconds'] = tempActiveDeadlineSeconds;
  }

  if (tempBackoffLimit != null) {
    jsonData['backoffLimit'] = tempBackoffLimit;
  }

  if (tempCompletionMode != null) {
    jsonData['completionMode'] = tempCompletionMode;
  }

  if (tempCompletions != null) {
    jsonData['completions'] = tempCompletions;
  }

  if (tempManualSelector != null) {
    jsonData['manualSelector'] = tempManualSelector;
  }

  if (tempParallelism != null) {
    jsonData['parallelism'] = tempParallelism;
  }

  if (tempPodFailurePolicy != null) {
    jsonData['podFailurePolicy'] = tempPodFailurePolicy.toJson();
  }

  if (tempSelector != null) {
    jsonData['selector'] = tempSelector.toJson();
  }

  if (tempSuspend != null) {
    jsonData['suspend'] = tempSuspend;
  }

  jsonData['template'] = tempTemplate.toJson();

  if (tempTtlSecondsAfterFinished != null) {
    jsonData['ttlSecondsAfterFinished'] = tempTtlSecondsAfterFinished;
  }

  return jsonData;
}