class AAIDeleteTasks {

    public void deleteNetworkPolicies(BuildingBlockExecution execution) {
        try {
            String fqdns = execution.getVariable(contrailNetworkPolicyFqdnList);
            if (fqdns != null && !fqdns.isEmpty()) {
                String[] fqdnList = fqdns.split(",");
                int fqdnCount = fqdnList.length;
                if (fqdnCount > 0) {
                    for (int i = 0; i < fqdnCount; i++) {
                        String fqdn = fqdnList[i];
                        AAIPluralResourceUri uri =
                                AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies());
                        uri.queryParam(networkPolicyFqdnParam, fqdn);
                        Optional<NetworkPolicies> oNetPolicies = aaiNetworkResources.getNetworkPolicies(uri);
                        if (oNetPolicies.isPresent()) {
                            NetworkPolicies networkPolicies = oNetPolicies.get();
                            List<NetworkPolicy> networkPolicyList = networkPolicies.getNetworkPolicy();
                            if (networkPolicyList != null && !networkPolicyList.isEmpty()) {
                                NetworkPolicy networkPolicy = networkPolicyList.get(0);
                                String networkPolicyId = networkPolicy.getNetworkPolicyId();
                                logger.debug("Deleting network-policy with network-policy-id {}", networkPolicyId);
                                aaiNetworkResources.deleteNetworkPolicy(networkPolicyId);
                            }
                        }
                    }
                }
            }
        } catch (Exception ex) {
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
        }
    }

}