ehsan-dashboards/dashboards/get_elastic_index_files.py

15 lines
569 B
Python

import requests
import base64
gitlab_pat = 'glpat-mJPdjrPiHCTj2NqNZN_m'
headers = {'PRIVATE-TOKEN': gitlab_pat}
for path in ['src/models/helper/elastic/index.ts', 'src/models/helper/elastic/update.ts']:
encoded = requests.utils.quote(path, safe='')
r = requests.get(f'https://gitlab.ekeepa.co/api/v4/projects/10/repository/files/{encoded}?ref=dev', headers=headers)
print("=== " + path + " ===")
if 'content' in r.json():
content = base64.b64decode(r.json()['content']).decode('utf-8')
print(content)
else:
print(r.json())