MatchResources.fromJson constructor

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

Creates a MatchResources from JSON data.

Implementation

factory MatchResources.fromJson(Map<String, dynamic> json) {
  final tempExcludeResourceRulesJson = json['excludeResourceRules'];
  final tempMatchPolicyJson = json['matchPolicy'];
  final tempNamespaceSelectorJson = json['namespaceSelector'];
  final tempObjectSelectorJson = json['objectSelector'];
  final tempResourceRulesJson = json['resourceRules'];

  final List<NamedRuleWithOperations>? tempExcludeResourceRules =
      tempExcludeResourceRulesJson != null
          ? List<dynamic>.from(tempExcludeResourceRulesJson)
              .map(
                (e) => NamedRuleWithOperations.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final String? tempMatchPolicy = tempMatchPolicyJson;
  final LabelSelector? tempNamespaceSelector =
      tempNamespaceSelectorJson != null
          ? LabelSelector.fromJson(tempNamespaceSelectorJson)
          : null;
  final LabelSelector? tempObjectSelector = tempObjectSelectorJson != null
      ? LabelSelector.fromJson(tempObjectSelectorJson)
      : null;

  final List<NamedRuleWithOperations>? tempResourceRules =
      tempResourceRulesJson != null
          ? List<dynamic>.from(tempResourceRulesJson)
              .map(
                (e) => NamedRuleWithOperations.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  return MatchResources(
    excludeResourceRules: tempExcludeResourceRules,
    matchPolicy: tempMatchPolicy,
    namespaceSelector: tempNamespaceSelector,
    objectSelector: tempObjectSelector,
    resourceRules: tempResourceRules,
  );
}