uipath 0.0.1__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of uipath might be problematic. Click here for more details.

Files changed (42) hide show
  1. uipath-1.0.0/.github/workflows/docs.yml +40 -0
  2. uipath-1.0.0/.gitignore +47 -0
  3. uipath-1.0.0/LICENSE +21 -0
  4. uipath-1.0.0/PKG-INFO +181 -0
  5. uipath-1.0.0/README.md +140 -0
  6. uipath-1.0.0/docs/index.md +30 -0
  7. uipath-1.0.0/docs/requirements.txt +3 -0
  8. uipath-1.0.0/mkdocs.yml +58 -0
  9. uipath-1.0.0/pyproject.toml +25 -0
  10. {uipath-0.0.1 → uipath-1.0.0}/setup.cfg +4 -4
  11. uipath-1.0.0/setup.py +44 -0
  12. uipath-1.0.0/uipath/__init__.py +9 -0
  13. uipath-1.0.0/uipath/__version__.py +3 -0
  14. uipath-1.0.0/uipath/auth/authentication.py +53 -0
  15. uipath-1.0.0/uipath/client/api_client.py +58 -0
  16. uipath-1.0.0/uipath/client/base_client.py +46 -0
  17. uipath-1.0.0/uipath/client/resources/__init__.py +5 -0
  18. uipath-1.0.0/uipath/client/resources/assets.py +29 -0
  19. uipath-1.0.0/uipath/client/resources/folders.py +107 -0
  20. uipath-1.0.0/uipath/client/resources/jobs.py +113 -0
  21. uipath-1.0.0/uipath/client/resources/libraries.py +120 -0
  22. uipath-1.0.0/uipath/client/resources/machines.py +136 -0
  23. uipath-1.0.0/uipath/client/resources/packages.py +112 -0
  24. uipath-1.0.0/uipath/client/resources/processes.py +173 -0
  25. uipath-1.0.0/uipath/client/resources/queues.py +90 -0
  26. uipath-1.0.0/uipath/client/resources/releases.py +114 -0
  27. uipath-1.0.0/uipath/client/resources/robots.py +155 -0
  28. uipath-1.0.0/uipath.egg-info/PKG-INFO +181 -0
  29. uipath-1.0.0/uipath.egg-info/SOURCES.txt +30 -0
  30. uipath-1.0.0/uipath.egg-info/requires.txt +12 -0
  31. uipath-0.0.1/MANIFEST.in +0 -2
  32. uipath-0.0.1/PKG-INFO +0 -18
  33. uipath-0.0.1/README.md +0 -5
  34. uipath-0.0.1/UiPath.egg-info/PKG-INFO +0 -18
  35. uipath-0.0.1/UiPath.egg-info/SOURCES.txt +0 -16
  36. uipath-0.0.1/UiPath.egg-info/requires.txt +0 -1
  37. uipath-0.0.1/docs/documentation_coming_soon.txt +0 -0
  38. uipath-0.0.1/setup.py +0 -24
  39. uipath-0.0.1/uipath/__init__.py +0 -1
  40. uipath-0.0.1/uipath/sequence.py +0 -483
  41. {uipath-0.0.1/UiPath.egg-info → uipath-1.0.0/uipath.egg-info}/dependency_links.txt +0 -0
  42. {uipath-0.0.1/UiPath.egg-info → uipath-1.0.0/uipath.egg-info}/top_level.txt +0 -0
