Here, in the code. I can only use 5 values maximum(API limitation) at a time in the below API.
import requests
import json
import datetime
from datetime import date, datetime
import itertools
from sentimeterdb import dbconnect
from dotenv import load_dotenv #for python-dotenv method
load_dotenv() #for python-dotenv method
import os
#Connection string pointing to the PROD db.
dbclient = dbconnect.process()
db = dbclient.abc
co_open = db.open_ab
myquery = {"bugs" : {"$ne" : {}, "$exists": True}}
mydoc = co_open.find(myquery)
lst = []
for x in mydoc:
y = x.get('bugs')
id_list = lst.append([*y.values()])
cdets = list(itertools.chain(*lst))
cdets_split = cdets
string_cdets = ','.join(cdets_split[:5])
Access_URL = 'https://generating-token-from--here/oauth2/default/v1/token'
client_id = os.environ.get('CLIENT_ID')
client_secret = os.environ.get('CLIENT_SECRET')
grant_type = os.environ.get('GRANT_TYPE')
BASE_URL = f'https://google.com/{string_cdets}'
response = requests.post(Access_URL,
data={'grant_type': grant_type, 'client_id': client_id, 'client_secret': client_secret, 'content-type': 'application/x-www-form-urlencoded'})
json_response = response.json()
tokenvalue = (json_response['access_token'])
headers = {'Authorization': 'Bearer ' +
tokenvalue, 'Content-Type': 'application/json'}
auth_response = requests.get(BASE_URL, headers=headers)
auth_response_json = auth_response.json()
severity_list = []
for severity_5 in auth_response_json['bugs']:
severity_list.append([severity_5['severity']])
print ("Severity ==> ", severity_list)
Severity and Status should be given for all the CDETs. Currently, It is only giving for 5 items. how can I get the response of all the CDETs?