Skip to content

Commit eb99d80

Browse files
docs for cpu usage.
1 parent 155f6a3 commit eb99d80

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

docs/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Programming Interface
88

99
base
1010
files
11+
resources
1112
schedule
1213
students
1314
webapp

docs/api/resources.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Resources
2+
=========
3+
4+
.. automodule:: resources
5+
:members:

pythonanywhere_core/resources.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@
55

66

77
class CPU:
8+
"""Interface for PythonAnywhere CPU resources API.
9+
10+
Uses `pythonanywhere_core.base` :method: `get_api_endpoint` to
11+
create url, which is stored in a class variable `CPU.base_url`,
12+
then calls `call_api` with appropriate arguments to execute CPU
13+
resource actions.
14+
15+
Methods:
16+
- :meth:`CPU.get_cpu_usage`: Get current CPU usage information.
17+
"""
18+
819
def __init__(self):
920
self.base_url = get_api_endpoint(username=getpass.getuser(), flavor="cpu")
1021

1122
def get_cpu_usage(self):
12-
"""Get current CPU usage information."""
23+
"""Get current CPU usage information.
24+
25+
:returns: dictionary with CPU usage information including daily limit,
26+
total usage, and next reset time
27+
:raises PythonAnywhereApiException: if API call fails
28+
"""
1329
response = call_api(url=self.base_url, method="GET")
1430
if not response.ok:
1531
raise PythonAnywhereApiException(f"GET to {self.base_url} failed, got {response}:{response.text}")

0 commit comments

Comments
 (0)