Bulk delete role mappings

I have role mapping created like the following:

PUT {{es_ip_port}}/_security/role_mapping/dummy_1
{
    "enabled": true,
    "roles": [
        "client_role",
        "kibana_dashboard_only_user"
    ],
    "rules": {
        "all": [
            {
                "field": {
                    "realm.name": "oidc1"
                }
            },
            {
                "field": {
                    "username": [
                        "dummy_user@dummy.com"
                    ]
                }
            }
        ]
    }
}

Similarly I have more role-mappings created with role_mapping name dummy_2, dummy_3, etc.
I want to delete all the role mappings starting with the name, dummy_ like dummy_*. Is there any way to do it over DELETE API at one shot like below:

DELETE {{es_ip_port}}/_security/role_mapping/dummy_*

I do not want to delete the role mappings one by one. Is there any way? Please help.

This is for any future visitor to this thread. There is not bulk delete role mapping option. I knew what was I doing so used _delete_by_query API call on the .security-7 index. My sample API looks like below:

POST {{es_ip_port}}/.security-7/_delete_by_query?conflicts=proceed
{
    "query": {
        "match": {
            "roles": "<role mapping with the needed role to delete>"
        }
    }
}

Generally this option is not recommended. Please use it carefully.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.