def delete(self):
        # Check if main object exists
        config = NitroResourceConfig(
            module=self.module,
            resource=self.main_nitro_class,
            attribute_values_dict=self.module.params,
            attributes_list=self.attibute_config[
                self.main_nitro_class]['attributes_list'],
            transforms=self.attibute_config[self.main_nitro_class]
            ['transforms'],
        )

        try:
            appfw_policy_exists = config.exists(
                get_id_attributes=self.attibute_config[
                    self.main_nitro_class]['get_id_attributes'])
        except NitroException as e:
            # This is the no such policy exists exception
            if e.errorcode == 2054:
                appfw_policy_exists = False
            else:
                raise
        if appfw_policy_exists:
            self.module_result['changed'] = True
            if not self.module.check_mode:
                config.delete(delete_id_attributes=self.attibute_config[
                    self.main_nitro_class]['delete_id_attributes'])
    def sync_binding_with_data(self, data):

        binding_key = data['binding_key']
        binding_object = data['binding_object']

        if self.module.params.get(binding_key) is None:
            return

        log('ModuleExecutor syncing binding %s' % binding_key)

        mode = self.module.params[binding_key]['mode']

        # Make a list of config objects for configured bindings
        configured_bindings = []
        for bind_values in self.module.params[binding_key]['attributes']:
            all_bind_values = copy.deepcopy(bind_values)
            configured_binding = NitroResourceConfig(
                module=self.module,
                resource=binding_object,
                attribute_values_dict=all_bind_values,
                attributes_list=self.attribute_config[binding_key]
                ['attributes_list'],
                transforms=self.attribute_config[binding_key]['transforms'],
            )

            configured_bindings.append(configured_binding)

        if mode == 'bind':
            for configured_binding in configured_bindings:
                self.module_result['changed'] = True
                try:
                    configured_binding.create()
                except NitroException as e:
                    if e.errorcode != 273:
                        raise

        elif mode == 'unbind':
            for configured_binding in configured_bindings:
                self.module_result['changed'] = True
                try:
                    configured_binding.delete(
                        delete_id_attributes=self.attribute_config[binding_key]
                        ['delete_id_attributes'])
                except NitroException as e:
                    # Handle exceptions when trying to unbind objects that are not bound
                    # Every binding has its own errorcode
                    if binding_object == 'appfwglobal_appfwpolicy_binding':
                        if e.errorcode == 3093:
                            log('Ignoring nitro_errocode 3093 for appfwglobal_appfwpolicy_binding'
                                )
                        else:
                            raise