bsn-cloud-api 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tobiasz Gans
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.
@@ -0,0 +1,7 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ recursive-include src *.py
5
+ recursive-exclude * __pycache__
6
+ recursive-exclude * *.py[co]
7
+ recursive-exclude * .DS_Store
@@ -0,0 +1,439 @@
1
+ Metadata-Version: 2.4
2
+ Name: bsn-cloud-api
3
+ Version: 1.0.0
4
+ Summary: A comprehensive Python library for the BrightSign Network (BSN) Cloud API
5
+ Home-page: https://github.com/TobiaszGans/py_BSN_Cloud_API
6
+ Author: Tobiasz Gans
7
+ Author-email: Your Name <your.email@example.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/yourusername/bsn-cloud-api
10
+ Project-URL: Documentation, https://docs.brightsign.biz/developers/cloud-apis
11
+ Project-URL: Repository, https://github.com/yourusername/bsn-cloud-api
12
+ Project-URL: Bug Tracker, https://github.com/yourusername/bsn-cloud-api/issues
13
+ Keywords: brightsign,bsn,cloud,api,digital signage,remote control
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Topic :: System :: Hardware
18
+ Classifier: Topic :: Multimedia :: Video :: Display
19
+ Classifier: License :: OSI Approved :: MIT License
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Operating System :: OS Independent
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: requests>=2.25.0
28
+ Requires-Dist: python-dotenv>=0.19.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=3.0; extra == "dev"
32
+ Requires-Dist: black>=22.0; extra == "dev"
33
+ Requires-Dist: flake8>=4.0; extra == "dev"
34
+ Requires-Dist: mypy>=0.950; extra == "dev"
35
+ Dynamic: author
36
+ Dynamic: home-page
37
+ Dynamic: license-file
38
+ Dynamic: requires-python
39
+
40
+ # BSN Cloud API Python Library
41
+
42
+ A comprehensive Python library for interacting with the BrightSign Network (BSN) Cloud API. This library provides easy-to-use functions for managing BrightSign players remotely. At the moment, most non-DWS-related functions are not supported; this release focuses on remote DWS functionality.
43
+
44
+ ## Features
45
+
46
+ - **Automatic Authentication** - Handles OAuth2 authentication and automatic token renewal
47
+ - **Extensive rDWS API Coverage** – Covers the majority of remote DWS-related BSN Cloud API endpoints
48
+ - **File Management** - Upload, download, and manage files on BrightSign players
49
+ - **Device Control** - Reboot, configure, and control BrightSign devices remotely
50
+ - **Diagnostics** - Run network diagnostics, ping tests, and packet captures
51
+ - **Video & Display Control** - Manage video modes and display settings
52
+ - **Registry Management** - Read and modify player registry settings
53
+ - **Storage Operations** - Manage SD cards and other storage devices
54
+ - **Advanced Features** - SSH, DWS, firmware updates, and more
55
+
56
+ ## Installation
57
+
58
+ ```bash
59
+ pip install bsn-cloud-api
60
+ ```
61
+
62
+ ## Quick Start
63
+
64
+ ### Method 1: Using Environment Variables (Recommended)
65
+
66
+ Create a `.env` file in your project root:
67
+
68
+ ```env
69
+ BSN_CLIENT_ID=your_client_id_here
70
+ BSN_SECRET=your_client_secret_here
71
+ BSN_NETWORK=your_network_name_here
72
+ ```
73
+
74
+ Then use the library:
75
+
76
+ ```python
77
+ import bsn_cloud_api as bsn
78
+
79
+ # Get all devices
80
+ devices = bsn.get_devices()
81
+
82
+ # Reboot a player
83
+ result = bsn.reboot_device("SERIAL123")
84
+
85
+ # Upload a file to a player
86
+ bsn.put_device_files(
87
+ serial_number="SERIAL123",
88
+ local_file_path="video.mp4",
89
+ file_path="media/videos"
90
+ )
91
+ ```
92
+
93
+ ### Method 2: Programmatic Configuration
94
+
95
+ ```python
96
+ import bsn_cloud_api as bsn
97
+
98
+ # Configure credentials in code
99
+ bsn.configure(
100
+ client_id="your_client_id",
101
+ secret="your_secret",
102
+ network="your_network"
103
+ )
104
+
105
+ # Now use the API
106
+ devices = bsn.get_devices()
107
+ ```
108
+
109
+ ### Method 3: System Environment Variables
110
+
111
+ Set environment variables in your system:
112
+
113
+ ```bash
114
+ export BSN_CLIENT_ID="your_client_id"
115
+ export BSN_SECRET="your_secret"
116
+ export BSN_NETWORK="your_network"
117
+ ```
118
+
119
+ Then use the library without any configuration.
120
+
121
+ ## Authentication
122
+
123
+ The library automatically handles authentication for you:
124
+
125
+ The library automatically manages OAuth2 authentication for all API requests.
126
+
127
+ Lazy Initialization – No authentication or network requests are made until the first API call.
128
+
129
+ Automatic Login – Authentication is performed automatically when required.
130
+
131
+ Token Validity Checking – Before every API request, the library verifies that a valid access token is available.
132
+
133
+ Automatic Token Refresh – If the access token has expired, a new token is fetched automatically.
134
+
135
+ Time-Based Expiration – Token validity is determined using the expiration timestamp returned by the OAuth provider.
136
+
137
+ Network Selection – The configured BSN network is selected automatically after authentication.
138
+
139
+ Most authentication-related failures are returned as dictionaries containing an error key. Network-level issues (such as connectivity problems) may still raise exceptions from the underlying HTTP library.
140
+
141
+ You do not need to call login() manually in normal usage — authentication is handled transparently.
142
+
143
+ ## API Credentials
144
+
145
+ To get your BSN Cloud API credentials:
146
+
147
+ 1. Log in to https://adminpanel.bsn.cloud
148
+ 2. Select your network
149
+ 3. Navigate to **Settings** → **Applications**
150
+ 4. Create a new Application or use an existing one
151
+ 5. Copy your **Client ID**, **Client Secret**
152
+
153
+ ## Usage Examples
154
+
155
+ ### Device Management
156
+
157
+ ```python
158
+ # Get all devices
159
+ devices = bsn.get_devices()
160
+
161
+ # Get devices filtered by site
162
+ devices = bsn.get_devices(description="London HQ")
163
+
164
+ # Get specific device info
165
+ device = bsn.get_device("SERIAL123")
166
+
167
+ # Reboot a device
168
+ bsn.reboot_device("SERIAL123")
169
+
170
+ # Factory reset a device
171
+ bsn.reboot_device("SERIAL123", factory_reset=True)
172
+ ```
173
+
174
+ ### File Operations
175
+
176
+ ```python
177
+ # List files on SD card
178
+ files = bsn.get_device_files("SERIAL123", storage_type="sd", path="media")
179
+
180
+ # Upload a file
181
+ bsn.put_device_files(
182
+ serial_number="SERIAL123",
183
+ local_file_path="/local/path/video.mp4",
184
+ storage_type="sd",
185
+ file_path="media/videos",
186
+ dest_filename="intro.mp4"
187
+ )
188
+
189
+ # Create a directory
190
+ bsn.create_device_directory("SERIAL123", "media/videos")
191
+
192
+ # Delete a file
193
+ bsn.delete_device_file("SERIAL123", "media/old_video.mp4")
194
+
195
+ # Rename a file
196
+ bsn.rename_device_file("SERIAL123", "media/video.mp4", "intro.mp4")
197
+ ```
198
+
199
+ ### Diagnostics
200
+
201
+ ```python
202
+ # Run full network diagnostics
203
+ diagnostics = bsn.get_device_diagnostics("SERIAL123")
204
+
205
+ # Ping a server
206
+ ping_result = bsn.get_device_ping("SERIAL123", "8.8.8.8")
207
+
208
+ # DNS lookup
209
+ dns_result = bsn.get_device_dns_lookup("SERIAL123", "google.com")
210
+
211
+ # Traceroute
212
+ trace = bsn.get_device_traceroute("SERIAL123", "google.com")
213
+
214
+ # Get network configuration
215
+ network_config = bsn.get_device_network_config("SERIAL123", interface="eth0")
216
+
217
+ # Start packet capture
218
+ bsn.start_device_packet_capture("SERIAL123", duration=60)
219
+ ```
220
+
221
+ ### Video & Display Control
222
+
223
+ ```python
224
+ # Get current video mode
225
+ mode = bsn.get_device_video_mode("SERIAL123")
226
+
227
+ # Set video mode to 1080p60
228
+ bsn.set_device_video_mode("SERIAL123", "1920x1080x60p")
229
+
230
+ # Get display brightness (Moka displays only)
231
+ brightness = bsn.get_display_brightness("SERIAL123")
232
+
233
+ # Set display brightness
234
+ bsn.set_display_brightness("SERIAL123", 75)
235
+
236
+ # Control display power
237
+ bsn.set_display_power_settings("SERIAL123", "standby")
238
+
239
+ # Set volume
240
+ bsn.set_display_volume("SERIAL123", 50)
241
+ ```
242
+
243
+ ### Registry Operations
244
+
245
+ ```python
246
+ # Get entire registry
247
+ registry = bsn.get_device_registry("SERIAL123")
248
+
249
+ # Get specific registry key
250
+ value = bsn.get_device_registry_key("SERIAL123", "networking", "dhcp")
251
+
252
+ # Set registry value
253
+ bsn.set_device_registry_key("SERIAL123", "networking", "dhcp", "yes")
254
+
255
+ # Delete registry key
256
+ bsn.delete_device_registry_key("SERIAL123", "customsection", "customkey")
257
+
258
+ # Flush registry to disk
259
+ bsn.flush_device_registry("SERIAL123")
260
+ ```
261
+
262
+ ### Screenshots & Custom Commands
263
+
264
+ ```python
265
+ # Take a screenshot
266
+ snapshot = bsn.take_device_snapshot("SERIAL123")
267
+ thumbnail = snapshot['data']['result']['remoteSnapshotThumbnail']
268
+
269
+ # Send custom UDP command
270
+ bsn.send_device_custom_command("SERIAL123", "next", return_immediately=True)
271
+
272
+ # Download firmware
273
+ bsn.download_device_firmware(
274
+ "SERIAL123",
275
+ "https://example.com/firmware.bsfw"
276
+ )
277
+ ```
278
+
279
+ ## API Documentation
280
+
281
+ For complete API documentation, see the [BSN Cloud API Documentation](https://docs.brightsign.biz/developers/cloud-apis).
282
+
283
+ ### Available Functions by Category
284
+
285
+ #### Authentication
286
+ - `configure()` - Set credentials programmatically
287
+ - `login()` - Manual login (automatic when needed)
288
+
289
+ Most API failures are returned as dictionaries containing an `error` key. Network-level errors may still raise exceptions from the underlying HTTP library.
290
+ The API session is lazily initialized. No authentication or network requests occur until the first API call is made.
291
+
292
+ #### Device Management
293
+ - `get_devices()` - List all devices
294
+ - `get_setups()` - List setups/presentations
295
+
296
+ #### Control Endpoints
297
+ - `reboot_device()` - Reboot or factory reset
298
+ - `get_device_password()` - Get DWS password status
299
+ - `put_device_password()` - Set DWS password
300
+ - `get_device_local_dws_status()` - Check local DWS status
301
+ - `set_device_local_dws()` - Enable/disable local DWS
302
+ - `reset_device_ssh_host_keys()` - Reset SSH keys
303
+ - `reset_device_dws_default_certs()` - Reset DWS certificates
304
+
305
+ #### Storage/File Endpoints
306
+ - `get_device_files()` - List files
307
+ - `put_device_files()` - Upload files
308
+ - `create_device_directory()` - Create directories
309
+ - `rename_device_file()` - Rename files
310
+ - `delete_device_file()` - Delete files
311
+
312
+ #### Diagnostic Endpoints
313
+ - `get_device_diagnostics()` - Full network diagnostics
314
+ - `get_device_dns_lookup()` - DNS resolution test
315
+ - `get_device_ping()` - Ping test
316
+ - `get_device_traceroute()` - Traceroute
317
+ - `get_device_network_config()` - Network configuration
318
+ - `put_device_network_config()` - Update network settings
319
+ - `get_device_network_neighborhood()` - Discover nearby players
320
+ - `get_device_packet_capture_status()` - Packet capture status
321
+ - `start_device_packet_capture()` - Start packet capture
322
+ - `stop_device_packet_capture()` - Stop packet capture
323
+ - `get_device_telnet_status()` - Telnet configuration
324
+ - `put_device_telnet_config()` - Configure telnet
325
+ - `get_device_ssh_status()` - SSH configuration
326
+ - `put_device_ssh_config()` - Configure SSH
327
+
328
+ #### Other Endpoints
329
+ - `reformat_device_storage()` - Format storage device
330
+ - `reprovision_device()` - Re-provision player
331
+ - `take_device_snapshot()` - Take screenshot
332
+ - `send_device_custom_command()` - Send custom UDP command
333
+ - `download_device_firmware()` - Update firmware
334
+
335
+ #### Video Endpoints
336
+ - `get_device_video_mode()` - Convenience method that returns the currently active video mode
337
+ - `get_device_video_output()` - Get output information
338
+ - `get_device_video_edid()` - Get EDID data
339
+ - `get_device_video_power_save()` - Power save status
340
+ - `set_device_video_power_save()` - Enable/disable power save
341
+ - `get_device_video_modes()` - List available modes
342
+ - `get_device_video_current_mode()` - Exposes the full BSN API and allows querying best, active, configured, or current modes.
343
+ - `set_device_video_mode()` - Change video mode
344
+
345
+ #### Registry Endpoints
346
+ - `get_device_registry()` - Get full registry
347
+ - `get_device_registry_key()` - Get specific key
348
+ - `set_device_registry_key()` - Set registry value
349
+ - `delete_device_registry_key()` - Delete registry key
350
+ - `flush_device_registry()` - Flush to disk
351
+ - `get_device_recovery_url()` - Get recovery URL
352
+ - `set_device_recovery_url()` - Set recovery URL
353
+
354
+ #### Advanced Endpoints
355
+ - `get_device_property_lock()` - Property lock status
356
+ - `set_device_property_lock()` - Configure property lock
357
+
358
+ #### Display Control Endpoints (Moka displays only)
359
+ - `get_display_control_all()` - All display settings
360
+ - `get_display_brightness()` / `set_display_brightness()` - Brightness
361
+ - `get_display_contrast()` / `set_display_contrast()` - Contrast
362
+ - `get_display_volume()` / `set_display_volume()` - Volume
363
+ - `get_display_power_settings()` / `set_display_power_settings()` - Power
364
+ - `get_display_white_balance()` / `set_display_white_balance()` - Color
365
+ - `get_display_video_output()` / `set_display_video_output()` - Output
366
+ - `get_display_always_connected()` / `set_display_always_connected()` - Connection
367
+ - `get_display_always_on()` / `set_display_always_on()` - Always on
368
+ - `update_display_firmware()` - Firmware update
369
+ - `get_display_info()` - Display information
370
+ - And more...
371
+
372
+ ## Error Handling
373
+
374
+ The library returns error dictionaries when requests fail:
375
+
376
+ ```python
377
+ result = bsn.get_device_files("INVALID_SERIAL", storage_type="sd")
378
+
379
+ if "error" in result:
380
+ print(f"Error {result['error']}: {result['details']}")
381
+ else:
382
+ # Success - process result
383
+ files = result['data']['result']
384
+ ```
385
+
386
+ ## Requirements
387
+
388
+ - Python 3.10+
389
+ - `requests` - HTTP library
390
+ - `python-dotenv` - Environment variable management
391
+
392
+ ## Contributing
393
+
394
+ Contributions are welcome! Please feel free to submit a Pull Request.
395
+
396
+ ## License
397
+
398
+ MIT License - see LICENSE file for details
399
+
400
+ ## Support
401
+
402
+ For issues and questions:
403
+ - GitHub Issues: https://github.com/TobiaszGans/py_BSN_Cloud_API/issues
404
+ - BSN Cloud API Documentation: https://docs.brightsign.biz/developers/cloud-apis
405
+ - BrightSign Support: https://support.brightsign.biz
406
+
407
+ ## Design Philosophy
408
+
409
+ - Simple functional API (no client objects required)
410
+ - Single global authenticated session per process
411
+ - Thin wrapper around BSN Cloud API responses
412
+ - Minimal abstraction: responses closely match API output
413
+
414
+ ## Not Yet Supported
415
+
416
+ - Multi-network concurrent sessions
417
+ - Async / asyncio interface
418
+ - Automatic retry on rate limits
419
+
420
+
421
+ ## Changelog
422
+
423
+ ### Version 1.0.0 (Initial Release)
424
+ - Complete implementation of rDWS BSN Cloud API endpoints
425
+ - Automatic authentication and token renewal
426
+ - Support for all device control operations
427
+ - File management capabilities
428
+ - Network diagnostics tools
429
+ - Video and display control
430
+ - Registry management
431
+ - Display control for Moka displays
432
+
433
+ ## Author
434
+
435
+ Tobiasz Gans
436
+
437
+ ## Acknowledgments
438
+
439
+ - BrightSign for providing the BSN Cloud API