CustomResourceDefinitionSpec.fromJson constructor

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

Creates a CustomResourceDefinitionSpec from JSON data.

Implementation

factory CustomResourceDefinitionSpec.fromJson(Map<String, dynamic> json) {
  final tempConversionJson = json['conversion'];
  final tempGroupJson = json['group'];
  final tempNamesJson = json['names'];
  final tempPreserveUnknownFieldsJson = json['preserveUnknownFields'];
  final tempScopeJson = json['scope'];
  final tempVersionsJson = json['versions'];

  final CustomResourceConversion? tempConversion = tempConversionJson != null
      ? CustomResourceConversion.fromJson(tempConversionJson)
      : null;
  final String tempGroup = tempGroupJson;
  final CustomResourceDefinitionNames tempNames =
      CustomResourceDefinitionNames.fromJson(tempNamesJson);
  final bool? tempPreserveUnknownFields = tempPreserveUnknownFieldsJson;
  final String tempScope = tempScopeJson;

  final List<CustomResourceDefinitionVersion> tempVersions =
      List<dynamic>.from(tempVersionsJson)
          .map(
            (e) => CustomResourceDefinitionVersion.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList();

  return CustomResourceDefinitionSpec(
    conversion: tempConversion,
    group: tempGroup,
    names: tempNames,
    preserveUnknownFields: tempPreserveUnknownFields,
    scope: tempScope,
    versions: tempVersions,
  );
}