# openapi-client
The Onshape REST API consumed by all client.
# Authorization
The simplest way to authorize and enable the **Try it out** functionality is to sign in to Onshape and use the current session. The **Authorize** button enables other authorization techniques. To ensure the current session isn't used when trying other authentication techniques, make sure to remove the Onshape cookie as per the instructions for your particular browser. Alternatively, a private or incognito window may be used. Here's [how to remove a specific cookie on Chrome](https://support.google.com/chrome/answer/95647#zippy=%2Cdelete-cookies-from-a-site).
- **Current Session** authorization is enabled by default if the browser is already signed in to [Onshape](/).
- **OAuth2** authorization uses an Onshape OAuth2 app created on the [Onshape Developer Portal](https://dev-portal.onshape.com/oauthApps). The redirect URL field should include `https://cad.onshape.com/glassworks/explorer/oauth2-redirect.html`.
- **API Key** authorization using basic authentication is also available. The keys can be generated in the [Onshape Developer Portal](https://dev-portal.onshape.com/keys). In the authentication dialog, enter the access key in the `Username` field, and enter the secret key in the `Password` field. Basic authentication should only be used during the development process since sharing API Keys provides the same level of access as a username and password.

This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 1.148.5096-9e2122142227
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.PythonExperimentalClientCodegen

## Requirements.

Python &gt;&#x3D;3.9
v3.9 is needed so one can combine classmethod and property decorators to define
object schema properties as classes

## Installation & Usage
### pip install

If the python package is hosted on a repository, you can install directly using:

```sh
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
```
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)

Then import the package:
```python
import openapi_client
```

### Setuptools

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)

Then import the package:
```python
import openapi_client
```

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:

```python

import time
import openapi_client
from pprint import pprint
from openapi_client.api import user_api
from openapi_client.model.bt_user_o_auth2_summary_info import BTUserOAuth2SummaryInfo
# Defining the host is optional and defaults to https://cad.onshape.com/api
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
    host = "https://cad.onshape.com/api"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure HTTP basic authorization: BasicAuth
configuration = openapi_client.Configuration(
    username = 'YOUR_USERNAME',
    password = 'YOUR_PASSWORD'
)

# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = user_api.UserApi(api_client)
    
    try:
        # Check if current user is signed-in. Information returned depends on OAuth2ReadPII scope.
        api_response = api_instance.session_info()
        pprint(api_response)
    except openapi_client.ApiException as e:
        print("Exception when calling UserApi->session_info: %s\n" % e)
```

## Documentation for API Endpoints

All URIs are relative to *https://cad.onshape.com/api*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*UserApi* | [**session_info**](docs/UserApi.md#session_info) | **GET** /users/sessioninfo | Check if current user is signed-in. Information returned depends on OAuth2ReadPII scope.

## Documentation For Models

 - [BTCompanySummaryInfo](docs/BTCompanySummaryInfo.md)
 - [BTUserOAuth2SummaryInfo](docs/BTUserOAuth2SummaryInfo.md)
 - [GlobalPermissionInfo](docs/GlobalPermissionInfo.md)

## Documentation For Authorization


## BasicAuth

- **Type**: HTTP basic authentication

 Authentication schemes defined for the API:
## OAuth2

- **Type**: OAuth
- **Flow**: accessCode
- **Authorization URL**: /oauth/authorize
- **Scopes**: 
 - **OAuth2Internal**: Application is Onshape Internal
 - **OAuth2ReadPII**: Application can read your profile information
 - **OAuth2Read**: Application can read your documents
 - **OAuth2Write**: Application can write to your documents
 - **OAuth2Delete**: Application can delete your documents and workspaces
 - **OAuth2Purchase**: Application can request purchases on your behalf
 - **OAuth2Share**: Application can share and unshare documents on your behalf
 - **document.create**: Atlas Application can create a document
 - **document.edit**: Atlas Application can edit a document
 - **document.delete**: Atlas Application can delete a document
 - **document.read**: Atlas Application can read a document
 - **enterprise.create**: Atlas Application can create an enterprise
 - **enterprise.read**: Atlas Application can read from an enterprise
 - **enterprise.edit**: Atlas Application can edit an enterprise
 - **enterprise.delete**: Atlas Application can delete an enterprise
 - **enterprise.member.create**: Atlas Application can create an enterprise member
 - **enterprise.member.read**: Atlas Application can read the details of an enterprise member
 - **enterprise.member.edit**: Atlas Application can edit the details of an enterprise member
 - **enterprise.member.delete**: Atlas Application can delete a member from an enterprise
 - **webhook.create**: Atlas Application can create a webhook on behalf of the logged-in user
 - **webhook.edit**: Atlas Application can edit a webhook on behalf of the logged-in user
 - **webhook.read**: Atlas Application can read a webhook on behalf of the logged-in user
 - **webhook.delete**: Atlas Application can delete a webhook on behalf of the logged-in user


## Author

api-support@onshape.zendesk.com

## Notes for Large OpenAPI documents
If the OpenAPI document is large, imports in openapi_client.apis and openapi_client.models may fail with a
RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:

Solution 1:
Use specific imports for apis and models like:
- `from openapi_client.api.default_api import DefaultApi`
- `from openapi_client.model.pet import Pet`

Solution 1:
Before importing the package, adjust the maximum recursion limit as shown below:
```
import sys
sys.setrecursionlimit(1500)
import openapi_client
from openapi_client.apis import *
from openapi_client.models import *
```