@@ -0,0 +1,40 @@
1
+ name: docs
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ tags:
8
+ - '*'
9
+
10
+ permissions:
11
+ contents: write
12
+
13
+ jobs:
14
+ deploy:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v4
21
+ with:
22
+ python-version: '3.x'
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -r docs/requirements.txt
28
+ pip install -e .
29
+
30
+ - name: Build docs
31
+ run: mkdocs build
32
+
33
+ - name: Deploy docs
34
+ if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
35
+ uses: peaceiris/actions-gh-pages@v3
36
+ with:
37
+ github_token: ${{ secrets.GITHUB_TOKEN }}
38
+ publish_dir: ./site
39
+ force_orphan: true
40
+ commit_message: 'docs: update documentation'
@@ -0,0 +1,47 @@
1
+ api_spec.json
2
+
3
+ # Python
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+ *.so
8
+ .Python
9
+ build/
10
+ develop-eggs/
11
+ dist/
12
+ downloads/
13
+ eggs/
14
+ .eggs/
15
+ lib/
16
+ lib64/
17
+ parts/
18
+ sdist/
19
+ var/
20
+ wheels/
21
+ *.egg-info/
22
+ .installed.cfg
23
+ *.egg
24
+
25
+ # Virtual Environment
26
+ .env
27
+ .venv
28
+ env/
29
+ venv/
30
+ ENV/
31
+ uipath-env/
32
+
33
+ # IDE
34
+ .idea/
35
+ .vscode/
36
+ *.swp
37
+ *.swo
38
+
39
+ # Testing
40
+ .coverage
41
+ .pytest_cache/
42
+ htmlcov/
43
+
44
+ # Distribution
45
+ dist/
46
+ build/
47
+ *.egg-info/
uipath-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
uipath-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.2
2
+ Name: uipath
3
+ Version: 1.0.0
4
+ Summary: A Python SDK for UiPath
5
+ Home-page: https://github.com/christianblandford/uipath
6
+ Author: Christian Blandford
7
+ Author-email: christianblandford@me.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.7
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.7
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests>=2.25.0
23
+ Requires-Dist: typing-extensions>=4.0.0; python_version < "3.8"
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=6.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=2.0; extra == "dev"
27
+ Requires-Dist: black>=22.0; extra == "dev"
28
+ Requires-Dist: isort>=5.0; extra == "dev"
29
+ Requires-Dist: mypy>=0.900; extra == "dev"
30
+ Requires-Dist: flake8>=3.9; extra == "dev"
31
+ Dynamic: author
32
+ Dynamic: author-email
33
+ Dynamic: classifier
34
+ Dynamic: description
35
+ Dynamic: description-content-type
36
+ Dynamic: home-page
37
+ Dynamic: provides-extra
38
+ Dynamic: requires-dist
39
+ Dynamic: requires-python
40
+ Dynamic: summary
41
+
42
+ # UiPath Python SDK
43
+
44
+ A Python SDK for interacting with UiPath's APIs. This SDK provides a simple and intuitive way to automate UiPath operations programmatically.
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install uipath
50
+ ```
51
+
52
+ ## Quick Start
53
+
54
+ ```python
55
+ from uipath.auth.authentication import UiPathAuth
56
+ from uipath.client.api_client import UiPathClient
57
+ from uipath.resources.robots import RobotsResource
58
+
59
+ # Initialize authentication
60
+ auth = UiPathAuth(
61
+ tenant_name="your_tenant",
62
+ client_id="your_client_id",
63
+ client_secret="your_client_secret"
64
+ )
65
+
66
+ # Create API client
67
+ client = UiPathClient(auth)
68
+
69
+ # Use the robots resource
70
+ robots = RobotsResource(client)
71
+
72
+ # List all robots
73
+ all_robots = robots.list_robots()
74
+ ```
75
+
76
+ ## Features
77
+
78
+ - Simple, intuitive interface for UiPath APIs
79
+ - Authentication handling
80
+ - Comprehensive error handling
81
+ - Type hints for better IDE support
82
+ - Resource classes for all major UiPath entities:
83
+ - Robots
84
+ - Jobs
85
+ - Processes
86
+ - Assets
87
+ - And more...
88
+
89
+ ## Authentication
90
+
91
+ The SDK supports client credentials authentication. You'll need:
92
+ - Tenant name
93
+ - Client ID
94
+ - Client secret
95
+
96
+ You can obtain these credentials from your UiPath Orchestrator account under Admin → API Access.
97
+
98
+ ```python
99
+ auth = UiPathAuth(
100
+ tenant_name="your_tenant",
101
+ client_id="your_client_id",
102
+ client_secret="your_client_secret",
103
+ scope="OR.Default" # Optional, defaults to OR.Default
104
+ )
105
+ ```
106
+
107
+ ## Usage Examples
108
+
109
+ ### Working with Robots
110
+
111
+ ```python
112
+ # List all robots
113
+ robots = RobotsResource(client)
114
+ all_robots = robots.list_robots()
115
+
116
+ # Get a specific robot
117
+ robot = robots.get_robot(robot_id=123)
118
+
119
+ # Create a new robot
120
+ new_robot = robots.create_robot(
121
+ name="MyNewRobot",
122
+ machine_name="DESKTOP-123",
123
+ type="Unattended"
124
+ )
125
+ ```
126
+
127
+ ### Error Handling
128
+
129
+ The SDK provides custom exceptions for different types of errors:
130
+
131
+ ```python
132
+ from uipath.exceptions.exceptions import AuthenticationError, ApiError
133
+
134
+ try:
135
+ robots.get_robot(robot_id=999)
136
+ except AuthenticationError as e:
137
+ print("Authentication failed:", e)
138
+ except ApiError as e:
139
+ print("API request failed:", e)
140
+ ```
141
+
142
+ ## Configuration
143
+
144
+ The SDK can be configured with custom endpoints and API versions:
145
+
146
+ ```python
147
+ client = UiPathClient(
148
+ auth,
149
+ base_url="https://cloud.uipath.com", # Custom base URL
150
+ api_version="v1" # API version
151
+ )
152
+ ```
153
+
154
+ ## Contributing
155
+
156
+ Contributions are welcome! Please feel free to submit a Pull Request.
157
+
158
+ 1. Fork the repository
159
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
160
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
161
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
162
+ 5. Open a Pull Request
163
+
164
+ ## License
165
+
166
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
167
+
168
+ ## Support
169
+
170
+ If you encounter any problems or have questions, please:
171
+ 1. Check the [documentation](docs/)
172
+ 2. Open an issue in the GitHub repository
173
+
174
+ ## Requirements
175
+
176
+ - Python 3.7+
177
+ - requests library
178
+
179
+ ## Disclaimer
180
+
181
+ This is an unofficial SDK and is not affiliated with, maintained, authorized, endorsed, or sponsored by UiPath.
uipath-1.0.0/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # UiPath Python SDK
2
+
3
+ A Python SDK for interacting with UiPath's APIs. This SDK provides a simple and intuitive way to automate UiPath operations programmatically.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install uipath
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from uipath.auth.authentication import UiPathAuth
15
+ from uipath.client.api_client import UiPathClient
16
+ from uipath.resources.robots import RobotsResource
17
+
18
+ # Initialize authentication
19
+ auth = UiPathAuth(
20
+ tenant_name="your_tenant",
21
+ client_id="your_client_id",
22
+ client_secret="your_client_secret"
23
+ )
24
+
25
+ # Create API client
26
+ client = UiPathClient(auth)
27
+
28
+ # Use the robots resource
29
+ robots = RobotsResource(client)
30
+
31
+ # List all robots
32
+ all_robots = robots.list_robots()
33
+ ```
34
+
35
+ ## Features
36
+
37
+ - Simple, intuitive interface for UiPath APIs
38
+ - Authentication handling
39
+ - Comprehensive error handling
40
+ - Type hints for better IDE support
41
+ - Resource classes for all major UiPath entities:
42
+ - Robots
43
+ - Jobs
44
+ - Processes
45
+ - Assets
46
+ - And more...
47
+
48
+ ## Authentication
49
+
50
+ The SDK supports client credentials authentication. You'll need:
51
+ - Tenant name
52
+ - Client ID
53
+ - Client secret
54
+
55
+ You can obtain these credentials from your UiPath Orchestrator account under Admin → API Access.
56
+
57
+ ```python
58
+ auth = UiPathAuth(
59
+ tenant_name="your_tenant",
60
+ client_id="your_client_id",
61
+ client_secret="your_client_secret",
62
+ scope="OR.Default" # Optional, defaults to OR.Default
63
+ )
64
+ ```
65
+
66
+ ## Usage Examples
67
+
68
+ ### Working with Robots
69
+
70
+ ```python
71
+ # List all robots
72
+ robots = RobotsResource(client)
73
+ all_robots = robots.list_robots()
74
+
75
+ # Get a specific robot
76
+ robot = robots.get_robot(robot_id=123)
77
+
78
+ # Create a new robot
79
+ new_robot = robots.create_robot(
80
+ name="MyNewRobot",
81
+ machine_name="DESKTOP-123",
82
+ type="Unattended"
83
+ )
84
+ ```
85
+
86
+ ### Error Handling
87
+
88
+ The SDK provides custom exceptions for different types of errors:
89
+
90
+ ```python
91
+ from uipath.exceptions.exceptions import AuthenticationError, ApiError
92
+
93
+ try:
94
+ robots.get_robot(robot_id=999)
95
+ except AuthenticationError as e:
96
+ print("Authentication failed:", e)
97
+ except ApiError as e:
98
+ print("API request failed:", e)
99
+ ```
100
+
101
+ ## Configuration
102
+
103
+ The SDK can be configured with custom endpoints and API versions:
104
+
105
+ ```python
106
+ client = UiPathClient(
107
+ auth,
108
+ base_url="https://cloud.uipath.com", # Custom base URL
109
+ api_version="v1" # API version
110
+ )
111
+ ```
112
+
113
+ ## Contributing
114
+
115
+ Contributions are welcome! Please feel free to submit a Pull Request.
116
+
117
+ 1. Fork the repository
118
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
119
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
120
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
121
+ 5. Open a Pull Request
122
+
123
+ ## License
124
+
125
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
126
+
127
+ ## Support
128
+
129
+ If you encounter any problems or have questions, please:
130
+ 1. Check the [documentation](docs/)
131
+ 2. Open an issue in the GitHub repository
132
+
133
+ ## Requirements
134
+
135
+ - Python 3.7+
136
+ - requests library
137
+
138
+ ## Disclaimer
139
+
140
+ This is an unofficial SDK and is not affiliated with, maintained, authorized, endorsed, or sponsored by UiPath.
@@ -0,0 +1,30 @@
1
+ # UiPath Python SDK
2
+
3
+ A Python SDK for interacting with the UiPath Orchestrator API.
4
+
5
+ ## Features
6
+
7
+ - Complete API coverage for UiPath Orchestrator
8
+ - Easy-to-use interface
9
+ - Type hints for better IDE support
10
+ - Comprehensive documentation
11
+ - Examples for common use cases
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install uipath
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```python
22
+ from uipath import UiPathClient
23
+
24
+ client = UiPathClient(
25
+ organization_id="your_organization_id",
26
+ tenant_id="your_tenant_id",
27
+ client_id="your_client_id",
28
+ client_secret="your_client_secret"
29
+ )
30
+ ```
@@ -0,0 +1,3 @@
1
+ mkdocs-material
2
+ mkdocs-autorefs
3
+ mkdocstrings[python]
@@ -0,0 +1,58 @@
1
+ site_name: UiPath Python SDK
2
+ site_description: Python SDK for UiPath Orchestrator API
3
+ repo_url: https://github.com/christianblandford/uipath
4
+ repo_name: christianblandford/uipath
5
+
6
+ theme:
7
+ name: material
8
+ palette:
9
+ - scheme: default
10
+ primary: indigo
11
+ accent: indigo
12
+ toggle:
13
+ icon: material/brightness-7
14
+ name: Switch to dark mode
15
+ - scheme: slate
16
+ primary: indigo
17
+ accent: indigo
18
+ toggle:
19
+ icon: material/brightness-4
20
+ name: Switch to light mode
21
+ features:
22
+ - navigation.instant
23
+ - navigation.tracking
24
+ - navigation.sections
25
+ - navigation.expand
26
+ - navigation.top
27
+ - search.suggest
28
+ - search.highlight
29
+
30
+ plugins:
31
+ - search
32
+ - autorefs
33
+ - mkdocstrings:
34
+ default_handler: python
35
+ handlers:
36
+ python:
37
+ paths: [uipath]
38
+ options:
39
+ show_source: false
40
+ show_root_heading: true
41
+
42
+ nav:
43
+ - Home: index.md
44
+ - Getting Started: getting-started.md
45
+ - API Reference:
46
+ - Client: api/client.md
47
+ - Resources:
48
+ - Assets: api/resources/assets.md
49
+ - Folders: api/resources/folders.md
50
+ - Jobs: api/resources/jobs.md
51
+ - Libraries: api/resources/libraries.md
52
+ - Machines: api/resources/machines.md
53
+ - Packages: api/resources/packages.md
54
+ - Processes: api/resources/processes.md
55
+ - Queues: api/resources/queues.md
56
+ - Releases: api/resources/releases.md
57
+ - Robots: api/resources/robots.md
58
+ - Examples: examples.md
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.black]
6
+ line-length = 88
7
+ include = '\.pyi?$'
8
+ exclude = '''
9
+ /(
10
+ \.eggs
11
+ | \.git
12
+ | \.hg
13
+ | \.mypy_cache
14
+ | \.tox
15
+ | \.venv
16
+ | _build
17
+ | buck-out
18
+ | build
19
+ | dist
20
+ )/
21
+ '''
22
+
23
+ [tool.isort]
24
+ profile = "black"
25
+ multi_line_output = 3
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
uipath-1.0.0/setup.py ADDED
@@ -0,0 +1,44 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open("README.md", "r", encoding="utf-8") as fh:
4
+ long_description = fh.read()
5
+
6
+ setup(
7
+ name="uipath",
8
+ version="1.0.0",
9
+ author="Christian Blandford",
10
+ author_email="christianblandford@me.com",
11
+ description="A Python SDK for UiPath",
12
+ long_description=long_description,
13
+ long_description_content_type="text/markdown",
14
+ url="https://github.com/christianblandford/uipath",
15
+ packages=find_packages(),
16
+ classifiers=[
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.7",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
28
+ ],
29
+ python_requires=">=3.7",
30
+ install_requires=[
31
+ "requests>=2.25.0",
32
+ "typing-extensions>=4.0.0;python_version<'3.8'",
33
+ ],
34
+ extras_require={
35
+ "dev": [
36
+ "pytest>=6.0",
37
+ "pytest-cov>=2.0",
38
+ "black>=22.0",
39
+ "isort>=5.0",
40
+ "mypy>=0.900",
41
+ "flake8>=3.9",
42
+ ],
43
+ }
44
+ )
@@ -0,0 +1,9 @@
1
+ from uipath.__version__ import __version__
2
+ from uipath.auth.authentication import UiPathAuth
3
+ from uipath.client.api_client import UiPathClient
4
+
5
+ __all__ = [
6
+ '__version__',
7
+ 'UiPathAuth',
8
+ 'UiPathClient',
9
+ ]
@@ -0,0 +1,3 @@
1
+ VERSION = (1, 0, 0)
2
+
3
+ __version__ = '.'.join(map(str, VERSION))
@@ -0,0 +1,53 @@
1
+ import requests
2
+ from typing import Optional, Dict
3
+
4
+ class UiPathAuth:
5
+ def __init__(
6
+ self,
7
+ client_id: str,
8
+ client_secret: str,
9
+ scope: str = "OR.Assets",
10
+ tenant_name: Optional[str] = None,
11
+ organization_id: Optional[str] = None,
12
+ auth_url: str = "https://cloud.uipath.com/identity_/connect/token"
13
+ ):
14
+ self.client_id = client_id
15
+ self.client_secret = client_secret
16
+ self.scope = scope
17
+ self.tenant_name = tenant_name
18
+ self.organization_id = organization_id
19
+ self.auth_url = auth_url
20
+ self._token = None
21
+
22
+ def get_token(self) -> str:
23
+ """Get OAuth token, refreshing if necessary"""
24
+ if not self._token:
25
+ self._token = self._fetch_token()
26
+ return self._token
27
+
28
+ def _fetch_token(self) -> str:
29
+ """Fetch new OAuth token"""
30
+ data = {
31
+ 'grant_type': 'client_credentials',
32
+ 'client_id': self.client_id,
33
+ 'client_secret': self.client_secret,
34
+ 'scope': self.scope
35
+ }
36
+
37
+ response = requests.post(self.auth_url, data=data)
38
+ response.raise_for_status()
39
+
40
+ token_data = response.json()
41
+ return token_data['access_token']
42
+
43
+ def get_headers(self) -> Dict[str, str]:
44
+ """Get headers needed for API requests"""
45
+ headers = {
46
+ 'Authorization': f'Bearer {self.get_token()}',
47
+ 'Content-Type': 'application/json'
48
+ }
49
+
50
+ if self.organization_id:
51
+ headers['X-UIPATH-OrganizationUnitId'] = self.organization_id
52
+
53
+ return headers