toJson method

Map<String, Object> toJson()

Converts a ServiceAccount instance to JSON data.

Implementation

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

  final tempApiVersion = apiVersion;
  final tempAutomountServiceAccountToken = automountServiceAccountToken;
  final tempImagePullSecrets = imagePullSecrets;
  final tempKind = kind;
  final tempMetadata = metadata;
  final tempSecrets = secrets;

  if (tempApiVersion != null) {
    jsonData['apiVersion'] = tempApiVersion;
  }

  if (tempAutomountServiceAccountToken != null) {
    jsonData['automountServiceAccountToken'] =
        tempAutomountServiceAccountToken;
  }

  if (tempImagePullSecrets != null) {
    jsonData['imagePullSecrets'] =
        tempImagePullSecrets.map((e) => e.toJson()).toList(growable: false);
  }

  if (tempKind != null) {
    jsonData['kind'] = tempKind;
  }

  if (tempMetadata != null) {
    jsonData['metadata'] = tempMetadata.toJson();
  }

  if (tempSecrets != null) {
    jsonData['secrets'] =
        tempSecrets.map((e) => e.toJson()).toList(growable: false);
  }

  return jsonData;
}