ObjectMeta.fromJson constructor

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

Creates a ObjectMeta from JSON data.

Implementation

factory ObjectMeta.fromJson(Map<String, dynamic> json) {
  final tempAnnotationsJson = json['annotations'];
  final tempCreationTimestampJson = json['creationTimestamp'];
  final tempDeletionGracePeriodSecondsJson =
      json['deletionGracePeriodSeconds'];
  final tempDeletionTimestampJson = json['deletionTimestamp'];
  final tempFinalizersJson = json['finalizers'];
  final tempGenerateNameJson = json['generateName'];
  final tempGenerationJson = json['generation'];
  final tempLabelsJson = json['labels'];
  final tempManagedFieldsJson = json['managedFields'];
  final tempNameJson = json['name'];
  final tempNamespaceJson = json['namespace'];
  final tempOwnerReferencesJson = json['ownerReferences'];
  final tempResourceVersionJson = json['resourceVersion'];
  final tempSelfLinkJson = json['selfLink'];
  final tempUidJson = json['uid'];

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

  final DateTime? tempCreationTimestamp = tempCreationTimestampJson != null
      ? DateTime.tryParse(tempCreationTimestampJson)
      : null;
  final int? tempDeletionGracePeriodSeconds =
      tempDeletionGracePeriodSecondsJson;
  final DateTime? tempDeletionTimestamp = tempDeletionTimestampJson != null
      ? DateTime.tryParse(tempDeletionTimestampJson)
      : null;
  final List<String>? tempFinalizers = tempFinalizersJson != null
      ? List<String>.from(tempFinalizersJson)
      : null;
  final String? tempGenerateName = tempGenerateNameJson;
  final int? tempGeneration = tempGenerationJson;

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

  final List<ManagedFieldsEntry>? tempManagedFields =
      tempManagedFieldsJson != null
          ? List<dynamic>.from(tempManagedFieldsJson)
              .map(
                (e) => ManagedFieldsEntry.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final String? tempName = tempNameJson;
  final String? tempNamespace = tempNamespaceJson;

  final List<OwnerReference>? tempOwnerReferences =
      tempOwnerReferencesJson != null
          ? List<dynamic>.from(tempOwnerReferencesJson)
              .map(
                (e) => OwnerReference.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final String? tempResourceVersion = tempResourceVersionJson;
  final String? tempSelfLink = tempSelfLinkJson;
  final String? tempUid = tempUidJson;

  return ObjectMeta(
    annotations: tempAnnotations,
    creationTimestamp: tempCreationTimestamp,
    deletionGracePeriodSeconds: tempDeletionGracePeriodSeconds,
    deletionTimestamp: tempDeletionTimestamp,
    finalizers: tempFinalizers,
    generateName: tempGenerateName,
    generation: tempGeneration,
    labels: tempLabels,
    managedFields: tempManagedFields,
    name: tempName,
    namespace: tempNamespace,
    ownerReferences: tempOwnerReferences,
    resourceVersion: tempResourceVersion,
    selfLink: tempSelfLink,
    uid: tempUid,
  );
}