refactor: migrate marketplace.py from requests to httpx (#24015)
This commit is contained in:
parent
ffba341258
commit
60d9d0584a
1 changed files with 4 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
|
||||||
import requests
|
import httpx
|
||||||
from yarl import URL
|
from yarl import URL
|
||||||
|
|
||||||
from configs import dify_config
|
from configs import dify_config
|
||||||
|
|
@ -23,7 +23,7 @@ def batch_fetch_plugin_manifests(plugin_ids: list[str]) -> Sequence[MarketplaceP
|
||||||
return []
|
return []
|
||||||
|
|
||||||
url = str(marketplace_api_url / "api/v1/plugins/batch")
|
url = str(marketplace_api_url / "api/v1/plugins/batch")
|
||||||
response = requests.post(url, json={"plugin_ids": plugin_ids})
|
response = httpx.post(url, json={"plugin_ids": plugin_ids})
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
return [MarketplacePluginDeclaration(**plugin) for plugin in response.json()["data"]["plugins"]]
|
return [MarketplacePluginDeclaration(**plugin) for plugin in response.json()["data"]["plugins"]]
|
||||||
|
|
@ -36,7 +36,7 @@ def batch_fetch_plugin_manifests_ignore_deserialization_error(
|
||||||
return []
|
return []
|
||||||
|
|
||||||
url = str(marketplace_api_url / "api/v1/plugins/batch")
|
url = str(marketplace_api_url / "api/v1/plugins/batch")
|
||||||
response = requests.post(url, json={"plugin_ids": plugin_ids})
|
response = httpx.post(url, json={"plugin_ids": plugin_ids})
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
result: list[MarketplacePluginDeclaration] = []
|
result: list[MarketplacePluginDeclaration] = []
|
||||||
for plugin in response.json()["data"]["plugins"]:
|
for plugin in response.json()["data"]["plugins"]:
|
||||||
|
|
@ -50,5 +50,5 @@ def batch_fetch_plugin_manifests_ignore_deserialization_error(
|
||||||
|
|
||||||
def record_install_plugin_event(plugin_unique_identifier: str):
|
def record_install_plugin_event(plugin_unique_identifier: str):
|
||||||
url = str(marketplace_api_url / "api/v1/stats/plugins/install_count")
|
url = str(marketplace_api_url / "api/v1/stats/plugins/install_count")
|
||||||
response = requests.post(url, json={"unique_identifier": plugin_unique_identifier})
|
response = httpx.post(url, json={"unique_identifier": plugin_unique_identifier})
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue