Skip to content

Commit 3690334

Browse files
author
Kairo de Araujo
committed
Improve documentation and file headers consistency
This commit improves the documentation for the API, README, and the docstrings. The python files headers are also standardized. Some typos are also fixed. Signed-off-by: Kairo de Araujo <[email protected]>
1 parent ebfaa95 commit 3690334

File tree

16 files changed

+104
-33
lines changed

16 files changed

+104
-33
lines changed

README.md

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ This project still not functional. Please wait for the first functional release
99

1010
The Tern REST API is a RESTful API for Tern Project.
1111

12-
At the moment the API is not functional as it is still in the Specification
13-
development and project structure phase.
12+
Currently, the API is not functional as it is still in the Specification development and project structure phase.
1413

15-
The specification is available at
16-
[Tern REST API Offline Swagger](https://tern-tools.github.io/tern-rest-api/) and
17-
contributions are welcome.
14+
The specification is available at [Tern REST API Offline Swagger](https://tern-tools.github.io/tern-rest-api/), and contributions are welcome.
1815

19-
Mostly of the API is implemented in asynchronous way on the server side as the
20-
tern reports can take a while to be generated.
16+
Mainly the API is implemented asynchronously on the server-side as the tern
17+
reports can take a while to be generated.
2118

2219
```mermaid
2320
sequenceDiagram
@@ -26,36 +23,79 @@ tern reports can take a while to be generated.
2623
participant Tern
2724
User->>API: GET /api/v1/version
2825
API-->>User: 200 OK, JSON with version data
29-
User->>API: GET /api/v1/reports
26+
User->>API: POST /api/v1/reports with JSON payload
3027
API-->>User: 200 OK, JSON with request id
31-
User->>API: GET /api/v1/reports/status
28+
User->>API: POST /api/v1/reports/status with JSON payload
3229
API-->>User: 200 OK, JSON with status RUNNING
33-
API->>Tern: Process the request caling asynchronous
30+
API->>Tern: Process the request calling asynchronous
3431
Tern->>Tern: Processing
3532
loop
36-
User->>API: GET /api/v1/reports/status
33+
User->>API: POST /api/v1/reports/status with JSON payload
3734
Tern->>Tern: Processing
3835
API-->>User: 200 OK, JSON with status RUNNING or UNKOWN
3936
end
4037
Tern->>API: Provides the answer for the id
41-
User->>API: GET /api/v1/reports/status
38+
User->>API: POST /api/v1/reports/status with JSON payload
4239
API-->>User: 200 OK, JSON with status FAILED with error or DONE with report
4340
```
4441

4542
## Development
4643

47-
This repository has the ``requirements.txt`` and the ``requirements-dev.txt`` files to help building your virtual environment. I also recomend use pipenv to manage your virtual environment.
44+
This repository has the ``requirements.txt`` and the ``requirements-dev.txt``
45+
files to help build your virtual environment.
46+
47+
We also recommend using [Pipenv](https://pipenv.pypa.io/en/latest/) to manage your virtual environment.
48+
49+
```shell
50+
$ Pip install pipenv
51+
$ pipenv shell
52+
```
53+
54+
Install development requirements
55+
```shell
56+
$ pipenv install -d
57+
```
58+
59+
### Running the development Tern REST API
60+
61+
62+
Runing the API locally
63+
64+
```shell
65+
$ flask run --reload
66+
```
67+
68+
Open http://localhost:5000/ in your browser.
69+
70+
## Tests
71+
72+
We use [Tox](https://tox.wiki/en/latest/) to manage running the tests.
73+
74+
Running tests
75+
```shell
76+
$ tox
77+
```
78+
79+
## Managing the requirements
80+
81+
Installing new requirements
4882

4983
```shell
50-
pip install pipenv
51-
pipenv shell
52-
pipenv install -d
84+
$ pipenv install {package}
5385
```
5486

55-
Runing the API locally:
87+
Development requirements
88+
```shell
89+
$ pipenv install -d {package}
90+
```
5691

92+
Updating packages
5793
```shell
58-
flask run --reload
94+
$ pipenv update
5995
```
6096

61-
Open http://localhost:5000/ in your browser.
97+
Updating the ``requirements.txt`` and ``requirements-dev.txt``
98+
```shell
99+
$ pipenv lock -r > requirements.txt
100+
$ pipenv lock -r -d > requirements-dev.txt
101+
```

app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
23
#
34
# Copyright (c) 2022 VMware, Inc. All Rights Reserved.

docs/swagger.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
}
1313
}
1414
},
15-
"summary": "Tern report",
15+
"summary": "Tern BoM report",
16+
"description": "**Note**: This request will be processed assynchronous.",
1617
"operationId": "post_report",
1718
"parameters": [
1819
{
@@ -39,7 +40,7 @@
3940
}
4041
}
4142
},
42-
"summary": "Tern report status/result",
43+
"summary": "Request Tern BoM report status/result",
4344
"operationId": "post_report_status",
4445
"parameters": [
4546
{
@@ -72,7 +73,7 @@
7273
}
7374
}
7475
},
75-
"summary": "Tern repoort",
76+
"summary": "Get Tern Rest API base versions",
7677
"operationId": "get_version",
7778
"tags": [
7879
"/version"
@@ -98,7 +99,7 @@
9899
},
99100
{
100101
"name": "/reports",
101-
"description": "Tern Report"
102+
"description": "Tern Bill of Materials Report"
102103
}
103104
],
104105
"definitions": {

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
#
44
# Copyright (c) 2022 VMware, Inc. All Rights Reserved.

tern_api/__version__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
23
#
34
# Copyright (c) 2022 VMware, Inc. All Rights Reserved.

tern_api/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
23
#
34
# Copyright (c) 2022 VMware, Inc. All Rights Reserved.

tern_api/api/v1/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
23
#
34
# Copyright (c) 2022 VMware, Inc. All Rights Reserved.

tern_api/api/v1/common_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
23
#
34
# Copyright (c) 2022 VMware, Inc. All Rights Reserved.

tern_api/api/v1/reports.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
23
#
34
# Copyright (c) 2022 VMware, Inc. All Rights Reserved.
@@ -10,7 +11,7 @@
1011
report_model,
1112
)
1213

13-
ns = Namespace("/reports", description="Tern Report")
14+
ns = Namespace("/reports", description="Tern Bill of Materials Report")
1415

1516

1617
@ns.route("")
@@ -47,7 +48,10 @@ class Report(Resource):
4748
@ns.response(200, "OK", report_response_request)
4849
@ns.expect(report_parameters)
4950
def post(self):
50-
"""Tern report"""
51+
"""Tern BoM report
52+
53+
**Note**: This request will be processed assynchronous.
54+
"""
5155

5256

5357
@ns.route("/status")
@@ -85,4 +89,4 @@ class ReportStatus(Resource):
8589
@ns.response(200, "OK", report_status_response)
8690
@ns.expect(report_status_parameters)
8791
def post(self):
88-
"""Tern report status/result"""
92+
"""Request Tern BoM report status/result"""

tern_api/api/v1/version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
23
#
34
# Copyright (c) 2022 VMware, Inc. All Rights Reserved.
@@ -40,7 +41,7 @@ class Version(Resource):
4041
@ns.response(400, "Bad request")
4142
@ns.response(500, "Internal Server Error")
4243
def get(self):
43-
"""Tern repoort"""
44+
"""Get Tern Rest API base versions"""
4445

4546
response = get_version()
4647
return response.to_response()

0 commit comments

Comments
 (0)