sketchgraphs.onshape.onshape.Onshape¶
-
class
sketchgraphs.onshape.onshape.
Onshape
(stack, creds='./sketchgraphs/onshape/creds/creds.json', logging=True)¶ Provides access to the Onshape REST API.
-
- stack
Base URL
- Type
-
- creds
Credentials location
- Type
str, default=’./sketchgraphs/onshape/creds/creds.json’
-
- logging
Turn logging on or off
- Type
bool, default=True
-
__init__
(stack, creds='./sketchgraphs/onshape/creds/creds.json', logging=True)¶ Instantiates an instance of the Onshape class. Reads credentials from a JSON file of this format:
- {
- “http://cad.onshape.com”: {
“access_key”: “YOUR KEY HERE”, “secret_key”: “YOUR KEY HERE”
}, etc… add new object for each stack to test on
}
The creds.json file should be stored in the root project folder; optionally, you can specify the location of a different file.
- Parameters
stack (-) – Base URL
creds (-) – Credentials location
-
request
(method, path, query={}, headers={}, body={}, base_url=None, timeout=None, check_status=True)¶ Issues a request to Onshape
- Parameters
method (-) – HTTP method
path (-) – Path e.g. /api/documents/:id
query (-) – Query params in key-value pairs
headers (-) – Key-value pairs of headers
body (-) – Body for POST request
base_url (-) – Host, including scheme and port (if different from creds file)
timeout (-) – Timeout to use with requests.request().
check_status (-) – Raise exception if response status code is unsuccessful.
- Returns
Object containing the response from Onshape
- Return type
requests.Response
-