Skip to content

Commit b20b568

Browse files
authored
Create get-all-role-es.py
1 parent 445069d commit b20b568

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from elasticsearch import Elasticsearch
2+
import json
3+
4+
# Configure Elasticsearch client
5+
es = Elasticsearch(
6+
["https://localhost:9200"],
7+
http_auth=("username", "password"),
8+
scheme="https",
9+
port=9200,
10+
)
11+
12+
# Fetch all roles
13+
roles = es.security.get_role()
14+
15+
# Save roles to a JSON file
16+
with open("roles_export.json", "w") as f:
17+
json.dump(roles, f, indent=4)
18+
19+
print("Roles have been exported to roles_export.json")

0 commit comments

Comments
 (0)