fix 534: ループを使用してアプリの詳細情報を取得する

This commit is contained in:
Mouriya
2024-07-22 16:40:52 +09:00
parent c6a577b5ec
commit b9a7dd99da

View File

@@ -516,10 +516,25 @@ async def allapps(request:Request,c:config.KINTONE_ENV=Depends(getkintoneenv)):
try: try:
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE} headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
url = f"{c.BASE_URL}{config.API_V1_STR}/apps.json" url = f"{c.BASE_URL}{config.API_V1_STR}/apps.json"
r = httpx.get(url,headers=headers) offset = 0
return r.json() all_apps = []
while True:
r = httpx.get(f"{url}?limit=100&offset={offset}", headers=headers)
json_data = r.json()
if "apps" in json_data:
all_apps.extend(json_data["apps"])
if len(json_data["apps"]) == 100:
offset += 100
else:
break
else:
break
return {"apps": all_apps}
except Exception as e: except Exception as e:
raise APIException('kintone:allapps',request.url._url, f"Error occurred while get allapps({c.DOMAIN_NAME}):",e) raise APIException('kintone:allapps', request.url._url, f"Error occurred while get allapps({c.DOMAIN_NAME}):", e)
@r.get("/appfields") @r.get("/appfields")
async def appfields(request:Request,app:str,env = Depends(getkintoneenv)): async def appfields(request:Request,app:str,env = Depends(getkintoneenv)):