|
6 | 6 | import requests |
7 | 7 | from datetime import date, timedelta |
8 | 8 |
|
9 | | -from .obj import Agents, User, SearchTypes |
| 9 | +from .obj import Agents, User, TokenScope, SearchTypes |
10 | 10 | from .folders import Folders |
11 | 11 | from .uploads import Uploads |
12 | 12 | from .jobs import Jobs |
|
18 | 18 |
|
19 | 19 |
|
20 | 20 | def fossology_token( |
21 | | - url, username, password, token_name, token_scope, token_expire=None |
| 21 | + url, username, password, token_name, token_scope=TokenScope.READ, token_expire=None |
22 | 22 | ): |
23 | 23 | """Generate an API token using username/password |
24 | 24 |
|
25 | 25 | API endpoint: POST /tokens |
26 | 26 |
|
| 27 | + :Example: |
| 28 | +
|
| 29 | + >>> from fossology import fossology_token |
| 30 | + >>> from fossology.obj import TokenScope |
| 31 | + >>> token = fossology_token("https://fossology.example.com", "Me", "MyPassword", "MyToken") |
| 32 | +
|
| 33 | +
|
27 | 34 | :param url: the URL of the Fossology server |
28 | 35 | :param username: name of the user the token will be generated for |
29 | 36 | :param password: the password of the user |
30 | 37 | :param name: the name of the token |
31 | | - :param scope: the scope of the token |
| 38 | + :param scope: the scope of the token (default: READ) |
32 | 39 | :param expire: the expire date of the token (default max. 30 days) |
33 | 40 | :type url: string |
34 | 41 | :type username: string |
35 | 42 | :type password: string |
36 | 43 | :type name: string |
37 | | - :type scope: string |
| 44 | + :type scope: TokenScope (default TokenScope.READ) |
38 | 45 | :type expire: string, e.g. 2019-12-25 |
39 | 46 | :return: the new token |
40 | 47 | :rtype: string |
@@ -70,7 +77,7 @@ class Fossology(Folders, Uploads, Jobs, Report): |
70 | 77 |
|
71 | 78 | :Example: |
72 | 79 |
|
73 | | - >>> from fossology.api import Fossology |
| 80 | + >>> from fossology import Fossology |
74 | 81 | >>> foss = Fossology(FOSS_URL, FOSS_TOKEN, username) |
75 | 82 |
|
76 | 83 | .. note:: |
|
0 commit comments