Coverage for src/receptiviti/frameworks.py: 83%
12 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-12-01 10:33 -0500
« prev ^ index » next coverage.py v7.6.1, created at 2024-12-01 10:33 -0500
1"""Check the status of the API."""
3import os
4from typing import List, Union
6import requests
8from receptiviti.status import _resolve_request_def
11def frameworks(
12 url: str = os.getenv("RECEPTIVITI_URL", ""),
13 key: str = os.getenv("RECEPTIVITI_KEY", ""),
14 secret: str = os.getenv("RECEPTIVITI_SECRET", ""),
15 dotenv: Union[bool, str] = False,
16) -> List[str]:
17 """
18 List Available Frameworks.
20 Retrieve a list of all frameworks available to your account.
22 Args:
23 url (str): The URL of the API.
24 key (str): Your API key.
25 secret (str): Your API secret.
26 dotenv (bool | str): Path to a .env file to read environment variables from, or `True`
27 to look for a file in the current directory.
29 Returns:
30 List of framework names.
32 Examples:
33 ```
34 receptiviti.frameworks()
35 ```
36 """
37 _, url, key, secret = _resolve_request_def(url, key, secret, dotenv)
38 res = requests.get(url.lower() + "/v2/frameworks", auth=(key, secret), timeout=9999)
39 content = res.json() if res.text[:1] == "[" else {"message": res.text}
40 if res.status_code != 200:
41 msg = f"Request Error ({res.status_code!s})" + (
42 (" (" + str(content["code"]) + ")" if "code" in content else "") + ": " + content["message"]
43 )
44 raise RuntimeError(msg)
45 return content if isinstance(content, list) else []