@Override
    public List<ManifestSnippet> handle(ServiceSpec serviceSpec, ManifestContext manifestContext) throws HyscaleException {
        // Check if the Spec is External
        if (!ManifestPredicates.isNetworkPolicyEnabled().test(serviceSpec)) {
            return Collections.emptyList();
        }
        try {
            // All Network Traffic Rules Go Under Allow Traffic
            List<NetworkTrafficRule> networkTrafficRules = serviceSpec.get(HyscaleSpecFields.allowTraffic, new TypeReference<>() {
            });

            // Only Port Number required to generate traffic rules
            networkTrafficRules.stream().forEach(rule -> rule
                    .setPorts(rule.getPorts().stream().map(port -> port.split(ToolConstants.PORTS_PROTOCOL_SEPARATOR)[0]).collect(Collectors.toList())));

            // To Generate k8s YAML Template
            logger.info("Started Network Policies Handler");
            ConfigTemplate networkPoliciesTemplate = templateProvider.get(PluginTemplateProvider.PluginTemplateType.NETWORK_POLICY);
            String yamlString = templateResolver.resolveTemplate(networkPoliciesTemplate.getTemplatePath(), getContext(networkTrafficRules, serviceSpec));
            ManifestSnippet snippet = new ManifestSnippet();
            snippet.setKind(ManifestResource.NETWORK_POLICY.getKind());
            snippet.setPath("spec");
            snippet.setSnippet(yamlString);

            List<ManifestSnippet> snippetList = new LinkedList<>();
            snippetList.add(snippet);
            logger.info("Successfully generated manifest for Network Policy");
            return snippetList;
        } catch (Exception e) {
            HyscaleException ex = new HyscaleException(e, ManifestErrorCodes.ERROR_WHILE_CREATING_MANIFEST);
            logger.error("Error while generating Manifest Files", ex);
            throw ex;
        }
    }
This class generates manifests to apply
the network policy rules
provided in the service spec.
manifest-generator/generator-services/src/main/java/io/hyscale/generator/services/plugins/NetworkPoliciesHandler.java