Skip to content

Commit 05db930

Browse files
committed
Record recipe for logging REST requests made by library. Several customer requests have been solved by this pattern.
1 parent a0cab7a commit 05db930

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,26 @@ Function List
5454
-------------
5555

5656
Please Refer to the [Python Script Library documentation page](http://python-sdc-client.readthedocs.io/en/latest/) for the list of functions available.
57+
58+
Transitioning from python to REST
59+
---------------------------------
60+
61+
If your goal is to interact with the REST API directly, you can get there from the python library by logging the actions it takes. This is useful because a full documentation of the REST API has not yet been created; and also provides a complete example of a working sequence.
62+
63+
- Use or modify an example, or write a new script against the python sdcclient module.
64+
- Log the http requests made by the script.
65+
66+
To log all the requests made by your script in significant detail, add to your script:
67+
68+
``` python
69+
import logging
70+
httplib.HTTPConnection.debuglevel = 1
71+
72+
logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests
73+
logging.getLogger().setLevel(logging.DEBUG)
74+
requests_log = logging.getLogger("requests.packages.urllib3")
75+
requests_log.setLevel(logging.DEBUG)
76+
requests_log.propagate = True
77+
```
78+
79+
Then run as normal.

0 commit comments

Comments
 (0)